Package org.firebirdsql.gds.ng.jna

## Class BigEndianDatatypeCoder

- java.lang.Object
- - org.firebirdsql.gds.ng.DefaultDatatypeCoder
  - - org.firebirdsql.gds.ng.jna.BigEndianDatatypeCoder

- All Implemented Interfaces:
    `DatatypeCoder`

      public final class BigEndianDatatypeCoder
      extends DefaultDatatypeCoder

  Datatype encoder and decoder for big endian platforms, specifically for use with the Firebird client library.

  For wire protocol use `DefaultDatatypeCoder`.

  Since:
    3.0
  Author:
    Mark Rotteveel

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface org.firebirdsql.gds.ng.DatatypeCoder

      `DatatypeCoder.RawDateTimeStruct`

  - ### Field Summary

    - ### Fields inherited from interface org.firebirdsql.gds.ng.DatatypeCoder

      `FRACTIONS_PER_HOUR, FRACTIONS_PER_MILLISECOND, FRACTIONS_PER_MINUTE, FRACTIONS_PER_SECOND, NANOSECONDS_PER_FRACTION`

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `BigEndianDatatypeCoder​(IEncodingFactory encodingFactory)` | Creates a big-endian datatype coder for native access on big-endian platforms.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `short` | `decodeShort​(byte[] byte_int)` | Decode a `byte` array into a `short` value.
    `short` | `decodeShort​(byte[] bytes, int fromIndex)` | Decode from a `byte` array to a `short` value.
    `void` | `encodeShort​(int value, byte[] target, int fromIndex)` | Encode a `short` value into the `target` byte array starting at index `fromIndex`.
    `byte[]` | `encodeShort​(short value)` | Encode a `short` value as a `byte` array.
    `static BigEndianDatatypeCoder` | `forEncodingFactory​(IEncodingFactory encodingFactory)` | Returns an instance of `BigEndianDatatypeCoder` for an encoding factory.
    `int` | `sizeOfShort()` | The size of an encoded short in this data type coder.

    - ### Methods inherited from class org.firebirdsql.gds.ng.DefaultDatatypeCoder

      `createReader, createWriter, decodeBoolean, decodeDate, decodeDate, decodeDateCalendar, decodeDateRaw, decodeDecimal128, decodeDecimal64, decodeDouble, decodeFloat, decodeInt, decodeInt, decodeInt128, decodeLong, decodeString, decodeTime, decodeTime, decodeTimeCalendar, decodeTimeRaw, decodeTimestamp, decodeTimestamp, decodeTimestamp, decodeTimestampCalendar, decodeTimestampRaw, encodeBoolean, encodeDate, encodeDate, encodeDateCalendar, encodeDateRaw, encodeDecimal128, encodeDecimal64, encodeDouble, encodeFloat, encodeInt, encodeInt, encodeInt128, encodeLocalDate, encodeLocalDateTime, encodeLocalTime, encodeLong, encodeShort, encodeString, encodeTime, encodeTime, encodeTimeCalendar, encodeTimeRaw, encodeTimestamp, encodeTimestamp, encodeTimestamp, encodeTimestampCalendar, encodeTimestampRaw, equals, forEncodingDefinition, getEncoding, getEncodingDefinition, getEncodingFactory, hashCode, intToBytes, unwrap`

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

      `clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### BigEndianDatatypeCoder

          public BigEndianDatatypeCoder​(IEncodingFactory encodingFactory)

      Creates a big-endian datatype coder for native access on big-endian platforms.

      In almost all cases, it is better to use `forEncodingFactory(IEncodingFactory)`.

      Parameters:
        `encodingFactory` - Encoding factory

  - ### Method Detail

    - #### forEncodingFactory

          public static BigEndianDatatypeCoder forEncodingFactory​(IEncodingFactory encodingFactory)

      Returns an instance of `BigEndianDatatypeCoder` for an encoding factory.
      Parameters:
        `encodingFactory` - Encoding factory
      Returns:
        Datatype coder, this might be a cached instance

    - #### sizeOfShort

          public int sizeOfShort()

      Description copied from interface: `DatatypeCoder`
      The size of an encoded short in this data type coder.
      Specified by:
        `sizeOfShort` in interface `DatatypeCoder`
      Overrides:
        `sizeOfShort` in class `DefaultDatatypeCoder`
      Returns:
        The size of an encoded short (either `2` or `4` bytes)

    - #### encodeShort

          public byte[] encodeShort​(short value)

      Description copied from interface: `DatatypeCoder`
      Encode a `short` value as a `byte` array.
      Specified by:
        `encodeShort` in interface `DatatypeCoder`
      Overrides:
        `encodeShort` in class `DefaultDatatypeCoder`
      Parameters:
        `value` - The value to be encoded
      Returns:
        The value of `value` encoded as a `byte` array
      See Also:
        `DatatypeCoder.encodeShort(int)`

    - #### encodeShort

          public void encodeShort​(int value,
                                  byte[] target,
                                  int fromIndex)

      Description copied from interface: `DatatypeCoder`
      Encode a `short` value into the `target` byte array starting at index `fromIndex`.
      Specified by:
        `encodeShort` in interface `DatatypeCoder`
      Overrides:
        `encodeShort` in class `DefaultDatatypeCoder`
      Parameters:
        `value` - The value to be encoded
        `target` - Target byte array of sufficient size (warning: this may be datatype coder specific)
        `fromIndex` - Index to start writing

    - #### decodeShort

          public short decodeShort​(byte[] byte_int)

      Description copied from interface: `DatatypeCoder`
      Decode a `byte` array into a `short` value.
      Specified by:
        `decodeShort` in interface `DatatypeCoder`
      Overrides:
        `decodeShort` in class `DefaultDatatypeCoder`
      Parameters:
        `byte_int` - The `byte` array to be decoded
      Returns:
        The `short` value of the decoded `byte` array

    - #### decodeShort

          public short decodeShort​(byte[] bytes,
                                   int fromIndex)

      Description copied from interface: `DatatypeCoder`
      Decode from a `byte` array to a `short` value.
      Specified by:
        `decodeShort` in interface `DatatypeCoder`
      Overrides:
        `decodeShort` in class `DefaultDatatypeCoder`
      Parameters:
        `bytes` - The `byte` array to be decoded
        `fromIndex` - The index to start reading
      Returns:
        The `short` value of the decoded `byte` array