private boolean isValid ( final String path , final int pathPosition , final int segmentIndex ) { Segment segment = segments . get ( segmentIndex ) ; String expectedValue = segment . getStaticText ( ) ; if ( expectedValue == null ) { if ( segmentIndex == segments . size ( ) - 1 ) { return segment . validateToken ( path . substring ( pathPosition ) ) ; } else { String nextValue = segments . get ( segmentIndex + 1 ) . getStaticText ( ) ; for ( int i = path . indexOf ( nextValue , pathPosition ) ; i >= 0 ; i = path . indexOf ( nextValue , i + 1 ) ) { if ( segment . validateToken ( path . substring ( pathPosition , i ) ) && isValid ( path , i , segmentIndex + 1 ) ) { return true ; } } return false ; } } else if ( path . startsWith ( expectedValue , pathPosition ) ) { if ( segmentIndex == segments . size ( ) - 1 ) { return pathPosition + expectedValue . length ( ) == path . length ( ) ; } else { return isValid ( path , pathPosition + expectedValue . length ( ) , segmentIndex + 1 ) ; } } else { return false ; } }
Checks if a partial path to a file is compatible with this dynamic path .