Package ratpack.path.internal

Examples of ratpack.path.internal.DefaultPathBinderBuilder


  private PathBinders() {

  }

  public static PathBinder parse(String path, boolean exact) {
    PathBinderBuilder pathBinderBuilder = new DefaultPathBinderBuilder();

    Matcher matchResult = PLACEHOLDER.matcher(path);

    int lastIndex = 0;

    if (matchResult.find()) {
      do {
        int thisIndex = matchResult.start();
        if (thisIndex != lastIndex) {
          pathBinderBuilder.literal(path.substring(lastIndex, thisIndex));
        }
        lastIndex = matchResult.end();
        String component = matchResult.group(0);
        boolean found = false;
        for (TokenType type : TokenType.values()) {
          if (type.match(component, pathBinderBuilder)) {
            found = true;
            break;
          }
        }
        if (!found) {
          throw new IllegalArgumentException(String.format("Cannot match path %s (%s)", path, component));
        }
      } while (matchResult.find());
      if (lastIndex < path.length()) {
        pathBinderBuilder.literal(path.substring(lastIndex));
      }
    } else {
      pathBinderBuilder.literal(path);
    }
    return pathBinderBuilder.build(exact);
  }
View Full Code Here


    }
    return pathBinderBuilder.build(exact);
  }

  public static PathBinderBuilder builder() {
    return new DefaultPathBinderBuilder();
  }
View Full Code Here

TOP

Related Classes of ratpack.path.internal.DefaultPathBinderBuilder

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.