@Override public boolean matches( final StringCursor string , final Map<String, String> foundParameters ) { return string.shiftCursorToNextChar( nextValidChar ); }
@Override public boolean matches( final StringCursor string , final Map<String, String> foundParameters ) { final boolean existsNextChar = string.shiftCursorToNextChar( nextChar ); if ( existsNextChar ) foundParameters.put( placeholder, string.substringFromLastMark( GAP_BETWEEN_END_OF_PLACEHOLDER_AND_NEXT_CHAR ) ); return existsNextChar; }
private void appendPlaceHolderMatcher( final StringCursor cursor ) { if ( !cursor.shiftCursorToNextChar( '}' ) ) throw new RuntimeException( "Invalid expression!" ); final String placeholder = cursor.substringFromLastMark( 1 ); if ( cursor.hasNext() ) { final char nextChar = cursor.next(); patternMatchers.add( new PlaceHolderMatcher( placeholder, nextChar ) ); } else patternMatchers.add( new PlaceHolderForAnyStringUntilEndMatcher( placeholder, doNotIgnoreSlashes ) ); } }
@Override public boolean matches( final StringCursor string , final Map<String, String> foundParameters ) { val pattern = new StringCursor( patternChars ); final char firstPatternChar = pattern.next(); return string.shiftCursorToNextChar( firstPatternChar ) && pattern.matches( string ); }
String stripHostFromHeader( final String hostHeader ) { val cursor = new StringCursor( hostHeader ); if ( !cursor.shiftCursorToNextChar( ':' ) ) cursor.end(); else cursor.prev(); val host = cursor.substringUntilCursor(); return host; }
private UsernameAndPasswordCredential convertToCredential( StringCursor decodedCredentials ) { decodedCredentials.shiftCursorToNextChar( COLON ); final String username = decodedCredentials.substringFromLastMark(1); decodedCredentials.mark(); decodedCredentials.end(); final String password = decodedCredentials.substringFromLastMark(); return new UsernameAndPasswordCredential( username, password ); }
static Tuple<String, String> fixContentType( String contentType, String defaultEncoding ){ if ( contentType == null ) return Tuple.empty(); final StringCursor cursor = new StringCursor(contentType); if ( cursor.shiftCursorToNextChar( ';' ) ) { contentType = cursor.substringFromLastMark( 1 ); cursor.mark(1); cursor.end(); defaultEncoding = cursor.substringFromLastMark(); } return Tuple.of( contentType, defaultEncoding ); } }