Package org.forgerock.opendj.io
Interface Asn1Writer
-
- All Superinterfaces:
AutoCloseable
,Closeable
,Flushable
- All Known Implementing Classes:
AbstractAsn1Writer
public interface Asn1Writer extends Closeable, Flushable
An interface for encoding ASN.1 elements to a data source.Methods for creating
Asn1Writer
s are provided in theAsn1
class.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
close()
Closes this ASN.1 writer, flushing it first.void
flush()
Flushes this ASN.1 writer so that any buffered elements are written immediately to their intended destination.Asn1Writer
writeAsn1Element(byte[] asn1Element)
Writes exactly the provided bytes without encoding the data.Asn1Writer
writeAsn1Element(byte[] asn1Element, int offset, int length)
Writes exactly the provided bytes without encoding the data.Asn1Writer
writeAsn1Element(ByteSequence asn1Element)
Writes exactly the provided byte sequence without encoding the data.Asn1Writer
writeBigInteger(byte type, BigInteger value)
Writes an integer element from the providedBigInteger
using the provided type tag.Asn1Writer
writeBigInteger(BigInteger value)
Writes an integer element from the providedBigInteger
value using the Universal Integer ASN.1 type tag.Asn1Writer
writeBoolean(boolean value)
Writes a boolean element using the Universal Boolean ASN.1 type tag.Asn1Writer
writeBoolean(byte type, boolean value)
Writes a boolean element using the provided type tag.Asn1Writer
writeEndExplicitTag()
Finishes writing elements within the explicit tag.Asn1Writer
writeEndSequence()
Finishes writing a sequence element.Asn1Writer
writeEndSet()
Finishes writing a set element.Asn1Writer
writeEnumerated(byte type, int value)
Writes an enumerated element using the provided type tag.Asn1Writer
writeEnumerated(int value)
Writes an enumerated element using the Universal Enumerated ASN.1 type tag.Asn1Writer
writeInteger(byte type, int value)
Writes an integer element using the provided type tag.Asn1Writer
writeInteger(byte type, long value)
Writes an integer element using the provided type tag.Asn1Writer
writeInteger(int value)
Writes an integer element using the Universal Integer ASN.1 type tag.Asn1Writer
writeInteger(long value)
Writes an integer element using the Universal Integer ASN.1 type tag.Asn1Writer
writeNull()
Writes a null element using the Universal Null ASN.1 type tag.Asn1Writer
writeNull(byte type)
Writes a null element using the provided type tag.Asn1Writer
writeOctetString(byte[] value)
Writes an octet string element using the Universal Octet String ASN.1 type tag.Asn1Writer
writeOctetString(byte[] value, int offset, int length)
Writes an octet string element using the Universal Octet String ASN.1 type tag.Asn1Writer
writeOctetString(byte type, byte[] value)
Writes an octet string element using the provided type tag.Asn1Writer
writeOctetString(byte type, byte[] value, int offset, int length)
Writes an octet string element using the provided type tag.Asn1Writer
writeOctetString(byte type, CharSequence value)
Writes a string as a UTF-8 encoded octet string element using the provided type tag.Asn1Writer
writeOctetString(byte type, ByteSequence value)
Writes an octet string element using the provided type tag.Asn1Writer
writeOctetString(CharSequence value)
Writes a string as a UTF-8 encoded octet string element using the Universal Octet String ASN.1 type tag.Asn1Writer
writeOctetString(ByteSequence value)
Writes an octet string element using the Universal Octet String ASN.1 type tag.Asn1Writer
writeStartExplicitTag(byte type)
Writes an explicit tag element.Asn1Writer
writeStartSequence()
Writes a sequence element using the Universal Sequence ASN.1 type tag.Asn1Writer
writeStartSequence(byte type)
Writes a sequence element using the provided type tag.Asn1Writer
writeStartSet()
Writes a set element using the Universal Set ASN.1 type tag.Asn1Writer
writeStartSet(byte type)
Writes a set element using the provided type tag.
-
-
-
Method Detail
-
close
void close() throws IOException
Closes this ASN.1 writer, flushing it first. Closing a previously closed ASN.1 writer has no effect. Any unfinished sequences and/or sets will be ended.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
- If an error occurs while closing.
-
flush
void flush() throws IOException
Flushes this ASN.1 writer so that any buffered elements are written immediately to their intended destination. Then, if that destination is another byte stream, flush it. Thus oneflush()
invocation will flush all the buffers in a chain of streams.If the intended destination of this stream is an abstraction provided by the underlying operating system, for example a file, then flushing the stream guarantees only that bytes previously written to the stream are passed to the operating system for writing; it does not guarantee that they are actually written to a physical device such as a disk drive.
- Specified by:
flush
in interfaceFlushable
- Throws:
IOException
- If an error occurs while flushing.
-
writeBoolean
Asn1Writer writeBoolean(boolean value) throws IOException
Writes a boolean element using the Universal Boolean ASN.1 type tag.- Parameters:
value
- The boolean value.- Returns:
- A reference to this ASN.1 writer.
- Throws:
IOException
- If an error occurs while writing the element.
-
writeBoolean
Asn1Writer writeBoolean(byte type, boolean value) throws IOException
Writes a boolean element using the provided type tag.- Parameters:
type
- The type tag of the element.value
- The boolean value.- Returns:
- A reference to this ASN.1 writer.
- Throws:
IOException
- If an error occurs while writing the element.
-
writeEndSequence
Asn1Writer writeEndSequence() throws IOException
Finishes writing a sequence element.- Returns:
- A reference to this ASN.1 writer.
- Throws:
IOException
- If an error occurs while writing the element.IllegalStateException
- If there is no sequence being written.
-
writeEndExplicitTag
Asn1Writer writeEndExplicitTag() throws IOException
Finishes writing elements within the explicit tag.- Returns:
- A reference to this ASN.1 writer.
- Throws:
IOException
- If an error occurs while writing the element.
-
writeEndSet
Asn1Writer writeEndSet() throws IOException
Finishes writing a set element.- Returns:
- A reference to this ASN.1 writer.
- Throws:
IOException
- If an error occurs while writing the element.IllegalStateException
- If there is no set being written.
-
writeEnumerated
Asn1Writer writeEnumerated(byte type, int value) throws IOException
Writes an enumerated element using the provided type tag.- Parameters:
type
- The type tag of the element.value
- The enumerated value.- Returns:
- A reference to this ASN.1 writer.
- Throws:
IOException
- If an error occurs while writing the element.
-
writeEnumerated
Asn1Writer writeEnumerated(int value) throws IOException
Writes an enumerated element using the Universal Enumerated ASN.1 type tag.- Parameters:
value
- The enumerated value.- Returns:
- A reference to this ASN.1 writer.
- Throws:
IOException
- If an error occurs while writing the element.
-
writeInteger
Asn1Writer writeInteger(byte type, int value) throws IOException
Writes an integer element using the provided type tag.- Parameters:
type
- The type tag of the element.value
- The integer value.- Returns:
- A reference to this ASN.1 writer.
- Throws:
IOException
- If an error occurs while writing the element.
-
writeInteger
Asn1Writer writeInteger(byte type, long value) throws IOException
Writes an integer element using the provided type tag.- Parameters:
type
- The type tag of the element.value
- The integer value.- Returns:
- A reference to this ASN.1 writer.
- Throws:
IOException
- If an error occurs while writing the element.
-
writeInteger
Asn1Writer writeInteger(int value) throws IOException
Writes an integer element using the Universal Integer ASN.1 type tag.- Parameters:
value
- The integer value.- Returns:
- A reference to this ASN.1 writer.
- Throws:
IOException
- If an error occurs while writing the element.
-
writeInteger
Asn1Writer writeInteger(long value) throws IOException
Writes an integer element using the Universal Integer ASN.1 type tag.- Parameters:
value
- The integer value.- Returns:
- A reference to this ASN.1 writer.
- Throws:
IOException
- If an error occurs while writing the element.
-
writeBigInteger
Asn1Writer writeBigInteger(BigInteger value) throws IOException
Writes an integer element from the providedBigInteger
value using the Universal Integer ASN.1 type tag.- Parameters:
value
- TheBigInteger
to be written.- Returns:
- A reference to this ASN.1 writer.
- Throws:
IOException
- If an error occurs while writing the element.
-
writeBigInteger
Asn1Writer writeBigInteger(byte type, BigInteger value) throws IOException
Writes an integer element from the providedBigInteger
using the provided type tag.- Parameters:
type
- The type tag of the element.value
- TheBigInteger
to be written.- Returns:
- A reference to this ASN.1 writer.
- Throws:
IOException
- If an error occurs while writing the element.
-
writeNull
Asn1Writer writeNull() throws IOException
Writes a null element using the Universal Null ASN.1 type tag.- Returns:
- A reference to this ASN.1 writer.
- Throws:
IOException
- If an error occurs while writing the element.
-
writeNull
Asn1Writer writeNull(byte type) throws IOException
Writes a null element using the provided type tag.- Parameters:
type
- The type tag of the element.- Returns:
- A reference to this ASN.1 writer.
- Throws:
IOException
- If an error occurs while writing the element.
-
writeOctetString
Asn1Writer writeOctetString(byte type, byte[] value) throws IOException
Writes an octet string element using the provided type tag.- Parameters:
type
- The type tag of the element.value
- The byte array containing the octet string data.- Returns:
- A reference to this ASN.1 writer.
- Throws:
IOException
- If an error occurs while writing the element.
-
writeOctetString
Asn1Writer writeOctetString(byte type, byte[] value, int offset, int length) throws IOException
Writes an octet string element using the provided type tag.- Parameters:
type
- The type tag of the element.value
- The byte array containing the octet string data.offset
- The offset in the byte array.length
- The number of bytes to write.- Returns:
- A reference to this ASN.1 writer.
- Throws:
IOException
- If an error occurs while writing the element.
-
writeOctetString
Asn1Writer writeOctetString(byte type, ByteSequence value) throws IOException
Writes an octet string element using the provided type tag.- Parameters:
type
- The type tag of the element.value
- The octet string value.- Returns:
- A reference to this ASN.1 writer.
- Throws:
IOException
- If an error occurs while writing the element.
-
writeOctetString
Asn1Writer writeOctetString(byte type, CharSequence value) throws IOException
Writes a string as a UTF-8 encoded octet string element using the provided type tag.- Parameters:
type
- The type tag of the element.value
- The string to be written as a UTF-8 encoded octet string.- Returns:
- A reference to this ASN.1 writer.
- Throws:
IOException
- If an error occurs while writing the element.
-
writeOctetString
Asn1Writer writeOctetString(byte[] value) throws IOException
Writes an octet string element using the Universal Octet String ASN.1 type tag.- Parameters:
value
- The byte array containing the octet string data.- Returns:
- A reference to this ASN.1 writer.
- Throws:
IOException
- If an error occurs while writing the element.
-
writeOctetString
Asn1Writer writeOctetString(byte[] value, int offset, int length) throws IOException
Writes an octet string element using the Universal Octet String ASN.1 type tag.- Parameters:
value
- The byte array containing the octet string data.offset
- The offset in the byte array.length
- The number of bytes to write.- Returns:
- A reference to this ASN.1 writer.
- Throws:
IOException
- If an error occurs while writing the element.
-
writeOctetString
Asn1Writer writeOctetString(ByteSequence value) throws IOException
Writes an octet string element using the Universal Octet String ASN.1 type tag.- Parameters:
value
- The octet string value.- Returns:
- A reference to this ASN.1 writer.
- Throws:
IOException
- If an error occurs while writing the element.
-
writeOctetString
Asn1Writer writeOctetString(CharSequence value) throws IOException
Writes a string as a UTF-8 encoded octet string element using the Universal Octet String ASN.1 type tag.- Parameters:
value
- The string to be written as a UTF-8 encoded octet string.- Returns:
- A reference to this ASN.1 writer.
- Throws:
IOException
- If an error occurs while writing the element.
-
writeAsn1Element
Asn1Writer writeAsn1Element(byte[] asn1Element) throws IOException
Writes exactly the provided bytes without encoding the data.It is the caller responsibility to ensure the provided bytes form a valid ASN.1 element encoding.
- Parameters:
asn1Element
- The ASN.1-encoded element to be written as is.- Returns:
- A reference to this ASN.1 writer.
- Throws:
IOException
- If an error occurs while writing the element.
-
writeAsn1Element
Asn1Writer writeAsn1Element(byte[] asn1Element, int offset, int length) throws IOException
Writes exactly the provided bytes without encoding the data.It is the caller responsibility to ensure the provided bytes form a valid ASN.1 element encoding.
- Parameters:
asn1Element
- The byte array containing the ASN.1-encoded element to be written as is.offset
- The offset in the byte array.length
- The number of bytes to write.- Returns:
- A reference to this ASN.1 writer.
- Throws:
IOException
- If an error occurs while writing the element.
-
writeAsn1Element
Asn1Writer writeAsn1Element(ByteSequence asn1Element) throws IOException
Writes exactly the provided byte sequence without encoding the data.It is the caller responsibility to ensure the provided byte sequence form a valid ASN.1 element encoding.
- Parameters:
asn1Element
- The ASN.1-encoded element to be written as is.- Returns:
- A reference to this ASN.1 writer.
- Throws:
IOException
- If an error occurs while writing the element.
-
writeStartSequence
Asn1Writer writeStartSequence() throws IOException
Writes a sequence element using the Universal Sequence ASN.1 type tag. All further writes will append elements to the sequence untilwriteEndSequence()
is called.- Returns:
- A reference to this ASN.1 writer.
- Throws:
IOException
- If an error occurs while writing the element.
-
writeStartSequence
Asn1Writer writeStartSequence(byte type) throws IOException
Writes a sequence element using the provided type tag. All further writes will append elements to the sequence untilwriteEndSequence()
is called.- Parameters:
type
- The type tag of the element.- Returns:
- A reference to this ASN.1 writer.
- Throws:
IOException
- If an error occurs while writing the element.
-
writeStartExplicitTag
Asn1Writer writeStartExplicitTag(byte type) throws IOException
Writes an explicit tag element. Once the value for the tag is written, callwriteEndExplicitTag()
.- Parameters:
type
- The type tag of the element.- Returns:
- A reference to this ASN.1 writer.
- Throws:
IOException
- If an error occurs while writing the element.
-
writeStartSet
Asn1Writer writeStartSet() throws IOException
Writes a set element using the Universal Set ASN.1 type tag. All further writes will append elements to the set untilwriteEndSet()
is called.- Returns:
- A reference to this ASN.1 writer.
- Throws:
IOException
- If an error occurs while writing the element.
-
writeStartSet
Asn1Writer writeStartSet(byte type) throws IOException
Writes a set element using the provided type tag. All further writes will append elements to the set untilwriteEndSet()
is called.- Parameters:
type
- The type tag of the element.- Returns:
- A reference to this ASN.1 writer.
- Throws:
IOException
- If an error occurs while writing the element.
-
-