Top Description Inners Fields Constructors Methods
org.eclipse.jetty.http.pathmap

public Class RegexPathSpec

extends AbstractPathSpec
Class Inheritance
Imports
java.util.HashMap, .Map, java.util.regex.Matcher, .Pattern, org.slf4j.Logger, .LoggerFactory

RegexPathSpec is a PathSpec implementation for a PathMappings instance.

Supports the standard Java regex found in java.util.regex.Pattern.

Supports PathSpecGroup for PathSpecGroup#EXACT, PathSpecGroup#PREFIX_GLOB, PathSpecGroup#MIDDLE_GLOB, and PathSpecGroup#SUFFIX_GLOB. This is done by evaluating the signature or the provided regex pattern for what is a literal vs a glob (of any kind).

The use of regex capture groups, regex character classes, regex quantifiers, and regex special contructs will be identified as a glob (for signature determination), all other characters are identified as literal. The regex ^ beginning of line, and regex $ end of line are ignored.

Support for MatchedPath and PathMatch vs PathInfo

There's a few steps in evaluating the matched input path for determining where the split in the input path should occur for MatchedPath#getPathMatch() and MatchedPath#getPathInfo().

  1. If there are no regex capturing groups, the entire path is returned in MatchedPath#getPathMatch(), and a null returned for MatchedPath#getPathInfo()
  2. If both the named regex capturing groups name and info are present, then the name group is returned in MatchedPath#getPathMatch() and the info group is returned in MatchedPath#getPathInfo()
  3. If there is only 1 regex capturing group If the split on pathMatch ends with / AND the pathInfo doesn't start with / then the slash is moved from pathMatch to pathInfo.
  4. All other RegexPathSpec signatures will return the entire path in MatchedPath#getPathMatch(), and a null returned for MatchedPath#getPathInfo()

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class

Field Summary

Modifier and TypeField and Description
private final String
private final PathSpecGroup
private final int
private final Pattern
private final int
private static final Map<Character, String>
private static final Logger

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public String
public PathSpecGroup
protected Matcher
public int
getPathDepth()

Implements org.eclipse.jetty.http.pathmap.PathSpec.getPathDepth.

Get the number of path elements that this path spec declares.
public String
getPathInfo(String
the path to match against
path
)

Implements org.eclipse.jetty.http.pathmap.PathSpec.getPathInfo.

Return the portion of the path that is after the path spec.
public String
getPathMatch(String
the path to match against
path
)

Implements org.eclipse.jetty.http.pathmap.PathSpec.getPathMatch.

Return the portion of the path that matches a path spec.
public Pattern
public String
getPrefix()

Implements org.eclipse.jetty.http.pathmap.PathSpec.getPrefix.

A simple prefix match for the pathspec or null
public int
public String
getSuffix()

Implements org.eclipse.jetty.http.pathmap.PathSpec.getSuffix.

A simple suffix match for the pathspec or null
public MatchedPath
matched(String
the path to test
path
)

Implements org.eclipse.jetty.http.pathmap.PathSpec.matched.

Get the complete matched details of the provided path.
public boolean
matches(final String
the path to test
path
)

Overrides default org.eclipse.jetty.http.pathmap.PathSpec.matches.

Test to see if the provided path matches this path spec.
Inherited from org.eclipse.jetty.http.pathmap.AbstractPathSpec:
compareToequalshashCodetoString

Field Detail

_declarationback to summary
private final String _declaration
_groupback to summary
private final PathSpecGroup _group
_pathDepthback to summary
private final int _pathDepth
_patternback to summary
private final Pattern _pattern
_specLengthback to summary
private final int _specLength
FORBIDDEN_ESCAPEDback to summary
private static final Map<Character, String> FORBIDDEN_ESCAPED
LOGback to summary
private static final Logger LOG

Constructor Detail

RegexPathSpecback to summary
public RegexPathSpec(String regex)

Method Detail

getDeclarationback to summary
public String getDeclaration()

Implements org.eclipse.jetty.http.pathmap.PathSpec.getDeclaration.

Doc from org.eclipse.jetty.http.pathmap.PathSpec.getDeclaration.

The as-provided path spec.

Returns:String

the as-provided path spec

Annotations
@Override
getGroupback to summary
public PathSpecGroup getGroup()

Implements org.eclipse.jetty.http.pathmap.PathSpec.getGroup.

Doc from org.eclipse.jetty.http.pathmap.PathSpec.getGroup.

The spec group.

Returns:PathSpecGroup

the spec group.

Annotations
@Override
getMatcherback to summary
protected Matcher getMatcher(String path)
getPathDepthback to summary
public int getPathDepth()

Implements org.eclipse.jetty.http.pathmap.PathSpec.getPathDepth.

Doc from org.eclipse.jetty.http.pathmap.PathSpec.getPathDepth.

Get the number of path elements that this path spec declares.

This is used to determine longest match logic.

Returns:int

the depth of the path segments that this spec declares

Annotations
@Override
getPathInfoback to summary
public String getPathInfo(String path)

