jp.bitmeister.asn1.type
Class CollectionType<T extends ASN1Type>

java.lang.Object
  extended by jp.bitmeister.asn1.type.ASN1Type
      extended by jp.bitmeister.asn1.type.CollectionType<T>
All Implemented Interfaces:
java.lang.Cloneable, SizeCountable
Direct Known Subclasses:
SEQUENCE_OF, SET_OF

public abstract class CollectionType<T extends ASN1Type>
extends ASN1Type
implements SizeCountable

The base class for structured types defined by referencing a single ASN.1 type.

This class provides generic interfaces and common methods for classes that represents structured types which defined by referencing a single ASN.1 type. This class is the parent class of SEQUENCE_OF and SET_OF.

Author:
WATANABE, Jun.
See Also:
SEQUENCE_OF, SET_OF

Field Summary
 
Fields inherited from class jp.bitmeister.asn1.type.ASN1Type
stringBuilder
 
Constructor Summary
protected CollectionType(java.lang.Class<T> componentType)
          Instantiate a CollectionType instance whose component is the type.
protected CollectionType(java.lang.Class<T> componentType, T... components)
          Instantiate a CollectionType instance whose component is the type and initialize it with the components.
 
Method Summary
 void clear()
          Clears the value of this ASN.1 data.
 java.lang.Object clone()
          Creates and returns a copy of this ASN.1 data.
 java.util.Collection<T> collection()
          Returns the collection that contained in the data.
 TypeSpecification componentSpecification()
          Returns a TypeSpecification instance that associated to the component type.
 java.lang.Class<T> componentType()
          Returns the type of component of this data.
 int hashCode()
          Returns a hash code value for this ASN.1 data.
 boolean hasValue()
          Tests if this ASN.1 data has value.
protected abstract  java.util.Collection<T> newCollection()
          Instantiates a new collection of the component type.
 int size()
          Returns the measured size of this instance.
 boolean valueEquals(java.lang.Object other)
          Tests if the value of this ASN.1 data equals the value of the other ASN.1 data.
 
Methods inherited from class jp.bitmeister.asn1.type.ASN1Type
accept, equals, instantiate, matches, specification, toString, validate
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CollectionType

protected CollectionType(java.lang.Class<T> componentType)
Instantiate a CollectionType instance whose component is the type.

Parameters:
componentType - The class object of the component of this collection.

CollectionType

protected CollectionType(java.lang.Class<T> componentType,
                         T... components)
Instantiate a CollectionType instance whose component is the type and initialize it with the components.

Parameters:
componentType - The class object of the component of this collection.
components - Components to be set this instance.
Method Detail

collection

public java.util.Collection<T> collection()
Returns the collection that contained in the data.

Returns:
The collection.

componentType

public java.lang.Class<T> componentType()
Returns the type of component of this data.

Returns:
The type of component.

componentSpecification

public TypeSpecification componentSpecification()
Returns a TypeSpecification instance that associated to the component type.

Returns:
TypeSpecification instance

newCollection

protected abstract java.util.Collection<T> newCollection()
Instantiates a new collection of the component type.

Returns:
A new collection.

size

public int size()
Description copied from interface: SizeCountable
Returns the measured size of this instance.

Specified by:
size in interface SizeCountable
Returns:
The size.

clear

public void clear()
Description copied from class: ASN1Type
Clears the value of this ASN.1 data.

Specified by:
clear in class ASN1Type

hasValue

public boolean hasValue()
Description copied from class: ASN1Type
Tests if this ASN.1 data has value.

Specified by:
hasValue in class ASN1Type
Returns:
true when this ASN.1 data has value.

valueEquals

public boolean valueEquals(java.lang.Object other)
Description copied from class: ASN1Type
Tests if the value of this ASN.1 data equals the value of the other ASN.1 data. This method returns true when they have same value even if their types are different.

Specified by:
valueEquals in class ASN1Type
Parameters:
other - The ASN.1 data which to be compared.
Returns:
true when they have same value.

hashCode

public int hashCode()
Description copied from class: ASN1Type
Returns a hash code value for this ASN.1 data.

Specified by:
hashCode in class ASN1Type
See Also:
Object.hashCode()

clone

public java.lang.Object clone()
Description copied from class: ASN1Type
Creates and returns a copy of this ASN.1 data. This method performs a 'deep copy' operation.

Specified by:
clone in class ASN1Type
See Also:
Object.clone()