private static Token createToken ( char symbol , StringBuilder nameBuf , StringBuilder valueBuf ) { String value = null ; if ( valueBuf . length ( ) > 0 ) { value = valueBuf . toString ( ) ; valueBuf . setLength ( 0 ) ; // empty the value buffer } if ( nameBuf . length ( ) > 0 ) { TokenType type = Token . resolveTypeAsSymbol ( symbol ) ; String name = nameBuf . toString ( ) ; nameBuf . setLength ( 0 ) ; // empty the name buffer int offset = name . indexOf ( Token . GETTER_SEPARATOR ) ; if ( offset > - 1 ) { String name2 = name . substring ( 0 , offset ) ; String getter = name . substring ( offset + 1 ) ; Token token = new Token ( type , name2 ) ; if ( ! getter . isEmpty ( ) ) { token . setGetterName ( getter ) ; } token . setDefaultValue ( value ) ; return token ; } else if ( value != null ) { TokenDirectiveType directiveType = TokenDirectiveType . resolve ( name ) ; if ( directiveType != null ) { String getter = null ; String defaultValue = null ; offset = value . indexOf ( Token . GETTER_SEPARATOR ) ; if ( offset > - 1 ) { String value2 = value . substring ( 0 , offset ) ; String getter2 = value . substring ( offset + 1 ) ; value = value2 ; offset = getter2 . indexOf ( Token . VALUE_SEPARATOR ) ; if ( offset > - 1 ) { String getter3 = getter2 . substring ( 0 , offset ) ; String value3 = getter2 . substring ( offset + 1 ) ; if ( ! getter3 . isEmpty ( ) ) { getter = getter3 ; } if ( ! value3 . isEmpty ( ) ) { defaultValue = value3 ; } } else { if ( ! getter2 . isEmpty ( ) ) { getter = getter2 ; } } } Token token = new Token ( type , directiveType , value ) ; token . setGetterName ( getter ) ; token . setDefaultValue ( defaultValue ) ; return token ; } else { Token token = new Token ( type , name ) ; token . setDefaultValue ( value ) ; return token ; } } else { return new Token ( type , name ) ; } } else { // when not exists tokenName then tokenType must be TEXT type return new Token ( value ) ; } }
Create a token .