diff --git a/src/net/sourceforge/plantuml/AnnotatedWorker.java b/src/net/sourceforge/plantuml/AnnotatedWorker.java index 080fbbfc4..4cac307da 100644 --- a/src/net/sourceforge/plantuml/AnnotatedWorker.java +++ b/src/net/sourceforge/plantuml/AnnotatedWorker.java @@ -179,7 +179,8 @@ public class AnnotatedWorker { final Style style = StyleSignatureBasic.of(SName.root, SName.document, SName.caption) .getMergedStyle(skinParam.getCurrentStyleBuilder()); - return style.createTextBlockBordered(caption.getDisplay(), skinParam.getIHtmlColorSet(), skinParam); + return style.createTextBlockBordered(caption.getDisplay(), skinParam.getIHtmlColorSet(), skinParam, + Style.ID_CAPTION); } @@ -191,7 +192,7 @@ public class AnnotatedWorker { final Style style = StyleSignatureBasic.of(SName.root, SName.document, SName.title) .getMergedStyle(skinParam.getCurrentStyleBuilder()); final TextBlock block = style.createTextBlockBordered(title.getDisplay(), skinParam.getIHtmlColorSet(), - skinParam); + skinParam, Style.ID_TITLE); return DecorateEntityImage.addTop(original, block, HorizontalAlignment.CENTER); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/EntityImageLegend.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/EntityImageLegend.java index d64176e79..e84c09991 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/EntityImageLegend.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/EntityImageLegend.java @@ -49,7 +49,7 @@ public class EntityImageLegend { final Style style = StyleSignatureBasic .of(SName.root, SName.root, SName.document, skinParam.getUmlDiagramType().getStyleName(), SName.legend) .getMergedStyle(skinParam.getCurrentStyleBuilder()); - return style.createTextBlockBordered(note, skinParam.getIHtmlColorSet(), skinParam); + return style.createTextBlockBordered(note, skinParam.getIHtmlColorSet(), skinParam, Style.ID_LEGEND); } } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileBoxOld.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileBoxOld.java index d0501f0db..ff82a7c2f 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileBoxOld.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileBoxOld.java @@ -57,7 +57,6 @@ import net.sourceforge.plantuml.creole.SheetBlock1; import net.sourceforge.plantuml.creole.SheetBlock2; import net.sourceforge.plantuml.creole.Stencil; import net.sourceforge.plantuml.cucadiagram.Display; -import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.Rainbow; @@ -135,23 +134,6 @@ public class FtileBoxOld extends AbstractFtile { } - public static FtileBoxOld create(ISkinParam skinParam, Display label, Swimlane swimlane, BoxStyle boxStyle, - Stereotype stereotype) { - final Style style = getDefaultStyleDefinitionActivity().withTOBECHANGED(stereotype) - .getMergedStyle(skinParam.getCurrentStyleBuilder()); - final Style styleArrow = getDefaultStyleDefinitionArrow().getMergedStyle(skinParam.getCurrentStyleBuilder()); - - return new FtileBoxOld(skinParam, label, swimlane, boxStyle, style, styleArrow); - } - - public static TextBlock createWbs(StyleBuilder styleBuilder, ISkinParam skinParam, Display label, - StyleSignatureBasic styleDefinition) { - final Style style = styleDefinition.getMergedStyle(styleBuilder); - final Style styleArrow = style; - - return new FtileBoxOld(skinParam, label, null, BoxStyle.PLAIN, style, styleArrow); - } - public static TextBlock createWbs(Style style, ISkinParam skinParam, Display label) { final Style styleArrow = style; return new FtileBoxOld(skinParam, label, null, BoxStyle.PLAIN, style, styleArrow); @@ -232,8 +214,7 @@ public class FtileBoxOld extends AbstractFtile { tb.drawU(ug.apply(new UTranslate(dimTotal.getWidth() - tbWidth(stringBounder) - padding.getRight(), padding.getBottom()))); else if (horizontalAlignment == HorizontalAlignment.CENTER) - tb.drawU(ug.apply(new UTranslate(padding.getRight() + (dimTotal.getWidth() - tbWidth(stringBounder)) / 2, - padding.getBottom()))); + tb.drawU(ug.apply(new UTranslate((dimTotal.getWidth() - tbWidth(stringBounder)) / 2, padding.getBottom()))); } diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClassMultilines.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClassMultilines.java index f011d49d7..1274ab806 100644 --- a/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClassMultilines.java +++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClassMultilines.java @@ -92,7 +92,8 @@ public class CommandCreateClassMultilines extends CommandMultilines2 1) { entity.setCodeLine(lines.getAt(0).getLocation()); lines = lines.subExtract(1, 1); @@ -165,9 +166,9 @@ public class CommandCreateClassMultilines extends CommandMultilines2 0 && VisibilityModifier.isVisibilityCharacter(s.getString())) { + if (s.getString().length() > 0 && VisibilityModifier.isVisibilityCharacter(s.getString())) diagram.setVisibilityModifierPresent(true); - } + entity.getBodier().addFieldOrMethod(s.getString()); } // if (url != null) { @@ -183,9 +184,9 @@ public class CommandCreateClassMultilines extends CommandMultilines2 LIMIT) { // Log.debug("Line truncated from " + s.length() + " to " + LIMIT); // s = s.substring(0, LIMIT); // } - if (s.startsWith("\uFEFF")) { + if (s.startsWith("\uFEFF")) s = s.substring(1); - } + s = s.replace('\u2013', '-'); // s = BackSlash.convertHiddenNewLine(s); // s = s.replace('\u00A0', ' '); diff --git a/src/net/sourceforge/plantuml/security/SURL.java b/src/net/sourceforge/plantuml/security/SURL.java index fb9a48777..c8533b84d 100644 --- a/src/net/sourceforge/plantuml/security/SURL.java +++ b/src/net/sourceforge/plantuml/security/SURL.java @@ -244,7 +244,7 @@ public class SURL { } private boolean forbiddenURL(String full) { - if (full.matches("^https?://[.0-9]+/.*")) + if (full.matches("^https?://[-#.0-9:\\[\\]+]+/.*")) return true; if (full.matches("^https?://[^.]+/.*")) return true; diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/SequenceDiagramFileMakerPuma2.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/SequenceDiagramFileMakerPuma2.java index 4068599af..a70690ce6 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/graphic/SequenceDiagramFileMakerPuma2.java +++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/SequenceDiagramFileMakerPuma2.java @@ -149,7 +149,7 @@ public class SequenceDiagramFileMakerPuma2 implements FileMaker { final Style style = StyleSignatureBasic.of(SName.root, SName.document, SName.title) .getMergedStyle(diagram.getSkinParam().getCurrentStyleBuilder()); compTitle = style.createTextBlockBordered(page.getTitle(), diagram.getSkinParam().getIHtmlColorSet(), - diagram.getSkinParam()); + diagram.getSkinParam(), Style.ID_TITLE); final Dimension2D dimTitle = compTitle.calculateDimension(stringBounder); area.setTitleArea(dimTitle.getWidth(), dimTitle.getHeight()); } @@ -163,7 +163,7 @@ public class SequenceDiagramFileMakerPuma2 implements FileMaker { final Style style = StyleSignatureBasic.of(SName.root, SName.document, SName.legend) .getMergedStyle(diagram.getSkinParam().getCurrentStyleBuilder()); legendBlock = style.createTextBlockBordered(diagram.getLegend().getDisplay(), - diagram.getSkinParam().getIHtmlColorSet(), diagram.getSkinParam()); + diagram.getSkinParam().getIHtmlColorSet(), diagram.getSkinParam(), Style.ID_LEGEND); } final Dimension2D dimLegend = legendBlock.calculateDimension(stringBounder); area.setLegend(dimLegend, isLegendTop(), diagram.getLegend().getHorizontalAlignment()); diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/SequenceDiagramFileMakerTeoz.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/SequenceDiagramFileMakerTeoz.java index d78dbe13f..18f84328c 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/teoz/SequenceDiagramFileMakerTeoz.java +++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/SequenceDiagramFileMakerTeoz.java @@ -209,7 +209,7 @@ public class SequenceDiagramFileMakerTeoz implements FileMaker { final Style style = StyleSignatureBasic.of(SName.root, SName.document, SName.title) .getMergedStyle(diagram.getSkinParam().getCurrentStyleBuilder()); final TextBlock compTitle = style.createTextBlockBordered(diagram.getTitle().getDisplay(), - diagram.getSkinParam().getIHtmlColorSet(), diagram.getSkinParam()); + diagram.getSkinParam().getIHtmlColorSet(), diagram.getSkinParam(), Style.ID_TITLE); return compTitle; } diff --git a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseArrow.java b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseArrow.java index 58dc71596..eec849af2 100644 --- a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseArrow.java +++ b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseArrow.java @@ -150,11 +150,10 @@ public class ComponentRoseArrow extends AbstractComponentRoseArrow { if (inclination1 == 0 && inclination2 == 0) getArrowConfiguration().applyStroke(ug).apply(new UTranslate(start, posArrow)).draw(new ULine(len, 0)); - else if (inclination1 != 0) { + else if (inclination1 != 0) drawLine(getArrowConfiguration().applyStroke(ug), start + len, posArrow, 0, posArrow + inclination1); - } else if (inclination2 != 0) { + else if (inclination2 != 0) drawLine(getArrowConfiguration().applyStroke(ug), start, posArrow, pos2, posArrow + inclination2); - } final ArrowDirection direction2 = getDirection2(); final double textPos; @@ -203,10 +202,12 @@ public class ComponentRoseArrow extends AbstractComponentRoseArrow { if (dressing.getHead() == ArrowHead.ASYNC) { if (dressing.getPart() != ArrowPart.BOTTOM_PART) - getArrowConfiguration().applyThicknessOnly(ug).draw(new ULine(getArrowDeltaX(), -getArrowDeltaY())); + getArrowConfiguration().applyThicknessOnly(ug).draw( + new ULine(getArrowDeltaX(), -getArrowDeltaY()).rotate(Math.atan2(-inclination1, lenFull))); if (dressing.getPart() != ArrowPart.TOP_PART) - getArrowConfiguration().applyThicknessOnly(ug).draw(new ULine(getArrowDeltaX(), getArrowDeltaY())); + getArrowConfiguration().applyThicknessOnly(ug) + .draw(new ULine(getArrowDeltaX(), getArrowDeltaY()).rotate(Math.atan2(-inclination1, lenFull))); } else if (dressing.getHead() == ArrowHead.CROSSX) { ug = ug.apply(new UStroke(2)); @@ -237,10 +238,12 @@ public class ComponentRoseArrow extends AbstractComponentRoseArrow { if (dressing.getHead() == ArrowHead.ASYNC) { if (dressing.getPart() != ArrowPart.BOTTOM_PART) - getArrowConfiguration().applyThicknessOnly(ug).draw(new ULine(-getArrowDeltaX(), -getArrowDeltaY())); + getArrowConfiguration().applyThicknessOnly(ug).draw( + new ULine(-getArrowDeltaX(), -getArrowDeltaY()).rotate(Math.atan2(inclination2, lenFull))); if (dressing.getPart() != ArrowPart.TOP_PART) - getArrowConfiguration().applyThicknessOnly(ug).draw(new ULine(-getArrowDeltaX(), getArrowDeltaY())); + getArrowConfiguration().applyThicknessOnly(ug) + .draw(new ULine(-getArrowDeltaX(), getArrowDeltaY()).rotate(Math.atan2(inclination2, lenFull))); } else if (dressing.getHead() == ArrowHead.CROSSX) { ug = ug.apply(new UStroke(2)); diff --git a/src/net/sourceforge/plantuml/style/Style.java b/src/net/sourceforge/plantuml/style/Style.java index c6badc0b3..9fc2b5763 100644 --- a/src/net/sourceforge/plantuml/style/Style.java +++ b/src/net/sourceforge/plantuml/style/Style.java @@ -269,8 +269,12 @@ public class Style { final FontConfiguration fc = getFontConfiguration(spriteContainer.getThemeStyle(), set); return display.create(fc, alignment, spriteContainer); } + + public static final String ID_TITLE = "_title"; + public static final String ID_CAPTION = "_caption"; + public static final String ID_LEGEND = "_legend"; - public TextBlock createTextBlockBordered(Display note, HColorSet set, ISkinSimple spriteContainer) { + public TextBlock createTextBlockBordered(Display note, HColorSet set, ISkinSimple spriteContainer, String id) { final HorizontalAlignment alignment = this.getHorizontalAlignment(); final TextBlock textBlock = this.createTextBlockInternal(note, set, spriteContainer, alignment); @@ -281,7 +285,7 @@ public class Style { final ClockwiseTopRightBottomLeft margin = this.getMargin(); final ClockwiseTopRightBottomLeft padding = this.getPadding(); final TextBlock result = TextBlockUtils.bordered(textBlock, stroke, lineColor, backgroundColor, cornersize, - padding); + padding, id); return TextBlockUtils.withMargin(result, margin); } diff --git a/src/net/sourceforge/plantuml/svek/ClusterDecoration.java b/src/net/sourceforge/plantuml/svek/ClusterDecoration.java index 4fce7f333..ba421b441 100644 --- a/src/net/sourceforge/plantuml/svek/ClusterDecoration.java +++ b/src/net/sourceforge/plantuml/svek/ClusterDecoration.java @@ -70,9 +70,9 @@ public class ClusterDecoration { } private static USymbol guess(USymbol symbol, PackageStyle style) { - if (symbol != null) { + if (symbol != null) return symbol; - } + return style.toUSymbol(); } diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageClass.java b/src/net/sourceforge/plantuml/svek/image/EntityImageClass.java index 1659a933c..5faae7513 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageClass.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageClass.java @@ -169,14 +169,14 @@ public class EntityImageClass extends AbstractEntityImage implements Stencil, Wi double shadow = 0; - HColor classBorder = lineConfig.getColors().getColor(ColorType.LINE); + HColor borderColor = lineConfig.getColors().getColor(ColorType.LINE); HColor headerBackcolor = getEntity().getColors().getColor(ColorType.HEADER); HColor backcolor = getEntity().getColors().getColor(ColorType.BACK); shadow = getStyle().value(PName.Shadowing).asDouble(); - if (classBorder == null) - classBorder = getStyle().value(PName.LineColor).asColor(getSkinParam().getThemeStyle(), + if (borderColor == null) + borderColor = getStyle().value(PName.LineColor).asColor(getSkinParam().getThemeStyle(), getSkinParam().getIHtmlColorSet()); if (headerBackcolor == null) @@ -189,7 +189,7 @@ public class EntityImageClass extends AbstractEntityImage implements Stencil, Wi rect.setDeltaShadow(shadow); - ug = ug.apply(classBorder); + ug = ug.apply(borderColor); ug = ug.apply(backcolor.bg()); final UStroke stroke = getStyle().getStroke(lineConfig.getColors()); diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageMap.java b/src/net/sourceforge/plantuml/svek/image/EntityImageMap.java index af27409c3..05391cfcd 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageMap.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageMap.java @@ -156,13 +156,16 @@ public class EntityImageMap extends AbstractEntityImage implements Stencil, With final double heightTotal = dimTotal.getHeight(); final Shadowable rect = new URectangle(widthTotal, heightTotal).rounded(roundCorner); + HColor borderColor = lineConfig.getColors().getColor(ColorType.LINE); HColor backcolor = getEntity().getColors().getColor(ColorType.BACK); HColor headerBackcolor = getEntity().getColors().getColor(ColorType.HEADER); final Style style = getStyle(); - final HColor borderColor = style.value(PName.LineColor).asColor(getSkinParam().getThemeStyle(), - getSkinParam().getIHtmlColorSet()); - + + if (borderColor == null) + borderColor = getStyle().value(PName.LineColor).asColor(getSkinParam().getThemeStyle(), + getSkinParam().getIHtmlColorSet()); + if (headerBackcolor == null) headerBackcolor = backcolor == null ? getStyleHeader().value(PName.BackGroundColor) .asColor(getSkinParam().getThemeStyle(), getSkinParam().getIHtmlColorSet()) : backcolor; @@ -170,7 +173,7 @@ public class EntityImageMap extends AbstractEntityImage implements Stencil, With if (backcolor == null) backcolor = style.value(PName.BackGroundColor).asColor(getSkinParam().getThemeStyle(), getSkinParam().getIHtmlColorSet()); - + rect.setDeltaShadow(style.value(PName.Shadowing).asDouble()); final UStroke stroke = style.getStroke(); @@ -184,7 +187,7 @@ public class EntityImageMap extends AbstractEntityImage implements Stencil, With typeIDent.put(UGroupType.ID, "elem_" + getEntity().getCode()); ug.startGroup(typeIDent); ug.apply(stroke).draw(rect); - + if (roundCorner == 0 && headerBackcolor != null && backcolor.equals(headerBackcolor) == false) { final Shadowable rect2 = new URectangle(widthTotal, dimTitle.getHeight()); final UGraphic ugHeader = ug.apply(headerBackcolor.bg()); diff --git a/src/net/sourceforge/plantuml/svek/image/Footprint.java b/src/net/sourceforge/plantuml/svek/image/Footprint.java index 0e8b2afa4..bb99e9ed9 100644 --- a/src/net/sourceforge/plantuml/svek/image/Footprint.java +++ b/src/net/sourceforge/plantuml/svek/image/Footprint.java @@ -46,6 +46,7 @@ import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.UDrawable; import net.sourceforge.plantuml.ugraphic.UBackground; import net.sourceforge.plantuml.ugraphic.UChange; +import net.sourceforge.plantuml.ugraphic.UEllipse; import net.sourceforge.plantuml.ugraphic.UEmpty; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UGraphicNo; @@ -111,6 +112,8 @@ public class Footprint { drawPath(x, y, (UPath) shape); } else if (shape instanceof URectangle) { drawRectangle(x, y, (URectangle) shape); + } else if (shape instanceof UEllipse) { + drawEllipse(x, y, (UEllipse) shape); } else if (shape instanceof UEmpty) { drawEmpty(x, y, (UEmpty) shape); } else { @@ -153,6 +156,11 @@ public class Footprint { addPoint(x + rect.getWidth(), y + rect.getHeight()); } + private void drawEllipse(double x, double y, UEllipse rect) { + addPoint(x, y); + addPoint(x + rect.getWidth(), y + rect.getHeight()); + } + private void drawEmpty(double x, double y, UEmpty rect) { addPoint(x, y); addPoint(x + rect.getWidth(), y + rect.getHeight()); diff --git a/src/net/sourceforge/plantuml/tim/EaterTheme.java b/src/net/sourceforge/plantuml/tim/EaterTheme.java index d78b1fe63..782a93ce6 100644 --- a/src/net/sourceforge/plantuml/tim/EaterTheme.java +++ b/src/net/sourceforge/plantuml/tim/EaterTheme.java @@ -38,6 +38,7 @@ import static java.nio.charset.StandardCharsets.UTF_8; import java.io.BufferedReader; import java.io.IOException; +import java.io.Reader; import java.io.UnsupportedEncodingException; import net.sourceforge.plantuml.AFile; @@ -114,7 +115,11 @@ public class EaterTheme extends Eater { try { final FileWithSuffix file = context.getFileWithSuffix(from, realName); - return ReadLineReader.create(file.getReader(UTF_8), "theme " + realName); + final Reader tmp = file.getReader(UTF_8); + if (tmp == null) + throw EaterException.located("No such theme " + realName); + + return ReadLineReader.create(tmp, "theme " + realName); } catch (IOException e) { e.printStackTrace(); throw EaterException.located("Cannot load " + realName); diff --git a/src/net/sourceforge/plantuml/timingdiagram/graphic/Ribbon.java b/src/net/sourceforge/plantuml/timingdiagram/graphic/Ribbon.java index 57265ff66..adbec2af6 100644 --- a/src/net/sourceforge/plantuml/timingdiagram/graphic/Ribbon.java +++ b/src/net/sourceforge/plantuml/timingdiagram/graphic/Ribbon.java @@ -151,7 +151,8 @@ public class Ribbon implements PDrawing { private void drawNotes(UGraphic ug, final Position position) { for (TimingNote note : notes) if (note.getPosition() == position) { - final double x = ruler.getPosInPixel(note.getWhen()); + final TimeTick when = note.getWhen(); + final double x = when == null ? 0 : ruler.getPosInPixel(when); note.drawU(ug.apply(UTranslate.dx(x))); } } diff --git a/src/net/sourceforge/plantuml/ugraphic/ULine.java b/src/net/sourceforge/plantuml/ugraphic/ULine.java index cb5c5be3e..2f6fbed49 100644 --- a/src/net/sourceforge/plantuml/ugraphic/ULine.java +++ b/src/net/sourceforge/plantuml/ugraphic/ULine.java @@ -35,6 +35,7 @@ */ package net.sourceforge.plantuml.ugraphic; +import java.awt.geom.AffineTransform; import java.awt.geom.Point2D; public class ULine extends AbstractShadowable implements UShapeSized { @@ -51,6 +52,14 @@ public class ULine extends AbstractShadowable implements UShapeSized { this.dy = dy; } + public ULine rotate(double theta) { + if (theta == 0) + return this; + final AffineTransform rot = AffineTransform.getRotateInstance(theta); + final Point2D result = rot.transform(new Point2D.Double(dx, dy), null); + return new ULine(result.getX(), result.getY()); + } + public static ULine hline(double dx) { return new ULine(dx, 0); } diff --git a/src/net/sourceforge/plantuml/version/Version.java b/src/net/sourceforge/plantuml/version/Version.java index 729f441ea..0c650fa8d 100644 --- a/src/net/sourceforge/plantuml/version/Version.java +++ b/src/net/sourceforge/plantuml/version/Version.java @@ -80,7 +80,7 @@ public class Version { } public static int beta() { - final int beta = 0; + final int beta = 1; return beta; } diff --git a/src/net/sourceforge/plantuml/yaml/YamlLines.java b/src/net/sourceforge/plantuml/yaml/YamlLines.java index 7fdf08ad0..5ea9b1afe 100644 --- a/src/net/sourceforge/plantuml/yaml/YamlLines.java +++ b/src/net/sourceforge/plantuml/yaml/YamlLines.java @@ -44,15 +44,15 @@ import java.util.regex.Pattern; public class YamlLines implements Iterable { - public static final String KEY = "([^:\\s]+)"; + public static final String KEY = "([^:]+)"; private List lines = new ArrayList<>(); public YamlLines(List rawLines) { for (String s : rawLines) { - if (s.startsWith("#")) { + if (s.startsWith("#")) continue; - } + s = removeDiese(s); if (s.trim().length() == 0) continue; @@ -79,9 +79,9 @@ public class YamlLines implements Iterable { private String removeDiese(String s) { final int idx = s.indexOf(" #"); - if (idx == -1) { + if (idx == -1) return s; - } + return s.substring(0, idx); } @@ -104,9 +104,9 @@ public class YamlLines implements Iterable { } private void removeFirstCols(int startingEmptyCols) { - if (startingEmptyCols == 0) { + if (startingEmptyCols == 0) return; - } + for (ListIterator it = lines.listIterator(); it.hasNext();) { final String s = it.next().substring(startingEmptyCols); it.set(s); @@ -117,9 +117,8 @@ public class YamlLines implements Iterable { int result = Integer.MAX_VALUE; for (String s : lines) { result = Math.min(result, startingSpaces(s)); - if (result == 0) { + if (result == 0) return 0; - } } return result; } @@ -127,9 +126,9 @@ public class YamlLines implements Iterable { private static int startingSpaces(String s) { final Pattern p1 = Pattern.compile("^(\\s*).*"); final Matcher m1 = p1.matcher(s); - if (m1.matches()) { + if (m1.matches()) return m1.group(1).length(); - } + return 0; }