Package com.adobe.xmp.impl
Class ByteBuffer
- java.lang.Object
-
- com.adobe.xmp.impl.ByteBuffer
-
public class ByteBuffer extends Object
Byte buffer container including length of valid data.- Since:
- 11.10.2006
-
-
Constructor Summary
Constructors Constructor Description ByteBuffer(byte[] buffer)
ByteBuffer(byte[] buffer, int length)
ByteBuffer(byte[] buffer, int offset, int length)
ByteBuffer(int initialCapacity)
ByteBuffer(InputStream in)
Loads the stream into a buffer.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
append(byte b)
Appends a byte to the buffer.void
append(byte[] bytes)
Append a byte array to the buffervoid
append(byte[] bytes, int offset, int len)
Appends a byte array or part of to the buffer.void
append(ByteBuffer anotherBuffer)
Append another buffer to this buffer.byte
byteAt(int index)
int
charAt(int index)
InputStream
getByteStream()
String
getEncoding()
Detects the encoding of the byte buffer, stores and returns it.int
length()
-
-
-
Constructor Detail
-
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
public ByteBuffer(InputStream in) throws IOException
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 Detail
-
getByteStream
public InputStream 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 byte array or part of to the buffer.- Parameters:
bytes
- a byte arrayoffset
- an offset withlen
-
-
append
public void append(byte[] bytes)
Append a byte array to the buffer- Parameters:
bytes
- a byte array
-
append
public void append(ByteBuffer anotherBuffer)
Append another buffer to this buffer.- Parameters:
anotherBuffer
- anotherByteBuffer
-
getEncoding
public String 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.
-
-