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
  • Constructor Details

    • 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 Details

    • 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:
    • 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