Class ByteBufferEncoder

  • All Implemented Interfaces:
    Encoder

    public final class ByteBufferEncoder
    extends Object
    implements Encoder
    Encoder using a byte buffer.
    • Constructor Detail

      • ByteBufferEncoder

        public ByteBufferEncoder​(ByteBuffer buf)
    • Method Detail

      • encodeBoolean

        public void encodeBoolean​(boolean bool)
                           throws Exception
        Description copied from interface: Encoder
        Encodes a boolean.
        Specified by:
        encodeBoolean in interface Encoder
        Parameters:
        bool - the value to encode
        Throws:
        Exception - if an error occurs during encoding
      • encodeByte

        public void encodeByte​(byte b)
                        throws Exception
        Description copied from interface: Encoder
        Encodes a byte.
        Specified by:
        encodeByte in interface Encoder
        Parameters:
        b - the value to encode
        Throws:
        Exception - if an error occurs during encoding
      • encodeSignedShort

        public void encodeSignedShort​(short s)
                               throws Exception
        Description copied from interface: Encoder
        Encodes a signed short integer. The encoding format depends on the implementation.
        Specified by:
        encodeSignedShort in interface Encoder
        Parameters:
        s - the value to encode
        Throws:
        Exception - if an error occurs during encoding
      • encodeUnsignedShort

        public void encodeUnsignedShort​(short s)
                                 throws Exception
        Description copied from interface: Encoder
        Encodes an unsigned short integer. The encoding format depends on the implementation.
        Specified by:
        encodeUnsignedShort in interface Encoder
        Parameters:
        s - the value to encode
        Throws:
        Exception - if an error occurs during encoding
      • encode16

        public void encode16​(short s)
                      throws Exception
        Description copied from interface: Encoder
        Encodes a signed short integer. The encoding format is the 2's complement representation encoded in 2 bytes.
        Specified by:
        encode16 in interface Encoder
        Parameters:
        s - the value to encode
        Throws:
        Exception - if an error occurs during encoding
      • encodeSignedInt

        public void encodeSignedInt​(int i)
                             throws Exception
        Description copied from interface: Encoder
        Encodes a signed integer. The encoding format depends on the implementation.
        Specified by:
        encodeSignedInt in interface Encoder
        Parameters:
        i - the value to encode
        Throws:
        Exception - if an error occurs during encoding
      • encodeUnsignedInt

        public void encodeUnsignedInt​(int i)
                               throws Exception
        Description copied from interface: Encoder
        Encodes an unsigned integer. The encoding format depends on the implementation.
        Specified by:
        encodeUnsignedInt in interface Encoder
        Parameters:
        i - the value to encode
        Throws:
        Exception - if an error occurs during encoding
      • encode32

        public void encode32​(int i)
                      throws Exception
        Description copied from interface: Encoder
        Encodes a signed integer. The encoding format is the 2's complement representation encoded in 4 bytes.
        Specified by:
        encode32 in interface Encoder
        Parameters:
        i - the value to encode
        Throws:
        Exception - if an error occurs during encoding
      • encodeSignedLong

        public void encodeSignedLong​(long l)
                              throws Exception
        Description copied from interface: Encoder
        Encodes a signed long integer. The encoding format depends on the implementation.
        Specified by:
        encodeSignedLong in interface Encoder
        Parameters:
        l - the value to encode
        Throws:
        Exception - if an error occurs during encoding
      • encodeUnsignedLong

        public void encodeUnsignedLong​(long l)
                                throws Exception
        Description copied from interface: Encoder
        Encodes an unsigned long integer. The encoding format depends on the implementation.
        Specified by:
        encodeUnsignedLong in interface Encoder
        Parameters:
        l - the value to encode
        Throws:
        Exception - if an error occurs during encoding
      • encode64

        public void encode64​(long l)
                      throws Exception
        Description copied from interface: Encoder
        Encodes a signed long integer. The encoding format is the 2's complement representation encoded in 8 bytes.
        Specified by:
        encode64 in interface Encoder
        Parameters:
        l - the value to encode
        Throws:
        Exception - if an error occurs during encoding
      • encodeNullableString

        public void encodeNullableString​(String str)
                                  throws Exception
        Description copied from interface: Encoder
        Encodes a string that can be null. Be careful, since Joram 5.19, by default String are encoded using UTF-8.
        Specified by:
        encodeNullableString in interface Encoder
        Parameters:
        str - the value to encode
        Throws:
        Exception - if an error occurs during encoding
      • encodeString

        public void encodeString​(String str)
                          throws Exception
        Description copied from interface: Encoder
        Encodes a string that cannot be null. Be careful, since Joram 5.19, by default String are encoded using UTF-8.
        Specified by:
        encodeString in interface Encoder
        Parameters:
        str - the value to encode
        Throws:
        Exception - if an error occurs during encoding
      • encodeNullableByteArray

        public void encodeNullableByteArray​(byte[] tab)
                                     throws Exception
        Description copied from interface: Encoder
        Encodes a byte array that can be null.
        Specified by:
        encodeNullableByteArray in interface Encoder
        Parameters:
        tab - the value to encode
        Throws:
        Exception - if an error occurs during encoding
      • encodeByteArray

        public void encodeByteArray​(byte[] tab)
                             throws Exception
        Description copied from interface: Encoder
        Encodes a byte array that cannot be null.
        Specified by:
        encodeByteArray in interface Encoder
        Parameters:
        tab - the value to encode
        Throws:
        Exception - if an error occurs during encoding
      • encodeNullableByteArray

        public void encodeNullableByteArray​(byte[] tab,
                                            int offset,
                                            int length)
                                     throws Exception
        Description copied from interface: Encoder
        Encodes a byte array that can be null.
        Specified by:
        encodeNullableByteArray in interface Encoder
        Parameters:
        tab - the value to encode
        offset - the starting index in array b
        length - the number of bytes to be encoded
        Throws:
        Exception - if an error occurs during encoding
      • encodeByteArray

        public void encodeByteArray​(byte[] tab,
                                    int offset,
                                    int length)
                             throws Exception
        Description copied from interface: Encoder
        Encodes a byte array that cannot be null.
        Specified by:
        encodeByteArray in interface Encoder
        Parameters:
        tab - the value to encode
        offset - the starting index in array b
        length - the number of bytes to be encoded
        Throws:
        Exception - if an error occurs during encoding
      • encodeFloat

        public void encodeFloat​(float f)
                         throws Exception
        Description copied from interface: Encoder
        Encodes a float.
        Specified by:
        encodeFloat in interface Encoder
        Parameters:
        f - the value to encode
        Throws:
        Exception - if an error occurs during encoding
      • encodeDouble

        public void encodeDouble​(double d)
                          throws Exception
        Description copied from interface: Encoder
        Encodes a double.
        Specified by:
        encodeDouble in interface Encoder
        Parameters:
        d - the value to encode
        Throws:
        Exception - if an error occurs during encoding