@Override public boolean matches( final StringCursor string , final Map<String, String> foundParameters ) { string.mark(); string.end(); foundParameters.put(placeholder, string.substringFromLastMark()); return true; }
private String getAuthString( StringCursor headerValue ) { headerValue.cursorAt( PREFIX_LENGTH ); headerValue.mark(); headerValue.end(); return headerValue.substringFromLastMark(); }
/** * Shift the cursor to the next occurrence of {@code ch} and returns * {@code true}. Otherwise, it will keep the cursor at same position, but * will return {@code false}. * * @param ch * @return */ public boolean shiftCursorToNextChar( final char ch ) { mark(); while ( hasNext() ) if ( next() == ch ) return true; flip(); return false; }
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 ); } }