edu.washington.cs.supple.rep
Class ContainerTypeImpl

java.lang.Object
  extended byedu.washington.cs.supple.rep.SuppleBeanImpl
      extended byedu.washington.cs.supple.rep.BaseType
          extended byedu.washington.cs.supple.rep.ContainerTypeImpl
All Implemented Interfaces:
java.lang.Cloneable, ContainerType, java.io.Serializable, SuppleBean, SuppleType, ValueListener
Direct Known Subclasses:
ActionTypeImpl, DynamicTypeImpl, VectorTypeImpl

public class ContainerTypeImpl
extends BaseType
implements ContainerType, java.lang.Cloneable

Author:
kgajos The default implementation of the container type
See Also:
Serialized Form

Field Summary
protected  java.util.Vector children
           
protected  java.util.Hashtable childTable
           
protected  ContainerTypeImpl derivedFrom
           
protected  java.util.Vector dynamicChildren
           
protected  java.util.Hashtable hiddenChildren
           
protected  int numChildrenAdded
           
protected  UiObject object
           
 
Fields inherited from class edu.washington.cs.supple.rep.BaseType
finalLegalValues, hasOrdering, lastUid, legalValues, legalValuesBinding, likelyValues, likelyValuesBinding, maxNumLegalValues, nullLegal, typicalIndexLength, uid
 
Fields inherited from class edu.washington.cs.supple.rep.SuppleBeanImpl
pcs
 
Constructor Summary
ContainerTypeImpl()
           
ContainerTypeImpl(java.util.Collection likelyValues, java.util.Collection legalValues)
           
ContainerTypeImpl(java.lang.Object[] likelyValues, java.lang.Object[] legalValues)
           
