public static AbstractType < ? > parse ( String str ) throws SyntaxException , ConfigurationException { if ( str == null ) return BytesType . instance ; AbstractType < ? > type = cache . get ( str ) ; if ( type != null ) return type ; // This could be simplier (i.e. new TypeParser(str).parse()) but we avoid creating a TypeParser object if not really necessary. int i = 0 ; i = skipBlank ( str , i ) ; int j = i ; while ( ! isEOS ( str , i ) && isIdentifierChar ( str . charAt ( i ) ) ) ++ i ; if ( i == j ) return BytesType . instance ; String name = str . substring ( j , i ) ; i = skipBlank ( str , i ) ; if ( ! isEOS ( str , i ) && str . charAt ( i ) == ' ' ) type = getAbstractType ( name , new TypeParser ( str , i ) ) ; else type = getAbstractType ( name ) ; // We don't really care about concurrency here. Worst case scenario, we do some parsing unnecessarily cache . put ( str , type ) ; return type ; }
Parse a string containing an type definition .