Package org.forgerock.opendj.io
Interface ASN1Writer
- All Superinterfaces:
AutoCloseable,Closeable,Flushable
- All Known Implementing Classes:
AbstractASN1Writer
An interface for encoding ASN.1 elements to a data source.
Methods for creating ASN1Writers are provided in the ASN1
class.
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes this ASN.1 writer, flushing it first.voidflush()Flushes this ASN.1 writer so that any buffered elements are written immediately to their intended destination.writeBoolean(boolean value) Writes a boolean element using the Universal Boolean ASN.1 type tag.writeBoolean(byte type, boolean value) Writes a boolean element using the provided type tag.Finishes writing a sequence element.Finishes writing a set element.writeEnumerated(byte type, int value) Writes an enumerated element using the provided type tag.writeEnumerated(int value) Writes an enumerated element using the Universal Enumerated ASN.1 type tag.writeInteger(byte type, int value) Writes an integer element using the provided type tag.writeInteger(byte type, long value) Writes an integer element using the provided type tag.writeInteger(int value) Writes an integer element using the Universal Integer ASN.1 type tag.writeInteger(long value) Writes an integer element using the Universal Integer ASN.1 type tag.Writes a null element using the Universal Null ASN.1 type tag.writeNull(byte type) Writes a null element using the provided type tag.writeOctetString(byte[] value) Writes an octet string element using the Universal Octet String ASN.1 type tag.writeOctetString(byte[] value, int offset, int length) Writes an octet string element using the Universal Octet String ASN.1 type tag.writeOctetString(byte type, byte[] value) Writes an octet string element using the provided type tag.writeOctetString(byte type, byte[] value, int offset, int length) Writes an octet string element using the provided type tag.writeOctetString(byte type, String value) Writes a string as a UTF-8 encoded octet string element using the provided type tag.writeOctetString(byte type, ByteSequence value) Writes an octet string element using the provided type tag.writeOctetString(String value) Writes a string as a UTF-8 encoded octet string element using the Universal Octet String ASN.1 type tag.writeOctetString(ByteSequence value) Writes an octet string element using the Universal Octet String ASN.1 type tag.Writes a sequence element using the Universal Sequence ASN.1 type tag.writeStartSequence(byte type) Writes a sequence element using the provided type tag.Writes a set element using the Universal Set ASN.1 type tag.writeStartSet(byte type) Writes a set element using the provided type tag.
-
Method Details
-
close
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:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException- If an error occurs while closing.
-
flush
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:
flushin interfaceFlushable- Throws:
IOException- If an error occurs while flushing.
-
writeBoolean
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
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
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.
-
writeEndSet
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
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
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
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
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
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
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.
-
writeNull
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
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
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
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
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
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
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
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
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
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.
-
writeStartSequence
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
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.
-
writeStartSet
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
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.
-