- All Implemented Interfaces:
IEncodingFactory
EncodingDefinition
and Encoding
.- Author:
- Mark Rotteveel
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic IEncodingFactory
createInstance
(Charset charset) static IEncodingFactory
createInstance
(EncodingDefinition encodingDefinition) Returns anIEncodingFactory
that usesencodingDefinition
as the default.static EncodingFactory
createInstance
(EncodingSet... encodingSets) Creates a new EncodingFactory based on the supplied encodingSets.Returns theEncodingDefinition
for the default platform character set.getEncodingDefinition
(String firebirdEncodingName, String javaCharsetAlias) Gets or creates anEncodingDefinition
for the supplied Firebird encoding and Java charset.getEncodingDefinitionByCharacterSetId
(int firebirdCharacterSetId) Looks up theEncodingDefinition
for the specified Firebird character set id.getEncodingDefinitionByCharset
(Charset charset) Looks up anEncodingDefinition
for the JavaCharset
.getEncodingDefinitionByCharsetAlias
(String charsetAlias) Looks up theEncodingDefinition
by the specified Java character set name or alias.getEncodingDefinitionByFirebirdName
(String firebirdEncodingName) Looks up theEncodingDefinition
for the specified Firebird encoding name.getEncodingForCharacterSetId
(int firebirdCharacterSetId) Gets anEncoding
for the specified Firebird character set id.getEncodingForCharacterSetId
(int firebirdCharacterSetId, Encoding fallbackEncoding) Gets anEncoding
for the specified Firebird character set id.getEncodingForCharset
(Charset charset) Gets anEncoding
for the specified Java character set.getEncodingForCharset
(Charset charset, Encoding fallbackEncoding) Gets anEncoding
for the specified Java character set.getEncodingForCharsetAlias
(String charsetAlias) Gets anEncoding
for the specified Java character set name or alias.getEncodingForCharsetAlias
(String charsetAlias, Encoding fallbackEncoding) Gets anEncoding
for the specified Java character set name or alias.getEncodingForFirebirdName
(String firebirdEncodingName) Gets anEncoding
for the specified Firebird encoding.getEncodingForFirebirdName
(String firebirdEncodingName, Encoding fallbackEncoding) Gets anEncoding
for the specified Firebird encoding.<T extends DatatypeCoder>
TgetOrCreateDatatypeCoder
(Class<T> datatypeCoderClass, Function<IEncodingFactory, T> datatypeCoderFactory) Gets or - if necessary - creates a datatype coder of the specified type.getOrCreateEncodingForCharset
(Charset charset) Creates anEncoding
for the specified Java character set.static IEncodingFactory
Returns an instance ofIEncodingFactory
with the default encoding set to the platform encoding.static Encoding
Returns anConnectionEncodingFactory
that usesgetDefaultEncodingDefinition()
as the default.withDefaultEncodingDefinition
(Charset charset) withDefaultEncodingDefinition
(EncodingDefinition encodingDefinition) Returns anIEncodingFactory
that usesencodingDefinition
as the default.
-
Field Details
-
ENCODING_NAME_NONE
- See Also:
-
ENCODING_NAME_OCTETS
- See Also:
-
-
Method Details
-
getDefaultEncoding
- Specified by:
getDefaultEncoding
in interfaceIEncodingFactory
- Returns:
- The
Encoding
forCharset.defaultCharset()
.
-
getPlatformEncoding
- Returns:
- The default encoding of the platform.
-
getDefaultEncodingDefinition
Description copied from interface:IEncodingFactory
Returns theEncodingDefinition
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"
.- Specified by:
getDefaultEncodingDefinition
in interfaceIEncodingFactory
- Returns:
- The
EncodingDefinition
forCharset.defaultCharset()
.
-
getEncodingDefinitionByFirebirdName
Description copied from interface:IEncodingFactory
Looks up theEncodingDefinition
for the specified Firebird encoding name.- Specified by:
getEncodingDefinitionByFirebirdName
in interfaceIEncodingFactory
- Parameters:
firebirdEncodingName
- The Firebird encoding name (case-insensitive)- Returns:
- EncodingDefinition instance or
null
if the encoding name is unknown
-
getEncodingForFirebirdName
Gets anEncoding
for the specified Firebird encoding. If there is no known encoding for this name, or the loaded EncodingDefinition is information-only, then the fallbackEncoding.- Parameters:
firebirdEncodingName
- The Firebird encoding name (case-insensitive)fallbackEncoding
- The Encoding to use as fallback if no encoding is found (usually the connection encoding). Ifnull
, the defaultEncoding for the JVM is used.- Returns:
- Encoding instance (never null)
-
getEncodingForFirebirdName
Description copied from interface:IEncodingFactory
Gets anEncoding
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.- Specified by:
getEncodingForFirebirdName
in interfaceIEncodingFactory
- Parameters:
firebirdEncodingName
- The Firebird encoding name (case-insensitive)- Returns:
- Encoding instance (never null)
-
getEncodingDefinitionByCharacterSetId
Description copied from interface:IEncodingFactory
Looks up theEncodingDefinition
for the specified Firebird character set id.Implementations that do not know the connection character set should return
null
for the valueISCConstants.CS_dynamic
(= 127), as that is the indicator to use the connection character set.- Specified by:
getEncodingDefinitionByCharacterSetId
in interfaceIEncodingFactory
- Parameters:
firebirdCharacterSetId
- Firebird character set id- Returns:
- EncodingDefinition instance or
null
if the character set id is unknown or127
and this implementation doesn't know the connection character set.
-
getEncodingForCharacterSetId
Gets anEncoding
for the specified Firebird character set id. If there is no known encoding for this character set id (or if it is 127, seegetEncodingDefinitionByCharacterSetId(int)
), or the loaded EncodingDefinition is information-only, then the fallbackEncoding will be used.- Parameters:
firebirdCharacterSetId
- The Firebird character set idfallbackEncoding
- The Encoding to use as fallback if no encoding is found (usually the connection encoding). Ifnull
, the defaultEncoding for the JVM is used.- Returns:
- Encoding instance (never null)
-
getEncodingForCharacterSetId
Description copied from interface:IEncodingFactory
Gets anEncoding
for the specified Firebird character set id. If there is no known encoding for this character set id (or if it is 127, seeIEncodingFactory.getEncodingDefinitionByCharacterSetId(int)
), or the loaded EncodingDefinition is information-only, then the defaultEncoding will be used.- Specified by:
getEncodingForCharacterSetId
in interfaceIEncodingFactory
- Parameters:
firebirdCharacterSetId
- The Firebird character set id- Returns:
- Encoding instance (never null)
-
getEncodingDefinitionByCharset
Description copied from interface:IEncodingFactory
Looks up anEncodingDefinition
for the JavaCharset
.- Specified by:
getEncodingDefinitionByCharset
in interfaceIEncodingFactory
- Parameters:
charset
- The Java character set- Returns:
- EncodingDefinition instance or
null
if the character set is not mapped
-
getEncodingForCharset
Description copied from interface:IEncodingFactory
Gets anEncoding
for the specified Java character set. If there is no known encoding for thisCharset
, or the loaded EncodingDefinition is information-only, then the fallbackEncoding will be used.- Specified by:
getEncodingForCharset
in interfaceIEncodingFactory
- Parameters:
charset
- The Java character setfallbackEncoding
- The Encoding to use as fallback if no encoding is found (usually the connection encoding). Ifnull
, the defaultEncoding for the JVM is used.- Returns:
- Encoding instance (never null)
- See Also:
-
getEncodingForCharset
Description copied from interface:IEncodingFactory
Gets anEncoding
for the specified Java character set. If there is no known encoding for thisCharset
, or the loaded EncodingDefinition is information-only, then the defaultEncoding will be used.- Specified by:
getEncodingForCharset
in interfaceIEncodingFactory
- Parameters:
charset
- The Java character set- Returns:
- Encoding instance (never null)
-
getOrCreateEncodingForCharset
Description copied from interface:IEncodingFactory
Creates anEncoding
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.- Specified by:
getOrCreateEncodingForCharset
in interfaceIEncodingFactory
- Parameters:
charset
- The Java character set- Returns:
- Encoding instance (never null)
- See Also:
-
getEncodingDefinitionByCharsetAlias
Description copied from interface:IEncodingFactory
Looks up theEncodingDefinition
by the specified Java character set name or alias.- Specified by:
getEncodingDefinitionByCharsetAlias
in interfaceIEncodingFactory
- Parameters:
charsetAlias
- Name (or alias) of the Java character set (case-insensitive)- Returns:
- EncodingDefinition instance or
null
if the character set name is not mapped
-
getEncodingForCharsetAlias
Gets anEncoding
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.- Parameters:
charsetAlias
- The Java character set name or aliasfallbackEncoding
- The Encoding to use as fallback if no encoding is found (usually the connection encoding). Ifnull
, the defaultEncoding for the JVM is used.- Returns:
- Encoding instance (never null)
-
getEncodingForCharsetAlias
Description copied from interface:IEncodingFactory
Gets anEncoding
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.- Specified by:
getEncodingForCharsetAlias
in interfaceIEncodingFactory
- Parameters:
charsetAlias
- The Java character set name or alias- Returns:
- Encoding instance (never null)
-
getEncodingDefinition
public EncodingDefinition getEncodingDefinition(String firebirdEncodingName, String javaCharsetAlias) Description copied from interface:IEncodingFactory
Gets or creates anEncodingDefinition
for the supplied Firebird encoding and Java charset.When
firebirdEncodingName
is not null andjavaCharsetAlias
is null, then the encoding definition as returned byIEncodingFactory.getEncodingDefinitionByFirebirdName(String)
is returned. For the reverse (firebirdEncodingName
is null andjavaCharsetAlias
isn't), the encoding definition as returned byIEncodingFactory.getEncodingDefinitionByCharsetAlias(String)
is returned.When both parameters are set, the result of
IEncodingFactory.getEncodingDefinitionByFirebirdName(String)
is returned if the character set matches, otherwise a newDefaultEncodingDefinition
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.- Specified by:
getEncodingDefinition
in interfaceIEncodingFactory
- Parameters:
firebirdEncodingName
- 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 encoding- Returns:
- An EncodingDefinition or null if both parameters are null, no encoding was found or if an exception occurred.
-
withDefaultEncodingDefinition
Returns anIEncodingFactory
that usesencodingDefinition
as the default.This implementation returns an instance of
ConnectionEncodingFactory
.- Specified by:
withDefaultEncodingDefinition
in interfaceIEncodingFactory
- Parameters:
encodingDefinition
- The default encoding to use (ornull
for the value ofIEncodingFactory.getDefaultEncoding()
- Returns:
- IEncodingFactory instance with the specified default.
-
withDefaultEncodingDefinition
Returns anIEncodingFactory
that uses anEncodingDefinition
identified bycharSet
as the default.This implementation returns an instance of
ConnectionEncodingFactory
.- Specified by:
withDefaultEncodingDefinition
in interfaceIEncodingFactory
- Parameters:
charset
- The default charset to use.- Returns:
- IEncodingFactory instance with the specified default.
-
getOrCreateDatatypeCoder
public <T extends DatatypeCoder> T getOrCreateDatatypeCoder(Class<T> datatypeCoderClass, Function<IEncodingFactory, T> datatypeCoderFactory) Description copied from interface:IEncodingFactory
Gets or - if necessary - creates a datatype coder of the specified type.In general this method should only be called from a static factory method on the datatype coder itself.
- Specified by:
getOrCreateDatatypeCoder
in interfaceIEncodingFactory
- Type Parameters:
T
- type parameter of typeDatatypeCoder
- Parameters:
datatypeCoderClass
- type of datatype coderdatatypeCoderFactory
- function for creating the datatype coder if it doesn't already exist- Returns:
- New or cached instance of datatype coder
-
withDefaultEncodingDefinition
Returns anConnectionEncodingFactory
that usesgetDefaultEncodingDefinition()
as the default.- Returns:
- IEncodingFactory instance with the specified default.
-
getPlatformDefault
Returns an instance ofIEncodingFactory
with the default encoding set to the platform encoding.- Returns:
- Instance of
IEncodingFactory
.
-
createInstance
Returns anIEncodingFactory
that usesencodingDefinition
as the default.If
encodingDefinition
isnull
or an information-only encoding, the implementation will return the cached instance returned bygetPlatformDefault()
.- Parameters:
encodingDefinition
- The default encoding to use (ornull
to getgetPlatformDefault()
- Returns:
- IEncodingFactory instance with the specified default.
-
createInstance
Returns anIEncodingFactory
that uses anEncodingDefinition
identified bycharSet
as the default.If
charset
isnull
, the implementation will return the cached instance return bygetPlatformDefault()
.- Parameters:
charset
- The default charset to use, ornull
forgetPlatformDefault()
.- Returns:
- IEncodingFactory instance with the specified default.
-
createInstance
Creates a new EncodingFactory based on the supplied encodingSets. The suppliedEncodingSet
instances are processed highest preferenceWeight first.- Parameters:
encodingSets
- The EncodingSet definitions to use for the EncodingFactory instance- Returns:
- EncodingFactory instance based on the supplied encodingSets.
-