Package com.itextpdf.kernel.xmp.impl
Class ByteBuffer
java.lang.Object
com.itextpdf.kernel.xmp.impl.ByteBuffer
Byte buffer container including length of valid data.
- Since:
- 11.10.2006
-
Constructor Summary
ConstructorsConstructorDescriptionByteBuffer(byte[] buffer) ByteBuffer(byte[] buffer, int length) ByteBuffer(byte[] buffer, int offset, int length) ByteBuffer(int initialCapacity) Loads the stream into a buffer. -
Method Summary
Modifier and TypeMethodDescriptionvoidappend(byte b) Appends a byte to the buffer.voidappend(byte[] bytes) Append a byte array to the buffervoidappend(byte[] bytes, int offset, int len) Appends a part of byte array to the buffer.voidappend(ByteBuffer anotherBuffer) Append another buffer to this buffer.bytebyteAt(int index) intcharAt(int index) Detects the encoding of the byte buffer, stores and returns it.intlength()
-
Constructor Details
-
ByteBuffer
public ByteBuffer(int initialCapacity) - Parameters:
-
initialCapacity- the initial capacity for this buffer
-
ByteBuffer
public ByteBuffer(byte[] buffer) - Parameters:
-
buffer- a byte array that will be wrapped withByteBuffer.
-
ByteBuffer
public ByteBuffer(byte[] buffer, int length) - Parameters:
-
buffer- a byte array that will be wrapped withByteBuffer. -
length- the length of valid bytes in the array
-
ByteBuffer
Loads the stream into a buffer.- Parameters:
-
in- an InputStream - Throws:
-
IOException- If the stream cannot be read.
-
ByteBuffer
public ByteBuffer(byte[] buffer, int offset, int length) - Parameters:
-
buffer- a byte array that will be wrapped withByteBuffer. -
offset- the offset of the provided buffer. -
length- the length of valid bytes in the array
-
-
Method Details
-
getByteStream
- Returns:
- Returns a byte stream that is limited to the valid amount of bytes.
-
length
public int length()- Returns:
- Returns the length, that means the number of valid bytes, of the buffer; the inner byte array might be bigger than that.
-
byteAt
public byte byteAt(int index) - Parameters:
-
index- the index to retrieve the byte from - Returns:
- Returns a byte from the buffer
-
charAt
public int charAt(int index) - Parameters:
-
index- the index to retrieve a byte as int or char. - Returns:
- Returns a byte from the buffer
-
append
public void append(byte b) Appends a byte to the buffer.- Parameters:
-
b- a byte
-
append
public void append(byte[] bytes, int offset, int len) Appends a part of byte array to the buffer. Elements on positionsoffsetthroughoffset+len-1of provided array will be copied- Parameters:
-
bytes- a byte array -
offset- is a position of the first element to copy -
len- the number of array elements to be added
-
append
public void append(byte[] bytes) Append a byte array to the buffer- Parameters:
-
bytes- a byte array
-
append
Append another buffer to this buffer.- Parameters:
-
anotherBuffer- anotherByteBuffer
-
getEncoding
Detects the encoding of the byte buffer, stores and returns it. Only UTF-8, UTF-16LE/BE and UTF-32LE/BE are recognized. Note: UTF-32 flavors are not supported by Java, the XML-parser will complain.- Returns:
- Returns the encoding string.
-