All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class openstar.util.TypedList

java.lang.Object
   |
   +----openstar.util.TypedList

public class TypedList
extends Object
implements Cloneable
Vector-like list class that is restricted to objects of a given type.

Version:
09 Apr 1997
Author:
Nils Schwabe

Variable Index

 o classTest
 o vector

Constructor Index

 o TypedList(String, boolean)
 o TypedList(String, boolean, int)

Method Index

 o add(TypedList)
 o addElement(Object)
 o clone()
Makes an independent copy of this list.
 o elementAt(int)
 o equals(Object)
Returns true if and only if the given object is also a TypedList (no matter which subclass thereof), and both lists contain the same number of objects, and the application of the equals method of all elements returns true.
 o getAt(int)
Same as elementAt() but returns null in case of an invalid index.
 o getElemClassName()
Returns the type name of the elements of this list.
 o indexOf(Object, int)
 o insertElementAt(Object, int)
 o isEmpty()
 o isPolymorphic()
 o length()
Same as size().
 o removeAllElements()
 o removeElement(Object)
 o removeElementAt(int)
 o setElementAt(Object, int)
 o size()
Returns the number of elements in the list.
 o test(Object)
Tests if the given object may be stored in this list.
 o toString()

Variables

 o classTest
  protected ClassTest classTest
 o vector
  protected Vector vector

Constructors

 o TypedList
  public TypedList(String requiredType,
                   boolean polymorphic)
Parameters:
requiredType - the fully qualified name of the class to which all elements of the list must belong.
polymorphic - true indicates that objects belongig to subclasses of the specified type may also be stored in the list.
 o TypedList
  public TypedList(String requiredType,
                   boolean polymorphic,
                   int initialCapacity)
Parameters:
requiredType - the fully qualified name of the class to which all elements of the list must belong.
polymorphic - true indicates that objects belongig to subclasses of the specified type may also be stored in the list.
initialCapacity - the initial capacity of the underlying Vector that is used to store the elements of the list.

Methods

 o clone
  public synchronized Object clone()
Makes an independent copy of this list.

The elements of the list are not cloned, i.e. only the references to the objects are copied.

Overrides:
clone in class Object
 o size
  public int size()
Returns the number of elements in the list.

 o length
  public int length()
Same as size().

 o isEmpty
  public boolean isEmpty()
 o indexOf
  public int indexOf(Object elem,
                     int startIndex) throws IllegalArgumentException
 o elementAt
  public Object elementAt(int index) throws ArrayIndexOutOfBoundsException
 o getAt
  public Object getAt(int index)
Same as elementAt() but returns null in case of an invalid index.

 o setElementAt
  public void setElementAt(Object elem,
                           int index) throws IllegalArgumentException, ArrayIndexOutOfBoundsException
 o removeElementAt
  public void removeElementAt(int index) throws ArrayIndexOutOfBoundsException
 o removeElement
  public void removeElement(Object elem)
 o insertElementAt
  public void insertElementAt(Object elem,
                              int index) throws IllegalArgumentException, ArrayIndexOutOfBoundsException
 o addElement
  public void addElement(Object elem) throws IllegalArgumentException
 o add
  public void add(TypedList a) throws IllegalArgumentException
 o removeAllElements
  public void removeAllElements()
 o toString
  public String toString()
Overrides:
toString in class Object
 o test
  protected void test(Object object) throws IllegalArgumentException
Tests if the given object may be stored in this list.

If the object has an invalid type, an IllegalArgumentException is thrown. Otherwise, nothing happens.

 o equals
  public boolean equals(Object obj)
Returns true if and only if the given object is also a TypedList (no matter which subclass thereof), and both lists contain the same number of objects, and the application of the equals method of all elements returns true.

Note 1: the above definition implies that two TypedList objects can be equal even if they support two types that are not related to each other in any way, as long as the actual objects in the list are related to both types through an implements or extends clause.

Note 2: the implementation of the equals method should, according to the Java specs, always be symetric. Thus, the information which equals method for a given pair of list elements is actually used should be irrelevant.

Overrides:
equals in class Object
 o getElemClassName
  public String getElemClassName()
Returns the type name of the elements of this list.

All elements are guaranteed to be either of this exact type, or ( if isPolymorphic() returns true) to be of this type or a subclass thereof.

 o isPolymorphic
  public boolean isPolymorphic()

All Packages  Class Hierarchy  This Package  Previous  Next  Index