codec.x501
Class Attribute

java.lang.Object
  |
  +--java.util.AbstractCollection
        |
        +--java.util.AbstractList
              |
              +--java.util.ArrayList
                    |
                    +--codec.asn1.ASN1AbstractCollection
                          |
                          +--codec.asn1.ASN1Sequence
                                |
                                +--codec.x501.Attribute
All Implemented Interfaces:
ASN1Collection, ASN1RegisteredType, ASN1Type, Cloneable, Collection, Externalizable, List, Serializable

public class Attribute
extends ASN1Sequence
implements ASN1RegisteredType

This class represents an Attribute as defined in X.501 standard. The ASN.1 definition of this structure is

 Attribute ::= SEQUENCE {
   type         AttributeType,
   values       SET OF AttributeValue
 }
 AttributeType ::= ObjectIdentifier
 AttributeValue ::= ANY
 

Version:
"$Id: Attribute.java,v 1.4 2007/08/30 08:45:05 pebinger Exp $"
Author:
Volker Roth
See Also:
Serialized Form

Field Summary
protected  ASN1ObjectIdentifier type_
          The Object Identifier specifying the attribute type.
protected  ASN1Set values_
          The List of Attribute values.
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
Attribute()
          Creates an instance ready for parsing.
Attribute(ASN1ObjectIdentifier oid, ASN1Type value)
          Creates a new instance that is initialized with the given OID and value.
Attribute(ASN1RegisteredType value)
          The arguments passed to this constructor are set up directly for parsing.
Attribute(OIDRegistry registry)
          Creates an instance ready for parsing.
 
Method Summary
 void decode(Decoder dec)
          Decodes this instance.
 ASN1ObjectIdentifier getOID()
          This method returns the OID of this Attribute.
 ASN1Type valueAt(int index)
          Returns the value at the given position where position is between 0 and valueCount()-1.
 int valueCount()
          returns the number of values in this attribute.
 List valueList()
          This method returns an unmodifiable view of the list of values of this Attribute.
 
Methods inherited from class codec.asn1.ASN1Sequence
getTag
 
Methods inherited from class codec.asn1.ASN1AbstractCollection
checkConstraints, encode, getCollection, getConstraint, getTagClass, getValue, isExplicit, isOptional, isType, readExternal, setConstraint, setExplicit, setOptional, toString, writeExternal
 
Methods inherited from class java.util.ArrayList
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, removeRange, set, size, toArray, toArray, trimToSize
 
Methods inherited from class java.util.AbstractList
equals, hashCode, iterator, listIterator, listIterator, subList
 
Methods inherited from class java.util.AbstractCollection
containsAll, remove, removeAll, retainAll
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface codec.asn1.ASN1Type
checkConstraints, encode, getConstraint, getTag, getTagClass, getValue, isExplicit, isOptional, isType, setConstraint, setExplicit, setOptional
 
Methods inherited from interface java.util.Collection
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray
 
Methods inherited from interface java.util.List
containsAll, equals, hashCode, iterator, listIterator, listIterator, remove, removeAll, retainAll, subList
 

Field Detail

type_

protected ASN1ObjectIdentifier type_
The Object Identifier specifying the attribute type.

values_

protected ASN1Set values_
The List of Attribute values.
Constructor Detail

Attribute

public Attribute()
Creates an instance ready for parsing. Any type of ASN.1 structure will be accepted as the values of this attribute. An ASN1OpenType is used for this.

Attribute

public Attribute(OIDRegistry registry)
Creates an instance ready for parsing. The given OIDRegistry is used to resolve the attribute type. If the attribute type cannot be resolved upon decoding then an exception is thrown.
Parameters:
registry - The OIDRegistry to use for resolving attribute value types, or null if the global registry shall be used.

Attribute

public Attribute(ASN1ObjectIdentifier oid,
                 ASN1Type value)
Creates a new instance that is initialized with the given OID and value. Note: the given values are not cloned or copied, they are used directly. Hence, the given types must not be modified after hereafter in order to avoid side effects.

The OID must not be null. The value can be null and is replaced by ASN1Null in that case.

Parameters:
oid - The OID that identifies the given value.
value - The ASN.1 type.

Attribute

public Attribute(ASN1RegisteredType value)
The arguments passed to this constructor are set up directly for parsing. They are not cloned! The OID of the Attribute is the OID returned by the registered type.
Parameters:
value - The registered ASN.1 type.
Method Detail

getOID

public ASN1ObjectIdentifier getOID()
This method returns the OID of this Attribute.
Specified by:
getOID in interface ASN1RegisteredType
Returns:
The OID

valueList

public List valueList()
This method returns an unmodifiable view of the list of values of this Attribute.
Returns:
The unmodifiable view of the list of attribute values.

valueCount

public int valueCount()
returns the number of values in this attribute.
Returns:
The number of values.

valueAt

public ASN1Type valueAt(int index)
Returns the value at the given position where position is between 0 and valueCount()-1.
Returns:
The value at the given position.
Throws:
ArrayIndexOutOfBoundsException - if the given position is not within the bounds of the list of attribute values.

decode

public void decode(Decoder dec)
            throws IOException,
                   ASN1Exception
Decodes this instance. If the internal storage object of attributes is a ASN1SetOf then that set is transformed into a ASN1Set, and any ASN1OpenType instances are stripped away. This makes a number of internal objects available for garbage collection.

Consequently, after decoding this instance contains a set with the pure attribute values.

Specified by:
decode in interface ASN1Type
Overrides:
decode in class ASN1AbstractCollection
Parameters:
dec - The decoder to use.


Copyright © Fraunhofer Gesellschaft. All Rights Reserved.