public static Set < String > getTokenKeys ( String str ) { Set < String > results = new HashSet < String > ( ) ; String sDelim = "{" ; String eDelim = "}" ; if ( StringUtils . isBlank ( str ) ) { return results ; } int start = - 1 ; int end = 0 ; do { start = str . indexOf ( sDelim , end ) ; if ( start != - 1 ) { end = str . indexOf ( eDelim , start ) ; if ( end != - 1 ) { results . add ( str . substring ( start + sDelim . length ( ) , end ) ) ; } } } while ( start != - 1 && end != - 1 ) ; return results ; }
Retrieve all token keys from a string . A token is found by its its start and end delimiters which are open and close curly braces .