ptolemy.actor.gt.ingredients.criteria
Class AttributeCriterion

java.lang.Object
  extended by ptolemy.actor.gt.GTIngredient
      extended by ptolemy.actor.gt.ingredients.criteria.Criterion
          extended by ptolemy.actor.gt.ingredients.criteria.AttributeCriterion

public class AttributeCriterion
extends Criterion

A criterion to constrain an attribute of an object in the host model.

Since:
Ptolemy II 8.0
Version:
$Id: AttributeCriterion.java 57046 2010-01-27 23:35:53Z cxh $
Author:
Thomas Huining Feng
Accepted Rating:
Red (tfeng)
Proposed Rating:
Yellow (tfeng)

Nested Class Summary
 
Nested classes/interfaces inherited from class ptolemy.actor.gt.GTIngredient
GTIngredient.FieldIterator
 
Field Summary
private  RegularExpressionString _attributeName
          Value of the attributeName element.
private  PtolemyExpressionString _attributeType
          Value of the attributeType element.
private  PtolemyExpressionString _attributeValue
          Value of the attributeValue element.
private static CriterionElement[] _ELEMENTS
          The elements.
 
Fields inherited from class ptolemy.actor.gt.GTIngredient
FIELD_SEPARATOR
 
Constructor Summary
AttributeCriterion(GTIngredientList owner)
          Construct a criterion within the given list as its owner.
AttributeCriterion(GTIngredientList owner, java.lang.String values)
          Construct a criterion within the given list as its owner and initialize all the elements with the given values, which are a string encoding of those elements.
AttributeCriterion(GTIngredientList owner, java.lang.String attributeName, java.lang.String attributeType, java.lang.String attributeValue)
          Construct a criterion within the given list as its owner and with the given value to each of its elements..
 
Method Summary
 GTIngredientElement[] getElements()
          Get the array of elements defined in this GTIngredient.
 java.lang.Object getValue(int index)
          Get the value of the index-th elements.
 java.lang.String getValues()
          Get a string that describes the values of all the elements.
 boolean isAttributeNameEnabled()
          Return whether the attributeName element is enabled.
 boolean isAttributeTypeEnabled()
          Return whether the attributeType element is enabled.
 boolean isAttributeValueEnabled()
          Return whether the attributeValue element is enabled.
 boolean match(NamedObj object)
          Test whether the given object in the host model matches the object in the pattern that has this criterion.
 void setValue(int index, java.lang.Object value)
          Set the value of the index-th element.
 void setValues(java.lang.String values)
          Set the values of all the elements with a string that describes them.
 void validate()
          Validate the enablements and values of all the elements.
 
Methods inherited from class ptolemy.actor.gt.ingredients.criteria.Criterion
canCheck
 
Methods inherited from class ptolemy.actor.gt.GTIngredient
_decodeBooleanField, _decodeStringField, _encodeBooleanField, _encodeStringField, _escapeElementString, _findMatchingParen, _findSeparator, _unescapeElementString, disableAll, enableAll, getOwner, isApplicable, isEnabled, setEnabled, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_ELEMENTS

private static final CriterionElement[] _ELEMENTS
The elements.


_attributeName

private RegularExpressionString _attributeName
Value of the attributeName element.


_attributeType

private PtolemyExpressionString _attributeType
Value of the attributeType element.


_attributeValue

private PtolemyExpressionString _attributeValue
Value of the attributeValue element.

Constructor Detail

AttributeCriterion

public AttributeCriterion(GTIngredientList owner)
Construct a criterion within the given list as its owner. All elements are enabled and are initialized to empty at the beginning.

Parameters:
owner - The list as the owner of the constructed GTIngredientList.

AttributeCriterion

public AttributeCriterion(GTIngredientList owner,
                          java.lang.String values)
Construct a criterion within the given list as its owner and initialize all the elements with the given values, which are a string encoding of those elements. All elements are enabled at the beginning.

Parameters:
owner - The list as the owner of the constructed GTIngredientList.
values - The string encoding of the values of the elements.

AttributeCriterion

public AttributeCriterion(GTIngredientList owner,
                          java.lang.String attributeName,
                          java.lang.String attributeType,
                          java.lang.String attributeValue)
Construct a criterion within the given list as its owner and with the given value to each of its elements..

Parameters:
owner - The list as the owner of the constructed GTIngredientList.
attributeName - Value of the attributeName element.
attributeType - Value of the attributeType element.
attributeValue - Value of the attributeValue element.
Method Detail

getElements

public GTIngredientElement[] getElements()
Get the array of elements defined in this GTIngredient.

Specified by:
getElements in class GTIngredient
Returns:
The array of elements.

getValue

public java.lang.Object getValue(int index)
Get the value of the index-th elements.

Specified by:
getValue in class GTIngredient
Parameters:
index - The index.
Returns:
The value.
See Also:
setValue(int, Object)

getValues

public java.lang.String getValues()
Get a string that describes the values of all the elements.

Specified by:
getValues in class GTIngredient
Returns:
A string that describes the values of all the elements.
See Also:
setValues(String)

isAttributeNameEnabled

public boolean isAttributeNameEnabled()
Return whether the attributeName element is enabled.

Returns:
true if the attributeName element is enabled.

isAttributeTypeEnabled

public boolean isAttributeTypeEnabled()
Return whether the attributeType element is enabled.

Returns:
true if the attributeType element is enabled.

isAttributeValueEnabled

public boolean isAttributeValueEnabled()
Return whether the attributeValue element is enabled.

Returns:
true if the attributeValue element is enabled.

match

public boolean match(NamedObj object)
Test whether the given object in the host model matches the object in the pattern that has this criterion.

Specified by:
match in class Criterion
Parameters:
object - The object.
Returns:
true if the object matches.

setValue

public void setValue(int index,
                     java.lang.Object value)
Set the value of the index-th element.

Specified by:
setValue in class GTIngredient
Parameters:
index - The index.
value - The value.
See Also:
getValue(int)

setValues

public void setValues(java.lang.String values)
Set the values of all the elements with a string that describes them.

Specified by:
setValues in class GTIngredient
Parameters:
values - A string that describes the new values of all the elements.
See Also:
getValues()

validate

public void validate()
              throws ValidationException
Validate the enablements and values of all the elements.

Specified by:
validate in class GTIngredient
Throws:
ValidationException - If some elements are invalid.