Package com.oss.asn1
Class ContainingBitString<T extends AbstractData>
java.lang.Object
com.oss.asn1.AbstractData
com.oss.asn1.AbstractBinary
com.oss.asn1.BitString
com.oss.asn1.ContainingBitString<T>
- Type Parameters:
T
- type of contained value
- All Implemented Interfaces:
com.oss.asn1.PDUContainer<T>
,com.oss.asn1.Sizeable
,Serializable
,Cloneable
public class ContainingBitString<T extends AbstractData>
extends BitString
implements com.oss.asn1.PDUContainer<T>
The ContainingBitString class represents an ASN.1 BIT STRING that is
constrained by a ContentsConstraint. The runtime presents the value of
this type in two forms: interpreted (the unencoded contained value) or
uninterpreted (raw bits).
For this reason, the class could behave differently when compared with the
For this reason, the class could behave differently when compared with the
BitString
class:
- When the automatic decoding of contained values is enabled and the content
constraint allows automatic decoding, the coder constructs the decoded
value using the interpreted form. Hence,
getDecodedValue()
returns the contained value, whilebyteArrayValue()
returnsnull
, andgetSize()
returns zero. Otherwise, the value is constructed using the uninterpreted form, wherebyteArrayValue()
andgetSize()
return raw bits, andgetDecodedValue()
returnsnull
. - When the automatic encoding of contained values is enabled, the content constraint allows automatic encoding, and the input value is specified in the interpreted form, the coder automatically constructs the bits of the BIT STRING from the contained value and writes them to the output encoding. Otherwise, the coder requires that the uninterpreted form is available before encoding, and throws an exception if it is not.
- Since:
- ASN.1/Java 6.0
- See Also:
-
Field Summary
Fields inherited from class com.oss.asn1.AbstractData
EQUALS, GREATER_THAN, LESS_THAN
-
Constructor Summary
ConstructorsConstructorDescriptionThe default constructor creates an empty bit stringContainingBitString
(byte[] value) Construct from a byte array.ContainingBitString
(byte[] value, int sigBits) Construct from a byte array and significant bits.ContainingBitString
(T decodedValue) Construct an instance of this class with an AbstractData object that represents an unencoded value of a contained ASN.1 type. -
Method Summary
Modifier and TypeMethodDescriptionclone()
Clone 'this' object.final boolean
equalTo
(ContainingBitString that) Compare 'this' object to another ContainingBitString object to see if their contents are the same.Get the unencoded value of contained ASN.1 type.final T
Get the unencoded value of contained ASN.1 type.void
setContainedValue
(T decodedValue) Set the value to the interpreted form (the value of the contained ASN.1 type).final void
setDecodedValue
(T decodedValue) Set the value to the interpreted form (the value of the contained ASN.1 type).Methods inherited from class com.oss.asn1.BitString
clearBit, equalTo, getBit, getLastBit, getNamedBits, getSignificantBits, getSize, getTypeName, hashCode, hasNamedBits, setBit, setSignificantBits, setValue, setValue
Methods inherited from class com.oss.asn1.AbstractBinary
byteArrayValue, delete
Methods inherited from class com.oss.asn1.AbstractData
equals, isEncodable, isPDU, isValid, toString, toString
-
Constructor Details
-
ContainingBitString
public ContainingBitString()The default constructor creates an empty bit string -
ContainingBitString
public ContainingBitString(byte[] value) Construct from a byte array. The significant bits are set to value.length * 8.- Parameters:
value
- the byte array to set this object to.
-
ContainingBitString
public ContainingBitString(byte[] value, int sigBits) Construct from a byte array and significant bits.- Parameters:
value
- the byte array to set this object to.sigBits
- the number of significant bits.
-
ContainingBitString
Construct an instance of this class with an AbstractData object that represents an unencoded value of a contained ASN.1 type.- Parameters:
decodedValue
- the AbstractData object to set.
-
-
Method Details
-
getDecodedValue
Get the unencoded value of contained ASN.1 type. This will be useful when automatic decoding has been used. See the methodenableAutomaticDecoding()
in the Coder class.- Specified by:
getDecodedValue
in interfacecom.oss.asn1.PDUContainer<T extends AbstractData>
- Returns:
- reference to the AbstractData object representing the unencoded value of 'this' object.
-
setDecodedValue
Set the value to the interpreted form (the value of the contained ASN.1 type). After this method is invoked thebyteArrayValue()
method will returnnull
and thegetSize()
method will return zero.- Specified by:
setDecodedValue
in interfacecom.oss.asn1.PDUContainer<T extends AbstractData>
- Parameters:
decodedValue
- the reference to the AbstractData object to set.
-
getContainedValue
Get the unencoded value of contained ASN.1 type. This will be useful when automatic decoding has been used. See the methodenableAutomaticDecoding()
in the Coder class.- Returns:
- reference to the AbstractData object representing the unencoded value of 'this' object.
-
setContainedValue
Set the value to the interpreted form (the value of the contained ASN.1 type). After this method is invoked thebyteArrayValue()
method will returnnull
and thegetSize()
method will return zero.- Parameters:
decodedValue
- the reference to the AbstractData object to set.
-
equalTo
Compare 'this' object to another ContainingBitString object to see if their contents are the same. If ASN.1 definition of a BIT STRING has named bits then the comparison ignores trailing zero bits in the BIT STRING value.- Parameters:
that
- the BitString object to compare 'this' object to.- Returns:
- true if contents of both objects are the same.
-
clone
Clone 'this' object.
-