ContainerTypeImpl(ValueBinding likelyVals, ValueBinding legalVals)
           
 
Method Summary
 void accept(UiVisitor visitor)
          Visitor pattern.
 boolean addChild(java.lang.String name, UiObject child)
          If the child is not on the list of children yet and if there exists no other child with the same name, it is added
 boolean addDynamicChild(java.lang.String name, UiObject child)
           
 boolean childrenHaveLabels()
          Checks if all children have meaningful labels
 java.lang.Object clone()
          Clone this type, does not clone children.
 UiObject getChild(java.lang.String name)
           
 java.util.Vector getChildren()
           
 java.lang.String getIndex(java.lang.Object value)
           
 int getNumChildren()
           
 int getNumChildrenAdded()
          Returns the total number of children added.
 UiObject getUiObject()
           
 boolean hasIndex()
          Index is a short unique summary of the value (which can be used for choosing present values, etc.
 boolean hasModifiableChild()
          Checks if any descendant of this type is modifiable
protected  void init()
          Initialize the container type.
 boolean isEnumerable()
          This method tells you if possible values for this type can be (reasonably) enumerated
 boolean isLegalValueClass(java.lang.Class c)
          Check if a class is legal for this type.
 boolean isPrimitiveType()
          Test if this is a primitive type.
 void rebindChildrenToValue(java.lang.Object value)
          rebinds children if the container value changes
 void removeChild(UiObject child)
          Removes a child from this container; can only be called before the UI is submitted for rendering
 int size()
           
 boolean swapChild(UiObject oldChild, UiObject newChild)
          To be used very carefully (pretty much only by UiTransformers) -- replaces one child ui object with another
 java.lang.String toPrettyString(java.lang.String pref)
           
 java.lang.String toString()
           
 
Methods inherited from class edu.washington.cs.supple.rep.BaseType
addLegalValue, addLegalValueHelper, addLegalValues, addLikelyValue, addLikelyValueHelper, bindLegalValues, bindLikelyValues, ensureLegalValues, equals, getIndex, getLegalValues, getLikelyValues, getLongestLegalIndex, getMaxNumLegalValues, getNumLegalValues, getNumLikelyValues, getTypicalIndexLength, getUniqueId, hashCode, hasOrdering, hasSetLegalValues, isFinalLegalValues, isLegalValue, orderValues, setFinalLegalValues, setLegalValues, setLikelyValues, setMaxNumLegalValues, setTypicalIndexLength, valueChanged, verifyCurrentValue, visitBoundProperties
 
Methods inherited from class edu.washington.cs.supple.rep.SuppleBeanImpl
addPropertyChangeListener, removePropertyChangeListener
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface edu.washington.cs.supple.rep.SuppleType
getIndex, getLegalValues, getLikelyValues, getLongestLegalIndex, getMaxNumLegalValues, getNumLegalValues, getNumLikelyValues, getTypicalIndexLength, getUniqueId, hasOrdering, hasSetLegalValues, isFinalLegalValues, isLegalValue, orderValues, verifyCurrentValue
 
Methods inherited from interface edu.washington.cs.supple.rep.SuppleBean
addPropertyChangeListener, removePropertyChangeListener
 

Field Detail

children

protected java.util.Vector children

dynamicChildren

protected java.util.Vector dynamicChildren

hiddenChildren

protected java.util.Hashtable hiddenChildren

childTable

protected java.util.Hashtable childTable

numChildrenAdded

protected int numChildrenAdded

object

protected UiObject object

derivedFrom

protected ContainerTypeImpl derivedFrom
Constructor Detail

ContainerTypeImpl

public ContainerTypeImpl()

ContainerTypeImpl

public ContainerTypeImpl(java.util.Collection likelyValues,
                         java.util.Collection legalValues)
Parameters:
likelyValues -
legalValues -

ContainerTypeImpl

public ContainerTypeImpl(java.lang.Object[] likelyValues,
                         java.lang.Object[] legalValues)
Parameters:
likelyValues -
legalValues -

ContainerTypeImpl

public ContainerTypeImpl(ValueBinding likelyVals,
                         ValueBinding legalVals)
Method Detail

init

protected void init()
Initialize the container type. Executed when object is bound to UiObject.


clone

public java.lang.Object clone()
Clone this type, does not clone children.


addChild

public boolean addChild(java.lang.String name,
                        UiObject child)
If the child is not on the list of children yet and if there exists no other child with the same name, it is added

Parameters:
name - unique name to distinguish it from other children
child - child to be added; cannot be null

addDynamicChild

public boolean addDynamicChild(java.lang.String name,
                               UiObject child)

swapChild

public boolean swapChild(UiObject oldChild,
                         UiObject newChild)
Description copied from interface: ContainerType
To be used very carefully (pretty much only by UiTransformers) -- replaces one child ui object with another

Specified by:
swapChild in interface ContainerType
Parameters:
oldChild -
newChild -
Returns:
true if the old child existed and was successfuly swapped; false otherwise

removeChild

public void removeChild(UiObject child)
Description copied from interface: ContainerType
Removes a child from this container; can only be called before the UI is submitted for rendering

Specified by:
removeChild in interface ContainerType
Parameters:
child - the child ui object to be removed

getChildren

public java.util.Vector getChildren()
Specified by:
getChildren in interface ContainerType
Returns:
returns a clone of the internal list of its children

getChild

public UiObject getChild(java.lang.String name)
Specified by:
getChild in interface ContainerType
Parameters:
name - name of the child
Returns:
the child with a given name or null if one does not exist

getNumChildren

public int getNumChildren()
Specified by:
getNumChildren in interface ContainerType
Returns:
the number of children

getNumChildrenAdded

public int getNumChildrenAdded()
Returns the total number of children added. We need this number to assign unique ids to all objects. This number does not equal getNumChildren(), after we have removed some children.

Specified by:
getNumChildrenAdded in interface ContainerType
Returns:
the total number of children added

isEnumerable

public boolean isEnumerable()
Description copied from interface: SuppleType
This method tells you if possible values for this type can be (reasonably) enumerated

Specified by:
isEnumerable in interface SuppleType
Specified by:
isEnumerable in class BaseType

size

public int size()
Specified by:
size in interface ContainerType
Returns:
the number of children

toString

public java.lang.String toString()
Overrides:
toString in class BaseType

toPrettyString

public java.lang.String toPrettyString(java.lang.String pref)
Specified by:
toPrettyString in interface SuppleType
Overrides:
toPrettyString in class BaseType

childrenHaveLabels

public boolean childrenHaveLabels()
Checks if all children have meaningful labels

Specified by:
childrenHaveLabels in interface ContainerType
Returns:
false if there exists a child with no label; otherwise true

getUiObject

public UiObject getUiObject()
Specified by:
getUiObject in interface ContainerType

hasModifiableChild

public boolean hasModifiableChild()
Description copied from interface: ContainerType
Checks if any descendant of this type is modifiable

Specified by:
hasModifiableChild in interface ContainerType
Returns:
true if at least one descendant of this type is modifiable

isPrimitiveType

public boolean isPrimitiveType()
Description copied from interface: SuppleType
Test if this is a primitive type.

Specified by:
isPrimitiveType in interface SuppleType
Returns:

isLegalValueClass

public boolean isLegalValueClass(java.lang.Class c)
Description copied from interface: SuppleType
Check if a class is legal for this type.

Specified by:
isLegalValueClass in interface SuppleType
Parameters:
c -
Returns:

hasIndex

public boolean hasIndex()
Description copied from interface: SuppleType
Index is a short unique summary of the value (which can be used for choosing present values, etc.

Specified by:
hasIndex in interface SuppleType
Returns:
true if the type has an index defined, false otherwise

getIndex

public java.lang.String getIndex(java.lang.Object value)
Specified by:
getIndex in interface SuppleType
Returns:
the index of a value (if exists); null otherwise

rebindChildrenToValue

public void rebindChildrenToValue(java.lang.Object value)
rebinds children if the container value changes


accept

public void accept(UiVisitor visitor)
Description copied from interface: SuppleType
Visitor pattern.

Specified by:
accept in interface SuppleType
Overrides:
accept in class BaseType