com.objsys.asn1j.runtime
Interface Asn1PerEncoder

All Known Implementing Classes:
Asn1PerEncodeBuffer, Asn1PerOutputStream

public interface Asn1PerEncoder

Common interface for PER encoding methods, implemented by Asn1PerEncodeBuffer and Asn1PerOutputStream.


Method Summary
 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.
 

Method Detail

encodeBit

void encodeBit(boolean value)
               throws java.io.IOException,
                      Asn1Exception
This method encodes a single bit value.

Parameters:
value - Boolean value of bit to be encoded.
Throws:
java.io.IOException - Any exception thrown by the underlying OutputStream.
Asn1Exception - Any exception thrown by the underlying Asn1PerEncodeBuffer.

encodeBit

void encodeBit(boolean value,
               java.lang.String ident)
               throws java.io.IOException,
                      Asn1Exception
This method encodes a single bit value.

Parameters:
value - Boolean value of bit to be encoded.
ident - Bit field identifier name for tracing.
Throws:
java.io.IOException - Any exception thrown by the underlying OutputStream.
Asn1Exception - Any exception thrown by the underlying Asn1PerEncodeBuffer.

encodeBits

void encodeBits(byte value,
                int nbits)
                throws java.io.IOException,
                       Asn1InvalidArgException
This method encodes bit values from an octet. The most significant bits from the octet are encoded.

Parameters:
value - Octet containing bits to be encoded
nbits - Number of bits to encode
Throws:
java.io.IOException - Any exception thrown by the underlying OutputStream.
Asn1InvalidArgException - Any exception thrown by the underlying Asn1PerEncodeBuffer.

encodeBits

void encodeBits(byte[] value,
                int offset,
                int nbits)
                throws java.io.IOException,
                       Asn1InvalidArgException
This method encodes bit values from an array of octets.

Parameters:
value - Octet array containing bits to be encoded
offset - Starting byte offset in value
nbits - Number of bits to encode
Throws:
java.io.IOException - Any exception thrown by the underlying OutputStream.
Asn1InvalidArgException - Any exception thrown by the underlying Asn1PerEncodeBuffer.

encodeBits

void encodeBits(byte[] value,
                int offset,
                int nbits,
                java.lang.String ident)
                throws java.io.IOException,
                       Asn1InvalidArgException
This method encodes bit values from an array of octets.

Parameters:
value - Octet array containing bits to be encoded
offset - Starting byte offset in value
nbits - Number of bits to encode
ident - Bit field identifier name for tracing.
Throws:
java.io.IOException - Any exception thrown by the underlying OutputStream.
Asn1InvalidArgException - Any exception thrown by the underlying Asn1PerEncodeBuffer.

encodeCharString

void encodeCharString(java.lang.String value,
                      int nchars,
                      int offset,
                      int abpc,
                      int ubpc,
                      Asn1CharSet charSet)
                      throws java.io.IOException,
                             Asn1Exception
This method encodes the contents of a known-multiplier character string type. This version assumes a permitted alphabet constraint was specified.

Parameters:
value - String containing characters to encode
nchars - Number of characters from string to encode
offset - Offset to first char in string to encode
abpc - Number of bits per character (aligned)
ubpc - Number of bits per character (unaligned)
charSet - Object representing permitted alphabet constraint character set (optional)
Throws:
java.io.IOException - Any exception thrown by the underlying OutputStream.
Asn1Exception - Any exception thrown by the underlying Asn1PerEncodeBuffer.

encodeConsWholeNumber

void encodeConsWholeNumber(long adjustedValue,
                           long rangeValue,
                           java.lang.String ident)
                           throws java.io.IOException,
                                  Asn1InvalidArgException
This method implements the rules to encode a constrained whole number as specified in section 10.5 of the X.691 standard.

Parameters:
adjustedValue - Adjusted value to be encoded = value - lower range endpoint value
rangeValue - lower - upper + 1
ident - Bit field identifier name for tracing.
Throws:
java.io.IOException - Any exception thrown by the underlying OutputStream.
Asn1InvalidArgException - Any exception thrown by the underlying Asn1PerEncodeBuffer.

encodeConsWholeNumber

void encodeConsWholeNumber(long adjustedValue,
                           long rangeValue)
                           throws java.io.IOException,
                                  Asn1InvalidArgException
This method implements the rules to encode a constrained whole number as specified in section 10.5 of the X.691 standard.

Parameters:
adjustedValue - Adjusted value to be encoded = value - lower range endpoint value
rangeValue - upper - lower + 1. Negative values are interpreted as unsigned integers. Zero is used to represent 2^64.
Throws:
java.io.IOException - Any exception thrown by the underlying OutputStream.
Asn1InvalidArgException - Any exception thrown by the underlying Asn1PerEncodeBuffer.

encodeInt

void encodeInt(long value,
               int nbits,
               java.lang.String ident)
               throws java.io.IOException,
                      Asn1InvalidArgException
This method encodes bit values from an integer value. The least significant bits from the integer are encoded.

Parameters:
value - Integer containing bits to be encoded
nbits - Number of bits to encode
ident - Bit field identifier name for tracing.
Throws:
java.io.IOException - Any exception thrown by the underlying OutputStream.
Asn1InvalidArgException - Any exception thrown by the underlying Asn1PerEncodeBuffer.

encodeInt

void encodeInt(long value,
               int nbits)
               throws java.io.IOException,
                      Asn1InvalidArgException
This method encodes bit values from an integer value. The least significant bits from the integer are encoded.

