fi.hut.tcm.spki
Interface Composite

All Known Subinterfaces:
GenericFormat, OnlineTest, Op, Tag, Validity
All Known Implementing Classes:
Composite, TagExpr, Tag, TagStar, GeneralOp, Cert, HashOp, SpkiCrl, OnlineTest, Valid, Sequence

public abstract interface Composite
extends Component

Composite An interface for SPKI components that have an internal structure. Used for traversing SPKI data structures.


Method Summary
 int add(Component addThis)
          Add a new component to a composite.
 boolean check(Component addition)
          Checks if the component to be added is of correct type.
 Component get(Component childClass)
          Returns the first element x that fullfills (x instanceof childClass).
 Component get(int number)
          Get returns the wanted child by it's number.
 java.util.Iterator iterator()
          Returns an iterator over all the children.
 boolean remove(Component child)
          Removes the first occurrence of this object.
 int size()
           
 
Methods inherited from interface fi.hut.tcm.spki.Component
accept
 

Method Detail

add

public int add(Component addThis)
        throws java.lang.IllegalArgumentException,
               java.lang.IllegalStateException
Add a new component to a composite. Returns the index of the added component. This index number may later change if earlier components are removed.

check

public boolean check(Component addition)
              throws java.lang.IllegalStateException
Checks if the component to be added is of correct type. Returns true if it is, false if it is not. Throws IllegalStateException if this component is of right type, but cannot be added now (there is already a max number of such components, for example). All composites override this to restrict what classes can be added to them.

get

public Component get(int number)
              throws java.lang.ArrayIndexOutOfBoundsException
Get returns the wanted child by it's number. If not found, throws ArrayIndexOutOfBoundsException.

get

public Component get(Component childClass)
Returns the first element x that fullfills (x instanceof childClass). This is handy for searching Composites and subclasses of ByteString, but not ByteStrings.

remove

public boolean remove(Component child)
Removes the first occurrence of this object. Returns true if the argument was a component of this composite; false otherwise. Elements of a higher index are moved one step downwards.

iterator

public java.util.Iterator iterator()
Returns an iterator over all the children.

size

public int size()