public class Asn1EncodeBitBuffer extends Asn1EncodeBuffer implements Asn1BitMessageBuffer, Asn1Writable
Modifier and Type | Field and Description |
---|---|
protected int |
mByteIndex |
protected byte[] |
mData |
protected Asn1PerTraceHandler |
mTraceHandler |
INITIAL_SIZE
context, mTypeCode
Constructor and Description |
---|
Asn1EncodeBitBuffer()
The default constructor initializes the encode buffer to the default
buffer size (INITIAL_SIZE bytes).
|
Asn1EncodeBitBuffer(int size)
This constructor allows specification of the initial size.
|
Modifier and Type | Method and Description |
---|---|
void |
binDump(java.io.PrintStream out,
java.lang.String varName)
This method dumps the encoded message in a human-readable format
showing a bit trace of all fields to the given print output stream.
|
void |
byteAlign()
Byte-align the buffer, possibly conditionally.
|
protected void |
checkSize(int bytesRequired)
This method determines if the encode buffer can hold the requested
number of additional bytes.
|
void |
copy(byte value)
This method is used to copy a single byte to the encode buffer.
|
void |
copy(byte[] value,
int offset,
int len)
This method copies multiple bytes from the given array to the encode
buffer.
|
void |
encodeBit(boolean value)
This method encodes a single bit value.
|
void |
encodeBits(byte[] value,
int offset,
int nbits)
This method encodes bit values from an array of octets.
|
void |
encodeBits(byte[] value,
int offset,
int bitOffset,
int nbits)
This method encodes bit values from an array of octets.
|
void |
encodeBits(byte value,
int nbits)
This method encodes bit values from an octet.
|
void |
encodeLongBits(long value,
int nbits)
This method encodes bit values from a long.
|
void |
encodeLongBits(long value,
int nbits,
boolean merge)
This method encodes bit values from a long.
|
int |
getBitOffsetInByte()
Return the bit offset of the next bit to be encoded.
|
byte[] |
getBuffer()
This method returns a reference to the byte buffer used to hold
the encoded message.
|
java.io.ByteArrayInputStream |
getByteArrayInputStream()
This method returns a reference to a byte array input stream
representing the encoded message.
|
int |
getByteIndex()
This method returns the current byte index into the encode buffer.
|
int |
getMsgBitCnt()
This method returns the number of bits in the encoded message.
|
int |
getMsgByteCnt()
This method returns the number of bytes written to the buffer.
|
byte[] |
getMsgCopy()
This method returns the encoded message in a byte array.
|
int |
getMsgLength()
This method returns the length (in bytes) of the encoded
message component.
|
Asn1PerTraceHandler |
getTraceHandler()
This method will return a reference to the internal trace handler
object used to trace the bit fields within a PER message.
|
void |
hexDump()
This method dumps the encoded message in hex/ascii format to
the standard output stream.
|
boolean |
isByteAligned()
Return true/false indicating whether a multiple of 8 bits has been
encoded thus far.
|
void |
reset()
This method resets the buffer object so that it can be reused to
encode another message.
|
void |
reverseBytes(int offset,
int nbytes)
This method reverses a series of bytes at a given offset within
the encode buffer.
|
void |
setMsgBitCnt(int count)
This method sets the position in the encoded message such that
getMsgBitCnt will subsequently return the given number.
|
java.lang.String |
toString()
This method will return a string representation of the data
in the encode buffer.
|
void |
write(byte[] value)
Implements Asn1Writable.write
|
void |
write(byte[] value,
int offset,
int len)
Implements Asn1Writable.write
|
void |
write(int value)
Implements Asn1Writable.write
|
void |
write(java.io.OutputStream out)
This method writes the encoded record to the given output stream.
|
binDump, copy, encodeIntSigned, encodeIntUnsigned, getInputStream, getMinimalOctetsSigned, getMinimalOctetsUnsigned, getOutputStream, hexDump
addNamedEventHandler, getEventHandlerListCount, hasEventHandlers, invokeCharacters, invokeEndElement, invokeStartElement, setEventHandlerList
getContext, hexDump, hexDump, setKey, setTypeCode
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getInputStream
protected int mByteIndex
protected byte[] mData
protected Asn1PerTraceHandler mTraceHandler
public Asn1EncodeBitBuffer()
public Asn1EncodeBitBuffer(int size)
size
- initial Buffer sizepublic void byteAlign()
byteAlign
in interface Asn1BitMessageBuffer
public final boolean isByteAligned()
public Asn1PerTraceHandler getTraceHandler()
getTraceHandler
in interface Asn1BitMessageBuffer
public void binDump(java.io.PrintStream out, java.lang.String varName)
binDump
in class Asn1EncodeBuffer
out
- stream to print to.varName
- Variable name to include in output.protected final void checkSize(int bytesRequired)
bytesRequired
- Number of required bytes.public void copy(byte value)
copy
in class Asn1EncodeBuffer
value
- The byte value to copypublic void copy(byte[] value, int offset, int len) throws Asn1Exception
copy
in class Asn1EncodeBuffer
value
- offset
- The first byte copied is value[offset]len
- The last byte copied is value[offset + len - 1]Asn1Exception
public final int getBitOffsetInByte()
public byte[] getBuffer()
public java.io.ByteArrayInputStream getByteArrayInputStream()
getByteArrayInputStream
in class Asn1EncodeBuffer
public final int getMsgBitCnt()
getMsgBitCnt
in interface Asn1BitMessageBuffer
public final void setMsgBitCnt(int count)
count
- The number of bits. This many bits must fit within the
current buffer.public final byte[] getMsgCopy()
getMsgCopy
in class Asn1EncodeBuffer
public void encodeBit(boolean value)
value
- Boolean value of bit to be encoded.public final void encodeLongBits(long value, int nbits)
public final void encodeLongBits(long value, int nbits, boolean merge)
value
- The value to take bits fromnbits
- The number of bits to encodemerge
- If true, preserve bits that follow the encoded bits in any
bytes that are touched. This can be set when overwriting certain
bits within an encoding.public final void encodeBits(byte value, int nbits) throws Asn1InvalidArgException
value
- Octet containing bits to be encodednbits
- Number of bits to encodeAsn1InvalidArgException
public void encodeBits(byte[] value, int offset, int bitOffset, int nbits) throws Asn1InvalidArgException
value
- Octet array containing bits to be encodedoffset
- Starting byte offset in valuebitOffset
- Starting bit offset in first byte. Pass 0 to begin
encoding with the most significant bit. Pass 7 to begin with the
least significant bit.nbits
- Number of bits to encodeAsn1InvalidArgException
public void encodeBits(byte[] value, int offset, int nbits) throws Asn1InvalidArgException
value
- Octet array containing bits to be encodedoffset
- Starting byte offset in valuenbits
- Number of bits to encodeAsn1InvalidArgException
public int getByteIndex()
public int getMsgByteCnt()
public int getMsgLength()
getMsgLength
in class Asn1EncodeBuffer
public void write(int value)
write
in interface Asn1Writable
value
- the byte
.public void write(byte[] value)
write
in interface Asn1Writable
value
- the data.public void write(byte[] value, int offset, int len)
write
in interface Asn1Writable
value
- the data.offset
- the start offset in the data.len
- the number of bytes to write.public void reset()
reset
in class Asn1EncodeBuffer
public void reverseBytes(int offset, int nbytes)
offset
- Starting byte offset within the buffernbytes
- Number of bytes to reversepublic final void write(java.io.OutputStream out) throws java.io.IOException
write
in class Asn1EncodeBuffer
out
- Output stream to which record is to be writtenjava.io.IOException
- for any I/O error.public java.lang.String toString()
toString
in class java.lang.Object
public void hexDump()
hexDump
in class Asn1EncodeBuffer