codec.asn1
Class ASN1SequenceOf

java.lang.Object
  |
  +--java.util.AbstractCollection
        |
        +--java.util.AbstractList
              |
              +--java.util.ArrayList
                    |
                    +--codec.asn1.ASN1AbstractCollection
                          |
                          +--codec.asn1.ASN1Sequence
                                |
                                +--codec.asn1.ASN1SequenceOf
All Implemented Interfaces:
ASN1Collection, ASN1CollectionOf, ASN1Type, Cloneable, Collection, Externalizable, List, Serializable
Direct Known Subclasses:
AuthenticatedSafe, Name, SafeContents

public class ASN1SequenceOf
extends ASN1Sequence
implements ASN1CollectionOf

Represents an ASN.1 SEQUENCE OF type as specified in ITU-T Recommendation X.680. The SequenceOf and SetOf types do not have default constructors in contrast to all the other ASN1Types. The reason is that these types are never created directly on decoding ASN.1 structures. The decoding process always decodes Sequence and Set types because creating the appropriate SequenceOf or SetOf type requires explicit knowledge of the syntactic structure definition. On the other hand, if an explicit structure is given for decoding then the SequenceOf and SetOf types are decoded properly (because they do not have to be created and hence the decoder need not know the component type).

Constraints are checked only after decoding by a call to method decode.

Version:
"$Id: ASN1SequenceOf.java,v 1.3 2004/08/06 15:16:08 flautens Exp $"
Author:
Volker Roth
See Also:
Serialized Form

Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
  ASN1SequenceOf(Class type)
          Creates an instance that keeps elements of the given type.
  ASN1SequenceOf(Class type, int capacity)
          Creates an instance with the given capacity.
protected ASN1SequenceOf(int capacity)
          Creates an instance with the given capacity.
  ASN1SequenceOf(Resolver resolver)
          Creates an instance that uses the given Resolver to create new elements.
 
Method Summary
 void decode(Decoder dec)
          Reads this collection from the given Decoder.
 Class getElementType()
          Returns the Java class representing the ASN.1 type of the elements in this collection or ASN1Type.class if the type cannot be determined.
 ASN1Type newElement()
          Creates and returns a new instance of the element type of this instance.
 
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.ASN1Collection
getCollection
 
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
 

Constructor Detail

ASN1SequenceOf

protected ASN1SequenceOf(int capacity)
Creates an instance with the given capacity. This constructor is provided for subclasses that wish to handle creation of new elements themselves and do not rely on an application-provided element type.
Parameters:
capacity - The initial capacity of the set.

ASN1SequenceOf

public ASN1SequenceOf(Class type)
Creates an instance that keeps elements of the given type. The type must be a valid ASN1Type. The given class must be public and it must have a public default constructor.
Parameters:
type - The class that represents the component type of this SET OF.
Throws:
IllegalArgumentException - if the given class does not implement ASN1Type.
NullPointerException - if type is null.

ASN1SequenceOf

public ASN1SequenceOf(Class type,
                      int capacity)
Creates an instance with the given capacity.
Parameters:
capacity - The capacity.

ASN1SequenceOf

public ASN1SequenceOf(Resolver resolver)
Creates an instance that uses the given Resolver to create new elements.
Parameters:
resolver - The resolver to use for generating elements.
Method Detail

getElementType

public Class getElementType()
Returns the Java class representing the ASN.1 type of the elements in this collection or ASN1Type.class if the type cannot be determined.
Specified by:
getElementType in interface ASN1CollectionOf
Returns:
The ASN.1 type of the elements in this collection.

newElement

public ASN1Type newElement()
Creates and returns a new instance of the element type of this instance. The freshly created instance is added to this instance automatically.

New instances are created by invoking the Resolver instance set in this instance.

If no new instance can be created then an IllegalStateException is thrown.

Decoders should call this method in order to create additional elements on decoding. Subclasses may use this method to keep track on elements added to them.

Specified by:
newElement in interface ASN1CollectionOf
Returns:
A new instance of the element type of this set.
Throws:
IllegalStateException - if no new instance could be created.

decode

public void decode(Decoder dec)
            throws ASN1Exception,
                   IOException
Reads this collection from the given Decoder.
Specified by:
decode in interface ASN1Type
Overrides:
decode in class ASN1AbstractCollection
Parameters:
dec - The decoder to read from.


Copyright © Fraunhofer Gesellschaft. All Rights Reserved.