Implements org.eclipse.jetty.http.pathmap.PathSpec.getPathInfo.

Doc from org.eclipse.jetty.http.pathmap.PathSpec.getPathInfo.

Return the portion of the path that is after the path spec.

Parameters
path:String

the path to match against

Returns:String

the path info portion of the string

Annotations
@Override
getPathMatchback to summary
public String getPathMatch(String path)

Implements org.eclipse.jetty.http.pathmap.PathSpec.getPathMatch.

Doc from org.eclipse.jetty.http.pathmap.PathSpec.getPathMatch.

Return the portion of the path that matches a path spec.

Parameters
path:String

the path to match against

Returns:String

the match, or null if no match at all

Annotations
@Override
getPatternback to summary
public Pattern getPattern()
getPrefixback to summary
public String getPrefix()

Implements org.eclipse.jetty.http.pathmap.PathSpec.getPrefix.

Doc from org.eclipse.jetty.http.pathmap.PathSpec.getPrefix.

A simple prefix match for the pathspec or null

Returns:String

A simple prefix match for the pathspec or null

Annotations
@Override
getSpecLengthback to summary
public int getSpecLength()

Implements org.eclipse.jetty.http.pathmap.PathSpec.getSpecLength.

Doc from org.eclipse.jetty.http.pathmap.PathSpec.getSpecLength.

The length of the spec.

Returns:int

the length of the spec.

Annotations
@Override
getSuffixback to summary
public String getSuffix()

Implements org.eclipse.jetty.http.pathmap.PathSpec.getSuffix.

Doc from org.eclipse.jetty.http.pathmap.PathSpec.getSuffix.

A simple suffix match for the pathspec or null

Returns:String

A simple suffix match for the pathspec or null

Annotations
@Override
matchedback to summary
public MatchedPath matched(String path)

Implements org.eclipse.jetty.http.pathmap.PathSpec.matched.

Doc from org.eclipse.jetty.http.pathmap.PathSpec.matched.

Get the complete matched details of the provided path.

Parameters
path:String

the path to test

Returns:MatchedPath

the matched details, if a match was possible, or null if not able to be matched.

Annotations
@Override
matchesback to summary
public boolean matches(final String path)

Overrides default org.eclipse.jetty.http.pathmap.PathSpec.matches.

Doc from org.eclipse.jetty.http.pathmap.PathSpec.matches.

Test to see if the provided path matches this path spec. This can be more efficient that matched(String) if the details of the match are not required.

Parameters
path:String

the path to test

Returns:boolean

true if the path matches this path spec, false otherwise

Annotations
@Override
org.eclipse.jetty.http.pathmap back to summary

private Class RegexPathSpec.RegexMatchedPath

extends Object
implements MatchedPath
Class Inheritance
  • java.lang.Object
  • org.eclipse.jetty.http.pathmap.RegexPathSpec.RegexMatchedPath
All Implemented Interfaces
org.eclipse.jetty.http.pathmap.MatchedPath

Field Summary

Modifier and TypeField and Description
private final String
private String
private String
private final RegexPathSpec

Constructor Summary

AccessConstructor and Description
public
RegexMatchedPath(RegexPathSpec regexPathSpec, String path, Matcher matcher)

Method Summary

Modifier and TypeMethod and Description
private void
private int
endOf(Matcher matcher, String groupName)

public String
getPathInfo()

Implements org.eclipse.jetty.http.pathmap.MatchedPath.getPathInfo.

Return the portion of the path that is after the path spec.
public String
getPathMatch()

Implements org.eclipse.jetty.http.pathmap.MatchedPath.getPathMatch.

Return the portion of the path that matches a path spec.
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
private String
valueOf(Matcher matcher, String groupName)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

pathback to summary
private final String path
pathInfoback to summary
private String pathInfo
pathMatchback to summary
private String pathMatch
pathSpecback to summary
private final RegexPathSpec pathSpec

Constructor Detail

RegexMatchedPathback to summary
public RegexMatchedPath(RegexPathSpec regexPathSpec, String path, Matcher matcher)

Method Detail

calcPathMatchInfoback to summary
private void calcPathMatchInfo(Matcher matcher)
endOfback to summary
private int endOf(Matcher matcher, String groupName)
getPathInfoback to summary
public String getPathInfo()

Implements org.eclipse.jetty.http.pathmap.MatchedPath.getPathInfo.

Doc from org.eclipse.jetty.http.pathmap.MatchedPath.getPathInfo.

Return the portion of the path that is after the path spec.

Returns:String

the path info portion of the match, or null if there is no portion after the getPathMatch()

Annotations
@Override
getPathMatchback to summary
public String getPathMatch()

Implements org.eclipse.jetty.http.pathmap.MatchedPath.getPathMatch.

Doc from org.eclipse.jetty.http.pathmap.MatchedPath.getPathMatch.

Return the portion of the path that matches a path spec.

Returns:String

the path name portion of the match.

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override
valueOfback to summary
private String valueOf(Matcher matcher, String groupName)