Class ByteArrayUtil.StringSerializer

  • All Implemented Interfaces:
    ByteBufferSerializer<java.lang.String>
    Enclosing class:
    ByteArrayUtil

    public static final class ByteArrayUtil.StringSerializer
    extends java.lang.Object
    implements ByteBufferSerializer<java.lang.String>
    Serializer for String objects.
    Author:
    Erich Schubert
    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) java.nio.charset.Charset charset
      Character set to use.
      (package private) java.nio.charset.CharsetDecoder decoder
      Decoder.
      (package private) java.nio.charset.CharsetEncoder encoder
      Encoder.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private StringSerializer()
      Constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String fromByteBuffer​(java.nio.ByteBuffer buffer)
      Deserialize an object from a byte buffer (e.g., disk)
      int getByteSize​(java.lang.String object)
      Get the size of the object in bytes.
      void toByteBuffer​(java.nio.ByteBuffer buffer, java.lang.String obj)
      Serialize the object to a byte array (e.g., disk)
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • charset

        java.nio.charset.Charset charset
        Character set to use.
      • encoder

        java.nio.charset.CharsetEncoder encoder
        Encoder.
      • decoder

        java.nio.charset.CharsetDecoder decoder
        Decoder.
    • Constructor Detail

      • StringSerializer

        private StringSerializer()
        Constructor. Protected: use static instance!
    • Method Detail

      • fromByteBuffer

        public java.lang.String fromByteBuffer​(java.nio.ByteBuffer buffer)
                                        throws java.io.IOException
        Description copied from interface: ByteBufferSerializer
        Deserialize an object from a byte buffer (e.g., disk)
        Specified by:
        fromByteBuffer in interface ByteBufferSerializer<java.lang.String>
        Parameters:
        buffer - Data array to process
        Returns:
        Deserialized object
        Throws:
        java.io.IOException - on IO errors
      • toByteBuffer

        public void toByteBuffer​(java.nio.ByteBuffer buffer,
                                 java.lang.String obj)
                          throws java.io.IOException
        Description copied from interface: ByteBufferSerializer
        Serialize the object to a byte array (e.g., disk)
        Specified by:
        toByteBuffer in interface ByteBufferSerializer<java.lang.String>
        Parameters:
        buffer - Buffer to serialize to
        obj - Object to serialize
        Throws:
        java.io.IOException - on IO errors
      • getByteSize

        public int getByteSize​(java.lang.String object)
                        throws java.io.IOException
        Description copied from interface: ByteBufferSerializer
        Get the size of the object in bytes.
        Specified by:
        getByteSize in interface ByteBufferSerializer<java.lang.String>
        Parameters:
        object - Object to serialize
        Returns:
        maximum size in serialized form
        Throws:
        java.io.IOException - on IO errors