private static EncodingInfo [ ] loadEncodingInfo ( ) { try { InputStream is ; SecuritySupport ss = SecuritySupport . getInstance ( ) ; is = ss . getResourceAsStream ( ObjectFactory . findClassLoader ( ) , ENCODINGS_FILE ) ; // j2objc: if resource wasn't found, load defaults from string. if ( is == null ) { is = new ByteArrayInputStream ( ENCODINGS_FILE_STR . getBytes ( StandardCharsets . UTF_8 ) ) ; } Properties props = new Properties ( ) ; if ( is != null ) { props . load ( is ) ; is . close ( ) ; } else { // Seems to be no real need to force failure here, let the // system do its best... The issue is not really very critical, // and the output will be in any case _correct_ though maybe not // always human-friendly... :) // But maybe report/log the resource problem? // Any standard ways to report/log errors (in static context)? } int totalEntries = props . size ( ) ; List encodingInfo_list = new ArrayList ( ) ; Enumeration keys = props . keys ( ) ; for ( int i = 0 ; i < totalEntries ; ++ i ) { String javaName = ( String ) keys . nextElement ( ) ; String val = props . getProperty ( javaName ) ; int len = lengthOfMimeNames ( val ) ; String mimeName ; char highChar ; if ( len == 0 ) { // There is no property value, only the javaName, so try and recover mimeName = javaName ; highChar = ' ' ; // don't know the high code point, will need to test every character } else { try { // Get the substring after the Mime names final String highVal = val . substring ( len ) . trim ( ) ; highChar = ( char ) Integer . decode ( highVal ) . intValue ( ) ; } catch ( NumberFormatException e ) { highChar = 0 ; } String mimeNames = val . substring ( 0 , len ) ; StringTokenizer st = new StringTokenizer ( mimeNames , "," ) ; for ( boolean first = true ; st . hasMoreTokens ( ) ; first = false ) { mimeName = st . nextToken ( ) ; EncodingInfo ei = new EncodingInfo ( mimeName , javaName , highChar ) ; encodingInfo_list . add ( ei ) ; _encodingTableKeyMime . put ( mimeName . toUpperCase ( ) , ei ) ; if ( first ) _encodingTableKeyJava . put ( javaName . toUpperCase ( ) , ei ) ; } } } // Convert the Vector of EncodingInfo objects into an array of them, // as that is the kind of thing this method returns. EncodingInfo [ ] ret_ei = new EncodingInfo [ encodingInfo_list . size ( ) ] ; encodingInfo_list . toArray ( ret_ei ) ; return ret_ei ; } catch ( java . net . MalformedURLException mue ) { throw new org . apache . xml . serializer . utils . WrappedRuntimeException ( mue ) ; } catch ( java . io . IOException ioe ) { throw new org . apache . xml . serializer . utils . WrappedRuntimeException ( ioe ) ; } }
Load a list of all the supported encodings .