public class BEROutputStream extends OutputStream
BEROutputStream
class wraps a ByteBuffer
to support BER encoding. The backing buffer can be accessed directly to
optimize performance and memory usage.Constructor and Description |
---|
BEROutputStream()
Creates a BER output stream without a backing buffer set.
|
BEROutputStream(ByteBuffer buffer)
Create a
BEROutputStream that uses the supplied buffer
as backing buffer. |
Modifier and Type | Method and Description |
---|---|
void |
close() |
void |
flush() |
ByteBuffer |
getBuffer()
Gets the backing buffer.
|
ByteBuffer |
rewind()
Rewinds backing buffer and returns it.
|
void |
setBuffer(ByteBuffer buffer)
Sets the backing buffer to the supplied one and sets the offset used by
rewind() to the buffers current position. |
void |
setFilledBuffer(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(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 IOException
write
in class OutputStream
IOException
public void write(byte[] b) throws IOException
write
in class OutputStream
IOException
public void write(byte[] b, int off, int len) throws IOException
write
in class OutputStream
IOException
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in class OutputStream
IOException
public void flush() throws IOException
flush
in interface Flushable
flush
in class OutputStream
IOException
public ByteBuffer rewind()
public ByteBuffer getBuffer()
ByteBuffer
backing this output stream.public void setBuffer(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(ByteBuffer buffer)
buffer
- a ByteBuffer
whose limit and capacity must be greater or
equal that the length of the encoded BER stream.Copyright © 2017 SNMP4J.org. All rights reserved.