private Entry convertToEntries ( String newAddress ) { byte [ ] ba = null ; if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) { Tr . entry ( tc , "convertToEntries" ) ; } try { ba = newAddress . getBytes ( "ISO-8859-1" ) ; } catch ( UnsupportedEncodingException x ) { // should never happen, log a message and use default encoding if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEventEnabled ( ) ) { Tr . event ( tc , "ISO-8859-1 encoding not supported. Exception: " + x ) ; } ba = newAddress . getBytes ( ) ; } int baLength = ba . length ; int hashValue = 0 ; int hashLength = 0 ; int e31 = 1 ; Entry oEntry = new Entry ( ) ; for ( int i = 0 ; i < baLength ; i ++ ) { if ( ba [ i ] == WILDCARD_VALUE ) { boolean valid = true ; // make sure it is the first entry, followed by a ".", or nothing if ( i != 0 ) { valid = false ; } if ( baLength >= 2 ) { if ( ba [ 1 ] != PERIOD_VALUE ) { valid = false ; } } if ( valid ) { // if isolated, then store it, and continue to next word. // Store as wildcard entry oEntry . addEntry ( 0 , 0 ) ; // jump over next period to avoid processing this char again i = 1 ; // go back to start of for loop continue ; } } if ( ba [ i ] != PERIOD_VALUE ) { // continue calculating hashcode for this entry hashValue += e31 * ba [ i ] ; e31 = e31 * 31 ; hashLength ++ ; } if ( ( ba [ i ] == PERIOD_VALUE ) || ( i == baLength - 1 ) ) { // end of a "word", need to add if length is non-zero if ( hashLength > 0 ) { oEntry . addEntry ( hashValue , hashLength ) ; } // prepare to calculate next entry hashLength = 0 ; e31 = 1 ; hashValue = 0 ; } } if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) { Tr . exit ( tc , "convertToEntries" ) ; } return oEntry ; }
Convert a single URL address to an Entry object . The entry object will contain the hashcode array and length array of the substrings of this address