com.objsys.asn1j.runtime
Class Asn1BitString

java.lang.Object
  extended by com.objsys.asn1j.runtime.Asn1Type
      extended by com.objsys.asn1j.runtime.Asn1BitString
All Implemented Interfaces:
Asn1TypeIF, java.io.Serializable, java.lang.Cloneable
Direct Known Subclasses:
Asn1_ABSTRACT_SYNTAX_property, Asn1Xer__ABSTRACT_SYNTAX_property_default_Type, Asn1Xml__ABSTRACT_SYNTAX_property_default_Type

public class Asn1BitString
extends Asn1Type

This is a container class for holding the components of an ASN.1 bit string value.

See Also:
Serialized Form

Field Summary
static short ASN1VALUE
          The ASN1VALUE constant describes the string format for hex or binary digit value.
static short BITS
          The BITS constant describes the string format for binary digit value (e.g. only 0 and 1 digits).
static short HEX
          The HEX constant describes the string format for hex digit value (e.g. 0123456789ABCDEF).
static short HEXBIN
          The HEXBIN constant describes the string format for hex or binary digit value (e.g. 0xAA 10xxxxxx).
static short mStringFormat
          The mStringFormat variable can be used to set the string format for print or event handler or toString() functions.
 int numbits
          This variable contains the number of bits in the bit string value.
static Asn1Tag TAG
          The TAG constant describes the universal tag for this data type (UNIVERSAL 3).
 boolean trimZeroBits
          This variable describes whether trailing zero bits should be truncated.
 byte[] value
          This variable holds the bit string value.
 
Fields inherited from class com.objsys.asn1j.runtime.Asn1Type
BIT_STRING, BMPString, BOOLEAN, DATE, DATE_TIME, DURATION, ENUMERATED, EOC, EXTERNAL, GeneralString, GeneralTime, GraphicString, IA5String, INTEGER, mAsn1TypeName, NULL, NumericString, OBJECT_IDENTIFIER, ObjectDescriptor, OCTET_STRING, OID_IRI, OpenType, PrintableString, REAL, RELATIVE_OID_IRI, RelativeOID, SEQUENCE, SET, T61String, TeletexString, TIME, TIME_OF_DAY, UniversalString, UTCTime, UTF8String, VideotexString, VisibleString
 
Constructor Summary
Asn1BitString()
          This constructor creates an empty bit string that can be used in a decode method call to receive a bit string value.
Asn1BitString(java.util.BitSet bitSet)
          This constructor initializes a bit string from the given BitSet object.
Asn1BitString(boolean[] bitValues)
          This constructor initializes a bit string from the given boolean array.
Asn1BitString(byte[] data)
          This constructor initializes a bit string with the given bytes, using all 8 bits of every byte.
Asn1BitString(int numbits_, byte[] data)
          This constructor initializes a bit string with the given number of bits and data.
Asn1BitString(java.lang.String value_)
          This constructor parses the given ASN.1 value text (either a binary or hex data string) and assigns the values to the internal bit string.
 
