private void parseFragment ( String fragment , boolean query ) { ChunkTokenizer tokenizer = new ChunkTokenizer ( fragment ) ; while ( tokenizer . hasNext ( ) ) { /* check to see if we have an expression or a literal */ String chunk = tokenizer . next ( ) ; if ( chunk . startsWith ( "{" ) ) { /* it's an expression, defer encoding until resolution */ FragmentType type = ( query ) ? FragmentType . QUERY : FragmentType . PATH_SEGMENT ; Expression expression = Expressions . create ( chunk , type ) ; if ( expression == null ) { this . templateChunks . add ( Literal . create ( encode ( chunk , query ) ) ) ; } else { this . templateChunks . add ( expression ) ; } } else { /* it's a literal, pct-encode it */ this . templateChunks . add ( Literal . create ( encode ( chunk , query ) ) ) ; } } }
Parse a template fragment .