net.sourceforge.plantuml.command.PSystemBasicFactory Maven / Gradle / Ivy
Show all versions of plantuml-mit Show documentation
// THIS FILE HAS BEEN GENERATED BY A PREPROCESSOR.
package net.sourceforge.plantuml.command;
import java.util.Map;
import net.sourceforge.plantuml.AbstractPSystem;
import net.sourceforge.plantuml.ErrorUml;
import net.sourceforge.plantuml.ErrorUmlType;
import net.sourceforge.plantuml.core.Diagram;
import net.sourceforge.plantuml.core.DiagramType;
import net.sourceforge.plantuml.core.UmlSource;
import net.sourceforge.plantuml.error.PSystemErrorUtils;
import net.sourceforge.plantuml.text.StringLocated;
import net.sourceforge.plantuml.utils.StartUtils;
import net.sourceforge.plantuml.version.IteratorCounter2;
public abstract class PSystemBasicFactory extends PSystemAbstractFactory {
public PSystemBasicFactory(DiagramType diagramType) {
super(diagramType);
}
public PSystemBasicFactory() {
this(DiagramType.UML);
}
public abstract P executeLine(UmlSource source, P system, String line);
public abstract P initDiagram(UmlSource source, String startLine);
private boolean isEmptyLine(StringLocated result) {
return result.getTrimmed().getString().length() == 0;
}
@Override
final public Diagram createSystem(UmlSource source, Map skinParam) {
source = source.removeInitialSkinparam();
final IteratorCounter2 it = source.iterator2();
final StringLocated startLine = it.next();
P system = initDiagram(source, startLine.getString());
boolean first = true;
while (it.hasNext()) {
final StringLocated s = it.next();
if (first && s != null && isEmptyLine(s)) {
continue;
}
first = false;
if (StartUtils.isArobaseEndDiagram(s.getString())) {
if (source.getTotalLineCount() == 2 && source.isStartDef() == false) {
return buildEmptyError(source, s.getLocation(), it.getTrace());
}
return system;
}
system = executeLine(source, system, s.getString());
if (system == null) {
final ErrorUml err = new ErrorUml(ErrorUmlType.SYNTAX_ERROR, "Syntax Error?", 0, s.getLocation());
// return PSystemErrorUtils.buildV1(source, err, null);
return PSystemErrorUtils.buildV2(source, err, null, it.getTrace());
}
}
return system;
}
}