@ -136,20 +136,19 @@ class RegexPathElement extends PathElement {
@@ -136,20 +136,19 @@ class RegexPathElement extends PathElement {
if ( matches ) {
if ( isNoMorePattern ( ) ) {
if ( matchingContext . determineRemainingPath & &
( this . variableNames . isEmpty ( ) | | textToMatch . length ( ) > 0 ) ) {
( this . variableNames . isEmpty ( ) | | textToMatch . length ( ) > 0 ) ) {
matchingContext . remainingPathIndex = pathIndex + 1 ;
matches = true ;
}
else {
// No more pattern, is there more data?
// If pattern is capturing variables there must be some actual data to bind to them
matches = ( pathIndex + 1 ) > = matchingContext . pathLength
& & ( this . variableNames . isEmpty ( ) | | textToMatch . length ( ) > 0 ) ;
matches = ( pathIndex + 1 > = matchingContext . pathLength ) & &
( this . variableNames . isEmpty ( ) | | textToMatch . length ( ) > 0 ) ;
if ( ! matches & & matchingContext . isMatchOptionalTrailingSeparator ( ) ) {
matches = ( this . variableNames . isEmpty ( )
| | textToMatch . length ( ) > 0 )
& & ( pathIndex + 2 ) > = matchingContext . pathLength
& & matchingContext . isSeparator ( pathIndex + 1 ) ;
matches = ( this . variableNames . isEmpty ( ) | | textToMatch . length ( ) > 0 ) & &
( pathIndex + 2 > = matchingContext . pathLength ) & &
matchingContext . isSeparator ( pathIndex + 1 ) ;
}
}
}
@ -160,11 +159,11 @@ class RegexPathElement extends PathElement {
@@ -160,11 +159,11 @@ class RegexPathElement extends PathElement {
if ( matches & & matchingContext . extractingVariables ) {
// Process captures
if ( this . variableNames . size ( ) ! = matcher . groupCount ( ) ) { // SPR-8455
throw new IllegalArgumentException ( "The number of capturing groups in the pattern segment "
+ this . pattern + " does not match the number of URI template variables it defines, "
+ "which can occur if capturing groups are used in a URI template regex. "
+ "Use non-capturing groups instead." ) ;
if ( this . variableNames . size ( ) ! = matcher . groupCount ( ) ) { // SPR-8455
throw new IllegalArgumentException ( "The number of capturing groups in the pattern segment " +
this . pattern + " does not match the number of URI template variables it defines, " +
"which can occur if capturing groups are used in a URI template regex. " +
"Use non-capturing groups instead." ) ;
}
for ( int i = 1 ; i < = matcher . groupCount ( ) ; i + + ) {
String name = this . variableNames . get ( i - 1 ) ;
@ -187,6 +186,11 @@ class RegexPathElement extends PathElement {
@@ -187,6 +186,11 @@ class RegexPathElement extends PathElement {
return ( this . regex . length - varsLength - this . variableNames . size ( ) ) ;
}
@Override
public char [ ] getChars ( ) {
return this . regex ;
}
@Override
public int getCaptureCount ( ) {
return this . variableNames . size ( ) ;
@ -208,8 +212,4 @@ class RegexPathElement extends PathElement {
@@ -208,8 +212,4 @@ class RegexPathElement extends PathElement {
return "Regex(" + String . valueOf ( this . regex ) + ")" ;
}
@Override
public char [ ] getChars ( ) {
return this . regex ;
}
}