类 ByteArray<T extends ByteArray<T>>
java.lang.Object
com.google.typography.font.sfntly.data.ByteArray<T>
- 类型参数:
T
- the concrete sub-class of ByteArray
An abstraction to a contiguous array of bytes.
- 作者:
- Stuart Gill
-
字段概要
字段修饰符和类型字段说明private boolean
private static final int
private int
private boolean
private int
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明abstract void
close()
Close this instance of the ByteArray.void
copyFrom
(InputStream is) Copies everything from the InputStream into this ByteArray.void
copyFrom
(InputStream is, int length) Copies from the InputStream into this ByteArray.int
Copies this ByteArray to another ByteArray.int
Fully copies this ByteArray to another ByteArray to the extent that the destination array has storage for the data copied.int
Copies a segment of this ByteArray to another ByteArray.int
copyTo
(OutputStream os) 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
growable()
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
length()
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
size()
Gets the maximum size of the array.toString()
toString
(int offset, int length) Returns a string representation of the ByteArray.
-
字段详细资料
-
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 offsetstorageLength
- the maximum storage size of the underlying datagrowable
- 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 offsetstorageLength
- 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 arrayb
- 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 arrayb
- the buffer to put the bytes read intooffset
- the location in the buffer to start putting the byteslength
- 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 arrayb
- 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 arrayb
- 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 ByteArrayb
- the bytes to put into the arrayoffset
- the offset in the bytes to start copying fromlength
- 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
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
Copies a segment of this ByteArray to another ByteArray.- 参数:
array
- the destinationoffset
- the offset in this ByteArray to start copying fromlength
- 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 toarray
- the destinationsrcOffset
- the offset in this ByteArray to start copying fromlength
- the maximum length in bytes to copy- 返回:
- the number of bytes copied
-
copyTo
Copies this ByteArray to an OutputStream.- 参数:
os
- the destination- 返回:
- the number of bytes copied
- 抛出:
IOException
-
copyTo
Copies this ByteArray to an OutputStream.- 参数:
os
- the destinationoffset
-length
-- 返回:
- the number of bytes copied
- 抛出:
IOException
-
copyFrom
Copies from the InputStream into this ByteArray.- 参数:
is
- the sourcelength
- the number of bytes to copy- 抛出:
IOException
-
copyFrom
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 atb
- 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 atb
- the bytes to storeoffset
- the offset to start from in the byte arraylength
- 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 fromb
- the array to put the bytes intooffset
- the offset in the array to put the bytes intolength
- the length of bytes to read- 返回:
- the number of bytes actually ready
-
close
public abstract void close()Close this instance of the ByteArray. -
toString
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
-