edu.washington.cs.supple.rep
Class VectorTypeImpl

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

public final class VectorTypeImpl
extends ContainerTypeImpl
implements VectorType

Author:
kgajos
See Also:
Serialized Form

Field Summary
protected  SuppleType elementType
           
 
Fields inherited from class edu.washington.cs.supple.rep.ContainerTypeImpl
children, childTable, derivedFrom, dynamicChildren, hiddenChildren, numChildrenAdded, 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
VectorTypeImpl(SuppleType elementType)
           
 
Method Summary
 void accept(UiVisitor visitor)
          Visitor pattern.
 void addValue(StateVar uiObject, java.lang.Object v)
          Adds an element to the vector held by the uiObject
protected  void addValue(java.util.Vector vector, java.lang.Object v)
           
 boolean containsValue(StateVar uiObject, java.lang.Object v)
          Checks if the vector held by the uiObjects contains a particular value
 SuppleType getElementType()
          Returns the type of the elements in this vector
 int getNumValues(StateVar uiObject)
           
 java.lang.Object getValue(StateVar uiObject, int i)
           
 java.util.Vector getValues(StateVar uiObject)
          Returns the value of the uiObject cast as a vector; if the object has no value, an empty vector is returned (never null)
 boolean hasIndex()
          Index is a short unique summary of the value (which can be used for choosing present values, etc.
protected  void init()
          Initialize the container type.
 boolean isEnumerable()
          By default we assume that a vector value type is enumerable (i.e.
 boolean isLegalValue(java.lang.Object value)
          Check if a value is legal for this type.
 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 rebindChildren(java.lang.Object value)
           
 boolean removeValue(StateVar uiObject, java.lang.Object v)
          Removes a value from the vector held by the uiObject
 void setValue(StateVar uiObject, java.lang.Object value)
          Erases whaver elements that might have been held by the uiObject and sets the value as the only element of the vector
 void setValues(StateVar uiObject, java.util.Collection c)
          Erases whaver elements that might have been held by the uiObject and sets the collection of values as the contents of the vector
 java.lang.String toString()
           
 java.lang.Object verifyCurrentValue(java.lang.Object value)
          This method gets called by UiObjects when they are notified that the legal values of their type have changed; this method looks at the current value of the object and verifies that the value is still legal.
 
Methods inherited from class edu.washington.cs.supple.rep.ContainerTypeImpl
addChild, addDynamicChild, childrenHaveLabels, clone, getChild, getChildren, getIndex, getNumChildren, getNumChildrenAdded, getUiObject, hasModifiableChild, rebindChildrenToValue, removeChild, size, swapChild, toPrettyString
 
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, orderValues, setFinalLegalValues, setLegalValues, setLikelyValues, setMaxNumLegalValues, setTypicalIndexLength, valueChanged, 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.ContainerType
childrenHaveLabels, getChild, getChildren, getNumChildren, getNumChildrenAdded, getUiObject, hasModifiableChild, removeChild, size, swapChild
 
Methods inherited from interface edu.washington.cs.supple.rep.SuppleType
getIndex, getIndex, getLegalValues, getLikelyValues, getLongestLegalIndex, getMaxNumLegalValues, getNumLegalValues, getNumLikelyValues, getTypicalIndexLength, getUniqueId, hasOrdering, hasSetLegalValues, isFinalLegalValues, orderValues, toPrettyString
 
Methods inherited from interface edu.washington.cs.supple.rep.SuppleBean
addPropertyChangeListener, removePropertyChangeListener
 

Field Detail

elementType

protected SuppleType elementType
Constructor Detail

VectorTypeImpl

public VectorTypeImpl(SuppleType elementType)
Method Detail

init

protected void init()
Description copied from class: ContainerTypeImpl
Initialize the container type. Executed when object is bound to UiObject.

Overrides:
init in class ContainerTypeImpl

isEnumerable

public boolean isEnumerable()
By default we assume that a vector value type is enumerable (i.e. the list of options to choose from can be enumerated). Override if not true.

Specified by:
isEnumerable in interface SuppleType
Overrides:
isEnumerable in class ContainerTypeImpl
Returns:
true

verifyCurrentValue

public java.lang.Object verifyCurrentValue(java.lang.Object value)
Description copied from interface: SuppleType
This method gets called by UiObjects when they are notified that the legal values of their type have changed; this method looks at the current value of the object and verifies that the value is still legal. A corrected value or null is returned if some change was needed in response to the change to the legal values of the type.

Specified by:
verifyCurrentValue in interface SuppleType
Overrides:
verifyCurrentValue in class BaseType
Parameters:
value - value to be verified
Returns:
a value that is legal

addValue

public void addValue(StateVar uiObject,
                     java.lang.Object v)
Description copied from interface: VectorType
Adds an element to the vector held by the uiObject

Specified by:
addValue in interface VectorType
Parameters:
uiObject - a ui Element of type VectorType
v - a value to be added to the vector

addValue

protected void addValue(java.util.Vector vector,
                        java.lang.Object v)

containsValue

public boolean containsValue(StateVar uiObject,
                             java.lang.Object v)
Description copied from interface: VectorType
Checks if the vector held by the uiObjects contains a particular value

Specified by:
containsValue in interface VectorType
Parameters:
uiObject - a ui Element of type VectorType
v - value to be checked
Returns:
true if value was found among the elements of the vector; false otherwise

getValues

public java.util.Vector getValues(StateVar uiObject)
Description copied from interface: VectorType
Returns the value of the uiObject cast as a vector; if the object has no value, an empty vector is returned (never null)

Specified by:
getValues in interface VectorType
Parameters:
uiObject - a ui Element of type VectorType
Returns:
a vector of values (it's a clone of the original)

getValue

public java.lang.Object getValue(StateVar uiObject,
                                 int i)
Specified by:
getValue in interface VectorType

getNumValues

public int getNumValues(StateVar uiObject)
Specified by:
getNumValues in interface VectorType

removeValue

public boolean removeValue(StateVar uiObject,
                           java.lang.Object v)
Description copied from interface: VectorType
Removes a value from the vector held by the uiObject

Specified by:
removeValue in interface VectorType
Parameters:
uiObject - a ui Element of type VectorType
v - a value to be added to the vector
Returns:
true if the value was contained in the vector, false otherwise

setValue

public void setValue(StateVar uiObject,
                     java.lang.Object value)
Description copied from interface: VectorType
Erases whaver elements that might have been held by the uiObject and sets the value as the only element of the vector

Specified by:
setValue in interface VectorType
Parameters:
uiObject - a ui Element of type VectorType
value - the value to be set

setValues

public void setValues(StateVar uiObject,
                      java.util.Collection c)
Description copied from interface: VectorType
Erases whaver elements that might have been held by the uiObject and sets the collection of values as the contents of the vector

Specified by:
setValues in interface VectorType
Parameters:
uiObject - a ui Element of type VectorType
c - the collection of values

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
Overrides:
hasIndex in class ContainerTypeImpl

rebindChildren

public void rebindChildren(java.lang.Object value)

getElementType

public SuppleType getElementType()
Description copied from interface: VectorType
Returns the type of the elements in this vector

Specified by:
getElementType in interface VectorType
Returns:
the type of the elements in this vector

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
Overrides:
isLegalValueClass in class ContainerTypeImpl

isLegalValue

public boolean isLegalValue(java.lang.Object value)
Description copied from interface: SuppleType
Check if a value is legal for this type.

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

accept

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

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

isPrimitiveType

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

Specified by:
isPrimitiveType in interface SuppleType
Overrides:
isPrimitiveType in class ContainerTypeImpl

toString

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