public class Attributes
extends java.lang.Object
Attributes
. When
encoding the attributes included in the container, they may be BER encoded
either as ASN.1 SET OF
or as
ASN.1 SEQUENCE OF
Attributes.Modifier and Type | Field and Description |
---|---|
protected java.util.Vector |
attributes_
The Attribute repository (order may be of interest).
|
Constructor and Description |
---|
Attributes()
Empty constructor.
|
Attributes(ASN1Object attributes)
Creates an Attribute container from a SET OF or SEQUENCE OF attributes.
|
Attributes(Attribute[] attributes)
Creates an Attribute container from the given list of attributes.
|
Attributes(byte[] encodedAttributes)
Creates an Attribute container from a BER encoded SET OF or SEQUENCE OF
attributes.
|
Attributes(java.io.InputStream is)
Creates an Attribute container from a BER encoded SET OF or SEQUENCE OF
attributes.
|
Modifier and Type | Method and Description |
---|---|
void |
addAttribute(Attribute attribute)
Adds the given attribute.
|
void |
addAttribute(Attribute attribute,
boolean replace)
Adds the given attribute.
|
void |
addAttributes(Attribute[] attributes)
Adds the given attributes.
|
void |
clearAll()
Clears all attributes included in the container.
|
byte[] |
encodeAsAsn1SEQUENCE(java.io.OutputStream os)
Builds and encodes an ASN.1 SEQUENCE of the attributes included in this container.
|
byte[] |
encodeAsAsn1SET()
Builds and encodes an ASN.1 SET of the attributes included in this container.
|
byte[] |
encodeAsAsn1SET(boolean sorted)
Builds and encodes an ASN.1 SET of the attributes included in this container.
|
Attribute |
getAttribute(ObjectID type)
Returns the first attribute with the given type.
|
java.util.Enumeration |
getAttributes()
Returns all attributes included in the container.
|
Attribute[] |
getAttributes(ObjectID type)
Returns all attributes with the given type.
|
void |
insertAttributeAt(Attribute attribute,
int index)
Inserts the given attribute.
|
boolean |
removeAttribute(Attribute attribute)
Removes the first representative of the given attribute.
|
Attribute |
removeAttribute(ObjectID type)
Removes the first attribute with the given type from the container
|
boolean |
removeAttributes(Attribute attribute)
Removes all representatives of the given attribute from the container.
|
Attribute[] |
removeAttributes(ObjectID type)
Removes all attributes with the given type from the container
|
int |
size()
Returns the number of attributes held by this Attributes object.
|
Attribute[] |
toArray()
Returns an array containing all the attributes included in this container.
|
SEQUENCE |
toAsn1SEQUENCE()
Returns the attributes included in this container as ASN.1 SEQUENCE.
|
SET |
toAsn1SET()
Returns the attributes included in this container as ASN.1 SET.
|
SET |
toAsn1SET(boolean sorted)
Returns the attributes included in this container as ASN.1 SET.
|
java.lang.String |
toString()
Returns a string that lists all the Attributes hold in this container.
|
void |
writeToAsn1SEQUENCE(java.io.OutputStream os)
Builds an ASN.1 SEQUENCE of the attributes included in this container and
writes it encoded to the given output stream.
|
void |
writeToAsn1SET(java.io.OutputStream os)
Builds an ASN.1 SET of the attributes included in this container and writes
it encoded to the given output stream.
|
void |
writeToAsn1SET(java.io.OutputStream os,
boolean sorted)
Builds an ASN.1 SET of the attributes included in this container and writes
it encoded to the given output stream.
|
protected java.util.Vector attributes_
public Attributes()
public Attributes(Attribute[] attributes)
attributes
- the attributes to be added to the containerpublic Attributes(ASN1Object attributes) throws CodingException
attributes
- the ASN.1 SET OF or SEQUENCE OF attributes to be parsedCodingException
- if an error occurs while parsing the attributespublic Attributes(java.io.InputStream is) throws CodingException, java.io.IOException
is
- the inputstream supplying the encoded ASN.1 SET OF or SEQUENCE OF
attributes to be parsedCodingException
- if an error occurs while parsing the attributesjava.io.IOException
public Attributes(byte[] encodedAttributes) throws CodingException
encodedAttributes
- the byte array supplying the encoded ASN.1 SET OF or SEQUENCE OF
attributes to be parsedCodingException
- if an error occurs while parsing the attributespublic void addAttribute(Attribute attribute)
attribute
- the attribute to be added.public void addAttribute(Attribute attribute, boolean replace)
attribute
- the attribute to be added.replace
- whether to replace any already existing attribute with the given
typepublic void addAttributes(Attribute[] attributes)
attributes
- the attributes to be added.public void insertAttributeAt(Attribute attribute, int index)
attribute
- the attribute to be inserted.index
- the position at which to insert the attributepublic java.util.Enumeration getAttributes()
public Attribute getAttribute(ObjectID type)
null
otherwisepublic Attribute[] getAttributes(ObjectID type)
public Attribute[] toArray()
public void clearAll()
public boolean removeAttribute(Attribute attribute)
attribute
- the attribute to be removedtrue
if the attribute has been removed,
false
if no such attribute was presentpublic Attribute removeAttribute(ObjectID type)
type
- the type of the attribute to be removednull
if no attribute
with this type was presentpublic boolean removeAttributes(Attribute attribute)
attribute
- the attribute to be removedtrue
if the attributes have been removed,
false
if no such attribute was presentpublic Attribute[] removeAttributes(ObjectID type)
type
- the type of the attributes to be removedpublic int size()
public SET toAsn1SET() throws CodingException
CodingException
- if an error occurs while building the SETpublic SET toAsn1SET(boolean sorted) throws CodingException
sorted
- whether to sort the elements of the SET when encoding itCodingException
- if an error occurs while building the SETpublic SEQUENCE toAsn1SEQUENCE() throws CodingException
CodingException
- if an error occurs while building the SEQUENCEpublic void writeToAsn1SET(java.io.OutputStream os) throws java.io.IOException
os
- the output stream to which to write the encoded SET of attributesjava.io.IOException
- if an error occurs while building/encoding the SET or writing
it to the streampublic void writeToAsn1SET(java.io.OutputStream os, boolean sorted) throws java.io.IOException
os
- the output stream to which to write the encoded SET of attributessorted
- whether to sort the elements of the SET when encoding itjava.io.IOException
- if an error occurs while building/encoding the SET or writing
it to the streampublic void writeToAsn1SEQUENCE(java.io.OutputStream os) throws java.io.IOException
os
- the output stream to which to write the encoded SEQUENCE of
attributesjava.io.IOException
- if an error occurs while building/encoding the SEQUENCE or
writing it to the streampublic byte[] encodeAsAsn1SET() throws CodingException
CodingException
- if an error occurs while building/encoding the SETpublic byte[] encodeAsAsn1SET(boolean sorted) throws CodingException
sorted
- whether to sort the elements of the SET when encoding itCodingException
- if an error occurs while building/encoding the SETpublic byte[] encodeAsAsn1SEQUENCE(java.io.OutputStream os) throws CodingException
CodingException
- if an error occurs while building/encoding the SEQUENCEpublic java.lang.String toString()
toString
in class java.lang.Object