Method Summary
 void clear(int bitno)
          This method clears the given bit in the bit string.
 void decode(Asn1BerDecodeBuffer buffer, boolean explicit, int implicitLength)
          This method decodes an ASN.1 bit string value using the BER or DER encoding rules.
 void decode(Asn1JsonDecodeBuffer buffer)
          Decode ASN.1 bit string from JSON.
 void decode(Asn1MderDecodeBuffer buffer, int length)
          Decode a BIT STRING from the MDER encoding into this object.
 void decode(Asn1PerDecodeBuffer buffer)
          This method decodes an ASN.1 bit string value using the packed encoding rules (PER).
 void decode(Asn1PerDecodeBuffer buffer, long lower, long upper)
          This method decodes a sized ASN.1 bit string value using the packed encoding rules (PER).
 void decode(Asn1PerDecodeBuffer buffer, long lower, java.lang.Object upper)
          This method decodes a sized ASN.1 bit string value using the packed encoding rules (PER).
 void decode(Asn1PerDecodeBuffer buffer, java.lang.Object lower, long upper)
          This method decodes a sized ASN.1 bit string value using the packed encoding rules (PER).
 void decode(Asn1PerDecodeBuffer buffer, java.lang.Object lower, java.lang.Object upper)
          This method decodes a sized ASN.1 bit string value using the packed encoding rules (PER).
 void decodeXER(java.lang.String buffer, java.lang.String attrs)
          This method decodes ASN.1 8-bit character string types including IA5String, PrintableString, NumericString, etc.
 void decodeXML(java.lang.String buffer, java.lang.String attrs)
          This method decodes an ASN.1 BIT STRING using the XML schema encoding rules.
 int encode(Asn1BerEncodeBuffer buffer, boolean explicit)
          This method encodes an ASN.1 bit string value using the BER or DER encoding rules.
 void encode(Asn1BerOutputStream out, boolean explicit)
          This method encodes and writes to the stream an ASN.1 bit string value including the UNIVERSAL tag value and length if explicit tagging is specified.
 void encode(Asn1JsonOutputStream outstream)
          Encode this bit string to JSON.
 void encode(Asn1MderOutputStream out, int length)
          Encode this BIT STRING into the MDER encoding.
 void encode(Asn1PerEncodeBuffer buffer)
          This method encodes an unconstrained ASN.1 bit string value using the packed encoding rules (PER).
 void encode(Asn1PerEncodeBuffer buffer, long lower, long upper)
          This method encodes a size-constrained ASN.1 bit string value using the packed encoding rules (PER).
 void encode(Asn1PerEncodeBuffer buffer, long lower, java.lang.Object upper)
          This method encodes a size-constrained ASN.1 bit string value using the packed encoding rules (PER).
 void encode(Asn1PerEncodeBuffer buffer, java.lang.Object lower, long upper)
          This method encodes a size-constrained ASN.1 bit string value using the packed encoding rules (PER).
 void encode(Asn1PerEncodeBuffer buffer, java.lang.Object lower, java.lang.Object upper)
          This method encodes a size-constrained ASN.1 bit string value using the packed encoding rules (PER).
 void encode(Asn1PerOutputStream out)
          This method encodes an unconstrained ASN.1 bit string value using the packed encoding rules (PER)into the stream.
 void encode(Asn1PerOutputStream out, long lower, long upper)
          This method encodes a size-constrained ASN.1 bit string value using the packed encoding rules (PER) into the stream.
 void encode(Asn1XerEncoder buffer, java.lang.String elemName)
          This method encodes ASN.1 bit string type using the XML encoding rules (XER).
 void encode(Asn1XmlEncoder buffer, java.lang.String elemName, java.lang.String nsPrefix)
          This method encodes ASN.1 bit string type using the XML Encoding as specified in the XML schema standard.
 void encode(Asn1XmlEncoder buffer, java.lang.String elemName, java.lang.String nsPrefix, java.lang.String[] namedbits, int[] namedbitindex)
          This method encodes ASN.1 bit string type using the XML Encoding as specified in the XML schema standard.
 boolean equals(int nbits, byte[] value)
          This method compares this bit string value to the given value for equality.
 boolean equals(java.lang.Object bs_)
          This method compares this bit string value to the given value for equality.
 java.lang.String getAsn1TypeName()
          This method gets the ASN.1 type name.
 int getLength()
          This method will return the length of the BIT STRING in bits.
 int hashCode()
          This method returns the hashCode for this bit string.
 boolean isNamedBitStr(java.lang.String buffer)
          This method determines is the input character string represented as named bit string or as bits sequence.
 boolean isSet(int bitno)
          This method tests if the given bit in the bit string is set or not.
 void set(int bitno)
          This method will set the given bit number to one (1).
 void set(int bitno, boolean bvalue)
          This method will set the given bit number to the given boolean value.
 boolean[] toBoolArray()
          This method converts the bit string stored in this object to a boolean array.
 java.lang.String toHexString()
          This method will return a hex string representation of the bit string value.
 java.io.InputStream toInputStream()
          This method will return a byte array input stream representation of the bit string value.
 java.lang.String toString()
          This method will return a string representation of the BIT STRING value.
 
Methods inherited from class com.objsys.asn1j.runtime.Asn1Type
clone, decode, decode, decode, decode, decode, encode, encode, equals, getTypeName, indent, isOpenType, matchTag, matchTag, pdiag, print, setKey, setOpenType
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

TAG

public static final Asn1Tag TAG
The TAG constant describes the universal tag for this data type (UNIVERSAL 3).


HEX

public static final short HEX
The HEX constant describes the string format for hex digit value (e.g. 0123456789ABCDEF).

See Also:
Constant Field Values

BITS

