Ejemplo n.º 1
0
 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();
 }
Ejemplo n.º 2
0
 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;
 }
Ejemplo n.º 3
0
 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));
 }