@ -33,19 +33,11 @@ import org.springframework.web.util.pattern.PatternParseException.PatternMessage
* /
* /
class InternalPathPatternParser {
class InternalPathPatternParser {
private PathPatternParser parser ;
private final PathPatternParser parser ;
// The expected path separator to split path elements during parsing
// The expected path separator to split path elements during parsing
char separator = PathPatternParser . DEFAULT_SEPARATOR ;
private final char separator = '/' ;
// Is the parser producing case sensitive PathPattern matchers
boolean caseSensitive = true ;
// If true the PathPatterns produced by the parser will allow patterns
// that don't have a trailing slash to match paths that may or may not
// have a trailing slash
private boolean matchOptionalTrailingSlash = false ;
// The input data for parsing
// The input data for parsing
private char [ ] pathPatternData = new char [ 0 ] ;
private char [ ] pathPatternData = new char [ 0 ] ;
@ -90,19 +82,8 @@ class InternalPathPatternParser {
PathElement currentPE ;
PathElement currentPE ;
/ * *
InternalPathPatternParser ( PathPatternParser parentParser ) {
* @param separator the path separator to look for when parsing
this . parser = parentParser ;
* @param caseSensitive true if PathPatterns should be sensitive to case
* @param matchOptionalTrailingSlash true if patterns without a trailing slash
* can match paths that do have a trailing slash
* /
public InternalPathPatternParser ( char separator , boolean caseSensitive , boolean matchOptionalTrailingSlash ) {
this . separator = separator ;
this . caseSensitive = caseSensitive ;
this . matchOptionalTrailingSlash = matchOptionalTrailingSlash ;
this . parser = new PathPatternParser ( this . separator ) ;
this . parser . setCaseSensitive ( this . caseSensitive ) ;
this . parser . setMatchOptionalTrailingSlash ( this . matchOptionalTrailingSlash ) ;
}
}
@ -210,8 +191,8 @@ class InternalPathPatternParser {
if ( this . pathElementStart ! = - 1 ) {
if ( this . pathElementStart ! = - 1 ) {
pushPathElement ( createPathElement ( ) ) ;
pushPathElement ( createPathElement ( ) ) ;
}
}
return new PathPattern (
return new PathPattern ( pathPattern , this . parser , this . headPE , this . separator ,
pathPattern , this . parser , this . headPE , this . separator , this . caseSensitive , this . matchOptionalTrailingSlash ) ;
this . parser . isCaseSensitive ( ) , this . parser . isMatchOptionalTrailingSlash ( ) ) ;
}
}
/ * *
/ * *
@ -347,7 +328,7 @@ class InternalPathPatternParser {
// It is a full capture of this element (possibly with constraint), for example: /foo/{abc}/
// It is a full capture of this element (possibly with constraint), for example: /foo/{abc}/
try {
try {
newPE = new CaptureVariablePathElement ( this . pathElementStart , getPathElementText ( ) ,
newPE = new CaptureVariablePathElement ( this . pathElementStart , getPathElementText ( ) ,
this . c aseSensitive, this . separator ) ;
this . parser . isC aseSensitive( ) , this . separator ) ;
}
}
catch ( PatternSyntaxException pse ) {
catch ( PatternSyntaxException pse ) {
throw new PatternParseException ( pse ,
throw new PatternParseException ( pse ,
@ -364,7 +345,7 @@ class InternalPathPatternParser {
PatternMessage . CAPTURE_ALL_IS_STANDALONE_CONSTRUCT ) ;
PatternMessage . CAPTURE_ALL_IS_STANDALONE_CONSTRUCT ) ;
}
}
RegexPathElement newRegexSection = new RegexPathElement ( this . pathElementStart ,
RegexPathElement newRegexSection = new RegexPathElement ( this . pathElementStart ,
getPathElementText ( ) , this . c aseSensitive,
getPathElementText ( ) , this . parser . isC aseSensitive( ) ,
this . pathPatternData , this . separator ) ;
this . pathPatternData , this . separator ) ;
for ( String variableName : newRegexSection . getVariableNames ( ) ) {
for ( String variableName : newRegexSection . getVariableNames ( ) ) {
recordCapturedVariable ( this . pathElementStart , variableName ) ;
recordCapturedVariable ( this . pathElementStart , variableName ) ;
@ -379,16 +360,16 @@ class InternalPathPatternParser {
}
}
else {
else {
newPE = new RegexPathElement ( this . pathElementStart , getPathElementText ( ) ,
newPE = new RegexPathElement ( this . pathElementStart , getPathElementText ( ) ,
this . c aseSensitive, this . pathPatternData , this . separator ) ;
this . parser . isC aseSensitive( ) , this . pathPatternData , this . separator ) ;
}
}
}
}
else if ( this . singleCharWildcardCount ! = 0 ) {
else if ( this . singleCharWildcardCount ! = 0 ) {
newPE = new SingleCharWildcardedPathElement ( this . pathElementStart , getPathElementText ( ) ,
newPE = new SingleCharWildcardedPathElement ( this . pathElementStart , getPathElementText ( ) ,
this . singleCharWildcardCount , this . c aseSensitive, this . separator ) ;
this . singleCharWildcardCount , this . parser . isC aseSensitive( ) , this . separator ) ;
}
}
else {
else {
newPE = new LiteralPathElement ( this . pathElementStart , getPathElementText ( ) ,
newPE = new LiteralPathElement ( this . pathElementStart , getPathElementText ( ) ,
this . c aseSensitive, this . separator ) ;
this . parser . isC aseSensitive( ) , this . separator ) ;
}
}
}
}