public static final short BITS
The BITS constant describes the string format for binary digit value (e.g. only 0 and 1 digits).

See Also:
Constant Field Values

ASN1VALUE

public static final short ASN1VALUE
The ASN1VALUE constant describes the string format for hex or binary digit value. The binary string value will end with letter 'B' and hex string value will end with letter 'H' (e.g. '0101'B or '11'H ). If the number of bits is less than or equal to 16, than it will be printed as Binary String, else as Hex String.

See Also:
Constant Field Values

HEXBIN

public static final short HEXBIN
The HEXBIN constant describes the string format for hex or binary digit value (e.g. 0xAA 10xxxxxx).

See Also:
Constant Field Values

mStringFormat

public static short mStringFormat
The mStringFormat variable can be used to set the string format for print or event handler or toString() functions. The possible options are: HEX, BITS, ASN1VALUE, HEXBIN HEXBIN is the default format.


numbits

public transient int numbits
This variable contains the number of bits in the bit string value.


value

public transient byte[] value
This variable holds the bit string value. These are the bits that are encoded when encode is invoked. It is also where the decoded bit string is stored after a decode operation.


trimZeroBits

public boolean trimZeroBits
This variable describes whether trailing zero bits should be truncated. This is required when encoding a named bit string using CER or DER. By default, no trimming is done.

Constructor Detail

Asn1BitString

public Asn1BitString()
This constructor creates an empty bit string that can be used in a decode method call to receive a bit string value.


Asn1BitString

public Asn1BitString(int numbits_,
                     byte[] data)
This constructor initializes a bit string with the given number of bits and data.

Parameters:
numbits_ - Number of bits
data - Binary bit string contents

Asn1BitString

public Asn1BitString(byte[] data)
This constructor initializes a bit string with the given bytes, using all 8 bits of every byte.

Parameters:
data - Binary bit string contents

Asn1BitString

public Asn1BitString(boolean[] bitValues)
This constructor initializes a bit string from the given boolean array. Each array position corresponds to a bit in the bit string.

Parameters:
bitValues - The boolean array

Asn1BitString

public Asn1BitString(java.lang.String value_)
              throws Asn1ValueParseException
This constructor parses the given ASN.1 value text (either a binary or hex data string) and assigns the values to the internal bit string. Examples of valid value formats are as follows: Binary string: '11010010111001'B Hex string: '0fa56920014abc'H

Parameters:
value_ - The ASN.1 value specification text
Throws:
Asn1ValueParseException

Asn1BitString

public Asn1BitString(java.util.BitSet bitSet)
This constructor initializes a bit string from the given BitSet object.

Parameters:
bitSet - Java BitSet object
Method Detail

getAsn1TypeName

public java.lang.String getAsn1TypeName()
This method gets the ASN.1 type name.

Overrides:
getAsn1TypeName in class Asn1Type

clear

public void clear(int bitno)
This method clears the given bit in the bit string.

Parameters:
bitno - Number of bit to clear. Bit numbers start at zero and with the MSB of the first byte and progress from left to right.

decode

public void decode(Asn1BerDecodeBuffer buffer,
                   boolean explicit,
                   int implicitLength)
            throws Asn1Exception,
                   java.io.IOException
This method decodes an ASN.1 bit string value using the BER or DER encoding rules. The UNIVERSAL tag value and length are decoded if explicit tagging is specified.

Specified by:
decode in interface Asn1TypeIF
Overrides:
decode in class Asn1Type
Parameters:
buffer - Decode message buffer object
explicit - Flag indicating element is explicitly tagged
implicitLength - Length of contents if implicit
Throws:
Asn1Exception
java.io.IOException

encode

public int encode(Asn1BerEncodeBuffer buffer,
                  boolean explicit)
           throws Asn1Exception
This method encodes an ASN.1 bit string value using the BER or DER encoding rules. The UNIVERSAL tag value and length are encoded if explicit tagging is specified.

Specified by:
encode in interface Asn1TypeIF
Overrides:
encode in class Asn1Type
Parameters:
buffer - Encode message buffer object
explicit - Flag indicating explicit tagging should be done
Returns:
Length of component or negative status value
Throws:
Asn1Exception

decode

public void decode(Asn1PerDecodeBuffer buffer)
            throws Asn1Exception,
                   java.io.IOException
This method decodes an ASN.1 bit string value using the packed encoding rules (PER). The string is assumed to not contain a size constraint.

