Top Description Fields Constructors Methods
org.springframework.web.util.pattern

pack-priv Class InternalPathPatternParser

extends Object
Class Inheritance
Imports
java.util.ArrayList, .List, java.util.regex.PatternSyntaxException, org.springframework.lang.Nullable, org.springframework.util.Assert, org.springframework.web.util.pattern.PatternParseException.PatternMessage

Parser for URI template patterns. It breaks the path pattern into a number of PathElements in a linked list. Instances are reusable but are not thread-safe.
Author
Andy Clement
Since
5.0

Field Summary

Modifier and TypeField and Description
private List<String>
private PathElement
private PathElement
private boolean
private boolean
private final PathPatternParser
private int
private char[]
private int
pack-priv int
private int
private int
private int
private boolean

Constructor Summary

AccessConstructor and Description
pack-priv
InternalPathPatternParser(PathPatternParser
reference back to the stateless, public parser
parentParser
)

Package private constructor for use in PathPatternParser#parse.

Method Summary

Modifier and TypeMethod and Description
private PathElement

Returns:

the new path element
createPathElement
()

Used the knowledge built up whilst processing since the last path element to determine what kind of path element to create.

private int

Returns:

the index of the character after the ':' within the pattern expression relative to the start of the whole expression
findRegexStart
(char[]
a complete path expression, e.g. /aaa/bbb/{ccc:...}
data
,
int
the start of the capture pattern of interest
offset
)

For a path element representing a captured variable, locate the constraint pattern.

private char[]
public PathPattern
parse(String pathPattern)

Package private delegate for PathPatternParser#parse(String).

private boolean
peekDoubleWildcard()

After processing a separator, a quick peek whether it is followed by a double wildcard (and only as the last path element).

private void
pushPathElement(PathElement
the new path element to add
newPathElement
)

Push a path element to the chain being build.

private void
recordCapturedVariable(int pos, String variableName)

Record a new captured variable.

private void
resetPathElementState()

Reset all the flags and position markers computed during path element processing.

private void
skipCaptureRegex()

Just hit a ':' and want to jump over the regex specification for this variable.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

capturedVariableNamesback to summary
private List<String> capturedVariableNames
Annotations
@Nullable
currentPEback to summary
private PathElement currentPE
Annotations
@Nullable
headPEback to summary
private PathElement headPE
Annotations
@Nullable
insideVariableCaptureback to summary
private boolean insideVariableCapture
isCaptureTheRestVariableback to summary
private boolean isCaptureTheRestVariable
parserback to summary
private final PathPatternParser parser
pathElementStartback to summary
private int pathElementStart
pathPatternDataback to summary
private char[] pathPatternData
pathPatternLengthback to summary
private int pathPatternLength
posback to summary
pack-priv int pos
singleCharWildcardCountback to summary
private int singleCharWildcardCount
variableCaptureCountback to summary
private int variableCaptureCount
variableCaptureStartback to summary
private int variableCaptureStart
wildcardback to summary
private boolean wildcard

Constructor Detail

InternalPathPatternParserback to summary
pack-priv InternalPathPatternParser(PathPatternParser parentParser)

Package private constructor for use in PathPatternParser#parse.

Parameters
parentParser:PathPatternParser

reference back to the stateless, public parser

Method Detail

createPathElementback to summary
private PathElement createPathElement()

Used the knowledge built up whilst processing since the last path element to determine what kind of path element to create.

Returns:PathElement

the new path element

findRegexStartback to summary
private int findRegexStart(char[] data, int offset)

For a path element representing a captured variable, locate the constraint pattern. Assumes there is a constraint pattern.

Parameters
data:char[]

a complete path expression, e.g. /aaa/bbb/{ccc:...}

offset:int

the start of the capture pattern of interest

Returns:int

the index of the character after the ':' within the pattern expression relative to the start of the whole expression

getPathElementTextback to summary
private char[] getPathElementText()
parseback to summary
public PathPattern parse(String pathPattern) throws PatternParseException

Package private delegate for PathPatternParser#parse(String).

peekDoubleWildcardback to summary
private boolean peekDoubleWildcard()

After processing a separator, a quick peek whether it is followed by a double wildcard (and only as the last path element).

pushPathElementback to summary
private void pushPathElement(PathElement newPathElement)

Push a path element to the chain being build.

Parameters
newPathElement:PathElement

the new path element to add

recordCapturedVariableback to summary
private void recordCapturedVariable(int pos, String variableName)

Record a new captured variable. If it clashes with an existing one then report an error.

resetPathElementStateback to summary
private void resetPathElementState()

Reset all the flags and position markers computed during path element processing.

skipCaptureRegexback to summary
private void skipCaptureRegex()

Just hit a ':' and want to jump over the regex specification for this variable. pos will be pointing at the ':', we want to skip until the }.

Nested {...} pairs don't have to be escaped: /abc/{var:x{1,2}}/def

An escaped } will not be treated as the end of the regex: /abc/{var:x\\{y:}/def

A separator that should not indicate the end of the regex can be escaped: