Class ByteStringBuffer

  • All Implemented Interfaces:
    ByteSequence, java.io.Serializable, java.lang.Comparable

    public class ByteStringBuffer
    extends java.lang.Object
    implements ByteSequence, java.lang.Comparable, java.io.Serializable
    See Also:
    Serialized Form
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      ByteStringBuffer append​(byte b)  
      ByteStringBuffer append​(byte[] b)  
      ByteStringBuffer append​(byte[] b, int offset, int length)  
      byte byteAt​(int index)
      Returns the byte at the specified index.
      int compareTo​(ByteStringBuffer otherByteString)
      This comparision is byte by byte and one byte string will be "lesser" or "greater" than the other based on the byte values at the first position in which they differ.
      int compareTo​(java.lang.Object otherObject)  
      void ensureCapacity​(int minimumCapacity)  
      boolean equals​(java.lang.Object otherObject)  
      byte[] getBytes()
      Returns a byte array containing the bytes in this sequence in the same order as this sequence.
      void getBytes​(int srcBegin, int srcEnd, byte[] dst, int dstBegin)
      Returns a byte array containing the bytes in this sequence in the same order as this sequence and within the bounds given.
      int length()
      Returns the length of this byte sequence.
      void setByteAt​(int index, byte b)  
      ByteSequence subSequence​(int start, int end)
      Returns a new byte sequence that is a subsequence of this sequence.
      ByteString substring​(int begin, int end)  
      • Methods inherited from class java.lang.Object

        getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ByteStringBuffer

        public ByteStringBuffer()
      • ByteStringBuffer

        public ByteStringBuffer​(int length)
        Parameters:
        length -
    • Method Detail

      • byteAt

        public byte byteAt​(int index)
        Description copied from interface: ByteSequence
        Returns the byte at the specified index. An index ranges from zero to length() - 1. The first byte of the sequence is at index zero, the next at index one, and so on, as for array indexing.

        Specified by:
        byteAt in interface ByteSequence
        Parameters:
        index - the index of the character to be returned
        Returns:
        the specified byte
      • length

        public int length()
        Description copied from interface: ByteSequence
        Returns the length of this byte sequence. The length is the number of bytes in the sequence.

        Specified by:
        length in interface ByteSequence
        Returns:
        the number of bytes in this sequence
      • subSequence

        public ByteSequence subSequence​(int start,
                                        int end)
        Description copied from interface: ByteSequence
        Returns a new byte sequence that is a subsequence of this sequence. The subsequence starts with the byte at the specified index and ends with the byte at index end - 1. The length of the returned sequence is end - start, so if start == end then an empty sequence is returned.

        Specified by:
        subSequence in interface ByteSequence
        Parameters:
        start - the start index, inclusive
        end - the end index, exclusive
        Returns:
        the specified subsequence
      • substring

        public ByteString substring​(int begin,
                                    int end)
        Parameters:
        begin - the first byte index to include in the substring
        end - the last byte index to include in the substring
        Returns:
        substring of this byte string from begin to end
      • getBytes

        public void getBytes​(int srcBegin,
                             int srcEnd,
                             byte[] dst,
                             int dstBegin)
        Description copied from interface: ByteSequence
        Returns a byte array containing the bytes in this sequence in the same order as this sequence and within the bounds given. The length of the byte array will be equal to srcEnd - srcBegin + 1.

        Specified by:
        getBytes in interface ByteSequence
        Parameters:
        srcBegin - the byte to start copying from
        srcEnd - the byte to end copying at
        dst - the destination to copy the bytes to
        dstBegin - the byte in the destination to begin the copying
      • getBytes

        public byte[] getBytes()
        Description copied from interface: ByteSequence
        Returns a byte array containing the bytes in this sequence in the same order as this sequence. The length of the byte array will be the length of this sequence.

        Specified by:
        getBytes in interface ByteSequence
        Returns:
        a byte array consisting of exactly this sequence of bytes
      • setByteAt

        public void setByteAt​(int index,
                              byte b)
      • append

        public ByteStringBuffer append​(byte[] b,
                                       int offset,
                                       int length)
      • ensureCapacity

        public void ensureCapacity​(int minimumCapacity)
      • compareTo

        public int compareTo​(java.lang.Object otherObject)
        Specified by:
        compareTo in interface java.lang.Comparable
      • compareTo

        public int compareTo​(ByteStringBuffer otherByteString)
        This comparision is byte by byte and one byte string will be "lesser" or "greater" than the other based on the byte values at the first position in which they differ. If both byte strings are identical in all positions but one is longer than the other then longer string is "greater". Only if both byte strings are of the same length and have identical byte values in all positions will they be identical.
        Parameters:
        otherByteString -
        Returns:
        0 if the argument byte string is equal to this byte string; a value less than 0 if this byte string is "less" than the argument byte string; and a value greater than 0 if this byte string is "greater" than the argument byte string
      • equals

        public boolean equals​(java.lang.Object otherObject)
        Overrides:
        equals in class java.lang.Object