Specified by:
decode in interface Asn1TypeIF
Overrides:
decode in class Asn1Type
Parameters:
buffer - Decode message buffer object
Throws:
Asn1Exception
java.io.IOException

decode

public void decode(Asn1PerDecodeBuffer buffer,
                   long lower,
                   long upper)
            throws Asn1Exception,
                   java.io.IOException
This method decodes a sized ASN.1 bit string value using the packed encoding rules (PER).

Parameters:
buffer - Decode message buffer object
lower - Lower bound (inclusive) of size constraint
upper - Upper bound (inclusive) of size constraint
Throws:
Asn1Exception
java.io.IOException

decode

public void decode(Asn1PerDecodeBuffer buffer,
                   long lower,
                   java.lang.Object upper)
            throws Asn1Exception,
                   java.io.IOException
This method decodes a sized ASN.1 bit string value using the packed encoding rules (PER). This method is invoked when the MAX keyword is used as a boundary.

Parameters:
buffer - Decode message buffer object
lower - Lower bound (inclusive) of size constraint
upper - Upper bound (inclusive) of size constraint
Throws:
Asn1Exception
java.io.IOException

decode

public void decode(Asn1PerDecodeBuffer buffer,
                   java.lang.Object lower,
                   long upper)
            throws Asn1Exception,
                   java.io.IOException
This method decodes a sized ASN.1 bit string value using the packed encoding rules (PER). This method is invoked when the MIN keyword is used as a boundary.

Parameters:
buffer - Decode message buffer object
lower - Lower bound (inclusive) of size constraint
upper - Upper bound (inclusive) of size constraint
Throws:
Asn1Exception
java.io.IOException

decode

public void decode(Asn1PerDecodeBuffer buffer,
                   java.lang.Object lower,
                   java.lang.Object upper)
            throws Asn1Exception,
                   java.io.IOException
This method decodes a sized ASN.1 bit string value using the packed encoding rules (PER). This method is invoked when the MIN and MAX keywords are used as a boundary.

Parameters:
buffer - Decode message buffer object
lower - Lower bound (inclusive) of size constraint
upper - Upper bound (inclusive) of size constraint
Throws:
Asn1Exception
java.io.IOException

encode

public void encode(Asn1PerEncodeBuffer buffer)
            throws Asn1Exception,
                   java.io.IOException
This method encodes an unconstrained ASN.1 bit string value using the packed encoding rules (PER). The value to be encoded is stored in the 'numbits' and 'value' public member variables within this class.

Specified by:
encode in interface Asn1TypeIF
Overrides:
encode in class Asn1Type
Parameters:
buffer - Encode message buffer object
Throws:
Asn1Exception
java.io.IOException

encode

public void encode(Asn1PerEncodeBuffer buffer,
                   long lower,
                   long upper)
            throws Asn1Exception,
                   java.io.IOException
This method encodes a size-constrained ASN.1 bit string value using the packed encoding rules (PER). The value to be encoded is stored in the 'numbits' and 'value' public member variables within this class.

Parameters:
buffer - Encode message buffer object
lower - Lower bound (inclusive) of size constraint
upper - Upper bound (inclusive) of size constraint
Throws:
Asn1Exception
java.io.IOException

encode

public void encode(Asn1PerEncodeBuffer buffer,
                   long lower,
                   java.lang.Object upper)
            throws Asn1Exception,
                   java.io.IOException
This method encodes a size-constrained ASN.1 bit string value using the packed encoding rules (PER). The value to be encoded is stored in the 'numbits' and 'value' public member variables within this class. This method is called when the MAX keyword is used in code generation.

Parameters:
buffer - Encode message buffer object
lower - Lower bound (inclusive) of size constraint
upper - Upper bound (inclusive) of size constraint
Throws:
Asn1Exception
java.io.IOException

encode

public void encode(Asn1PerEncodeBuffer buffer,
                   java.lang.Object lower,
                   long upper)
            throws Asn1Exception,
                   java.io.IOException
This method encodes a size-constrained ASN.1 bit string value using the packed encoding rules (PER). The value to be encoded is stored in the 'numbits' and 'value' public member variables within this class. This method is called when the MIN keyword is used in code generation.

Parameters:
buffer - Encode message buffer object
lower - Lower bound (inclusive) of size constraint
upper - Upper bound (inclusive) of size constraint
Throws:
Asn1Exception
java.io.IOException

