Class PathTemplate

java.lang.Object
org.atmosphere.util.PathTemplate

public final class PathTemplate extends Object
A lightweight URI path template that supports {varName} and {varName:regex} syntax. Replaces the Jersey-derived UriTemplate / UriPattern / UriTemplateParser / UriComponent classes.

Example usage:


     var t = new PathTemplate("/chat/{room}");
     var vars = new HashMap<String, String>();
     if (t.match("/chat/general", vars)) {
         // vars == {"room" -> "general"}
     }
 
  • Constructor Details

    • PathTemplate

      public PathTemplate(String template)
      Parse a URI template string into a compiled pattern.
      Parameters:
      template - the template (e.g. /chat/{room})
      Throws:
      IllegalArgumentException - if template is null, empty, or has invalid syntax
  • Method Details

    • match

      public boolean match(CharSequence uri, Map<String,String> vars)
      Match a URI against this template.
      Parameters:
      uri - the URI to match
      vars - map to populate with variable name → value pairs (cleared first)
      Returns:
      true if the URI matches, false otherwise
    • getTemplate

      public String getTemplate()
      Returns:
      the original template string
    • toString

      public String toString()
      Overrides:
      toString in class Object