public static Encoding getDatabaseEncoding ( String databaseEncoding ) { if ( "UTF8" . equals ( databaseEncoding ) ) { return UTF8_ENCODING ; } // If the backend encoding is known and there is a suitable // encoding in the JVM we use that. Otherwise we fall back // to the default encoding of the JVM. String [ ] candidates = encodings . get ( databaseEncoding ) ; if ( candidates != null ) { for ( String candidate : candidates ) { LOGGER . log ( Level . FINEST , "Search encoding candidate {0}" , candidate ) ; if ( Charset . isSupported ( candidate ) ) { return new Encoding ( candidate ) ; } } } // Try the encoding name directly -- maybe the charset has been // provided by the user. if ( Charset . isSupported ( databaseEncoding ) ) { return new Encoding ( databaseEncoding ) ; } // Fall back to default JVM encoding. LOGGER . log ( Level . FINEST , "{0} encoding not found, returning default encoding" , databaseEncoding ) ; return DEFAULT_ENCODING ; }
Construct an Encoding for a given database encoding .