Package org.forgerock.opendj.io
Class AbstractAsn1Reader
- java.lang.Object
-
- org.forgerock.opendj.io.AbstractAsn1Reader
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Asn1Reader
public abstract class AbstractAsn1Reader extends Object implements Asn1Reader
An abstractASN1Reader
which can be used as the basis for implementing new ASN1 reader implementations.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractAsn1Reader()
Creates a new abstract ASN.1 reader.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ByteString
readAsn1Element()
Reads the next element and returns its full encoding, which includes tag and length bytes.ByteStringBuilder
readAsn1Element(ByteStringBuilder destination)
Reads the next element and appends its full encoding, which includes tag and length bytes, to the providedByteStringBuilder
.BigInteger
readBigInteger()
Reads the next element as aBigInteger
having the Universal Integer ASN.1 type tag.BigInteger
readBigInteger(byte type)
Reads the next element as aBigInteger
having the provided type tag.boolean
readBoolean(byte type)
Reads the next element as a boolean having the provided type tag.int
readEnumerated(byte type)
Reads the next element as an enumerated having the provided type tag.long
readInteger(byte type)
Reads the next element as an integer having the provided type tag.void
readNull(byte type)
Reads the next element as a null element having the provided type tag.ByteString
readOctetString(byte type)
Reads the next element as an octet string having the provided type tag.ByteStringBuilder
readOctetString(byte type, ByteStringBuilder builder)
Reads the next element as an octet string having the provided type tag and appends it to the providedByteStringBuilder
.String
readOctetStringAsString(byte type)
Reads the next element as an octet string having the provided type tag and decodes the value as a UTF-8 encoded string.void
readStartExplicitTag(byte type)
Reads the next element as an explicit tag having the provided tag type.void
readStartSequence(byte type)
Reads the next element as a sequence having the provided type tag.void
readStartSet(byte type)
Reads the next element as a set having the provided type tag.Asn1Reader
skipElement(byte expectedType)
Skips the next element having the provided type tag without decoding it.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.forgerock.opendj.io.Asn1Reader
close, elementAvailable, hasNextElement, peekLength, peekType, readBoolean, readEndExplicitTag, readEndSequence, readEndSet, readEnumerated, readInteger, readNull, readOctetString, readOctetString, readOctetStringAsString, readStartExplicitTag, readStartSequence, readStartSet, skipElement
-
-
-
-
Method Detail
-
readBoolean
public boolean readBoolean(byte type) throws IOException
Description copied from interface:Asn1Reader
Reads the next element as a boolean having the provided type tag.- Specified by:
readBoolean
in interfaceAsn1Reader
- Parameters:
type
- The expected type tag of the element.- Returns:
- The decoded boolean value.
- Throws:
DecodeException
- If the element cannot be decoded as a boolean.IOException
- If an unexpected IO error occurred.
-
readEnumerated
public int readEnumerated(byte type) throws IOException
Description copied from interface:Asn1Reader
Reads the next element as an enumerated having the provided type tag.- Specified by:
readEnumerated
in interfaceAsn1Reader
- Parameters:
type
- The expected type tag of the element.- Returns:
- The decoded enumerated value.
- Throws:
DecodeException
- If the element cannot be decoded as an enumerated value.IOException
- If an unexpected IO error occurred.
-
readInteger
public long readInteger(byte type) throws IOException
Description copied from interface:Asn1Reader
Reads the next element as an integer having the provided type tag.- Specified by:
readInteger
in interfaceAsn1Reader
- Parameters:
type
- The expected type tag of the element.- Returns:
- The decoded integer value.
- Throws:
DecodeException
- If the element cannot be decoded as an integer.IOException
- If an unexpected IO error occurred.
-
readBigInteger
public BigInteger readBigInteger() throws IOException
Description copied from interface:Asn1Reader
Reads the next element as aBigInteger
having the Universal Integer ASN.1 type tag.- Specified by:
readBigInteger
in interfaceAsn1Reader
- Returns:
- The decoded
BigInteger
value. - Throws:
DecodeException
- If the element cannot be decoded as aBigInteger
.IOException
- If an unexpected IO error occurred.
-
readBigInteger
public BigInteger readBigInteger(byte type) throws IOException
Description copied from interface:Asn1Reader
Reads the next element as aBigInteger
having the provided type tag.- Specified by:
readBigInteger
in interfaceAsn1Reader
- Parameters:
type
- The expected type tag of the element.- Returns:
- The decoded
BigInteger
value. - Throws:
DecodeException
- If the element cannot be decoded as aBigInteger
.IOException
- If an unexpected IO error occurred.
-
readNull
public void readNull(byte type) throws IOException
Description copied from interface:Asn1Reader
Reads the next element as a null element having the provided type tag.- Specified by:
readNull
in interfaceAsn1Reader
- Parameters:
type
- The expected type tag of the element.- Throws:
DecodeException
- If the element cannot be decoded as a null element.IOException
- If an unexpected IO error occurred.
-
readOctetString
public ByteString readOctetString(byte type) throws IOException
Description copied from interface:Asn1Reader
Reads the next element as an octet string having the provided type tag.- Specified by:
readOctetString
in interfaceAsn1Reader
- Parameters:
type
- The expected type tag of the element.- Returns:
- The decoded octet string represented using a
ByteString
. - Throws:
DecodeException
- If the element cannot be decoded as an octet string.IOException
- If an unexpected IO error occurred.
-
readOctetString
public ByteStringBuilder readOctetString(byte type, ByteStringBuilder builder) throws IOException
Description copied from interface:Asn1Reader
Reads the next element as an octet string having the provided type tag and appends it to the providedByteStringBuilder
.- Specified by:
readOctetString
in interfaceAsn1Reader
- Parameters:
type
- The expected type tag of the element.builder
- TheByteStringBuilder
to append the octet string to.- Returns:
- A reference to
builder
. - Throws:
DecodeException
- If the element cannot be decoded as an octet string.IOException
- If an unexpected IO error occurred.
-
readOctetStringAsString
public String readOctetStringAsString(byte type) throws IOException
Description copied from interface:Asn1Reader
Reads the next element as an octet string having the provided type tag and decodes the value as a UTF-8 encoded string.- Specified by:
readOctetStringAsString
in interfaceAsn1Reader
- Parameters:
type
- The expected type tag of the element.- Returns:
- The decoded octet string as a UTF-8 encoded string.
- Throws:
DecodeException
- If the element cannot be decoded as an octet string.IOException
- If an unexpected IO error occurred.
-
readAsn1Element
public ByteString readAsn1Element() throws IOException
Description copied from interface:Asn1Reader
Reads the next element and returns its full encoding, which includes tag and length bytes.- Specified by:
readAsn1Element
in interfaceAsn1Reader
- Returns:
- The full encoding of the next element.
- Throws:
IOException
- If an unexpected IO error occurred.
-
readAsn1Element
public ByteStringBuilder readAsn1Element(ByteStringBuilder destination) throws IOException
Description copied from interface:Asn1Reader
Reads the next element and appends its full encoding, which includes tag and length bytes, to the providedByteStringBuilder
.- Specified by:
readAsn1Element
in interfaceAsn1Reader
- Parameters:
destination
- TheByteStringBuilder
to append the ASN.1 element to.- Returns:
- A reference to
builder
. - Throws:
IOException
- If an unexpected IO error occurred.
-
readStartExplicitTag
public void readStartExplicitTag(byte type) throws IOException
Description copied from interface:Asn1Reader
Reads the next element as an explicit tag having the provided tag type. All further reads will read the elements in the explicit tag untilAsn1Reader.readEndExplicitTag()
is called.- Specified by:
readStartExplicitTag
in interfaceAsn1Reader
- Parameters:
type
- The expected type tag of the element.- Throws:
DecodeException
- If the element cannot be decoded as an explicit tag.IOException
- If an unexpected IO error occurred.
-
readStartSequence
public void readStartSequence(byte type) throws IOException
Description copied from interface:Asn1Reader
Reads the next element as a sequence having the provided type tag. All further reads will read the elements in the sequence untilAsn1Reader.readEndSequence()
is called.- Specified by:
readStartSequence
in interfaceAsn1Reader
- Parameters:
type
- The expected type tag of the element.- Throws:
DecodeException
- If the element cannot be decoded as a sequence.IOException
- If an unexpected IO error occurred.
-
readStartSet
public void readStartSet(byte type) throws IOException
Description copied from interface:Asn1Reader
Reads the next element as a set having the provided type tag. All further reads will read the elements in the set untilAsn1Reader.readEndSet()
is called.- Specified by:
readStartSet
in interfaceAsn1Reader
- Parameters:
type
- The expected type tag of the element.- Throws:
DecodeException
- If the element cannot be decoded as a set.IOException
- If an unexpected IO error occurred.
-
skipElement
public Asn1Reader skipElement(byte expectedType) throws IOException
Description copied from interface:Asn1Reader
Skips the next element having the provided type tag without decoding it.- Specified by:
skipElement
in interfaceAsn1Reader
- Parameters:
expectedType
- The expected type tag of the element.- Returns:
- A reference to this ASN.1 reader.
- Throws:
DecodeException
- If the next element does not have the provided type tag.IOException
- If an unexpected IO error occurred.
-
-