net.sourceforge.plantuml.regex.RegexOr Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of plantuml-mit Show documentation
Show all versions of plantuml-mit Show documentation
PlantUML is a component that allows to quickly write diagrams from text.
// THIS FILE HAS BEEN GENERATED BY A PREPROCESSOR.
package net.sourceforge.plantuml.regex;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import net.sourceforge.plantuml.text.StringLocated;
public class RegexOr extends RegexComposed implements IRegex {
private final String name;
public RegexOr(IRegex... partial) {
this(null, partial);
}
public RegexOr(String name, IRegex... partials) {
super(partials);
this.name = name;
}
@Override
protected String getFullSlow() {
final StringBuilder sb = new StringBuilder("(");
if (name == null) {
sb.append("?:");
}
for (IRegex p : partials()) {
sb.append(p.getPattern());
sb.append("|");
}
sb.setLength(sb.length() - 1);
sb.append(')');
return sb.toString();
}
protected int getStartCount() {
return 1;
}
final public Map createPartialMatch(Iterator it) {
final Map result = new HashMap();
final String fullGroup = name == null ? null : it.next();
result.putAll(super.createPartialMatch(it));
if (name != null) {
final RegexPartialMatch m = new RegexPartialMatch(name);
m.add(fullGroup);
result.put(name, m);
}
return result;
}
public boolean match(StringLocated full) {
throw new UnsupportedOperationException();
}
}