private static List<String> parseTokens(String exp) {
        if (exp == null) {
            return null;
        }
        List<String> tokens = new ArrayList<String>();
        Character commentChar = null;
        int start = 0;
        for (int i = 0; i < exp.length(); i++) {
            if (exp.charAt(i) == '"') {
                if (commentChar == null) {
                    commentChar = '"';
                } else if (commentChar == '"') {
                    commentChar = null;
                    tokens.add(exp.substring(start, i + 1).trim());
                    start = i + 1;
                }
            } else if (exp.charAt(i) == '\'') {
                if (commentChar == null) {
                    commentChar = '\'';
                } else if (commentChar == '\'') {
                    commentChar = null;
                    tokens.add(exp.substring(start, i + 1).trim());
                    start = i + 1;
                }
            } else if (exp.charAt(i) == '[') {
                if (commentChar == null) {
                    if (start != i) {
                        tokens.add(exp.substring(start, i).trim());
                    }
                    tokens.add("[");
                    start = i + 1;
                }
            } else if (exp.charAt(i) == ']') {
                if (commentChar == null) {
                    if (start != i) {
                        tokens.add(exp.substring(start, i).trim());
                    }
                    tokens.add("]");
                    start = i + 1;
                }
            } else if (exp.charAt(i) == '.') {
                if (commentChar == null) {
                    if (start != i) {
                        tokens.add(exp.substring(start, i).trim());
                    }
                    start = i + 1;
                }
            } else if (i == exp.length() - 1) {
                tokens.add(exp.substring(start, i + 1).trim());
            }
        }
        return tokens;
    }
private static List < String > parseTokens ( String exp ) { if ( exp == null ) { return null ; } List < String > tokens = new ArrayList < String > ( ) ; Character commentChar = null ; int start = 0 ; for ( int i = 0 ; i < exp . length ( ) ; i ++ ) { if ( exp . charAt ( i ) == '"' ) { if ( commentChar == null ) { commentChar = '"' ; } else if ( commentChar == '"' ) { commentChar = null ; tokens . add ( exp . substring ( start , i + 1 ) . trim ( ) ) ; start = i + 1 ; } } else if ( exp . charAt ( i ) == '\'' ) { if ( commentChar == null ) { commentChar = '\'' ; } else if ( commentChar == '\'' ) { commentChar = null ; tokens . add ( exp . substring ( start , i + 1 ) . trim ( ) ) ; start = i + 1 ; } } else if ( exp . charAt ( i ) == '[' ) { if ( commentChar == null ) { if ( start != i ) { tokens . add ( exp . substring ( start , i ) . trim ( ) ) ; } tokens . add ( "[" ) ; start = i + 1 ; } } else if ( exp . charAt ( i ) == ']' ) { if ( commentChar == null ) { if ( start != i ) { tokens . add ( exp . substring ( start , i ) . trim ( ) ) ; } tokens . add ( "]" ) ; start = i + 1 ; } } else if ( exp . charAt ( i ) == '.' ) { if ( commentChar == null ) { if ( start != i ) { tokens . add ( exp . substring ( start , i ) . trim ( ) ) ; } start = i + 1 ; } } else if ( i == exp . length ( ) - 1 ) { tokens . add ( exp . substring ( start , i + 1 ) . trim ( ) ) ; } } return tokens ; }
First step tokenization.
<br/><br/>Example, for the following input:
<br/><pre><code>
$.map["akey"].array[*]
</code></pre> returns:
<pre><code>
$
map
[
"akey"
]
array
[
*
]
</code></pre>

@param exp
@return