Esempio n. 1
0
  @Override
  public <V> boolean match(final MatcherContext<V> context) {
    if (!context.fastStringMatching()) return super.match(context);

    if (!context.getInputBuffer().test(context.getCurrentIndex(), characters)) return false;
    context.advanceIndex(characters.length);
    context.createNode();
    return true;
  }
 @Override
 public <V> boolean match(final MatcherContext<V> context) {
   final InputBuffer buffer = context.getInputBuffer();
   final boolean success = buffer.test(context.getCurrentIndex(), chars);
   if (success) {
     context.advanceIndex(2);
     context.createNode();
   }
   return success;
 }
  @Override
  public <V> boolean match(final MatcherContext<V> context) {
    final boolean condition =
        inner == null ? context.getMatcher().match(context) : inner.match(context);
    if (!condition) return false;
    if (errorIndex < context.getCurrentIndex() && notTestNot(context))
      errorIndex = context.getCurrentIndex();

    return true;
  }
Esempio n. 4
0
  public boolean match(MatcherContext context) {
    int lastIndex = context.getCurrentIndex();
    Object valueStackSnapshot = context.getValueStack().takeSnapshot();

    if (!subMatcher.getSubContext(context).runMatcher()) return false;

    // reset location, Test matchers never advance
    context.setCurrentIndex(lastIndex);

    // erase all value stack changes the the submatcher could have made
    context.getValueStack().restoreSnapshot(valueStackSnapshot);
    return true;
  }
  @Override
  public <V> boolean match(final MatcherContext<V> context) {
    char tested;

    // Test the lead surrogate...
    tested = context.getCurrentChar();
    if (tested != lead) return false;

    // OK, there may be a match; we need to test for the trailing surrogate.
    context.advanceIndex(1);
    tested = context.getCurrentChar();

    if (tested >= lowTrail && tested <= highTrail) {
      // Match!
      context.advanceIndex(1);
      context.createNode();
      return true;
    }

    // No match. Too bad.
    context.advanceIndex(-1);
    return false;
  }
 private static boolean notTestNot(final MatcherContext<?> context) {
   if (context.getMatcher() instanceof TestNotMatcher) return false;
   return context.getParent() == null || notTestNot(context.getParent());
 }