Package juzu.impl.router.regex

Examples of juzu.impl.router.regex.REParser


      String[] templatePrefixes;
      String[] templateSuffixes;
      try {
        REVisitor<RuntimeException> transformer = descriptor.getCaptureGroup() ?
            new CaptureGroupTransformation() : new NonCaptureGroupTransformation();
        REParser parser = new REParser(regex);

        //
        RENode.Disjunction routingDisjunction = parser.parseDisjunction();
        if (!preservePath) {
          CharEscapeTransformation escaper = new CharEscapeTransformation('/', '_');
          routingDisjunction.accept(escaper);
        }
        routingDisjunction.accept(transformer);
        RERenderer.render(routingDisjunction, routingRegex);

        //
        parser.reset();
        RENode.Disjunction renderingDisjunction = parser.parseDisjunction();
        ValueResolverFactory factory = new ValueResolverFactory();
        renderingDisjunction.accept(transformer);
        List<ValueResolverFactory.Alternative> alt = factory.foo(renderingDisjunction);
        renderingRegexes = new RERef[alt.size()];
        templatePrefixes = new String[alt.size()];
View Full Code Here


  private void assertCapturing(String test, String expected) throws SyntaxException, IOException {
    assertTransform(test, expected, true);
  }

  private void assertTransform(String test, String expected, boolean capturing) throws SyntaxException, IOException {
    RENode node = new REParser(test).parse();
    REVisitor<RuntimeException> transformer = capturing ? new CaptureGroupTransformation() : new NonCaptureGroupTransformation();
    node.accept(transformer);
    StringBuilder sb = new StringBuilder();
    RERenderer renderer = new RERenderer(sb);
    node.accept(renderer);
View Full Code Here

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

  private static void assertSatisfied(String expression, String... expected) throws Exception {
    RENode root = new REParser(expression).parse();
    List<ValueResolverFactory.Alternative> alternatives = new ValueResolverFactory().foo(root);
    assertEquals(expected.length, alternatives.size());
    for (int i = 0;i < expected.length;i++) {
      assertEquals(expected[i], alternatives.get(i).getResolvingExpression().toString());
    }
View Full Code Here

* @version $Revision$
*/
public class CharEscapeTransformationTestCase extends AbstractTestCase {

  private void match(String pattern, String test, String expectedValue) throws Exception {
    REParser parser = new REParser(pattern);
    CharEscapeTransformation escaper = new CharEscapeTransformation('/', '_');
    RENode.Disjunction re = parser.parseDisjunction();
    re.accept(escaper);
    Pattern p = Pattern.compile(RERenderer.render(re, new StringBuilder()).toString());
    Matcher matcher = p.matcher(test);
    assertTrue(matcher.find());
    assertEquals(expectedValue, matcher.group());
View Full Code Here

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

  private static void assertSatisfied(String expression, String... expected) throws Exception {
    RENode root = new REParser(expression).parse();
    root.accept(new CaptureGroupTransformation());
    List<ValueResolverFactory.Alternative> alternatives = new ValueResolverFactory().foo(root);
    assertEquals(expected.length, alternatives.size());
    for (int i = 0;i < expected.length;i++) {
      assertEquals(expected[i], alternatives.get(i).getResolvingExpression().toString());
View Full Code Here

* @version $Revision$
*/
public class RouteEscaperTestCase extends AbstractTestCase {

  private void match(String pattern, String test, String expectedValue) throws Exception {
    REParser parser = new REParser(pattern);
    RouteEscaper escaper = new RouteEscaper('/', '_');
    RENode.Disjunction re = parser.parseDisjunction();
    re.accept(escaper);
    Pattern p = Pattern.compile(RERenderer.render(re, new StringBuilder()).toString());
    Matcher matcher = p.matcher(test);
    assertTrue(matcher.find());
    assertEquals(expectedValue, matcher.group());
View Full Code Here

TOP

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

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.