Class LongStringHelper.ByteArrayLongString

  • All Implemented Interfaces:
    LongString
    Enclosing class:
    LongStringHelper

    private static class LongStringHelper.ByteArrayLongString
    extends java.lang.Object
    implements LongString
    Private API - Implementation of LongString. When interpreting bytes as a string, uses UTF-8 encoding.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private byte[] bytes  
    • Constructor Summary

      Constructors 
      Constructor Description
      ByteArrayLongString​(byte[] bytes)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object o)  
      byte[] getBytes()
      Get the content as a byte array.
      java.io.DataInputStream getStream()
      Get the content stream.
      int hashCode()  
      long length()
      java.lang.String toString()
      Get the content as a String.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • bytes

        private final byte[] bytes
    • Constructor Detail

      • ByteArrayLongString

        public ByteArrayLongString​(byte[] bytes)
    • Method Detail

      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • getBytes

        public byte[] getBytes()
        Get the content as a byte array. This need not be a copy. Updates to the returned array may change the value of the string. Repeated calls to this function may return the same array. This function will fail if this string's length is greater than Integer.MAX_VALUE, throwing an IllegalStateException.
        Specified by:
        getBytes in interface LongString
        Returns:
        the array of bytes containing the content of the LongString
      • getStream

        public java.io.DataInputStream getStream()
                                          throws java.io.IOException
        Get the content stream. Repeated calls to this function return the same stream, which may not support rewind.
        Specified by:
        getStream in interface LongString
        Returns:
        An input stream that reads the content of the string
        Throws:
        java.io.IOException - if an error is encountered
      • length

        public long length()
        Specified by:
        length in interface LongString
        Returns:
        the length of the string in bytes between 0 and MAX_LENGTH (inclusive)
      • toString

        public java.lang.String toString()
        Description copied from interface: LongString
        Get the content as a String. Uses UTF-8 as encoding.
        Specified by:
        toString in interface LongString
        Overrides:
        toString in class java.lang.Object
        Returns:
        he content of the LongString as a string