org.firebirdsql.encodings

## Class DefaultEncodingDefinition

- java.lang.Object
- - org.firebirdsql.encodings.DefaultEncodingDefinition

- All Implemented Interfaces:
    EncodingDefinition

      public final class DefaultEncodingDefinition
      extends java.lang.Object
      implements EncodingDefinition

  Definition of a Firebird encoding. This is the default implementation of `EncodingDefinition`.
  Since:
    3.0
  Author:
    Mark Rotteveel

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `DefaultEncodingDefinition(java.lang.String firebirdEncodingName, java.nio.charset.Charset charset, int maxBytesPerChar, int firebirdCharacterSetId, boolean firebirdOnly)` Initializes an instance of DefaultEncodingDefinition.
    `DefaultEncodingDefinition(java.lang.String firebirdEncodingName, java.lang.String charsetName, int maxBytesPerChar, int firebirdCharacterSetId, boolean firebirdOnly)` Initializes an instance of DefaultEncodingDefinition.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `Encoding` | `getEncoding()` Returns the `Encoding` instance for this definition.
    `int` | `getFirebirdCharacterSetId()`
    `java.lang.String` | `getFirebirdEncodingName()`
    `java.nio.charset.Charset` | `getJavaCharset()`
    `java.lang.String` | `getJavaEncodingName()`
    `int` | `getMaxBytesPerChar()`
    `boolean` | `isFirebirdOnly()` Can (or should) this encoding be used for reverse mapping from Java to Firebird.
    `boolean` | `isInformationOnly()` Can this implementation create an `Encoding` instance, or does it provide information only (eg about unsupported character sets)
    `java.lang.String` | `toString()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### DefaultEncodingDefinition

          public DefaultEncodingDefinition(java.lang.String firebirdEncodingName,
                                   java.nio.charset.Charset charset,
                                   int maxBytesPerChar,
                                   int firebirdCharacterSetId,
                                   boolean firebirdOnly)

      Initializes an instance of DefaultEncodingDefinition.
      Parameters:
        `firebirdEncodingName` - Name of the Firebird encoding
        `charset` - Java `Charset` instance (`null` for information-only instances)
        `maxBytesPerChar` - Maximum number of bytes per character (eg 1 for ISO8859_1, 4 for UTF8, 3 for UNICODE-FSS)
        `firebirdCharacterSetId` - Firebird character set id
        `firebirdOnly` - Mapping only applies from Firebird to Java, but not from Java to Firebird (eg Firebird UNICODE-FSS maps to Java UTF-8, but Java UTF-8 does not map to Firebird UNICODE-FSS (but to Firebird UTF8)

    - #### DefaultEncodingDefinition

          public DefaultEncodingDefinition(java.lang.String firebirdEncodingName,
                                   java.lang.String charsetName,
                                   int maxBytesPerChar,
                                   int firebirdCharacterSetId,
                                   boolean firebirdOnly)

      Initializes an instance of DefaultEncodingDefinition.

      The actual Java character set is loaded on-demand. If the provided name cannot be resolved to a `Charset` at on-demand load time, it will be handled as information-only.

      Parameters:
        `firebirdEncodingName` - Name of the Firebird encoding
        `charsetName` - Java character set name, or `null` for information-only instances
        `maxBytesPerChar` - Maximum number of bytes per character (eg 1 for ISO8859_1, 4 for UTF8, 3 for UNICODE-FSS)
        `firebirdCharacterSetId` - Firebird character set id
        `firebirdOnly` - Mapping only applies from Firebird to Java, but not from Java to Firebird (eg Firebird UNICODE-FSS maps to Java UTF-8, but Java UTF-8 does not map to Firebird UNICODE-FSS (but to Firebird UTF8)

  - ### Method Detail

    - #### getMaxBytesPerChar

          public int getMaxBytesPerChar()

      Specified by:
        `getMaxBytesPerChar` in interface `EncodingDefinition`
      Returns:
        Maximum number of bytes per character.

    - #### getJavaEncodingName

          public java.lang.String getJavaEncodingName()

      Specified by:
        `getJavaEncodingName` in interface `EncodingDefinition`
      Returns:
        Java name of the encoding

    - #### getJavaCharset

          public java.nio.charset.Charset getJavaCharset()

      Specified by:
        `getJavaCharset` in interface `EncodingDefinition`
      Returns:
        Java `Charset` for this encoding

    - #### getFirebirdEncodingName

          public java.lang.String getFirebirdEncodingName()

      Specified by:
        `getFirebirdEncodingName` in interface `EncodingDefinition`
      Returns:
        Firebird name of the encoding

    - #### getFirebirdCharacterSetId

          public int getFirebirdCharacterSetId()

      Specified by:
        `getFirebirdCharacterSetId` in interface `EncodingDefinition`
      Returns:
        Firebird id of the encoding

    - #### isFirebirdOnly

          public boolean isFirebirdOnly()

      Description copied from interface: `EncodingDefinition`
      Can (or should) this encoding be used for reverse mapping from Java to Firebird.

      The best example of this is the Firebird character set `UNICODE-FSS` which maps to the Java character set `UTF-8`, but when Java character set`UTF-8` is requested, Jaybird should (in general) map to Firebird character set `UTF8`.

      Specified by:
        `isFirebirdOnly` in interface `EncodingDefinition`
      Returns:
        `true` when this encoding maps from Java to Firebird, `false` otherwise

    - #### isInformationOnly

          public boolean isInformationOnly()

      Description copied from interface: `EncodingDefinition`
      Can this implementation create an `Encoding` instance, or does it provide information only (eg about unsupported character sets)
      Specified by:
        `isInformationOnly` in interface `EncodingDefinition`
      Returns:
        `true` if this EncodingDefinition only provides information, and is not capable of building a concrete implementation.

    - #### getEncoding

          public Encoding getEncoding()

      Returns the `Encoding` instance for this definition. The same object is returned each time this method is called.
      Specified by:
        `getEncoding` in interface `EncodingDefinition`
      Returns:
        Encoding object or `null` if this is an information only EncodingDefinition
      See Also:
        `EncodingDefinition.isInformationOnly()`

    - #### toString

          public java.lang.String toString()

      Overrides:
        `toString` in class `java.lang.Object`

Copyright © 2001-2021 Jaybird (Firebird JDBC/JCA) team. All rights reserved.