public class BEROutputStream
extends java.io.OutputStream
BEROutputStream
class wraps a ByteBuffer
to support BER encoding. The backing buffer can be accessed directly to
optimize performance and memory usage.Modifier and Type | Field and Description |
---|---|
private java.nio.ByteBuffer |
buffer |
private int |
offset |
Constructor and Description |
---|
BEROutputStream()
Creates a BER output stream without a backing buffer set.
|
BEROutputStream(java.nio.ByteBuffer buffer)
Create a
BEROutputStream that uses the supplied buffer
as backing buffer. |
Modifier and Type | Method and Description |
---|---|
void |
close() |
void |
flush() |
java.nio.ByteBuffer |
getBuffer()
Gets the backing buffer.
|
java.nio.ByteBuffer |
rewind()
Rewinds backing buffer and returns it.
|
void |
setBuffer(java.nio.ByteBuffer buffer)
Sets the backing buffer to the supplied one and sets the offset used by
rewind() to the buffers current position. |
void |
setFilledBuffer(java.nio.ByteBuffer buffer)
Sets the backing buffer and sets the current position of the stream to
the buffers limit (end).
|
void |
write(byte[] b) |
void |
write(byte[] b,
int off,
int len) |
void |
write(int b) |
public BEROutputStream()
setBuffer(ByteBuffer buffer)
has to be
called before. Otherwise a NullPointerException
will be
thrown when calling one of the write
operations.public BEROutputStream(java.nio.ByteBuffer buffer)
BEROutputStream
that uses the supplied buffer
as backing buffer.buffer
- a ByteBuffer
whose limit and capacity must be greater or
equal that the length of the encoded BER stream.public void write(int b) throws java.io.IOException
write
in class java.io.OutputStream
java.io.IOException
public void write(byte[] b) throws java.io.IOException
write
in class java.io.OutputStream
java.io.IOException
public void write(byte[] b, int off, int len) throws java.io.IOException
write
in class java.io.OutputStream
java.io.IOException
public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in class java.io.OutputStream
java.io.IOException
public void flush() throws java.io.IOException
flush
in interface java.io.Flushable
flush
in class java.io.OutputStream
java.io.IOException
public java.nio.ByteBuffer rewind()
public java.nio.ByteBuffer getBuffer()
ByteBuffer
backing this output stream.public void setBuffer(java.nio.ByteBuffer buffer)
rewind()
to the buffers current position.buffer
- a ByteBuffer
whose limit and capacity must be greater or
equal that the length of the encoded BER stream.public void setFilledBuffer(java.nio.ByteBuffer buffer)
buffer
- a ByteBuffer
whose limit and capacity must be greater or
equal that the length of the encoded BER stream.