public class Asn1BitString extends Asn1Type
Modifier and Type | Field and Description |
---|---|
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).
|
protected java.util.HashMap<java.lang.Integer,java.lang.String> |
mPositionsToNames |
short |
mStringFormat
The mStringFormat variable can be used to set the string format
for print or event handler or toString() functions.
|
static short |
NAMEDBITS
The NAMEDBITS constant describes the string format as a list of
bit position names (where applicable) followed by 1 or 0 in
parentheses.
|
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.
|
BIT_STRING, BMPString, BOOLEAN, DATE, DATE_TIME, DURATION, ENUMERATED, EOC, EXTERNAL, GeneralString, GeneralTime, GraphicString, IA5String, INTEGER, mNonParameterizedTypeName, 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 and Description |
---|
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.
|
Modifier and Type | Method and Description |
---|---|
protected void |
baseDecode(Asn1PerDecodeBuffer buffer)
This method decodes an ASN.1 bit string value using the packed
encoding rules (PER).
|
protected void |
baseDecode(Asn1PerDecodeBuffer buffer,
long lower,
long upper)
This method decodes a sized ASN.1 bit string value using the
packed encoding rules (PER).
|
protected void |
baseEncode(Asn1PerEncodeBuffer buffer,
long minEncLen)
This method encodes the bit string as an unconstrained ASN.1 bit string
value using the packed encoding rules (PER).
|
protected void |
baseEncode(Asn1PerEncodeBuffer buffer,
long lower,
long upper)
This method encodes a size-constrained ASN.1 bit string value
using the packed encoding rules (PER).
|
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(Asn1NasDecodeBuffer buffer,
int numbits)
Decode the given number of bits from the buffer.
|
void |
decode(Asn1OerDecodeBuffer buffer)
This method decodes an ASN.1 BIT STRING that was encoded
according to OER.
|
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 |
decodeContent(Asn1OerDecodeBuffer buffer,
int numOctets,
int unusedBits)
This method decodes an ASN.1 BIT STRING's content that was encoded
according to OER, given the total number of octets and the number of
unused bits in the last octet.
|
void |
decodeRemainingBits(Asn1NasDecodeBuffer buffer)
Decode all remaining bits in the current container from the buffer.
|
void |
decodeString(Asn1JsonDecodeBuffer buffer,
int numbits)
Decode ASN.1 BIT STRING from JSON.
|
void |
decodeV72(Asn1JsonDecodeBuffer buffer)
Decode ASN.1 bit string from JSON.
|
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 ASN.1 BIT STRING to JSON.
|
void |
encode(Asn1MderOutputStream out,
int length)
Encode this BIT STRING into the MDER encoding.
|
void |
encode(Asn1OerEncodeBuffer buffer)
This method encodes this ASN.1 BIT STRING value, according
to OER.
|
void |
encode(Asn1PerEncodeBuffer buffer)
This method encodes this bit string using the packed encoding rules (PER).
|
void |
encode(Asn1PerEncodeBuffer buffer,
long lower,
long upper) |
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.
|
void |
encodeAsString(Asn1JsonOutputStream outstream)
Encode ASN.1 BIT STRING to JSON.
|
void |
encodeContent(Asn1OerEncodeBuffer buffer)
This method encodes the content of an ASN.1 bit string value, according
to OER.
|
void |
encodeV72(Asn1JsonOutputStream outstream)
Encode this bit string to JSON.
|
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.
|
protected int |
getOerEffectiveMin()
Return the lower bound for the OER effective size constraint.
|
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.
|
static void |
skip(Asn1PerDecodeBuffer buffer)
This method skips an ASN.1 BIT STRING value using the packed
encoding rules (PER).
|
static void |
skip(Asn1PerDecodeBuffer buffer,
long lower,
long upper)
This method skips a sized ASN.1 bit string value using the
packed encoding rules (PER).
|
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.
|
protected int |
trim(int minLength)
This method will trim trailing zero bits from this BIT STRING.
|
_setKey, _setLicLocation, clone, decode, decode, decode, decode, decode, decode, decode, decode, decode, decode, encode, encode, encode, encode, encode, encodeAsOpenType, equals, getNonParameterizedTypeName, getTypeName, indent, indent, isOpenType, matchTag, matchTag, pdiag, print, print, print, setNonParameterizedTypeName, setOpenType
public static final Asn1Tag TAG
protected java.util.HashMap<java.lang.Integer,java.lang.String> mPositionsToNames
public static final short HEX
public static final short BITS
public static final short ASN1VALUE
public static final short HEXBIN
public static final short NAMEDBITS
public short mStringFormat
public transient int numbits
public transient byte[] value
public boolean trimZeroBits
public Asn1BitString()
public Asn1BitString(int numbits_, byte[] data)
numbits_
- Number of bitsdata
- Binary bit string contentspublic Asn1BitString(byte[] data)
data
- Binary bit string contentspublic Asn1BitString(boolean[] bitValues)
bitValues
- The boolean arraypublic Asn1BitString(java.lang.String value_) throws Asn1ValueParseException
value_
- The ASN.1 value specification textAsn1ValueParseException
public Asn1BitString(java.util.BitSet bitSet)
bitSet
- Java BitSet objectpublic java.lang.String getAsn1TypeName()
getAsn1TypeName
in class Asn1Type
public void clear(int bitno)
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.public void decode(Asn1BerDecodeBuffer buffer, boolean explicit, int implicitLength) throws Asn1Exception, java.io.IOException
decode
in interface Asn1TypeIF
decode
in class Asn1Type
buffer
- Decode message buffer objectexplicit
- Flag indicating element is explicitly taggedimplicitLength
- Length of contents if implicitAsn1Exception
java.io.IOException
public int encode(Asn1BerEncodeBuffer buffer, boolean explicit) throws Asn1Exception
encode
in interface Asn1TypeIF
encode
in class Asn1Type
buffer
- Encode message buffer objectexplicit
- Flag indicating explicit tagging should be doneAsn1Exception
protected final void baseDecode(Asn1PerDecodeBuffer buffer) throws Asn1Exception, java.io.IOException
buffer
- Decode message buffer objectAsn1Exception
java.io.IOException
public void decode(Asn1PerDecodeBuffer buffer) throws Asn1Exception, java.io.IOException
decode
in interface Asn1TypeIF
decode
in class Asn1Type
buffer
- Decode message buffer objectAsn1Exception
java.io.IOException
protected final void baseDecode(Asn1PerDecodeBuffer buffer, long lower, long upper) throws Asn1Exception, java.io.IOException
buffer
- Decode message buffer objectlower
- Lower bound (inclusive) of size constraintupper
- Upper bound (inclusive) of size constraintjava.io.IOException
Asn1Exception
public void decode(Asn1PerDecodeBuffer buffer, long lower, long upper) throws Asn1Exception, java.io.IOException
buffer
- Decode message buffer objectlower
- Lower bound (inclusive) of size constraintupper
- Upper bound (inclusive) of size constraintjava.io.IOException
Asn1Exception
public void decode(Asn1PerDecodeBuffer buffer, long lower, java.lang.Object upper) throws Asn1Exception, java.io.IOException
buffer
- Decode message buffer objectlower
- Lower bound (inclusive) of size constraintupper
- Upper bound (inclusive) of size constraintjava.io.IOException
Asn1Exception
public void decode(Asn1PerDecodeBuffer buffer, java.lang.Object lower, long upper) throws Asn1Exception, java.io.IOException
buffer
- Decode message buffer objectlower
- Lower bound (inclusive) of size constraintupper
- Upper bound (inclusive) of size constraintjava.io.IOException
Asn1Exception
public void decode(Asn1PerDecodeBuffer buffer, java.lang.Object lower, java.lang.Object upper) throws Asn1Exception, java.io.IOException
buffer
- Decode message buffer objectlower
- Lower bound (inclusive) of size constraintupper
- Upper bound (inclusive) of size constraintjava.io.IOException
Asn1Exception
public static void skip(Asn1PerDecodeBuffer buffer) throws Asn1Exception, java.io.IOException
buffer
- Decode message buffer objectAsn1Exception
java.io.IOException
public static void skip(Asn1PerDecodeBuffer buffer, long lower, long upper) throws Asn1Exception, java.io.IOException
buffer
- Decode message buffer objectlower
- Lower bound (inclusive) of size constraintupper
- Upper bound (inclusive) of size constraintjava.io.IOException
Asn1Exception
protected final void baseEncode(Asn1PerEncodeBuffer buffer, long minEncLen) throws Asn1Exception, java.io.IOException
buffer
- Encode message buffer objectminEncLen
- Minimum number of bits to encode. Trailing zero bits
are added, if necessary. Pass 0 if no trailing zero
bits should ever be added.Asn1Exception
java.io.IOException
public void encode(Asn1PerEncodeBuffer buffer) throws Asn1Exception, java.io.IOException
encode
in interface Asn1TypeIF
encode
in class Asn1Type
buffer
- Encode message buffer objectAsn1Exception
java.io.IOException
protected final void baseEncode(Asn1PerEncodeBuffer buffer, long lower, long upper) throws Asn1Exception, java.io.IOException
buffer
- Encode message buffer objectlower
- Lower bound (inclusive) of size constraintupper
- Upper bound (inclusive) of size constraintjava.io.IOException
Asn1Exception
public void encode(Asn1PerEncodeBuffer buffer, long lower, long upper) throws Asn1Exception, java.io.IOException
Asn1Exception
java.io.IOException
public void encode(Asn1PerEncodeBuffer buffer, long lower, java.lang.Object upper) throws Asn1Exception, java.io.IOException
buffer
- Encode message buffer objectlower
- Lower bound (inclusive) of size constraintupper
- Upper bound (inclusive) of size constraintjava.io.IOException
Asn1Exception
public void encode(Asn1PerEncodeBuffer buffer, java.lang.Object lower, long upper) throws Asn1Exception, java.io.IOException
buffer
- Encode message buffer objectlower
- Lower bound (inclusive) of size constraintupper
- Upper bound (inclusive) of size constraintjava.io.IOException
Asn1Exception
public void encode(Asn1PerEncodeBuffer buffer, java.lang.Object lower, java.lang.Object upper) throws Asn1Exception, java.io.IOException
buffer
- Encode message buffer objectlower
- Lower bound (inclusive) of size constraintupper
- Upper bound (inclusive) of size constraintjava.io.IOException
Asn1Exception
public final void decode(Asn1NasDecodeBuffer buffer, int numbits) throws java.io.IOException
buffer
- numbits
- java.io.IOException
public final void decodeRemainingBits(Asn1NasDecodeBuffer buffer) throws java.io.IOException
buffer
- java.io.IOException
public void decode(Asn1MderDecodeBuffer buffer, int length) throws Asn1Exception, java.io.IOException
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.java.io.IOException
Asn1Exception
public final void decodeContent(Asn1OerDecodeBuffer buffer, int numOctets, int unusedBits) throws java.io.IOException
buffer
- Decode message buffer objectnumOctets
- Total number of octets encoding the content, including
the final, partial octet (if unusedBits > 0)unusedBits
- # of unused bits in last octet.java.io.IOException
public void decode(Asn1OerDecodeBuffer buffer) throws java.io.IOException
public final void encodeContent(Asn1OerEncodeBuffer buffer)
buffer
- Encode message buffer objectpublic void encode(Asn1OerEncodeBuffer buffer) throws java.io.IOException
protected int getOerEffectiveMin()
public void encode(Asn1XerEncoder buffer, java.lang.String elemName) throws java.io.IOException, Asn1Exception
encode
in interface Asn1TypeIF
encode
in class Asn1Type
buffer
- Encode message buffer objectelemName
- XML element name used to wrap stringjava.io.IOException
- Any exception thrown by the underlying stream.Asn1Exception
- Thrown, if operation is failed.public void decodeXER(java.lang.String buffer, java.lang.String attrs) throws Asn1Exception
buffer
- String containing data to be decodedattrs
- Attributes string from element tagAsn1Exception
public void encode(Asn1XmlEncoder buffer, java.lang.String elemName, java.lang.String nsPrefix, java.lang.String[] namedbits, int[] namedbitindex) throws java.io.IOException, Asn1Exception
buffer
- Encode message buffer objectelemName
- XML element name used to wrap stringnsPrefix
- XML element name space prefixnamedbits
- Array of named bitsnamedbitindex
- Arrat of named bits index valuesjava.io.IOException
Asn1Exception
public void encode(Asn1XmlEncoder buffer, java.lang.String elemName, java.lang.String nsPrefix) throws java.io.IOException, Asn1Exception
encode
in class Asn1Type
buffer
- Encode message buffer objectelemName
- XML element name used to wrap stringnsPrefix
- XML element namespace prefixjava.io.IOException
Asn1Exception
public void decodeXML(java.lang.String buffer, java.lang.String attrs) throws Asn1Exception
decodeXML
in interface Asn1TypeIF
decodeXML
in class Asn1Type
buffer
- String containing data to be decodedattrs
- Attributes string from element tagAsn1Exception
public boolean isNamedBitStr(java.lang.String buffer)
buffer
- Bit string as string to be tested.public void decodeV72(Asn1JsonDecodeBuffer buffer) throws java.io.IOException
buffer
- java.io.IOException
public void encodeV72(Asn1JsonOutputStream outstream) throws java.io.IOException
outstream
- The output JSON stream.java.io.IOException
public void decode(Asn1JsonDecodeBuffer buffer) throws java.io.IOException
public final void decodeString(Asn1JsonDecodeBuffer buffer, int numbits) throws java.io.IOException
buffer
- numbits
- The constrained length.java.io.IOException
public void encode(Asn1JsonOutputStream outstream) throws java.io.IOException
public final void encodeAsString(Asn1JsonOutputStream outstream) throws java.io.IOException
outstream
- The output JSON stream.java.io.IOException
public boolean equals(int nbits, byte[] value)
nbits
- Number of bitsvalue
- Byte array containing bit datapublic boolean equals(java.lang.Object bs_)
equals
in class java.lang.Object
bs_
- Bit string object to compare for equalitypublic int hashCode()
public int getLength() throws Asn1InvalidLengthException
getLength
in class Asn1Type
Asn1InvalidLengthException
public boolean isSet(int bitno)
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.public boolean[] toBoolArray()
public void set(int bitno, boolean bvalue)
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)public void set(int bitno)
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.public java.io.InputStream toInputStream()
public java.lang.String toHexString()
public java.lang.String toString()
toString
in class java.lang.Object
protected int trim(int minLength)
minLength
- The minimum length to trim down to; do not trim
the string to be shorter than this.public void encode(Asn1BerOutputStream out, boolean explicit) throws Asn1Exception, java.io.IOException
encode
in interface Asn1TypeIF
encode
in class Asn1Type
out
- BER Output Stream objectexplicit
- Flag indicating explicit tagging should be donejava.io.IOException
- Any exception thrown by the underlying OutputStream.Asn1Exception
- Thrown, if operation is failed.public void encode(Asn1PerOutputStream out) throws Asn1Exception, java.io.IOException
encode
in interface Asn1TypeIF
encode
in class Asn1Type
out
- PER Output Stream objectjava.io.IOException
- Any exception thrown by the Asn1PerOutputStream.Asn1Exception
- Thrown, if operation is failed.public void encode(Asn1PerOutputStream out, long lower, long upper) throws Asn1Exception, java.io.IOException
out
- PER Output Stream objectlower
- Lower bound (inclusive) of size constraintupper
- Upper bound (inclusive) of size constraintjava.io.IOException
- Any exception thrown by the Asn1PerOutputStream.Asn1Exception
- Thrown, if operation is failed.public void encode(Asn1MderOutputStream out, int length) throws Asn1Exception, java.io.IOException
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.Asn1Exception
java.io.IOException