Package juzu.impl.router.regex

Examples of juzu.impl.router.regex.RE


      if (regex.re.getPattern().equals(pattern)) {
        return regex;
      }
    }
    //
    RE regex = factory.compile(pattern);
    RERef holder = new RERef(regexes.length, regex);
    regexes = Tools.appendTo(regexes, holder);
    return holder;
  }
View Full Code Here


/** @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a> */
public class RegexTestCase extends AbstractTestCase {

  @Test
  public void testLiteral() {
    RE regex = JRegexFactory.INSTANCE.compile("abc");
    RE.Match[] matches = regex.matcher().find("abc");
    assertEquals(1, matches.length);
    assertEquals(0, matches[0].getStart());
    assertEquals(3, matches[0].getEnd());
    assertEquals("abc", matches[0].getValue());
  }
View Full Code Here

    assertEquals("abc", matches[0].getValue());
  }

  @Test
  public void testSimpleGroup1() {
    RE regex = JRegexFactory.INSTANCE.compile("(abc)");
    RE.Match[] matches = regex.matcher().find("abc");
    assertEquals(2, matches.length);
    assertEquals(0, matches[0].getStart());
    assertEquals(3, matches[0].getEnd());
    assertEquals("abc", matches[0].getValue());
    assertEquals(0, matches[1].getStart());
View Full Code Here

    assertEquals("abc", matches[1].getValue());
  }

  @Test
  public void testSimpleGroup2() {
    RE regex = JRegexFactory.INSTANCE.compile("a(b)c");
    RE.Match[] matches = regex.matcher().find("abc");
    assertEquals(2, matches.length);
    assertEquals(0, matches[0].getStart());
    assertEquals(3, matches[0].getEnd());
    assertEquals("abc", matches[0].getValue());
    assertEquals(1, matches[1].getStart());
View Full Code Here

    assertEquals("b", matches[1].getValue());
  }

  @Test
  public void testNonCapturingGroup() {
    RE regex = JRegexFactory.INSTANCE.compile("a(?:b)c");
    RE.Match[] matches = regex.matcher().find("abc");
    assertEquals(1, matches.length);
    assertEquals(0, matches[0].getStart());
    assertEquals(3, matches[0].getEnd());
    assertEquals("abc", matches[0].getValue());
  }
View Full Code Here

  private void assertLiteral(char c) {
    PatternBuilder pb = new PatternBuilder();
    pb.expr("^");
    pb.literal(c);
    pb.expr("$");
    RE pattern = REFactory.JAVA.compile(pb.build());
    assertTrue(pattern.matcher().matches(Character.toString(c)));
  }
View Full Code Here

TOP

Related Classes of juzu.impl.router.regex.RE

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.