public String parse(String format) { StringBuffer buffer = new StringBuffer(); Matcher m = formatPattern.matcher(format); while (m.find()) m.appendReplacement(buffer, getFormatSpecifierValue(m.group())); m.appendTail(buffer); return buffer.toString(); }
public boolean checkCondition(String format, ScoreBoardEvent event) { boolean triggerCondition = true; Matcher m = conditionPattern.matcher(format); if (!m.find()) throw new IllegalArgumentException("No conditions in format : " + format); do { String specifier = m.group(1); String comparator = m.group(2); String targetValue = m.group(3); if (null == comparator || null == targetValue) continue; String value = scoreBoardValues.get(specifier).getValue(); if (triggerCondition) { triggerCondition = false; // If current trigger event value == previous value after processing // (e.g. conversion to min:sec) then ignore, to prevent multiple consecutive // identical triggers if (value.equals( scoreBoardValues.get(specifier).getPreviousValue(event.getPreviousValue()))) return false; } try { if (!checkConditionValue(value, comparator, targetValue)) return false; } catch (IllegalArgumentException iaE) { return false; } } while (m.find()); return true; }
public ScoreBoardCondition getScoreBoardCondition(String format) throws IllegalArgumentException { Matcher m = eventPattern.matcher(format); if (!m.find()) throw new IllegalArgumentException("No valid event specified"); return getFormatSpecifierScoreBoardCondition(m.group(1)); }