|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.objsys.asn1j.runtime.Asn1MessageBufferBase com.objsys.asn1j.runtime.Asn1MessageBuffer com.objsys.asn1j.runtime.Asn1EncodeBuffer com.objsys.asn1j.runtime.Asn1PerEncodeBuffer
public class Asn1PerEncodeBuffer
This class handles the encoding of ASN.1 messages as specified in the Packed Encoding Rules (PER) as specified in the ITU-T X.691 standard.
Field Summary | |
---|---|
protected Asn1PerTraceHandler |
mTraceHandler
|
Fields inherited from class com.objsys.asn1j.runtime.Asn1EncodeBuffer |
---|
INITIAL_SIZE, mByteIndex, mData |
Fields inherited from class com.objsys.asn1j.runtime.Asn1MessageBufferBase |
---|
context, mTypeCode |
Constructor Summary | |
---|---|
Asn1PerEncodeBuffer(boolean aligned)
This constructor creates a PER encode buffer object with the default initial size. |
|
Asn1PerEncodeBuffer(boolean aligned,
int size)
This constructor creates a PER encode buffer object with the given initial size. |
Method Summary | |
---|---|
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()
This methods byte-aligns the buffer. |
protected void |
checkSize(int bytesRequired)
This method determines if the encode buffer can hold the requested number of bytes. |
void |
copy(byte value)
This method is used to copy a single byte to the encode buffer. |
void |
copy(byte[] value)
This method copies multiple bytes to the encode buffer |
void |
encodeBit(boolean value)
This method encodes a single bit value. |
void |
encodeBit(boolean value,
java.lang.String ident)
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,
java.lang.String ident)
This method encodes bit values from an array of octets. |
void |
encodeBits(byte[] value,
int offset,
int nbits,
java.lang.String ident)
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 |
encodeCharString(java.lang.String value,
int nchars,
int offset,
int abpc,
int ubpc,
Asn1CharSet charSet)
This method encodes the contents of a known-multiplier character string type. |
void |
encodeConsWholeNumber(long adjustedValue,
long rangeValue)
This method implements the rules to encode a constrained whole number as specified in section 10.5 of the X.691 standard. |
void |
encodeConsWholeNumber(long adjustedValue,
long rangeValue,
java.lang.String ident)
This method implements the rules to encode a constrained whole number as specified in section 10.5 of the X.691 standard. |
void |
encodeInt(long value,
boolean encodeLen,
boolean signExtend)
This method implements the rules to encode either a non-negative binary integer as specified in section 10.3 or a two's complement binary integer as specified in section 10.4 of the X.691 standard. |
void |
encodeInt(long value,
boolean encodeLen,
boolean signExtend,
java.lang.String ident)
This method implements the rules to encode either a non-negative binary integer as specified in section 10.3 or a two's complement binary integer as specified in section 10.4 of the X.691 standard. |
void |
encodeInt(long value,
int nbits)
This method encodes bit values from an integer value. |
void |
encodeInt(long value,
int nbits,
java.lang.String ident)
This method encodes bit values from an integer value. |
long |
encodeLength(long value)
This method encodes a general (unconstrained) length determinant value as described in section 10.9 or the X.691 standard. |
void |
encodeLength(long value,
long lower,
long upper)
This method encodes a constrained length determinant value. |
void |
encodeLengthEOM(long value)
This method checks to see if a zero byte needs to be added after a fragmented length has been encoded. |
void |
encodeOctetString(byte[] value,
int offset,
int nbytes)
This method encodes the given array of bytes as an unconstrained octet string value. |
void |
encodeOIDLengthAndValue(int[] value)
This method encodes the length and contents of an object identifier value. |
void |
encodeOpenType(Asn1PerEncodeBuffer buffer,
java.lang.String elemName)
This overloaded version of encodeOpenType will encode the componet in the given PER encode buffer into this PER encode buffer. |
void |
encodeOpenType(byte[] value,
int offset,
int nbytes)
This method encodes the given array of bytes as an open type. |
void |
encodeRelOIDLengthAndValue(int[] value)
This method encodes the length and contents of a relative object identifier value. |
void |
encodeSmallLength(int value)
This method implements the rules to encode a normally small length as specified in section 11.9 of the X.691 standard. |
void |
encodeSmallNonNegWholeNumber(int value)
This method implements the rules to encode a small non-negative whole number as specified in section 10.6 of the X.691 standard. |
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. |
java.io.InputStream |
getInputStream()
This method returns an input stream representing the encoded message. |
int |
getMsgBitCnt()
This method returns the number of bits in the encoded PER message. |
int |
getMsgByteCnt()
This method returns the number of bytes in the encoded PER message. |
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 |
isAligned()
This method is used to test if PER aligned encoding has been specified. |
void |
reset()
This method resets the buffer object so that it can be reused to encode another PER message. |
void |
reverseBytes(int offset,
int nbytes)
This method reverses a series of bytes at a given offset within the encode buffer. |
void |
setAligned(boolean value)
This method is used to turn PER aligned encoding on or off |
java.lang.String |
toString()
This method will return a string representation of the data in the encode buffer. |
void |
write(java.io.OutputStream out)
This method writes the encoded record to the given output stream. |
Methods inherited from class com.objsys.asn1j.runtime.Asn1EncodeBuffer |
---|
binDump, hexDump, initBuffer, trimBitString |
Methods inherited from class com.objsys.asn1j.runtime.Asn1MessageBuffer |
---|
addNamedEventHandler, getEventHandlerListCount, hasEventHandlers, invokeCharacters, invokeEndElement, invokeStartElement, setEventHandlerList |
Methods inherited from class com.objsys.asn1j.runtime.Asn1MessageBufferBase |
---|
getContext, hexDump, hexDump, setKey, setTypeCode |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected Asn1PerTraceHandler mTraceHandler
Constructor Detail |
---|
public Asn1PerEncodeBuffer(boolean aligned)
aligned
- Indicates whether PER aligned or unaligned encoding
should be done.public Asn1PerEncodeBuffer(boolean aligned, int size)
aligned
- Indicates whether PER aligned or unaligned encoding
should be done.size
- The initial size in bytes of an encode buffer.Method Detail |
---|
public void binDump(java.io.PrintStream out, java.lang.String varName)
binDump
in class Asn1EncodeBuffer
public void byteAlign()
byteAlign
in interface Asn1PerMessageBuffer
protected void checkSize(int bytesRequired)
checkSize
in class Asn1EncodeBuffer
bytesRequired
- Number of required bytes.public void copy(byte value)
copy
in class Asn1EncodeBuffer
value
- The byte value to copypublic void copy(byte[] value) throws Asn1Exception
copy
in class Asn1EncodeBuffer
value
- Array of bytes to copy to the encode buffer
Asn1Exception
public void encodeBit(boolean value, java.lang.String ident)
encodeBit
in interface Asn1PerEncoder
value
- Boolean value of bit to be encoded.ident
- Bit field identifier name for tracing.public void encodeBit(boolean value)
encodeBit
in interface Asn1PerEncoder
value
- Boolean value of bit to be encoded.public void encodeBits(byte value, int nbits) throws Asn1InvalidArgException
encodeBits
in interface Asn1PerEncoder
value
- Octet containing bits to be encodednbits
- Number of bits to encode
Asn1InvalidArgException
- Any exception thrown by the underlying
Asn1PerEncodeBuffer.public void encodeBits(byte[] value, int offset, int nbits, java.lang.String ident) throws Asn1InvalidArgException
encodeBits
in interface Asn1PerEncoder
value
- Octet array containing bits to be encodedoffset
- Starting byte offset in valuenbits
- Number of bits to encodeident
- Bit field identifier name for tracing, or null.
Asn1InvalidArgException
- Any exception thrown by the underlying
Asn1PerEncodeBuffer.public void encodeBits(byte[] value, int offset, int bitOffset, int nbits, java.lang.String ident) 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 encodeident
- Bit field identifier name for tracing, or null.
Asn1InvalidArgException
public void encodeBits(byte[] value, int offset, int nbits) throws Asn1InvalidArgException
encodeBits
in interface Asn1PerEncoder
value
- Octet array containing bits to be encodedoffset
- Starting byte offset in valuenbits
- Number of bits to encode
Asn1InvalidArgException
- Any exception thrown by the underlying
Asn1PerEncodeBuffer.public void encodeCharString(java.lang.String value, int nchars, int offset, int abpc, int ubpc, Asn1CharSet charSet) throws Asn1Exception
encodeCharString
in interface Asn1PerEncoder
value
- String containing characters to encodenchars
- Number of characters from string to encodeoffset
- Offset to first char in string to encodeabpc
- Number of bits per character (aligned)ubpc
- Number of bits per character (unaligned)charSet
- Object representing permitted alphabet
constraint character set (optional)
Asn1Exception
- Any exception thrown by the underlying
Asn1PerEncodeBuffer.public void encodeConsWholeNumber(long adjustedValue, long rangeValue, java.lang.String ident) throws Asn1InvalidArgException
encodeConsWholeNumber
in interface Asn1PerEncoder
adjustedValue
- Adjusted value to be encoded =
value - lower range endpoint value. Negative
values are interpreted as unsigned integers.rangeValue
- upper - lower + 1. Negative values are
interpreted as unsigned integers. Zero is
used to represent 2^64.ident
- Tracing identifier
Asn1InvalidArgException
- Any exception thrown by the underlying
Asn1PerEncodeBuffer.public void encodeConsWholeNumber(long adjustedValue, long rangeValue) throws Asn1InvalidArgException
encodeConsWholeNumber
in interface Asn1PerEncoder
adjustedValue
- Adjusted value to be encoded =
value - lower range endpoint valuerangeValue
- upper - lower + 1. Negative values are
interpreted as unsigned integers. Zero is
used to represent 2^64.
Asn1InvalidArgException
- Any exception thrown by the underlying
Asn1PerEncodeBuffer.public void encodeInt(long value, int nbits, java.lang.String ident) throws Asn1InvalidArgException
encodeInt
in interface Asn1PerEncoder
value
- Integer containing bits to be encodednbits
- Number of bits to encodeident
- Tracing identifier
Asn1InvalidArgException
- Any exception thrown by the underlying
Asn1PerEncodeBuffer.public void encodeInt(long value, int nbits) throws Asn1InvalidArgException
encodeInt
in interface Asn1PerEncoder
value
- Integer containing bits to be encodednbits
- Number of bits to encode
Asn1InvalidArgException
- Any exception thrown by the underlying
Asn1PerEncodeBuffer.public void encodeInt(long value, boolean encodeLen, boolean signExtend, java.lang.String ident) throws Asn1InvalidArgException
encodeInt
in interface Asn1PerEncoder
value
- Integer value to be encodedencodeLen
- Flag indicating length determinant should be
encoded before encoding integer value.signExtend
- Flag indicating if sign extension should be performed.ident
- Tracing identifier
Asn1InvalidArgException
- Any exception thrown by the underlying
Asn1PerEncodeBuffer.public void encodeInt(long value, boolean encodeLen, boolean signExtend) throws Asn1InvalidArgException
encodeInt
in interface Asn1PerEncoder
value
- Integer value to be encodedencodeLen
- Flag indicating length determinant should be
encoded before encoding integer value.signExtend
- Flag indicating if sign extension should be performed.
Asn1InvalidArgException
- Any exception thrown by the underlying
Asn1PerEncodeBuffer.public long encodeLength(long value) throws Asn1InvalidArgException
encodeLength
in interface Asn1PerEncoder
value
- Length value to be encoded
Asn1InvalidArgException
- Any exception thrown by the underlying
Asn1PerEncodeBuffer.public void encodeLength(long value, long lower, long upper) throws Asn1Exception
encodeLength
in interface Asn1PerEncoder
value
- Length value to be encodedlower
- Lower bound (inclusive) of length value rangeupper
- Upper bound (inclusive) of length value range
Asn1Exception
- Any exception thrown by the underlying
Asn1PerEncodeBuffer.public void encodeLengthEOM(long value)
encodeLengthEOM
in interface Asn1PerEncoder
value
- Original length value that was encoded.public void encodeOIDLengthAndValue(int[] value) throws Asn1Exception
encodeOIDLengthAndValue
in interface Asn1PerEncoder
value
- Integer array containing arcs to encode
Asn1Exception
- Any exception thrown by the underlying
Asn1PerEncodeBuffer.public void encodeRelOIDLengthAndValue(int[] value) throws Asn1Exception
encodeRelOIDLengthAndValue
in interface Asn1PerEncoder
value
- Integer array containing arcs to encode
Asn1Exception
- Any exception thrown by the underlying
Asn1PerEncodeBuffer.public void encodeOctetString(byte[] value, int offset, int nbytes) throws Asn1Exception
encodeOctetString
in interface Asn1PerEncoder
value
- Byte array containing data to encode. This is
assumed to contain a previously encoded PER
component.offset
- Starting offset in byte array valuenbytes
- Number of bytes to encode
Asn1Exception
- Any exception thrown by the underlying
Asn1PerEncodeBuffer.public void encodeOpenType(byte[] value, int offset, int nbytes) throws Asn1Exception
encodeOpenType
in interface Asn1PerEncoder
value
- Byte array containing data to encode. This is
assumed to contain a previously encoded PER
component.offset
- Starting offset in byte array valuenbytes
- Number of bytes to encode
Asn1Exception
- Any exception thrown by the underlying
Asn1PerEncodeBuffer.public void encodeOpenType(Asn1PerEncodeBuffer buffer, java.lang.String elemName) throws Asn1Exception
buffer
- PER encode buffer containing encoded message
component.elemName
- Name of element being encoded.
Asn1Exception
public void encodeSmallLength(int value) throws Asn1InvalidArgException
encodeSmallLength
in interface Asn1PerEncoder
value
- Value to be encoded
Asn1InvalidArgException
- Any exception thrown by the underlying
Asn1PerEncodeBuffer.public void encodeSmallNonNegWholeNumber(int value) throws Asn1InvalidArgException
encodeSmallNonNegWholeNumber
in interface Asn1PerEncoder
value
- Value to be encoded
Asn1InvalidArgException
- Any exception thrown by the underlying
Asn1PerEncodeBuffer.public byte[] getBuffer()
public int getByteIndex()
public java.io.ByteArrayInputStream getByteArrayInputStream()
public java.io.InputStream getInputStream()
getInputStream
in interface Asn1PerMessageBuffer
getInputStream
in class Asn1MessageBuffer
public int getMsgBitCnt()
getMsgBitCnt
in interface Asn1PerMessageBuffer
public int getMsgByteCnt()
public byte[] getMsgCopy()
getMsgCopy
in class Asn1EncodeBuffer
public int getMsgLength()
getMsgLength
in class Asn1EncodeBuffer
public void hexDump()
hexDump
in class Asn1EncodeBuffer
public boolean isAligned()
isAligned
in interface Asn1PerMessageBuffer
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 void setAligned(boolean value)
public void write(java.io.OutputStream out) throws java.io.IOException
write
in class Asn1EncodeBuffer
out
- Output stream to which record is to be written
java.io.IOException
public Asn1PerTraceHandler getTraceHandler()
getTraceHandler
in interface Asn1PerMessageBuffer
public java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |