public class Asn1PerOutputStream extends Asn1OutputStream implements Asn1PerEncoder
| Modifier and Type | Field and Description | 
|---|---|
protected Asn1PerOutputStreamTraceHandler | 
mTraceHandler  | 
os| Constructor and Description | 
|---|
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. 
 | 
| Modifier and Type | Method and Description | 
|---|---|
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. 
 | 
getContext, write2Bytes, write4Bytesprotected Asn1PerOutputStreamTraceHandler mTraceHandler
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.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.Flushableflush in class Asn1OutputStreamjava.io.IOException - Any exception thrown by the underlying OutputStream.public void close()
           throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in class Asn1OutputStreamjava.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
Asn1PerEncoderencodeBit in interface Asn1PerEncodervalue - 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
Asn1PerEncoderencodeBit in interface Asn1PerEncodervalue - 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
Asn1PerEncoderencodeBits in interface Asn1PerEncodervalue - Octet containing bits to be encodednbits - Number of bits to encodejava.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
Asn1PerEncoderencodeBits in interface Asn1PerEncodervalue - Octet array containing bits to be encodedoffset - Starting byte offset in valuenbits - Number of bits to encodejava.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
Asn1PerEncoderencodeBits in interface Asn1PerEncodervalue - 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
Asn1PerEncoderencodeCharString in interface Asn1PerEncodervalue - 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
Asn1PerEncoderencodeConsWholeNumber in interface Asn1PerEncoderadjustedValue - 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
Asn1PerEncoderencodeConsWholeNumber in interface Asn1PerEncoderadjustedValue - 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
Asn1PerEncoderencodeInt in interface Asn1PerEncodervalue - 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
Asn1PerEncoderencodeInt in interface Asn1PerEncodervalue - Integer containing bits to be encodednbits - Number of bits to encodejava.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
Asn1PerEncoderencodeInt in interface Asn1PerEncodervalue - 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
Asn1PerEncoderencodeInt in interface Asn1PerEncodervalue - 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
Asn1PerEncoderencodeLength in interface Asn1PerEncodervalue - Length value to be encodedjava.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
Asn1PerEncoderencodeLength in interface Asn1PerEncodervalue - Length value to be encodedlower - Lower bound (inclusive) of length value rangeupper - Upper bound (inclusive) of length value rangejava.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
Asn1PerEncoderencodeLengthEOM in interface Asn1PerEncodervalue - 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
Asn1PerEncoderencodeOctetString in interface Asn1PerEncodervalue - 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 encodejava.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
Asn1PerEncoderencodeOIDLengthAndValue in interface Asn1PerEncodervalue - Integer array containing arcs to encodejava.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
Asn1PerEncoderencodeRelOIDLengthAndValue in interface Asn1PerEncodervalue - Integer array containing arcs to encodejava.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
Asn1PerEncoderencodeOpenType in interface Asn1PerEncodervalue - 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 encodejava.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
Asn1PerEncoderencodeSmallLength in interface Asn1PerEncodervalue - Value to be encodedjava.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
Asn1PerEncoderencodeSmallNonNegWholeNumber in interface Asn1PerEncodervalue - Value to be encodedjava.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 interface Asn1Writablewrite in class Asn1OutputStreamb - 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 interface Asn1Writablewrite in class Asn1OutputStreamb - 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 interface Asn1Writablewrite in class Asn1OutputStreamb - 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.