public static Vector processAcceptLanguage ( String acceptLanguage ) { init ( ) ; StringTokenizer languageTokenizer = new StringTokenizer ( acceptLanguage , "," ) ; TreeMap map = new TreeMap ( Collections . reverseOrder ( ) ) ; while ( languageTokenizer . hasMoreTokens ( ) ) { String language = languageTokenizer . nextToken ( ) . trim ( ) ; /* begin pq57399: part 1 */ if ( language == null || language . length ( ) == 0 ) { if ( com . ibm . ejs . ras . TraceComponent . isAnyTracingEnabled ( ) && logger . isLoggable ( Level . FINE ) ) { logger . logp ( Level . FINE , CLASS_NAME , "processAcceptLanguage" , "Encountered zero length language token without quality index.. skipping token" ) ; logger . logp ( Level . FINE , CLASS_NAME , "processAcceptLanguage" , "acceptLanguage param = [" + acceptLanguage + "]" ) ; } continue ; } /* end pq57399: part 1 */ int semicolonIndex = language . indexOf ( ' ' ) ; Double qValue = new Double ( 1 ) ; if ( semicolonIndex > - 1 ) { int qIndex = language . indexOf ( "q=" ) ; String qValueStr = language . substring ( qIndex + 2 ) ; try { qValue = new Double ( qValueStr . trim ( ) ) ; } catch ( NumberFormatException nfe ) { com . ibm . wsspi . webcontainer . util . FFDCWrapper . processException ( nfe , "com.ibm.ws.webcontainer.srt.SRTRequestUtils.processAcceptLanguage" , "215" ) ; } language = language . substring ( 0 , semicolonIndex ) ; } if ( language . length ( ) > 0 ) { /* added for pq57399: part 2*/ if ( ( qValue . doubleValue ( ) > 0 ) && ( language . charAt ( 0 ) != ' ' ) ) { Vector newVector = new Vector ( ) ; if ( map . containsKey ( qValue ) ) { newVector = ( Vector ) map . get ( qValue ) ; } newVector . addElement ( language ) ; map . put ( qValue , newVector ) ; } /* begin pq57399: part 3 */ } else { if ( com . ibm . ejs . ras . TraceComponent . isAnyTracingEnabled ( ) && logger . isLoggable ( Level . FINE ) ) { logger . logp ( Level . FINE , CLASS_NAME , "processAcceptLanguage" , "Encountered zero length language token with quality index.. skipping token" ) ; logger . logp ( Level . FINE , CLASS_NAME , "processAcceptLanguage" , "acceptLanguage param = [" + acceptLanguage + "]" ) ; } } /* end pq57399: part 3 */ } if ( map . isEmpty ( ) ) { Vector v = new Vector ( ) ; v . addElement ( Locale . getDefault ( ) . toString ( ) ) ; map . put ( "1" , v ) ; } return new Vector ( map . values ( ) ) ; }
Processes the accept languages in a passed in String into a Vector object .