pasn
Class ASN1BitString

java.lang.Object
  extended by pasn.ASN1Object
      extended by pasn.ASN1UnformedOrderedObject<ASN1BitStringValue>
          extended by pasn.ASN1BitString
All Implemented Interfaces:
ASN1ConstructedObject, ASN1DefaultValuedObject, ASN1EncodingSpecificObject, ASN1GenericObject, ASN1PrimitiveObject<ASN1BitStringValue>, ASN1PrimitiveOrConstructedObject<ASN1BitStringValue>, ASN1Resetable

public class ASN1BitString
extends ASN1UnformedOrderedObject<ASN1BitStringValue>

A BIT STRING is an ordered sequence of bit values. It may be considered as an OCTET STRING used to store any number of bits and thus having from 0 to 7 unused trailing bits.

The need for unused bits is due to the necessary encoding within octets (8-bits groups), as shown hereafter.

In this example, the BIT STRING value is set to {false, false, true, false, true, true, false, true, false}.
Encoding this BIT STRING requires one octet and an extra bit. As a consequence, two octets will be used for encoding and unusedBits value is set to 7, indicating that the latest seven bits are not part of this BIT STRING.

Significant
bits (9)
Unused
bits (7)
 
0 0 1 0 1 1 0 1 0
0 0 0 0 0 0 0
=> (8 + 1) + 7 bits

Author:
ncottin

Constructor Summary
ASN1BitString()
           
 
Method Summary
 java.lang.String getASN1Name()
           
 java.util.Collection<ASN1PrimitiveObject> getConstructedValues(int maxSize)
           
 int getDefaultValueLength()
           
 int getValueLength()
           
 boolean hasDefaultValue()
           
 boolean hasValue()
           
 boolean isValueDefault()
           
 ASN1PrimitiveOrConstructedObject newInstance()
           
 void reset()
           Removes the value (or list or set of values) of this ASN.1 object.
 void setConstructedValues(java.util.Collection<ASN1PrimitiveOrConstructedObject> values)
           
 java.lang.String toString()
           
 void validateConstraints(ASN1BitStringValue value)
           
 
Methods inherited from class pasn.ASN1UnformedOrderedObject
equals, getDefaultConstructedLength, getDefaultValue, getMaximumConstructedSize, getMaximumLength, getMinimumLength, getValue, getValueOrDefault, hasValueOrDefault, isPrimitive, setDecodedValue, setDefaultConstructedLength, setDefaultValue, setMaximumLength, setMinimumLength, setPrimitive, setValue
 
Methods inherited from class pasn.ASN1Object
getAsnClass, getSpecificEncoding, getSpecificEncoding, getType, hasSpecificEncodings, setSpecificEncoding
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface pasn.ASN1GenericObject
getAsnClass, getType
 
Methods inherited from interface pasn.ASN1EncodingSpecificObject
getSpecificEncoding, hasSpecificEncodings
 
Methods inherited from interface pasn.ASN1GenericObject
getAsnClass, getType
 
Methods inherited from interface pasn.ASN1EncodingSpecificObject
getSpecificEncoding, hasSpecificEncodings
 

Constructor Detail

ASN1BitString

public ASN1BitString()
Method Detail

getASN1Name

public final java.lang.String getASN1Name()

isValueDefault

public final boolean isValueDefault()

getConstructedValues

public final java.util.Collection<ASN1PrimitiveObject> getConstructedValues(int maxSize)
                                                                     throws ASN1ConstraintException
Throws:
ASN1ConstraintException

reset

public final void reset()
Description copied from interface: ASN1Resetable

Removes the value (or list or set of values) of this ASN.1 object. This applies to simple and structured ASN.1 objects


hasValue

public final boolean hasValue()

hasDefaultValue

public final boolean hasDefaultValue()

validateConstraints

public final void validateConstraints(ASN1BitStringValue value)
                               throws ASN1ConstraintException
Throws:
ASN1ConstraintException

getValueLength

public final int getValueLength()
Returns:
The number of octets of the current value or 0 if no value

getDefaultValueLength

public final int getDefaultValueLength()
Returns:
The number of octets of the current default value or 0 if no default value

setConstructedValues

public final void setConstructedValues(java.util.Collection<ASN1PrimitiveOrConstructedObject> values)
                                throws ASN1DecodingException,
                                       ASN1ConstraintException,
                                       java.lang.ClassCastException
Throws:
ASN1DecodingException
ASN1ConstraintException
java.lang.ClassCastException

newInstance

public final ASN1PrimitiveOrConstructedObject newInstance()

toString

public final java.lang.String toString()
Overrides:
toString in class java.lang.Object