summaryrefslogtreecommitdiff
path: root/src/net/sourceforge/plantuml/objectdiagram/command/CommandAddData.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/net/sourceforge/plantuml/objectdiagram/command/CommandAddData.java')
-rw-r--r--src/net/sourceforge/plantuml/objectdiagram/command/CommandAddData.java33
1 files changed, 24 insertions, 9 deletions
diff --git a/src/net/sourceforge/plantuml/objectdiagram/command/CommandAddData.java b/src/net/sourceforge/plantuml/objectdiagram/command/CommandAddData.java
index c6bf8fd..b9f3f8d 100644
--- a/src/net/sourceforge/plantuml/objectdiagram/command/CommandAddData.java
+++ b/src/net/sourceforge/plantuml/objectdiagram/command/CommandAddData.java
@@ -2,7 +2,7 @@
* PlantUML : a free UML diagram generator
* ========================================================================
*
- * (C) Copyright 2009-2017, Arnaud Roques
+ * (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
@@ -35,26 +35,41 @@
*/
package net.sourceforge.plantuml.objectdiagram.command;
-import java.util.List;
-
+import net.sourceforge.plantuml.LineLocation;
import net.sourceforge.plantuml.command.CommandExecutionResult;
-import net.sourceforge.plantuml.command.SingleLineCommand;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+import net.sourceforge.plantuml.command.regex.IRegex;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexResult;
import net.sourceforge.plantuml.cucadiagram.Code;
import net.sourceforge.plantuml.cucadiagram.IEntity;
import net.sourceforge.plantuml.objectdiagram.AbstractClassOrObjectDiagram;
import net.sourceforge.plantuml.skin.VisibilityModifier;
-public class CommandAddData extends SingleLineCommand<AbstractClassOrObjectDiagram> {
+public class CommandAddData extends SingleLineCommand2<AbstractClassOrObjectDiagram> {
public CommandAddData() {
- super("(?i)^([\\p{L}0-9_.]+)[%s]*:[%s]*(.*)$");
+ super(getRegexConcat());
+ }
+
+ static IRegex getRegexConcat() {
+ return RegexConcat.build(CommandAddData.class.getName(), RegexLeaf.start(), //
+ new RegexLeaf("NAME", "([\\p{L}0-9_.]+)"), //
+ RegexLeaf.spaceZeroOrMore(), //
+ new RegexLeaf(":"), //
+ RegexLeaf.spaceZeroOrMore(), //
+ new RegexLeaf("DATA", "(.*)"), RegexLeaf.end()); //
}
@Override
- protected CommandExecutionResult executeArg(AbstractClassOrObjectDiagram diagram, List<String> arg) {
- final IEntity entity = diagram.getOrCreateLeaf(Code.of(arg.get(0)), null, null);
+ protected CommandExecutionResult executeArg(AbstractClassOrObjectDiagram diagram, LineLocation location,
+ RegexResult arg) {
+ final String name = arg.get("NAME", 0);
+ final IEntity entity = diagram.getOrCreateLeaf(diagram.buildLeafIdent(name),
+ diagram.buildCode(name), null, null);
- final String field = arg.get(1);
+ final String field = arg.get("DATA", 0);
if (field.length() > 0 && VisibilityModifier.isVisibilityCharacter(field)) {
diagram.setVisibilityModifierPresent(true);
}