Parameters:
value - Integer containing bits to be encoded
nbits - Number of bits to encode
Throws:
java.io.IOException - Any exception thrown by the underlying OutputStream.
Asn1InvalidArgException - Any exception thrown by the underlying Asn1PerEncodeBuffer.

encodeInt

void encodeInt(long value,
               boolean encodeLen,
               boolean signExtend,
               java.lang.String ident)
               throws java.io.IOException,
                      Asn1InvalidArgException
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.

Parameters:
value - Integer value to be encoded
encodeLen - 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.
Throws:
java.io.IOException - Any exception thrown by the underlying OutputStream.
Asn1InvalidArgException - Any exception thrown by the underlying Asn1PerEncodeBuffer.

encodeInt

void encodeInt(long value,
               boolean encodeLen,
               boolean signExtend)
               throws java.io.IOException,
                      Asn1InvalidArgException
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.

Parameters:
value - Integer value to be encoded
encodeLen - Flag indicating length determinant should be encoded before encoding integer value.
signExtend - Flag indicating if sign extension should be performed.
Throws:
java.io.IOException - Any exception thrown by the underlying OutputStream.
Asn1InvalidArgException - Any exception thrown by the underlying Asn1PerEncodeBuffer.

encodeLength

long encodeLength(long value)
                  throws java.io.IOException,
                         Asn1InvalidArgException
This method encodes a general (unconstrained) length determinant value as described in section 10.9 or the X.691 standard.

Parameters:
value - Length value to be encoded
Returns:
Value that was actually encoded. This may be less than the value that was passed in if fragementation was done (i.e the value was >= 16k).
Throws:
java.io.IOException - Any exception thrown by the underlying OutputStream.
Asn1InvalidArgException - Any exception thrown by the underlying Asn1PerEncodeBuffer.

encodeLength

void encodeLength(long value,
                  long lower,
                  long upper)
                  throws java.io.IOException,
                         Asn1Exception
This method encodes a constrained length determinant value.

Parameters:
value - Length value to be encoded
lower - Lower bound (inclusive) of length value range
upper - Upper bound (inclusive) of length value range
Throws:
java.io.IOException - Any exception thrown by the underlying OutputStream.
Asn1Exception - Any exception thrown by the underlying Asn1PerEncodeBuffer.

encodeLengthEOM

void encodeLengthEOM(long value)
                     throws java.io.IOException,
                            Asn1Exception
This method checks to see if a zero byte needs to be added after a fragmented length has been encoded. It will add it to the byte stream if necessary.

Parameters:
value - Original length value that was encoded.
Throws:
java.io.IOException - Any exception thrown by the underlying OutputStream.
Asn1Exception - Any exception thrown by the underlying Asn1PerEncodeBuffer.

encodeOctetString

void encodeOctetString(byte[] value,
                       int offset,
                       int nbytes)
                       throws java.io.IOException,
                              Asn1Exception
This method encodes the given array of bytes as an unconstrained octet string value.

Parameters:
value - Byte array containing data to encode. This is assumed to contain a previously encoded PER component.
offset - Starting offset in byte array value
nbytes - Number of bytes to encode
Throws:
java.io.IOException - Any exception thrown by the underlying OutputStream.
Asn1Exception - Any exception thrown by the underlying Asn1PerEncodeBuffer.

encodeOIDLengthAndValue

void encodeOIDLengthAndValue(int[] value)
                             throws java.io.IOException,
                                    Asn1Exception
This method encodes the length and contents of an object identifier value.

Parameters:
value - Integer array containing arcs to encode
Throws:
java.io.IOException - Any exception thrown by the underlying OutputStream.
Asn1Exception - Any exception thrown by the underlying Asn1PerEncodeBuffer.

encodeRelOIDLengthAndValue

void encodeRelOIDLengthAndValue(int[] value)
                                throws java.io.IOException,
                                       Asn1Exception
This method encodes the length and contents of a relative object identifier value.

Parameters:
value - Integer array containing arcs to encode
Throws:
java.io.IOException - Any exception thrown by the underlying OutputStream.
Asn1Exception - Any exception thrown by the underlying Asn1PerEncodeBuffer.

encodeOpenType

void encodeOpenType(byte[] value,
                    int offset,
                    int nbytes)
                    throws java.io.IOException,
                           Asn1Exception
This method encodes the given array of bytes as an open type.

Parameters:
value - Byte array containing data to encode. This is assumed to contain a previously encoded PER component.
offset - Starting offset in byte array value
nbytes - Number of bytes to encode
Throws:
java.io.IOException - Any exception thrown by the underlying OutputStream.
Asn1Exception - Any exception thrown by the underlying Asn1PerEncodeBuffer.

encodeSmallLength

void encodeSmallLength(int value)
                       throws java.io.IOException,
                              Asn1InvalidArgException
This method implements the rules to encode a normally small length as specified in section 11.9 of the X.691 standard.

Parameters:
value - Value to be encoded
Throws:
java.io.IOException - Any exception thrown by the underlying OutputStream.
Asn1InvalidArgException - Any exception thrown by the underlying Asn1PerEncodeBuffer.

encodeSmallNonNegWholeNumber

void encodeSmallNonNegWholeNumber(int value)
                                  throws java.io.IOException,
                                         Asn1InvalidArgException
This method implements the rules to encode a small non-negative whole number as specified in section 10.6 of the X.691 standard.

Parameters:
value - Value to be encoded
Throws:
java.io.IOException - Any exception thrown by the underlying OutputStream.
Asn1InvalidArgException - Any exception thrown by the underlying Asn1PerEncodeBuffer.