|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.io.OutputStream com.objsys.asn1j.runtime.Asn1OutputStream com.objsys.asn1j.runtime.Asn1PerOutputStream
public class Asn1PerOutputStream
This class handles the output stream for encoding of ASN.1 messages as specified in the Packed Encoding Rules (PER) ITU-T X.691 standard.
Field Summary | |
---|---|
protected Asn1PerOutputStreamTraceHandler |
mTraceHandler
|
Fields inherited from class com.objsys.asn1j.runtime.Asn1OutputStream |
---|
os |
Constructor Summary | |
---|---|
Asn1PerOutputStream(java.io.OutputStream os,
boolean aligned)
This constructor creates a buffered PER output stream object with the default size of buffer. |
|
Asn1PerOutputStream(java.io.OutputStream os,
int bufSize,
boolean aligned)
This constructor creates a buffered PER output stream object with the specified size of buffer. |
Method Summary | |
---|---|
void |
addCaptureBuffer(java.io.ByteArrayOutputStream buffer)
This method is used to add a capture buffer to the internal capture buffer list. |
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 |
binDump(java.lang.String varName)
This method invokes an overloaded version of binDump to dump the encoded message to standard output. |
void |
byteAlign()
This methods byte-aligns the buffer. |
void |
close()
Close the stream. |
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 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(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. |
void |
flush()
Flush the buffer to the stream. |
Asn1PerTraceHandler |
getTraceHandler()
This method will return a reference to the internal trace handler object used to trace the bit fields within a PER message. |
boolean |
isAligned()
This method is used to test if PER aligned encoding has been specified. |
void |
removeCaptureBuffer(java.io.ByteArrayOutputStream buffer)
This method is used to remove a capture buffer from the internal capture buffer list. |
void |
write(byte[] b)
Writes b.length bytes from the specified byte array
to this output stream. |
void |
write(byte[] b,
int off,
int len)
Writes len bytes from the specified byte array
starting at offset off to this output stream. |
void |
write(int b)
Writes the specified byte to this output stream. |
Methods inherited from class com.objsys.asn1j.runtime.Asn1OutputStream |
---|
getContext, write2Bytes, write4Bytes |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected Asn1PerOutputStreamTraceHandler mTraceHandler
Constructor Detail |
---|
public Asn1PerOutputStream(java.io.OutputStream os, boolean aligned)
os
- The underlying OutputStream object.aligned
- Indicates whether PER aligned or unaligned encoding
should be done.public Asn1PerOutputStream(java.io.OutputStream os, int bufSize, boolean aligned)
os
- The underlying OutputStream object.bufSize
- The buffer size.aligned
- Indicates whether PER aligned or unaligned encoding
should be done.Method Detail |
---|
public Asn1PerTraceHandler getTraceHandler()
public void binDump(java.lang.String varName)
public void binDump(java.io.PrintStream out, java.lang.String varName)
public void flush() throws java.io.IOException
flush
in interface java.io.Flushable
flush
in class Asn1OutputStream
java.io.IOException
- Any exception thrown by the underlying OutputStream.public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in class Asn1OutputStream
java.io.IOException
- Any exception thrown by the underlying OutputStream.public boolean isAligned()
public void byteAlign()
public void encodeBit(boolean value) throws java.io.IOException, Asn1Exception
Asn1PerEncoder
encodeBit
in interface Asn1PerEncoder
value
- Boolean value of bit to be encoded.
java.io.IOException
- Any exception thrown by the underlying OutputStream.
Asn1Exception
- Any exception thrown by the underlying
Asn1PerEncodeBuffer.public void encodeBit(boolean value, java.lang.String ident) throws java.io.IOException, Asn1Exception
Asn1PerEncoder
encodeBit
in interface Asn1PerEncoder
value
- Boolean value of bit to be encoded.ident
- Bit field identifier name for tracing.
java.io.IOException
- Any exception thrown by the underlying OutputStream.
Asn1Exception
- Any exception thrown by the underlying
Asn1PerEncodeBuffer.public void encodeBits(byte value, int nbits) throws java.io.IOException, Asn1InvalidArgException
Asn1PerEncoder
encodeBits
in interface Asn1PerEncoder
value
- Octet containing bits to be encodednbits
- Number of bits to encode
java.io.IOException
- Any exception thrown by the underlying OutputStream.
Asn1InvalidArgException
- Any exception thrown by the underlying
Asn1PerEncodeBuffer.public void encodeBits(byte[] value, int offset, int nbits) throws java.io.IOException, Asn1InvalidArgException
Asn1PerEncoder
encodeBits
in interface Asn1PerEncoder
value
- Octet array containing bits to be encodedoffset
- Starting byte offset in valuenbits
- Number of bits to encode
java.io.IOException
- Any exception thrown by the underlying OutputStream.
Asn1InvalidArgException
- Any exception thrown by the underlying
Asn1PerEncodeBuffer.public void encodeBits(byte[] value, int offset, int nbits, java.lang.String ident) throws java.io.IOException, Asn1InvalidArgException
Asn1PerEncoder
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.
java.io.IOException
- Any exception thrown by the underlying OutputStream.
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 java.io.IOException, Asn1Exception
Asn1PerEncoder
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)
java.io.IOException
- Any exception thrown by the underlying OutputStream.
Asn1Exception
- Any exception thrown by the underlying
Asn1PerEncodeBuffer.public void encodeConsWholeNumber(long adjustedValue, long rangeValue, java.lang.String ident) throws java.io.IOException, Asn1InvalidArgException
Asn1PerEncoder
encodeConsWholeNumber
in interface Asn1PerEncoder
adjustedValue
- Adjusted value to be encoded =
value - lower range endpoint valuerangeValue
- lower - upper + 1ident
- Bit field identifier name for tracing.
java.io.IOException
- Any exception thrown by the underlying OutputStream.
Asn1InvalidArgException
- Any exception thrown by the underlying
Asn1PerEncodeBuffer.public void encodeConsWholeNumber(long adjustedValue, long rangeValue) throws java.io.IOException, Asn1InvalidArgException
Asn1PerEncoder
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.
java.io.IOException
- Any exception thrown by the underlying OutputStream.
Asn1InvalidArgException
- Any exception thrown by the underlying
Asn1PerEncodeBuffer.public void encodeInt(long value, int nbits, java.lang.String ident) throws java.io.IOException, Asn1InvalidArgException
Asn1PerEncoder
encodeInt
in interface Asn1PerEncoder
value
- Integer containing bits to be encodednbits
- Number of bits to encodeident
- Bit field identifier name for tracing.
java.io.IOException
- Any exception thrown by the underlying OutputStream.
Asn1InvalidArgException
- Any exception thrown by the underlying
Asn1PerEncodeBuffer.public void encodeInt(long value, int nbits) throws java.io.IOException, Asn1InvalidArgException
Asn1PerEncoder
encodeInt
in interface Asn1PerEncoder
value
- Integer containing bits to be encodednbits
- Number of bits to encode
java.io.IOException
- Any exception thrown by the underlying OutputStream.
Asn1InvalidArgException
- Any exception thrown by the underlying
Asn1PerEncodeBuffer.public void encodeInt(long value, boolean encodeLen, boolean signExtend, java.lang.String ident) throws java.io.IOException, Asn1InvalidArgException
Asn1PerEncoder
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
- Bit field identifier name for tracing.
java.io.IOException
- Any exception thrown by the underlying OutputStream.
Asn1InvalidArgException
- Any exception thrown by the underlying
Asn1PerEncodeBuffer.public void encodeInt(long value, boolean encodeLen, boolean signExtend) throws java.io.IOException, Asn1InvalidArgException
Asn1PerEncoder
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.
java.io.IOException
- Any exception thrown by the underlying OutputStream.
Asn1InvalidArgException
- Any exception thrown by the underlying
Asn1PerEncodeBuffer.public long encodeLength(long value) throws java.io.IOException, Asn1InvalidArgException
Asn1PerEncoder
encodeLength
in interface Asn1PerEncoder
value
- Length value to be encoded
java.io.IOException
- Any exception thrown by the underlying OutputStream.
Asn1InvalidArgException
- Any exception thrown by the underlying
Asn1PerEncodeBuffer.public void encodeLength(long value, long lower, long upper) throws java.io.IOException, Asn1Exception
Asn1PerEncoder
encodeLength
in interface Asn1PerEncoder
value
- Length value to be encodedlower
- Lower bound (inclusive) of length value rangeupper
- Upper bound (inclusive) of length value range
java.io.IOException
- Any exception thrown by the underlying OutputStream.
Asn1Exception
- Any exception thrown by the underlying
Asn1PerEncodeBuffer.public void encodeLengthEOM(long value) throws java.io.IOException, Asn1Exception
Asn1PerEncoder
encodeLengthEOM
in interface Asn1PerEncoder
value
- Original length value that was encoded.
java.io.IOException
- Any exception thrown by the underlying OutputStream.
Asn1Exception
- Any exception thrown by the underlying
Asn1PerEncodeBuffer.public void encodeOctetString(byte[] value, int offset, int nbytes) throws java.io.IOException, Asn1Exception
Asn1PerEncoder
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
java.io.IOException
- Any exception thrown by the underlying OutputStream.
Asn1Exception
- Any exception thrown by the underlying
Asn1PerEncodeBuffer.public void encodeOIDLengthAndValue(int[] value) throws java.io.IOException, Asn1Exception
Asn1PerEncoder
encodeOIDLengthAndValue
in interface Asn1PerEncoder
value
- Integer array containing arcs to encode
java.io.IOException
- Any exception thrown by the underlying OutputStream.
Asn1Exception
- Any exception thrown by the underlying
Asn1PerEncodeBuffer.public void encodeRelOIDLengthAndValue(int[] value) throws java.io.IOException, Asn1Exception
Asn1PerEncoder
encodeRelOIDLengthAndValue
in interface Asn1PerEncoder
value
- Integer array containing arcs to encode
java.io.IOException
- Any exception thrown by the underlying OutputStream.
Asn1Exception
- Any exception thrown by the underlying
Asn1PerEncodeBuffer.public void encodeOpenType(byte[] value, int offset, int nbytes) throws java.io.IOException, Asn1Exception
Asn1PerEncoder
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
java.io.IOException
- Any exception thrown by the underlying OutputStream.
Asn1Exception
- Any exception thrown by the underlying
Asn1PerEncodeBuffer.public void encodeSmallLength(int value) throws java.io.IOException, Asn1InvalidArgException
Asn1PerEncoder
encodeSmallLength
in interface Asn1PerEncoder
value
- Value to be encoded
java.io.IOException
- Any exception thrown by the underlying OutputStream.
Asn1InvalidArgException
- Any exception thrown by the underlying
Asn1PerEncodeBuffer.public void encodeSmallNonNegWholeNumber(int value) throws java.io.IOException, Asn1InvalidArgException
Asn1PerEncoder
encodeSmallNonNegWholeNumber
in interface Asn1PerEncoder
value
- Value to be encoded
java.io.IOException
- Any exception thrown by the underlying OutputStream.
Asn1InvalidArgException
- Any exception thrown by the underlying
Asn1PerEncodeBuffer.public void addCaptureBuffer(java.io.ByteArrayOutputStream buffer)
buffer
- Buffer into which captured bytes are to be storedpublic void removeCaptureBuffer(java.io.ByteArrayOutputStream buffer)
buffer
- Buffer in which captured bytes storedpublic void write(byte[] b) throws java.io.IOException
b.length
bytes from the specified byte array
to this output stream. The general contract for write(b)
is that it should have exactly the same effect as the call
write(b, 0, b.length)
.
write
in class Asn1OutputStream
b
- the data.
java.io.IOException
- if an I/O error occurs.public void write(byte[] b, int off, int len) throws java.io.IOException
len
bytes from the specified byte array
starting at offset off
to this output stream.
write
in class Asn1OutputStream
b
- the data.off
- the start offset in the data.len
- the number of bytes to write.
java.io.IOException
- if an I/O error occurs. In particular,
an IOException
is thrown if the output
stream is closed.public void write(int b) throws java.io.IOException
write
in class Asn1OutputStream
b
- the byte
.
java.io.IOException
- if an I/O error occurs. In particular,
an IOException
may be thrown if the
output stream has been closed.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |