scphEditor
Class OperandVector

java.lang.Object
  extended by java.util.Observable
      extended by scphEditor.CloneableObservable
          extended by scphEditor.OperandVector
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable
Direct Known Subclasses:
Operand, Work

public abstract class OperandVector
extends CloneableObservable
implements java.lang.Cloneable, java.io.Serializable

This class models a vector of operands. Operands and Work are vectors of operands.

See Also:
Operand, Work, Serialized Form

Constructor Summary
OperandVector()
           
 
Method Summary
 void addChild(Operand newChild, int atIndex)
           
 int countChildren()
          Gives the actual, present number of my children.
 Operand delChild(int atIndex)
           
 Operand getChild(int atIndex)
          Gives my child at the given index.
 java.util.Enumeration getChildren()
          Enumerates all of my children, in ascending order of indexes.
 void setChild(Operand newChild, int atIndex)
          Adopts the given new child as my child at the given index, replacing the previous child at the same index.
 
Methods inherited from class scphEditor.CloneableObservable
addObserver, clone, cloneObserverList, cloneObserverList, countObservers, deleteObserver, deleteObservers, notifyObservers, notifyObservers
 
Methods inherited from class java.util.Observable
clearChanged, hasChanged, setChanged
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OperandVector

public OperandVector()
Method Detail

setChild

public void setChild(Operand newChild,
                     int atIndex)
Adopts the given new child as my child at the given index, replacing the previous child at the same index.

This default implementation is for a leaf node in which there must be no child, so it always throws an exception. A compound expression must re-implement this method sensibly.

Parameters:
newChild - the new child
atIndex - the index to where newChild goes
Throws:
java.lang.ArrayIndexOutOfBoundsException - if atIndex is an invalid index. (For leaf nodes, all indexes are invalid.)

getChild

public Operand getChild(int atIndex)
Gives my child at the given index.

This default implementation is for a leaf node in which there is no child, so it always throws an exception. A compound expression must re-implement this method sensibly.

Parameters:
atIndex - the index at where a child will be sought.
Returns:
the child at the index. (For leaf nodes, this does not make sense.)
Throws:
java.lang.ArrayIndexOutOfBoundsException - if atIndex is an invalid index. (For leaf nodes, all indexes are invalid.)

addChild

public void addChild(Operand newChild,
                     int atIndex)

delChild

public Operand delChild(int atIndex)

getChildren

public java.util.Enumeration getChildren()
Enumerates all of my children, in ascending order of indexes.

This default implementation returns an ``empty'' Enumeration, i.e., one that has no element at all, which makes sense for leaf nodes. A compound expression must override this behaviour sensibly.

Returns:
an Enumeration that iterates over my children in ascending order of indexes. (For leaf nodes, returns an ``empty'' Enumeration.)

countChildren

public int countChildren()
Gives the actual, present number of my children.

This default implementation returns zero, as a leaf node has no child.

Returns:
the present number of my children. (Zero for leaf nodes.)