Class ByteString

java.lang.Object
com.adobe.internal.util.ByteString
All Implemented Interfaces:
ByteSequence, Serializable, Comparable

public class ByteString extends Object implements ByteSequence, Comparable, Serializable
The ByteString class represents strings of bytes.
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    Create a ByteString that represents an empty byte sequence.
    ByteString(byte[] value)
    Create a ByteString that represents the same byte sequence as that contained in a byte array.
    ByteString(byte[] value, int offset, int length)
    Create a ByteString that represents the same byte sequence as that contained in a subsequence of a byte array.
    Create a ByteString that represents the same byte sequence as that represented by another ByteString.
  • Method Summary

    Modifier and Type
    Method
    Description
    byte
    byteAt(int index)
    Returns the byte at the specified index.
    int
    compareTo(ByteString otherByteString)
     
    int
    compareTo(Object otherObject)
     
    concat(ByteString byteString)
     
    boolean
    equals(Object otherObject)
     
    byte[]
    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
     
    int
    Returns the length of this byte sequence.
    subSequence(int start, int end)
    Returns a new byte sequence that is a subsequence of this sequence.
    substring(int begin, int end)
     
     

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • ByteString

      public ByteString()
      Create a ByteString that represents an empty byte sequence.
    • ByteString

      public ByteString(ByteString original)
      Create a ByteString that represents the same byte sequence as that represented by another ByteString.
      Parameters:
      original - ByteString to copy
    • ByteString

      public ByteString(byte[] value)
      Create a ByteString that represents the same byte sequence as that contained in a byte array. The byte array is copied and so subsequent modification of the byte array does not affect the ByteString.
      Parameters:
      value - the initial value of the ByteString
    • ByteString

      public ByteString(byte[] value, int offset, int length)
      Create a ByteString that represents the same byte sequence as that contained in a subsequence of a byte array. The subsequence is copied and so subsequent modification of the byte array does not affect the ByteString.
      Parameters:
      value - the initial value of the ByteString
      offset - the offset in the array for the subsequence
      length - the length of the subsequence
  • Method Details

    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • 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
    • 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
    • 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 -
      end -
      Returns:
      a substring of this ByteString
    • concat

      public ByteString concat(ByteString byteString)
    • compareTo

      public int compareTo(Object otherObject)
      Specified by:
      compareTo in interface Comparable
    • compareTo

      public int compareTo(ByteString otherByteString)
    • equals

      public boolean equals(Object otherObject)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object