Class UriPattern
- All Implemented Interfaces:
Comparable<UriPattern>
This class holds a regular expression designed so that it only matches certain URI
s. The constructor of
this class accepts a simplified pattern string, and turns that into something that can be used to quickly match
against URIs. This class also implements Comparable
in such a way that stricter patterns order before looser
patterns.
Here are some examples of ordering:
http://host/path
evaluated before*://host/path
http://host/path
evaluated beforehttp://*/path
http://a.host/path
evaluated beforehttp://*.host/path
http://*.host/path
evaluated beforehttp://host/path
http://host.a/path
evaluated beforehttp://host.*/path
http://host.*/path
evaluated beforehttp://host/path
http://host:80/path
evaluated beforehttp://host:*/path
http://host/path
evaluated beforehttp://host/*
http://host/path/*
evaluated beforehttp://host/path
- Author:
- Simon Thoresen Hult, bjorncs
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
This class holds the result of amatch(URI)
operation. -
Constructor Summary
ConstructorDescriptionUriPattern
(String uri) Creates a new instance of this class that represents the given pattern string, with a priority of0
. -
Method Summary
-
Constructor Details
-
UriPattern
Creates a new instance of this class that represents the given pattern string, with a priority of
0
. The input string must be on the form<scheme>://<host>[:<port>]<path>
, where '*' can be used as a wildcard character at any position.- Parameters:
uri
- The pattern to parse.- Throws:
IllegalArgumentException
- If the pattern could not be parsed.
-
-
Method Details
-
match
Attempts to match the given
URI
to this pattern. Note that only the scheme, host, port, and path components of the URI are used, and these must all be defined. Only absolute URIs are supported. Any user info, query or fragment part is ignored.- Parameters:
uri
- The URI to match.- Returns:
- A
UriPattern.Match
object describing the match found, or null if not found.
-
hashCode
public int hashCode() -
equals
-
toString
-
compareTo
- Specified by:
compareTo
in interfaceComparable<UriPattern>
-