encode

public void encode(Asn1PerEncodeBuffer buffer,
                   java.lang.Object lower,
                   java.lang.Object upper)
            throws Asn1Exception,
                   java.io.IOException
This method encodes a size-constrained ASN.1 bit string value using the packed encoding rules (PER). The value to be encoded is stored in the 'numbits' and 'value' public member variables within this class. This method is called when both the MIN and MAX keywords are used in code generation.

Parameters:
buffer - Encode message buffer object
lower - Lower bound (inclusive) of size constraint
upper - Upper bound (inclusive) of size constraint
Throws:
Asn1Exception
java.io.IOException

decode

public void decode(Asn1MderDecodeBuffer buffer,
                   int length)
            throws Asn1Exception,
                   java.io.IOException
Decode a BIT STRING from the MDER encoding into this object. Exactly the given length of bits will be decoded.

Parameters:
length - This should be 8, 16, or 32, as these are the only lengths MDER supports. However, this is not checked here as it should be able to be checked at code generation time.
Throws:
Asn1Exception
java.io.IOException

encode

public void encode(Asn1XerEncoder buffer,
                   java.lang.String elemName)
            throws java.io.IOException,
                   Asn1Exception
This method encodes ASN.1 bit string type using the XML encoding rules (XER).

Specified by:
encode in interface Asn1TypeIF
Overrides:
encode in class Asn1Type
Parameters:
buffer - Encode message buffer object
elemName - XML element name used to wrap string
Throws:
java.io.IOException - Any exception thrown by the underlying stream.
Asn1Exception - Thrown, if operation is failed.

decodeXER

public void decodeXER(java.lang.String buffer,
                      java.lang.String attrs)
               throws Asn1Exception
This method decodes ASN.1 8-bit character string types including IA5String, PrintableString, NumericString, etc. using the XML encoding rules (XER).

Parameters:
buffer - String containing data to be decoded
attrs - Attributes string from element tag
Throws:
Asn1Exception

encode

public void encode(Asn1XmlEncoder buffer,
                   java.lang.String elemName,
                   java.lang.String nsPrefix,
                   java.lang.String[] namedbits,
                   int[] namedbitindex)
            throws java.io.IOException,
                   Asn1Exception
This method encodes ASN.1 bit string type using the XML Encoding as specified in the XML schema standard.

Parameters:
buffer - Encode message buffer object
elemName - XML element name used to wrap string
nsPrefix - XML element name space prefix
namedbits - Array of named bits
namedbitindex - Arrat of named bits index values
Throws:
java.io.IOException
Asn1Exception

encode

public void encode(Asn1XmlEncoder buffer,
                   java.lang.String elemName,
                   java.lang.String nsPrefix)
            throws java.io.IOException,
                   Asn1Exception
This method encodes ASN.1 bit string type using the XML Encoding as specified in the XML schema standard.

Parameters:
buffer - Encode message buffer object
elemName - XML element name used to wrap string
nsPrefix - XML element namespace prefix
Throws:
java.io.IOException
Asn1Exception

decodeXML

public void decodeXML(java.lang.String buffer,
                      java.lang.String attrs)
               throws Asn1Exception
This method decodes an ASN.1 BIT STRING using the XML schema encoding rules.

Specified by:
decodeXML in interface Asn1TypeIF
Overrides:
decodeXML in class Asn1Type
Parameters:
buffer - String containing data to be decoded
attrs - Attributes string from element tag
Throws:
Asn1Exception

isNamedBitStr

public boolean isNamedBitStr(java.lang.String buffer)
This method determines is the input character string represented as named bit string or as bits sequence. It is used for XML decoding.

Parameters:
buffer - Bit string as string to be tested.
Returns:
true, if bit string is represented as sequnece of identifiers.

decode

public void decode(Asn1JsonDecodeBuffer buffer)
            throws java.io.IOException
Decode ASN.1 bit string from JSON.

Parameters:
buffer -
Throws:
java.io.IOException

encode

public void encode(Asn1JsonOutputStream outstream)
            throws java.io.IOException
Encode this bit string to JSON.

Parameters:
outstream -
Throws:
java.io.IOException

equals

public boolean equals(int nbits,
                      byte[] value)
This method compares this bit string value to the given value for equality. This method assumes all unused bits in the last byte are set to zero.

Parameters:
nbits - Number of bits
value - Byte array containing bit data

