public static URLMatcher compile( final String string, final boolean doNotIgnoreSlashes ) { val compiler = new URLPatternCompiler( doNotIgnoreSlashes ); compiler.compile( string ); return new URLMatcher( compiler.patternMatchers ); }
private void compileSpecialCharacters( final StringCursor cursor, final char next ) { appendEqualsMatcherForBufferedTextUntilNow( cursor ); cursor.mark(); handleSpecialCharacter( cursor, next ); cursor.mark(); }
public void compile( final String string ) { final StringCursor cursor = new StringCursor( string ); while ( cursor.hasNext() ) compile( cursor, cursor.next() ); if ( remainsUnparsedDataInCursor ) patternMatchers.add( new EqualsMatcher( cursor.substringFromLastMark() ) ); patternMatchers.add( new EndOfStringMatcher() ); }
MatchedEntry retrieveEntryThatMatchesUrlFromList( final List<Entry> list, final String url ) { final Map<String, String> matchedPathParameters = new HashMap<>(); for ( final Entry entry : list ) if ( entry.getMatcher().matches( url, matchedPathParameters ) ) return new MatchedEntry( url, entry.getHandler(), matchedPathParameters ); return null; }
@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 ); }
private String getAuthString( StringCursor headerValue ) { headerValue.cursorAt( PREFIX_LENGTH ); headerValue.mark(); headerValue.end(); return headerValue.substringFromLastMark(); }
private void appendMatcherForAsterisk( final StringCursor cursor ) { if ( cursor.hasNext() ) patternMatchers.add( new AnyStringNextValidCharMatcher( cursor.next() ) ); else patternMatchers.add( new AnyStringUntilEndMatcher() ); }
public boolean matches( final String string, final Map<String, String> foundParameters ) { return matches( new StringCursor( string ), foundParameters ); }
Entry( final String url, final String method, final AmazonHttpHandler handler ) { this.asString = method + " " + url; this.handler = handler; this.matcher = URLMatcher.compile( url, true ); }
@Override public boolean matches( final StringCursor string , final Map<String, String> foundParameters ) { val pattern = new StringCursor( patternChars ); return pattern.matches( string ); }
private void handleSpecialCharacter( final StringCursor cursor, final char next ) { if ( next == '*' ) appendMatcherForAsterisk( cursor ); else if ( next == '{' ) appendPlaceHolderMatcher( cursor ); }
@Override public boolean matches( final StringCursor string , final Map<String, String> foundParameters ) { string.end(); return true; }
@Override public void replace( final StringBuilder buffer, final Map<String, String> foundParameters ) { for ( final Matcher matcher : patternMatchers ) matcher.replace( buffer, foundParameters ); }
@Override public boolean matches( final StringCursor string , final Map<String, String> foundParameters ) { return string.shiftCursorToNextChar( nextValidChar ); }
public DeploymentContext fallbackHandler(final HttpHandler fallbackHandler ) { routingHandler.setFallbackHandler( fallbackHandler ); return this; }
public HttpHandler fallbackHandler(){ return routingHandler.getFallbackHandler(); } }
private void compile( final StringCursor cursor, final char next ) { if ( next == '*' || next == '{' ) { compileSpecialCharacters( cursor, next ); remainsUnparsedDataInCursor = false; } else remainsUnparsedDataInCursor = true; }
public Entry( final String url, final HttpHandler handler ) { this.handler = handler; this.matcher = URLMatcher.compile( url, true ); this.url = url; }