类 ByteArray<T extends ByteArray<T>>

java.lang.Object
com.google.typography.font.sfntly.data.ByteArray<T>
类型参数:
T - the concrete sub-class of ByteArray
直接已知子类:
GrowableMemoryByteArray, MemoryByteArray, SegmentedGrowableMemoryByteArray

abstract class ByteArray<T extends ByteArray<T>> extends Object
An abstraction to a contiguous array of bytes.
作者:
Stuart Gill
  • 字段概要

    字段
    修饰符和类型
    字段
    说明
    private boolean
     
    private static final int
     
    private int
     
    private boolean
     
    private int
     
  • 构造器概要

    构造器
    限定符
    构造器
    说明
    protected
    ByteArray(int filledLength, int storageLength)
    Constructor.
    protected
    ByteArray(int filledLength, int storageLength, boolean growable)
    Constructor.
  • 方法概要

    修饰符和类型
    方法
    说明
    abstract void
    Close this instance of the ByteArray.
    void
    Copies everything from the InputStream into this ByteArray.
    void
    copyFrom(InputStream is, int length)
    Copies from the InputStream into this ByteArray.
    int
    copyTo(int dstOffset, ByteArray<? extends ByteArray<?>> array, int srcOffset, int length)
    Copies this ByteArray to another ByteArray.
    int
    copyTo(ByteArray<? extends ByteArray<?>> array)
    Fully copies this ByteArray to another ByteArray to the extent that the destination array has storage for the data copied.
    int
    copyTo(ByteArray<? extends ByteArray<?>> array, int offset, int length)
    Copies a segment of this ByteArray to another ByteArray.
    int
    Copies this ByteArray to an OutputStream.
    int
    copyTo(OutputStream os, int offset, int length)
    Copies this ByteArray to an OutputStream.
    int
    get(int index)
    Gets the byte from the given index.
    int
    get(int index, byte[] b)
    Gets the bytes from the given index and fill the buffer with them.
    int
    get(int index, byte[] b, int offset, int length)
    Gets the bytes from the given index and fill the buffer with them starting at the offset given.
    final boolean
    Determines whether or not this array is growable or of fixed size.
    protected abstract int
    internalGet(int index)
    Gets the byte at the index given.
    protected abstract int
    internalGet(int index, byte[] b, int offset, int length)
    Gets the bytes at the index given of the given length.
    protected abstract void
    internalPut(int index, byte b)
    Stores the byte at the index given.
    protected abstract int
    internalPut(int index, byte[] b, int offset, int length)
    Stores the array of bytes at the given index.
    int
    Gets the current filled and readable length of the array.
    void
    put(int index, byte b)
    Puts the specified byte into the array at the given index unless that would be beyond the length of the array and it isn't growable.
    int
    put(int index, byte[] b)
    Puts the specified bytes into the array at the given index.
    int
    put(int index, byte[] b, int offset, int length)
    Puts the specified bytes into the array at the given index.
    int
    setFilledLength(int filledLength)
     
    int
    Gets the maximum size of the array.
     
    toString(int offset, int length)
    Returns a string representation of the ByteArray.

    从类继承的方法 java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • 字段详细资料

    • COPY_BUFFER_SIZE

      private static final int COPY_BUFFER_SIZE
      另请参阅:
    • bound

      private boolean bound
    • storageLength

      private int storageLength
    • filledLength

      private int filledLength
    • growable

      private boolean growable
  • 构造器详细资料

    • ByteArray

      protected ByteArray(int filledLength, int storageLength, boolean growable)
      Constructor.
      参数:
      filledLength - the length that is "filled" and readable counting from the offset
      storageLength - the maximum storage size of the underlying data
      growable - is the storage growable - storageLength is the maximum growable size
    • ByteArray

      protected ByteArray(int filledLength, int storageLength)
      Constructor.
      参数:
      filledLength - the length that is "filled" and readable counting from the offset
      storageLength - the maximum storage size of the underlying data
  • 方法详细资料

    • get

      public int get(int index)
      Gets the byte from the given index.
      参数:
      index - the index into the byte array
      返回:
      the byte or -1 if reading beyond the bounds of the data
    • get

      public int get(int index, byte[] b)
      Gets the bytes from the given index and fill the buffer with them. As many bytes as will fit into the buffer are read unless that would go past the end of the array.
      参数:
      index - the index into the byte array
      b - the buffer to put the bytes read into
      返回:
      the number of bytes read from the buffer
    • get

      public int get(int index, byte[] b, int offset, int length)
      Gets the bytes from the given index and fill the buffer with them starting at the offset given. As many bytes as the specified length are read unless that would go past the end of the array.
      参数:
      index - the index into the byte array
      b - the buffer to put the bytes read into
      offset - the location in the buffer to start putting the bytes
      length - the number of bytes to put into the buffer
      返回:
      the number of bytes read from the buffer
    • length

      public int length()
      Gets the current filled and readable length of the array.
      返回:
      the current length
    • size

      public int size()
      Gets the maximum size of the array. This is the maximum number of bytes that the array can hold and all of it may not be filled with data or even fully allocated yet.
      返回:
      the size of this array
    • growable

      public final boolean growable()
      Determines whether or not this array is growable or of fixed size.
      返回:
      true if the array is growable; false otherwise
    • setFilledLength

      public int setFilledLength(int filledLength)
    • put

      public void put(int index, byte b)
      Puts the specified byte into the array at the given index unless that would be beyond the length of the array and it isn't growable.
      参数:
      index - the index into the byte array
      b - the byte to put into the array
      抛出:
      IndexOutOfBoundsException - if attempt to write outside the bounds of the data
    • put

      public int put(int index, byte[] b)
      Puts the specified bytes into the array at the given index. The entire buffer is put into the array unless that would extend beyond the length and the array isn't growable.
      参数:
      index - the index into the byte array
      b - the bytes to put into the array
      返回:
      the number of bytes actually written
      抛出:
      IndexOutOfBoundsException - if the index for writing is outside the bounds of the data
    • put

      public int put(int index, byte[] b, int offset, int length)
      Puts the specified bytes into the array at the given index. All of the bytes specified are put into the array unless that would extend beyond the length and the array isn't growable. The bytes to be put into the array are those in the buffer from the given offset and for the given length.
      参数:
      index - the index into the ByteArray
      b - the bytes to put into the array
      offset - the offset in the bytes to start copying from
      length - the number of bytes to copy into the array
      返回:
      the number of bytes actually written
      抛出:
      IndexOutOfBoundsException - if the index for writing is outside the bounds of the data
    • copyTo

      public int copyTo(ByteArray<? extends ByteArray<?>> array)
      Fully copies this ByteArray to another ByteArray to the extent that the destination array has storage for the data copied.
      参数:
      array - the destination
      返回:
      the number of bytes copied
    • copyTo

      public int copyTo(ByteArray<? extends ByteArray<?>> array, int offset, int length)
      Copies a segment of this ByteArray to another ByteArray.
      参数:
      array - the destination
      offset - the offset in this ByteArray to start copying from
      length - the maximum length in bytes to copy
      返回:
      the number of bytes copied
    • copyTo

      public int copyTo(int dstOffset, ByteArray<? extends ByteArray<?>> array, int srcOffset, int length)
      Copies this ByteArray to another ByteArray.
      参数:
      dstOffset - the offset in the destination array to start copying to
      array - the destination
      srcOffset - the offset in this ByteArray to start copying from
      length - the maximum length in bytes to copy
      返回:
      the number of bytes copied
    • copyTo

      public int copyTo(OutputStream os) throws IOException
      Copies this ByteArray to an OutputStream.
      参数:
      os - the destination
      返回:
      the number of bytes copied
      抛出:
      IOException
    • copyTo

      public int copyTo(OutputStream os, int offset, int length) throws IOException
      Copies this ByteArray to an OutputStream.
      参数:
      os - the destination
      offset -
      length -
      返回:
      the number of bytes copied
      抛出:
      IOException
    • copyFrom

      public void copyFrom(InputStream is, int length) throws IOException
      Copies from the InputStream into this ByteArray.
      参数:
      is - the source
      length - the number of bytes to copy
      抛出:
      IOException
    • copyFrom

      public void copyFrom(InputStream is) throws IOException
      Copies everything from the InputStream into this ByteArray.
      参数:
      is - the source
      抛出:
      IOException
    • internalPut

      protected abstract void internalPut(int index, byte b)
      Stores the byte at the index given.
      参数:
      index - the location to store at
      b - the byte to store
    • internalPut

      protected abstract int internalPut(int index, byte[] b, int offset, int length)
      Stores the array of bytes at the given index.
      参数:
      index - the location to store at
      b - the bytes to store
      offset - the offset to start from in the byte array
      length - the length of the byte array to store from the offset
      返回:
      the number of bytes actually stored
    • internalGet

      protected abstract int internalGet(int index)
      Gets the byte at the index given.
      参数:
      index - the location to get from
      返回:
      the byte stored at the index
    • internalGet

      protected abstract int internalGet(int index, byte[] b, int offset, int length)
      Gets the bytes at the index given of the given length.
      参数:
      index - the location to start getting from
      b - the array to put the bytes into
      offset - the offset in the array to put the bytes into
      length - the length of bytes to read
      返回:
      the number of bytes actually ready
    • close

      public abstract void close()
      Close this instance of the ByteArray.
    • toString

      public String toString(int offset, int length)
      Returns a string representation of the ByteArray.
      参数:
      offset -
      length - the number of bytes of the ByteArray to include in the String
      返回:
      a string representation of the ByteArray
    • toString

      public String toString()
      覆盖:
      toString 在类中 Object