public final class EncodingFactory extends java.lang.Object implements IEncodingFactory
EncodingDefinition and Encoding.| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
ENCODING_NAME_NONE |
static java.lang.String |
ENCODING_NAME_OCTETS |
| Modifier and Type | Method and Description |
|---|---|
static IEncodingFactory |
createInstance(java.nio.charset.Charset charset)
|
static IEncodingFactory |
createInstance(EncodingDefinition encodingDefinition)
Returns an
IEncodingFactory that uses encodingDefinition as the
default. |
static EncodingFactory |
createInstance(EncodingSet... encodingSets)
Creates a new EncodingFactory based on the supplied encodingSets.
|
static int |
getCharacterSetSize(int characterSetId)
Deprecated.
Use the information provided by the
EncodingDefinition returned by getEncodingDefinitionByCharacterSetId(int) |
CharacterTranslator |
getCharacterTranslator(java.lang.String mappingPath)
Gets an instance of
CharacterTranslator for the specified mappingPath. |
Encoding |
getDefaultEncoding() |
EncodingDefinition |
getDefaultEncodingDefinition()
Returns the
EncodingDefinition for the default platform character set. |
static Encoding |
getEncoding(java.nio.charset.Charset charset)
|
static Encoding |
getEncoding(java.nio.charset.Charset charset,
java.lang.String mappingPath)
Deprecated.
To be removed in Jaybird 4, use
getEncodingForCharset(Charset) |
static Encoding |
getEncoding(java.lang.String javaCharsetAlias)
Deprecated.
|
static Encoding |
getEncoding(java.lang.String encoding,
java.lang.String mappingPath)
Deprecated.
To be removed in Jaybird 4, use
getEncodingForCharsetAlias(String) |
EncodingDefinition |
getEncodingDefinition(java.lang.String firebirdEncodingName,
java.lang.String javaCharsetAlias)
Gets or creates an
EncodingDefinition for the supplied Firebird encoding and Java charset. |
EncodingDefinition |
getEncodingDefinitionByCharacterSetId(int firebirdCharacterSetId)
Looks up the
EncodingDefinition for the specified Firebird character set id. |
EncodingDefinition |
getEncodingDefinitionByCharset(java.nio.charset.Charset charset)
Looks up an
EncodingDefinition for the Java Charset. |
EncodingDefinition |
getEncodingDefinitionByCharsetAlias(java.lang.String charsetAlias)
Looks up the
EncodingDefinition by the specified Java character set name or
alias. |
EncodingDefinition |
getEncodingDefinitionByFirebirdName(java.lang.String firebirdEncodingName)
Looks up the
EncodingDefinition for the specified Firebird encoding name. |
Encoding |
getEncodingForCharacterSetId(int firebirdCharacterSetId)
Gets an
Encoding for the specified Firebird character set id. |
Encoding |
getEncodingForCharacterSetId(int firebirdCharacterSetId,
Encoding fallbackEncoding)
Gets an
Encoding for the specified Firebird character set id. |
Encoding |
getEncodingForCharset(java.nio.charset.Charset charset)
Gets an
Encoding for the specified Java character set. |
Encoding |
getEncodingForCharset(java.nio.charset.Charset charset,
Encoding fallbackEncoding)
Gets an
Encoding for the specified Java character set. |
Encoding |
getEncodingForCharsetAlias(java.lang.String charsetAlias)
Gets an
Encoding for the specified Java character set name or alias. |
Encoding |
getEncodingForCharsetAlias(java.lang.String charsetAlias,
Encoding fallbackEncoding)
Gets an
Encoding for the specified Java character set name or alias. |
Encoding |
getEncodingForFirebirdName(java.lang.String firebirdEncodingName)
Gets an
Encoding for the specified Firebird encoding. |
Encoding |
getEncodingForFirebirdName(java.lang.String firebirdEncodingName,
Encoding fallbackEncoding)
Gets an
Encoding for the specified Firebird encoding. |
static java.lang.String |
getIscEncoding(java.nio.charset.Charset javaCharset)
Deprecated.
|
static java.lang.String |
getIscEncoding(java.lang.String javaCharsetAlias)
Deprecated.
|
static int |
getIscEncodingSize(java.lang.String iscEncoding)
Deprecated.
|
static java.lang.String |
getJavaEncoding(java.lang.String iscEncoding)
Deprecated.
|
static java.lang.String |
getJavaEncodingForAlias(java.lang.String javaAlias)
Deprecated.
|
Encoding |
getOrCreateEncodingForCharset(java.nio.charset.Charset charset)
Creates an
Encoding for the specified Java character set. |
static IEncodingFactory |
getPlatformDefault()
Returns an instance of
IEncodingFactory with the default encoding set to the platform encoding. |
static Encoding |
getPlatformEncoding() |
static CharacterTranslator |
getTranslator(java.lang.String mappingPath)
Gets the
CharacterTranslator for the specified mappingPath, or null if there is no such
mappingPath |
IEncodingFactory |
withDefaultEncodingDefinition()
Returns an
ConnectionEncodingFactory that uses
getDefaultEncodingDefinition() as the default. |
IEncodingFactory |
withDefaultEncodingDefinition(java.nio.charset.Charset charset)
|
IEncodingFactory |
withDefaultEncodingDefinition(EncodingDefinition encodingDefinition)
Returns an
IEncodingFactory that uses encodingDefinition as the
default. |
public static final java.lang.String ENCODING_NAME_NONE
public static final java.lang.String ENCODING_NAME_OCTETS
public Encoding getDefaultEncoding()
getDefaultEncoding in interface IEncodingFactoryEncoding for Charset.defaultCharset().public static Encoding getPlatformEncoding()
public EncodingDefinition getDefaultEncodingDefinition()
IEncodingFactoryEncodingDefinition for the default platform character set.
If the default character set is not supported by Jaybird, an instance of EncodingDefinition should be returned
with Firebird encoding name "NONE".
getDefaultEncodingDefinition in interface IEncodingFactoryEncodingDefinition for Charset.defaultCharset().public EncodingDefinition getEncodingDefinitionByFirebirdName(java.lang.String firebirdEncodingName)
IEncodingFactoryEncodingDefinition for the specified Firebird encoding name.getEncodingDefinitionByFirebirdName in interface IEncodingFactoryfirebirdEncodingName - The Firebird encoding name (case insensitive)null if the encoding name is unknownpublic Encoding getEncodingForFirebirdName(java.lang.String firebirdEncodingName, Encoding fallbackEncoding)
Encoding for the specified Firebird encoding. If there is no known
encoding for this name, or the loaded EncodingDefinition is information-only, then the fallbackEncoding.firebirdEncodingName - The Firebird encoding name (case insensitive)fallbackEncoding - The Encoding to use as fallback if no encoding is found (usually the connection encoding). If
null, the defaultEncoding for the JVM is used.public Encoding getEncodingForFirebirdName(java.lang.String firebirdEncodingName)
IEncodingFactoryEncoding for the specified Firebird encoding. If there is no known
encoding for this name,
or the loaded EncodingDefinition is information-only, then the defaultEncoding is used.getEncodingForFirebirdName in interface IEncodingFactoryfirebirdEncodingName - The Firebird encoding name (case insensitive)public EncodingDefinition getEncodingDefinitionByCharacterSetId(int firebirdCharacterSetId)
IEncodingFactoryEncodingDefinition for the specified Firebird character set id.
Implementations that do not know the connection character set should return null for the
value ISCConstants.CS_dynamic (= 127), as that is the indicator to use
the connection character set.
getEncodingDefinitionByCharacterSetId in interface IEncodingFactoryfirebirdCharacterSetId - Firebird character set idnull if the character set id is unknown or 127 and this
implementation doesn't know the connection character set.public Encoding getEncodingForCharacterSetId(int firebirdCharacterSetId, Encoding fallbackEncoding)
Encoding for the specified Firebird character set id. If there is no
known encoding for this character set id (or if it is 127, see getEncodingDefinitionByCharacterSetId(int)),
or the loaded EncodingDefinition is information-only, then the fallbackEncoding will be used.firebirdCharacterSetId - The Firebird character set idfallbackEncoding - The Encoding to use as fallback if no encoding is found (usually the connection encoding). If
null, the defaultEncoding for the JVM is used.public Encoding getEncodingForCharacterSetId(int firebirdCharacterSetId)
IEncodingFactoryEncoding for the specified Firebird character set id. If there is no
known encoding for this character set id (or if it is 127,
see IEncodingFactory.getEncodingDefinitionByCharacterSetId(int)), or the loaded EncodingDefinition is information-only,
then the defaultEncoding will be used.getEncodingForCharacterSetId in interface IEncodingFactoryfirebirdCharacterSetId - The Firebird character set idpublic EncodingDefinition getEncodingDefinitionByCharset(java.nio.charset.Charset charset)
IEncodingFactoryEncodingDefinition for the Java Charset.getEncodingDefinitionByCharset in interface IEncodingFactorycharset - The Java character setnull if the character set is not mappedpublic Encoding getEncodingForCharset(java.nio.charset.Charset charset, Encoding fallbackEncoding)
IEncodingFactoryEncoding for the specified Java character set. If there is no known
encoding for this Charset, or the loaded EncodingDefinition is information-only, then
the fallbackEncoding will be used.getEncodingForCharset in interface IEncodingFactorycharset - The Java character setfallbackEncoding - The Encoding to use as fallback if no encoding is found (usually the connection encoding). If
null, the defaultEncoding for the JVM is used.IEncodingFactory.getOrCreateEncodingForCharset(java.nio.charset.Charset)public Encoding getEncodingForCharset(java.nio.charset.Charset charset)
IEncodingFactoryEncoding for the specified Java character set. If there is no known
encoding for this Charset, or the loaded EncodingDefinition is information-only, then
the defaultEncoding will be used.getEncodingForCharset in interface IEncodingFactorycharset - The Java character setpublic Encoding getOrCreateEncodingForCharset(java.nio.charset.Charset charset)
IEncodingFactoryEncoding for the specified Java character set. If there is no known encoding for this
charset, then an Encoding instance based on the charset is returned.
In general the method IEncodingFactory.getEncodingForCharset(java.nio.charset.Charset, Encoding) should be used.
Don't confuse this method with IEncodingFactory.getEncodingForCharset(Charset), which falls back to the default
encoding.
getOrCreateEncodingForCharset in interface IEncodingFactorycharset - The Java character setIEncodingFactory.getEncodingForCharset(java.nio.charset.Charset, Encoding)public EncodingDefinition getEncodingDefinitionByCharsetAlias(java.lang.String charsetAlias)
IEncodingFactoryEncodingDefinition by the specified Java character set name or
alias.getEncodingDefinitionByCharsetAlias in interface IEncodingFactorycharsetAlias - Name (or alias) of the Java character set (case insensitive)null if the character set name is not mappedpublic Encoding getEncodingForCharsetAlias(java.lang.String charsetAlias, Encoding fallbackEncoding)
Encoding for the specified Java character set name or alias. If there
is no known encoding for this name, or the loaded EncodingDefinition is information-only, then the
fallbackEncoding will be used.charsetAlias - The Java character set name or aliasfallbackEncoding - The Encoding to use as fallback if no encoding is found (usually the connection encoding). If
null, the defaultEncoding for the JVM is used.public Encoding getEncodingForCharsetAlias(java.lang.String charsetAlias)
IEncodingFactoryEncoding for the specified Java character set name or alias. If there
is no known encoding for
this name, or the loaded EncodingDefinition is information-only, then the defaultEncoding will be used.getEncodingForCharsetAlias in interface IEncodingFactorycharsetAlias - The Java character set name or aliaspublic CharacterTranslator getCharacterTranslator(java.lang.String mappingPath) throws java.sql.SQLException
IEncodingFactoryCharacterTranslator for the specified mappingPath.getCharacterTranslator in interface IEncodingFactorymappingPath - Path of the file with mapping definitionjava.sql.SQLExceptionpublic EncodingDefinition getEncodingDefinition(java.lang.String firebirdEncodingName, java.lang.String javaCharsetAlias)
IEncodingFactoryEncodingDefinition for the supplied Firebird encoding and Java charset.
When firebirdEncodingName is not null and javaCharsetAlias is null, then the
encoding definition as returned by IEncodingFactory.getEncodingDefinitionByFirebirdName(String) is returned. For the
reverse (firebirdEncodingName is null and javaCharsetAlias isn't), the encoding
definition
as returned by IEncodingFactory.getEncodingDefinitionByCharsetAlias(String) is returned.
When both parameters are set, the result of IEncodingFactory.getEncodingDefinitionByFirebirdName(String) is returned if
the
character set matches, otherwise a new DefaultEncodingDefinition is created based on its information,
but
with the specified character set. This can be useful for attempting to fix encoding issues in Firebird.
If either of the parameters cannot be resolved, to an EncodingDefinition or Charset, or the
EncodingDefinition
is information-only - with the exception of Firebird encoding NONE - and no Java Charset is specified, then null
is returned.
getEncodingDefinition in interface IEncodingFactoryfirebirdEncodingName - Name of the Firebird encoding, or null to defer decision to the java Charset aliasjavaCharsetAlias - Alias of the Java character set, or null to defer decision to the Firebird encodingpublic IEncodingFactory withDefaultEncodingDefinition(EncodingDefinition encodingDefinition)
IEncodingFactory that uses encodingDefinition as the
default.
This implementation returns an instance of ConnectionEncodingFactory.
withDefaultEncodingDefinition in interface IEncodingFactoryencodingDefinition - The default encoding to use (or null for the value of IEncodingFactory.getDefaultEncoding()public IEncodingFactory withDefaultEncodingDefinition(java.nio.charset.Charset charset)
IEncodingFactory that uses an EncodingDefinition identified
by charSet as the default.
This implementation returns an instance of ConnectionEncodingFactory.
withDefaultEncodingDefinition in interface IEncodingFactorycharset - The default charset to use.public IEncodingFactory withDefaultEncodingDefinition()
ConnectionEncodingFactory that uses
getDefaultEncodingDefinition() as the default.public static IEncodingFactory getPlatformDefault()
IEncodingFactory with the default encoding set to the platform encoding.IEncodingFactory.public static IEncodingFactory createInstance(EncodingDefinition encodingDefinition)
IEncodingFactory that uses encodingDefinition as the
default.
If encodingDefinition is null or an information-only encoding, the implementation will
return the cached instance returned by getPlatformDefault().
encodingDefinition - The default encoding to use (or null to get getPlatformDefault()public static IEncodingFactory createInstance(java.nio.charset.Charset charset)
IEncodingFactory that uses an EncodingDefinition identified
by charSet as the default.
If charset is null, the implementation will return the cached instance return by
getPlatformDefault().
charset - The default charset to use, or null for getPlatformDefault().public static EncodingFactory createInstance(EncodingSet... encodingSets)
EncodingSet instances
are processed highest preferenceWeight first.encodingSets - The EncodingSet definitions to use for the EncodingFactory instance@Deprecated public static int getCharacterSetSize(int characterSetId)
EncodingDefinition returned by getEncodingDefinitionByCharacterSetId(int)characterSetId - of the character set.@Deprecated public static Encoding getEncoding(java.lang.String javaCharsetAlias)
getEncodingForCharsetAlias(String, Encoding)Encoding instance for the supplied java Charset name.javaCharsetAlias - Java Charset nameEncoding@Deprecated public static Encoding getEncoding(java.nio.charset.Charset charset)
getEncodingForCharset(java.nio.charset.Charset, Encoding) or getOrCreateEncodingForCharset(java.nio.charset.Charset)Encoding instance for the supplied java Charset.charset - Java CharsetEncoding@Deprecated public static Encoding getEncoding(java.lang.String encoding, java.lang.String mappingPath) throws java.sql.SQLException
getEncodingForCharsetAlias(String)Encoding instance for the supplied java Charset name and
alternative character mapping.encoding - Java Charset namemappingPath - Resource file with alternative character mappingEncodingjava.sql.SQLException@Deprecated public static Encoding getEncoding(java.nio.charset.Charset charset, java.lang.String mappingPath) throws java.sql.SQLException
getEncodingForCharset(Charset)Encoding instance for the supplied java Charset and
alternative character mapping.charset - Java CharsetmappingPath - Resource file with alternative character mappingEncodingjava.sql.SQLException@Deprecated public static java.lang.String getIscEncoding(java.lang.String javaCharsetAlias)
getEncodingDefinitionByCharsetAlias(String)javaCharsetAlias - Java language encoding.null if none
found.@Deprecated public static java.lang.String getIscEncoding(java.nio.charset.Charset javaCharset)
getEncodingDefinitionByCharset(java.nio.charset.Charset)javaCharset - Java Charsetnull if none
found.@Deprecated public static int getIscEncodingSize(java.lang.String iscEncoding)
getEncodingDefinitionByFirebirdName(String) and EncodingDefinition.getMaxBytesPerChar()iscEncoding - Firebird encoding.@Deprecated public static java.lang.String getJavaEncoding(java.lang.String iscEncoding)
iscEncoding - Firebird encodingnull if none found.
Use getEncodingDefinitionByFirebirdName(String) and EncodingDefinition.getJavaEncodingName()@Deprecated public static java.lang.String getJavaEncodingForAlias(java.lang.String javaAlias)
getEncodingDefinitionByCharsetAlias(String) and EncodingDefinition.getJavaEncodingName()Ensures that naming is consistent even if a different alias was used.
javaAlias - Java alias for the encodingpublic static CharacterTranslator getTranslator(java.lang.String mappingPath) throws java.sql.SQLException
CharacterTranslator for the specified mappingPath, or null if there is no such
mappingPathmappingPath - Path of the mapping definition filenulljava.sql.SQLExceptionCopyright © 2001-2021 Jaybird (Firebird JDBC/JCA) team. All rights reserved.