public int matchingSize(String line) { final Matcher2 m = p.matcher(line); if (m.find() == false) { return 0; } return m.group(1).length(); }
public String executeAndGetRemaining(final String line, StripeSimple stripe) { final Matcher2 m = p.matcher(line); if (m.find() == false) { throw new IllegalStateException(); } final FontConfiguration fc1 = stripe.getActualFontConfiguration(); final FontConfiguration fc2 = new AddStyle(style, getExtendedColor(m)).apply(fc1); stripe.setActualFontConfiguration(fc2); final int groupCount = m.groupCount(); stripe.analyzeAndAdd(m.group(groupCount)); stripe.setActualFontConfiguration(fc1); return line.substring(m.group(1).length()); }
public CharSequence2 readLine() throws IOException { final CharSequence2 s = source.readLine(); if (s == null) { return null; } if (StartUtils.isArobaseStartDiagram(s)) { this.defines.restoreState(); } Matcher2 m = definePattern.matcher(s); if (m.find()) { return manageDefine(m); } m = definelongPattern.matcher(s); if (m.find()) { return manageDefineLong(m); } m = undefPattern.matcher(s); if (m.find()) { return manageUndef(m); } if (ignoreDefineDuringSeveralLines > 0) { ignoreDefineDuringSeveralLines--; return s; } final List<String> result = defines.applyDefines(s.toString2()); if (result.size() > 1) { ignoreDefineDuringSeveralLines = result.size() - 2; source.insert(result.subList(1, result.size() - 1), s.getLocation()); } return new CharSequence2Impl(result.get(0), s.getLocation()); }
private CharSequence2 manageDefineLong(Matcher2 m) throws IOException { final String group1 = m.group(1); final List<String> def = new ArrayList<String>(); while (true) { final CharSequence2 read = this.readLine(); if (read == null) { return null; } def.add(read.toString2()); if (enddefinelongPattern.matcher(read).find()) { defines.define(group1, def); return this.readLine(); } } }
public final CommandControl isValid(BlocLines lines) { if (isCommandForbidden()) { return CommandControl.NOT_OK; } final Matcher2 m1 = starting.matcher(StringUtils.trim(lines.getFirst499())); if (m1.matches() == false) { return CommandControl.NOT_OK; } if (lines.size() == 1) { return CommandControl.OK_PARTIAL; } int level = 1; for (CharSequence cs : lines.subExtract(1, 0)) { final String s = StringUtils.trim(cs); if (isLineConsistent(s, level) == false) { return CommandControl.NOT_OK; } if (s.endsWith("{")) { level++; } if (s.endsWith("}")) { level--; } if (level < 0) { return CommandControl.NOT_OK; } } if (level != 0) { return CommandControl.OK_PARTIAL; } actionIfCommandValid(); return CommandControl.OK; }
private CharSequence2 manageDefine(Matcher2 m) throws IOException { final String group1 = m.group(1); final String group2 = m.group(2); if (group2 == null) { defines.define(group1, null); } else { final List<String> strings = defines.applyDefines(group2); if (strings.size() > 1) { defines.define(group1, strings); } else { final StringBuilder value = new StringBuilder(strings.get(0)); while (StringUtils.endsWithBackslash(value.toString())) { value.setLength(value.length() - 1); final CharSequence2 read = this.readLine(); value.append(read.toString2()); } final List<String> li = new ArrayList<String>(); li.add(value.toString()); defines.define(group1, li); } } return this.readLine(); }
private CharSequence2 manageUndef(Matcher2 m) throws IOException { defines.undefine(m.group(1)); return this.readLine(); }
private HtmlColor getExtendedColor(Matcher2 m) { if (tryExtendedColor) { return style.getExtendedColor(m.group(2)); } return null; }