Class ToBytesViaStringDeserialiser<T>

  • All Implemented Interfaces:
    Serializable, Serialiser<T,​byte[]>, ToBytesSerialiser<T>
    Direct Known Subclasses:
    StringSerialiser, TreeSetStringSerialiser

    public abstract class ToBytesViaStringDeserialiser<T>
    extends Object
    implements ToBytesSerialiser<T>
    Abstract serialiser that deserialises the given byte[] via an interim String object. The concrete implementation of this class may use the string in the constructor of the final return type.
    example :
       @Override
     public Date deserialiseString(final String value) {
     return new Date(Long.parseLong(value));
     }
    See Also:
    Serialized Form
    • Constructor Detail

      • ToBytesViaStringDeserialiser

        public ToBytesViaStringDeserialiser​(String charsetName)
    • Method Detail

      • getCharset

        public String getCharset()
      • setCharset

        public void setCharset​(String charset)
      • deserialise

        @Deprecated
        public final T deserialise​(byte[] bytes)
                            throws SerialisationException
        Deprecated.
        Deserialise an array of bytes into the original object.
        Specified by:
        deserialise in interface Serialiser<T,​byte[]>
        Specified by:
        deserialise in interface ToBytesSerialiser<T>
        Parameters:
        bytes - the bytes to deserialise
        Returns:
        T the deserialised object
        Throws:
        SerialisationException - if the object fails to deserialise

        Note that this implementation is less efficient than using deserialise with an offset and a length, but may still be used if necessary. It has been marked deprecated but will not be removed as it is needed in the Serialiser interface.

        See Also:
        deserialise(byte[], int, int)
      • deserialise

        public final T deserialise​(byte[] allBytes,
                                   int offset,
                                   int length)
                            throws SerialisationException
        Specified by:
        deserialise in interface ToBytesSerialiser<T>
        Parameters:
        allBytes - The bytes to be decoded into characters
        offset - The index of the first byte to decode
        length - The number of bytes to decode
        Returns:
        T the deserialised object
        Throws:
        SerialisationException - issues during deserialisation