Package org.snmp4j.asn1
Class BEROutputStream
java.lang.Object
java.io.OutputStream
org.snmp4j.asn1.BEROutputStream
- All Implemented Interfaces:
 Closeable,Flushable,AutoCloseable
The 
BEROutputStream class wraps a ByteBuffer
 to support BER encoding. The backing buffer can be accessed directly to
 optimize performance and memory usage.- Version:
 - 1.0
 - Author:
 - Frank Fock
 
- 
Constructor Summary
ConstructorsConstructorDescriptionCreates a BER output stream without a backing buffer set.BEROutputStream(ByteBuffer buffer) Create aBEROutputStreamthat uses the supplied buffer as backing buffer. - 
Method Summary
Modifier and TypeMethodDescriptionvoidclose()voidflush()Gets the backing buffer.rewind()Rewinds backing buffer and returns it.voidsetBuffer(ByteBuffer buffer) Sets the backing buffer to the supplied one and sets the offset used byrewind()to the buffers current position.voidsetFilledBuffer(ByteBuffer buffer) Sets the backing buffer and sets the current position of the stream to the buffers limit (end).voidwrite(byte[] b) voidwrite(byte[] b, int off, int len) voidwrite(int b)  
- 
Constructor Details
- 
BEROutputStream
public BEROutputStream()Creates a BER output stream without a backing buffer set. In order to be able to write anything to the stream,setBuffer(ByteBuffer buffer)has to be called before. Otherwise aNullPointerExceptionwill be thrown when calling one of thewriteoperations. - 
BEROutputStream
Create aBEROutputStreamthat uses the supplied buffer as backing buffer.- Parameters:
 buffer- aByteBufferwhose limit and capacity must be greater or equal that the length of the encoded BER stream.
 
 - 
 - 
Method Details
- 
write
- Specified by:
 writein classOutputStream- Throws:
 IOException
 - 
write
- Overrides:
 writein classOutputStream- Throws:
 IOException
 - 
write
- Overrides:
 writein classOutputStream- Throws:
 IOException
 - 
close
- Specified by:
 closein interfaceAutoCloseable- Specified by:
 closein interfaceCloseable- Overrides:
 closein classOutputStream- Throws:
 IOException
 - 
flush
- Specified by:
 flushin interfaceFlushable- Overrides:
 flushin classOutputStream- Throws:
 IOException
 - 
rewind
Rewinds backing buffer and returns it. In contrast to the backing buffer's rewind method, this method sets the position of the buffer to the first byte of this output stream rather than to the first byte of the underlying byte array!- Returns:
 - the ByteBuffer backing this output stream with its current position set to the begin of the output stream.
 
 - 
getBuffer
Gets the backing buffer.- Returns:
 - the 
ByteBufferbacking this output stream. 
 - 
setBuffer
Sets the backing buffer to the supplied one and sets the offset used byrewind()to the buffers current position.- Parameters:
 buffer- aByteBufferwhose limit and capacity must be greater or equal that the length of the encoded BER stream.
 - 
setFilledBuffer
Sets the backing buffer and sets the current position of the stream to the buffers limit (end).- Parameters:
 buffer- aByteBufferwhose limit and capacity must be greater or equal that the length of the encoded BER stream.
 
 -