Top Description Inners Fields Constructors Methods
io.undertow.util

public Class PathMatcher<T>

extends Object
Class Inheritance
Imports
io.undertow.UndertowLogger, .UndertowMessages, java.util.Collections, .Comparator, .Map, .Set, .TreeSet, java.util.concurrent.ConcurrentMap

Handler that dispatches to a given handler based of a prefix match of the path.

This only matches a single level of a request, e.g if you have a request that takes the form:

/foo/bar

Author
Stuart Douglas

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class

Field Summary

Modifier and TypeField and Description
private volatile T
private final ConcurrentMap<String, T>
private volatile int[]
lengths

lengths of all registered paths

private final SubstringMap<T>
private static final String

Constructor Summary

AccessConstructor and Description
public
PathMatcher(final T defaultHandler)

public

Method Summary

Modifier and TypeMethod and Description
public synchronized PathMatcher<T>
addExactPath(final String path, final T handler)

public synchronized PathMatcher<T>
addPrefixPath(final String
The path
path
,
final T
The handler
handler
)

Adds a path prefix and a handler for that path.

private void
public synchronized PathMatcher<T>
public T
getExactPath(final String path)

public Set<String>
public Set<String>
public Map<String, T>
public T
getPrefixPath(final String path)

public PathMatcher.PathMatch<T>

Returns:

The match match. This will never be null, however if none matched its value field will be
match
(String
The relative path to match
path
)

Matches a path against the registered handlers.

public synchronized PathMatcher<T>
removeExactPath(final String path)

public synchronized PathMatcher<T>
removePath(final String path)
Deprecated

public synchronized PathMatcher<T>
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

defaultHandlerback to summary
private volatile T defaultHandler
exactPathMatchesback to summary
private final ConcurrentMap<String, T> exactPathMatches
lengthsback to summary
private volatile int[] lengths

lengths of all registered paths

pathsback to summary
private final SubstringMap<T> paths
STRING_PATH_SEPARATORback to summary
private static final String STRING_PATH_SEPARATOR

Constructor Detail

PathMatcherback to summary
public PathMatcher(final T defaultHandler)
PathMatcherback to summary
public PathMatcher()

Method Detail

addExactPathback to summary
public synchronized PathMatcher<T> addExactPath(final String path, final T handler)
addPrefixPathback to summary
public synchronized PathMatcher<T> addPrefixPath(final String path, final T handler)

Adds a path prefix and a handler for that path. If the path does not start with a / then one will be prepended.

The match is done on a prefix bases, so registering /foo will also match /foo/bar. Exact path matches are taken into account first.

If / is specified as the path then it will replace the default handler.

Parameters
path:String

The path

handler:T

The handler

buildLengthsback to summary
private void buildLengths()
clearPathsback to summary
public synchronized PathMatcher<T> clearPaths()
getExactPathback to summary
public T getExactPath(final String path)
getExactPathMatchesSetback to summary
public Set<String> getExactPathMatchesSet()
getPathMatchesSetback to summary
public Set<String> getPathMatchesSet()
getPathsback to summary
public Map<String, T> getPaths()
getPrefixPathback to summary
public T getPrefixPath(final String path)
matchback to summary
public PathMatcher.PathMatch<T> match(String path)

Matches a path against the registered handlers.

Parameters
path:String

The relative path to match

Returns:PathMatcher.PathMatch<T>

The match match. This will never be null, however if none matched its value field will be

removeExactPathback to summary
public synchronized PathMatcher<T> removeExactPath(final String path)
removePathback to summary
public synchronized PathMatcher<T> removePath(final String path)

Deprecated

Annotations
@Deprecated
removePrefixPathback to summary
public synchronized PathMatcher<T> removePrefixPath(final String path)
io.undertow.util back to summary

public final Class PathMatcher.PathMatch<T>

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final String
private final String
private final T

Constructor Summary

AccessConstructor and Description
public
PathMatch(String matched, String remaining, T value)

Method Summary

Modifier and TypeMethod and Description
public String
public String
public T
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

matchedback to summary
private final String matched
remainingback to summary
private final String remaining
valueback to summary
private final T value

Constructor Detail

PathMatchback to summary
public PathMatch(String matched, String remaining, T value)

Method Detail

getMatchedback to summary
public String getMatched()
getRemainingback to summary
public String getRemaining()
getValueback to summary
public T getValue()