ptolemy.actor.gt.ingredients.criteria
Class PortCriterion

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

public class PortCriterion
extends Criterion

A criterion to constrain a port of an actor in the host model. The port name is matched by the portName element, which can be specified with a regular expression. The name of the port created for this criterion for the actor (or matcher) in the pattern, however, is defined by the matcherName element.

Since:
Ptolemy II 8.0
Version:
$Id: PortCriterion.java 59167 2010-09-21 17:08:02Z 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 static CriterionElement[] _ELEMENTS
          The elements.
private  boolean _input
          Value of the input element.
private  java.lang.String _matcherName
          Value of the matcherName element.
private  boolean _multiport
          Value of the multiport element.
private  boolean _output
          Value of the output element.
private  RegularExpressionString _portName
          Value of the portName element.
private  PtolemyExpressionString _portType
          Value of the portType element.
 
Fields inherited from class ptolemy.actor.gt.GTIngredient
FIELD_SEPARATOR
 
Constructor Summary
PortCriterion(GTIngredientList owner)
          Construct a criterion within the given list as its owner.
PortCriterion(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.
PortCriterion(GTIngredientList owner, java.lang.String portName, java.lang.String portType, boolean input, boolean output, boolean multiport, java.lang.String matcherName)
          Construct a criterion within the given list as its owner and with the given value to each of its elements..
 
Method Summary
private  java.lang.String _getUniqueName(GTIngredientList list, java.lang.String name)
          Get a unique name based on the given name within a list.
 boolean canCheck(NamedObj object)
          Return whether this criterion can check the given object.
 GTIngredientElement[] getElements()
          Get the array of elements defined in this GTIngredient.
 java.lang.String getMatcherName()
          Get the matcherName element.
 java.lang.String getPortID(GTIngredientList list)
          Get the ID of the port created for this criterion.
 java.lang.String getPortName()
          Get the portName element.
 java.lang.String getPortType()
          Get the portType element.
 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 isApplicable(NamedObj object)
          Check whether this GTIngredient is applicable to the object.
 boolean isInput()
          Get the input element.
 boolean isInputEnabled()
          Return whether the input element is enabled.
 boolean isMatcherNameEnabled()
          Return whether the matcherName element is enabled.
 boolean isMultiport()
          Get the multiport element.
 boolean isMultiportEnabled()
          Return whether the multiport element is enabled.
 boolean isOutput()
          Get the output element.
 boolean isOutputEnabled()
          Return whether the output element is enabled.
 boolean isPortNameEnabled()
          Return whether the portName element is enabled.
 boolean isPortTypeEnabled()
          Return whether the portType 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 setInputEnabled(boolean enabled)
          Enable or disable the input.
 void setMatcherNameEnabled(boolean enabled)
          Enable or disable the matcher name.
 void setMultiportEnabled(boolean enabled)
          Enable or disable the multiport.
 void setOutputEnabled(boolean enabled)
          Enable or disable the output.
 void setPortNameEnabled(boolean enabled)
          Enable or disable the port name.
 void setPortTypeEnabled(boolean enabled)
          Enable or disable the port type.
 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.GTIngredient
_decodeBooleanField, _decodeStringField, _encodeBooleanField, _encodeStringField, _escapeElementString, _findMatchingParen, _findSeparator, _unescapeElementString, disableAll, enableAll, getOwner, 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.


_input

private boolean _input
Value of the input element.


_matcherName

private java.lang.String _matcherName
Value of the matcherName element.


_multiport

private boolean _multiport
Value of the multiport element.


_output

private boolean _output
Value of the output element.


_portName

private RegularExpressionString _portName
Value of the portName element.


_portType

private PtolemyExpressionString _portType
Value of the portType element.

Constructor Detail

PortCriterion

public PortCriterion(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.

PortCriterion

public PortCriterion(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.

PortCriterion

public PortCriterion(GTIngredientList owner,
                     java.lang.String portName,
                     java.lang.String portType,
                     boolean input,
                     boolean output,
                     boolean multiport,
                     java.lang.String matcherName)
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.
portName - Value of the portName element.
portType - Value of the portType element.
input - Value of the input element.
output - Value of the output element.
multiport - Value of the multiport element.
matcherName - Value of the matcherName element.
Method Detail

canCheck

public boolean canCheck(NamedObj object)
Return whether this criterion can check the given object.

Overrides:
canCheck in class Criterion
Parameters:
object - The object.
Returns:
true if the object can be checked.

getElements

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

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

getMatcherName

public java.lang.String getMatcherName()
Get the matcherName element.

Returns:
The matcherName element.

getPortID

public java.lang.String getPortID(GTIngredientList list)
Get the ID of the port created for this criterion.

Parameters:
list - The list in which the port ID should be unique.
Returns:
The port ID.

getPortName

public java.lang.String getPortName()
Get the portName element.

Returns:
The portName element.

getPortType

public java.lang.String getPortType()
Get the portType element.

Returns:
The portType element.

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)

isApplicable

public boolean isApplicable(NamedObj object)
Check whether this GTIngredient is applicable to the object.

Overrides:
isApplicable in class GTIngredient
Parameters:
object - The object.
Returns:
true if this GTIngredient is applicable; false otherwise.

isInput

public boolean isInput()
Get the input element.

Returns:
The input element.

isInputEnabled

public boolean isInputEnabled()
Return whether the input element is enabled.

Returns:
true if the input element is enabled.

isMatcherNameEnabled

public boolean isMatcherNameEnabled()
Return whether the matcherName element is enabled.

Returns:
true if the matcherName element is enabled.

isMultiport

public boolean isMultiport()
Get the multiport element.

Returns:
The multiport element.

isMultiportEnabled

public boolean isMultiportEnabled()
Return whether the multiport element is enabled.

Returns:
true if the multiport element is enabled.

isOutput

public boolean isOutput()
Get the output element.

Returns:
The output element.

isOutputEnabled

public boolean isOutputEnabled()
Return whether the output element is enabled.

Returns:
true if the output element is enabled.

isPortNameEnabled

public boolean isPortNameEnabled()
Return whether the portName element is enabled.

Returns:
true if the portName element is enabled.

isPortTypeEnabled

public boolean isPortTypeEnabled()
Return whether the portType element is enabled.

Returns:
true if the portType 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.

setInputEnabled

public void setInputEnabled(boolean enabled)
Enable or disable the input.

Used as part of the test harness.

Parameters:
enabled - true if the element is set to be enabled; false if it is disabled.
See Also:
GTIngredient.setEnabled(int, boolean)

setMatcherNameEnabled

public void setMatcherNameEnabled(boolean enabled)
Enable or disable the matcher name.

Used as part of the test harness.

Parameters:
enabled - true if the element is set to be enabled; false if it is disabled.
See Also:
GTIngredient.setEnabled(int, boolean)

setMultiportEnabled

public void setMultiportEnabled(boolean enabled)
Enable or disable the multiport.

Used as part of the test harness.

Parameters:
enabled - true if the element is set to be enabled; false if it is disabled.
See Also:
GTIngredient.setEnabled(int, boolean)

setOutputEnabled

public void setOutputEnabled(boolean enabled)
Enable or disable the output.

Used as part of the test harness.

Parameters:
enabled - true if the element is set to be enabled; false if it is disabled.
See Also:
GTIngredient.setEnabled(int, boolean)

setPortNameEnabled

public void setPortNameEnabled(boolean enabled)
Enable or disable the port name.

Used as part of the test harness.

Parameters:
enabled - true if the element is set to be enabled; false if it is disabled.
See Also:
GTIngredient.setEnabled(int, boolean)

setPortTypeEnabled

public void setPortTypeEnabled(boolean enabled)
Enable or disable the port type.

Used as part of the test harness.

Parameters:
enabled - true if the element is set to be enabled; false if it is disabled.
See Also:
GTIngredient.setEnabled(int, boolean)

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.

_getUniqueName

private java.lang.String _getUniqueName(GTIngredientList list,
                                        java.lang.String name)
Get a unique name based on the given name within a list.

Parameters:
list - The list.
name - The name to be based on.
Returns:
The unique name within the list.