equals

public boolean equals(java.lang.Object bs_)
This method compares this bit string value to the given value for equality. This method assumes all unused bits in the last byte are set to zero.

Overrides:
equals in class java.lang.Object
Parameters:
bs_ - Bit string object to compare for equality

hashCode

public int hashCode()
This method returns the hashCode for this bit string.

Overrides:
hashCode in class Asn1Type

getLength

public int getLength()
              throws Asn1InvalidLengthException
This method will return the length of the BIT STRING in bits.

Overrides:
getLength in class Asn1Type
Returns:
Number of bits.
Throws:
Asn1InvalidLengthException

isSet

public boolean isSet(int bitno)
This method tests if the given bit in the bit string is set or not.

Parameters:
bitno - Number of bit to set. Bit numbers start at zero and with the MSB of the first byte and progress from left to right.
Returns:
Bit value (true or false)

toBoolArray

public boolean[] toBoolArray()
This method converts the bit string stored in this object to a boolean array.

Returns:
Boolean array value

set

public void set(int bitno,
                boolean bvalue)
This method will set the given bit number to the given boolean value. It will expand the existing bit array if it needs to.

Parameters:
bitno - Number of bit to set. Bit numbers start at zero and with the MSB of the first byte and progress from left to right.
bvalue - Bit value (true or false)

set

public void set(int bitno)
This method will set the given bit number to one (1). It will expand the existing bit array if it needs to.

Parameters:
bitno - Number of bit to set. Bit numbers start at zero and with the MSB of the first byte and progress from left to right.

toInputStream

public java.io.InputStream toInputStream()
This method will return a byte array input stream representation of the bit string value.

Returns:
Reference to input stream object

toHexString

public java.lang.String toHexString()
This method will return a hex string representation of the bit string value. The output format is a string of hex bytes with no extra delimiting characters (ex. 0D56EF).

Returns:
Stringified representation of the value

toString

public java.lang.String toString()
This method will return a string representation of the BIT STRING value. The output format is a string of hex digits/binary digits according to the value set for mStringFormat variable.

Overrides:
toString in class java.lang.Object
Returns:
Stringified representation of the value

encode

public void encode(Asn1BerOutputStream out,
                   boolean explicit)
            throws Asn1Exception,
                   java.io.IOException
This method encodes and writes to the stream an ASN.1 bit string value including the UNIVERSAL tag value and length if explicit tagging is specified. This overloaded version uses the Basic Encoding Rules (BER).

Specified by:
encode in interface Asn1TypeIF
Overrides:
encode in class Asn1Type
Parameters:
out - BER Output Stream object
explicit - Flag indicating explicit tagging should be done
Throws:
IOException - Any exception thrown by the underlying OutputStream.
Asn1Exception - Thrown, if operation is failed.

encode

public void encode(Asn1PerOutputStream out)
            throws Asn1Exception,
                   java.io.IOException
This method encodes an unconstrained ASN.1 bit string value using the packed encoding rules (PER)into the stream. The value to be encoded is stored in the 'numbits' and 'value' public member variables within this class.

Specified by:
encode in interface Asn1TypeIF
Overrides:
encode in class Asn1Type
Parameters:
out - PER Output Stream object
Throws:
IOException - Any exception thrown by the Asn1PerOutputStream.
Asn1Exception - Thrown, if operation is failed.

encode

public void encode(Asn1PerOutputStream out,
                   long lower,
                   long upper)
            throws Asn1Exception,
                   java.io.IOException
This method encodes a size-constrained ASN.1 bit string value using the packed encoding rules (PER) into the stream. The value to be encoded is stored in the 'numbits' and 'value' public member variables within this class.

Parameters:
out - PER Output Stream object
lower - Lower bound (inclusive) of size constraint
upper - Upper bound (inclusive) of size constraint
Throws:
IOException - Any exception thrown by the Asn1PerOutputStream.
Asn1Exception - Thrown, if operation is failed.

encode

public void encode(Asn1MderOutputStream out,
                   int length)
            throws Asn1Exception,
                   java.io.IOException
Encode this BIT STRING into the MDER encoding. The length of this BIT STRING must match the given length.

Parameters:
length - This should be 8, 16, or 32, as these are the only lengths MDER supports. However, this is not checked here as it should be able to be checked at code generation time. We only check here that the actual and given lengths match.
Throws:
Asn1Exception
java.io.IOException