Class OntologyAdapter
- java.lang.Object
-
- ptolemy.data.ontologies.OntologyAdapter
-
- Direct Known Subclasses:
LatticeOntologyAdapter
public abstract class OntologyAdapter extends java.lang.Object
Constraints for a component in the model.The model component can be an object of any Ptolemy class (e.g. ASTPtRootNode, Sink, Entity, and FSMActor). A model component, in turn, may have one or multiple property-able objects. Each constraint is relevant to a property-able object. For example, the PropertyAdapter associated with an actor may have each of its IOPorts as property-able.
A property-able object is an object that can be annotated with a Property object. Users can define different Property classes as part of their use-case definition.
Every PropertyAdapter is associated a property solver. PropertyAdapters support hierarchical structuring. They may have downward links to sub-adapters. This is helpful to construct PropertyAdapter for hierarchical component in the model. For example, a PropertyAdapter for the CompositeActor have all the contained actors' adapters as its sub-adapters.
A PropertyAdapter supports manual annotation. Users can define their own annotation evaluator to evaluate property expressions and/or constraints.
- Since:
- Ptolemy II 10.0
- Version:
- $Id$
- Author:
- Man-Kit Leung
- Pt.AcceptedRating:
- Red (mankit)
- Pt.ProposedRating:
- Red (mankit)
-
-
Field Summary
Fields Modifier and Type Field Description protected ParseTreeAnnotationEvaluator
_annotationEvaluator
The annotation evaluator.protected OntologySolver
_solver
The associated ontology solver.
-
Constructor Summary
Constructors Constructor Description OntologyAdapter()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract ParseTreeAnnotationEvaluator
_annotationEvaluator()
Create a new ParseTreeAnnotationEvaluator that is tailored for the ontology.protected java.util.List<OntologyAdapter>
_getASTNodeAdapters()
Return the list of PropertyAdapters for ASTPtRootNodes.protected java.util.List<ASTPtRootNode>
_getAttributeParseTrees()
Return the list of parse trees for all settable Attributes of the component.protected java.util.List<Attribute>
_getPropertyableAttributes()
Return the list of property-able Attributes.protected static java.util.List<IOPort>
_getSinkPortList(IOPort port)
Return the list of receiving (down-stream) ports that are connected to the specified port.protected static java.util.List<IOPort>
_getSourcePortList(IOPort port)
Return the list of sending (up-stream) ports that are connected to the specified port.protected java.util.List<OntologyAdapter>
_getSubAdapters()
Return the list of sub-adapters.java.lang.Object
getComponent()
Return the associated component object.Entity
getContainerEntity(ASTPtRootNode node)
Return the container entity for the specified ASTPtRootNode.java.lang.String
getName()
Return the name of the PropertyAdapter.protected ASTPtRootNode
getParseTree(Attribute attribute)
Return the ASTPtRootNode for the specified Attribute.java.util.List<java.lang.Object>
getPropertyables()
Return a list of property-able NamedObj contained by the component.OntologySolver
getSolver()
Return The PropertySolver that uses this adapter.protected void
putAttribute(ASTPtRootNode node, Attribute attribute)
Record the association between the specified ASTPtRootNode and the specified Attribute.void
reinitialize()
Reset and initialize the PropertyAdapter.void
setComponent(java.lang.Object component)
Associate this PropertyAdapter with the specified component.void
setEquals(java.lang.Object object, Concept property)
Set the property of specified object equal to the specified property.java.lang.String
toString()
Return the string representation of the PropertyAdapter.
-
-
-
Field Detail
-
_annotationEvaluator
protected ParseTreeAnnotationEvaluator _annotationEvaluator
The annotation evaluator.
-
_solver
protected OntologySolver _solver
The associated ontology solver.
-
-
Method Detail
-
getComponent
public java.lang.Object getComponent()
Return the associated component object.- Returns:
- The associated component.
- See Also:
setComponent(java.lang.Object)
-
getContainerEntity
public Entity getContainerEntity(ASTPtRootNode node)
Return the container entity for the specified ASTPtRootNode.- Parameters:
node
- The specified ASTPtRootNode.- Returns:
- The container entity for the specified ASTPtRootNode.
-
getName
public java.lang.String getName()
Return the name of the PropertyAdapter. In this base class, return the concatenation of the prefix "Adapter_" and the string representation of the component object. This method does not guarantee uniqueness.- Returns:
- The name of the PropertyAdapter.
-
getPropertyables
public java.util.List<java.lang.Object> getPropertyables()
Return a list of property-able NamedObj contained by the component. All ports and parameters are considered property-able.- Returns:
- The list of property-able named object.
-
getSolver
public OntologySolver getSolver()
Return The PropertySolver that uses this adapter.- Returns:
- The PropertySolver that uses this adapter.
-
reinitialize
public void reinitialize() throws IllegalActionException
Reset and initialize the PropertyAdapter. This clears any cached states and the resolved properties of the property-able objects. This call is recursive, so every sub-adapter will be reset and initialized after the call.- Throws:
IllegalActionException
- Thrown ifgetPropertyables()
throws it.
-
setComponent
public void setComponent(java.lang.Object component)
Associate this PropertyAdapter with the specified component.- Parameters:
component
- The specified component.- See Also:
getComponent()
-
setEquals
public void setEquals(java.lang.Object object, Concept property)
Set the property of specified object equal to the specified property.- Parameters:
object
- The specified object.property
- The specified property.
-
toString
public java.lang.String toString()
Return the string representation of the PropertyAdapter.- Overrides:
toString
in classjava.lang.Object
- Returns:
- The string representation of the PropertyAdapter.
-
_annotationEvaluator
protected abstract ParseTreeAnnotationEvaluator _annotationEvaluator()
Create a new ParseTreeAnnotationEvaluator that is tailored for the ontology. This class parses the user-defined ontology annotations in the model containing the OntologySolver.- Returns:
- A new ParseTreeAnnotationEvaluator.
-
_getASTNodeAdapters
protected java.util.List<OntologyAdapter> _getASTNodeAdapters() throws IllegalActionException
Return the list of PropertyAdapters for ASTPtRootNodes. These ASTPtRootNodes are nodes of the parse tree constructed from parsing the expression of every property-able Attribute.- Returns:
- The list of PropertyAdapters for ASTPtRootNodes.
- Throws:
IllegalActionException
- If the AST expression is not parseable
-
_getAttributeParseTrees
protected java.util.List<ASTPtRootNode> _getAttributeParseTrees() throws IllegalActionException
Return the list of parse trees for all settable Attributes of the component.- Returns:
- The list of ASTPtRootNodes.
- Throws:
IllegalActionException
- Thrown if there is a problem getting the parse trees for the attributes.
-
_getPropertyableAttributes
protected java.util.List<Attribute> _getPropertyableAttributes()
Return the list of property-able Attributes. A property-able Attribute is a StringAttribute with the name "guardTransition", a StringAttribute in an Expression actor, a StringAttribute with the name "expression" or a Variable with full visibility. However, Variables with certain names are excluded.- Returns:
- The list of property-able Attributes.
-
_getSinkPortList
protected static java.util.List<IOPort> _getSinkPortList(IOPort port)
Return the list of receiving (down-stream) ports that are connected to the specified port. This treats every port as an opaque port.- Parameters:
port
- The specified port.- Returns:
- The list of receiving ports.
-
_getSourcePortList
protected static java.util.List<IOPort> _getSourcePortList(IOPort port)
Return the list of sending (up-stream) ports that are connected to the specified port. This treats every port as an opaque port.- Parameters:
port
- The specified port.- Returns:
- The list of sending ports.
-
_getSubAdapters
protected java.util.List<OntologyAdapter> _getSubAdapters() throws IllegalActionException
Return the list of sub-adapters. By default, this returns the list of ASTNode adapters that are associated with the expressions of the propertyable attributes.- Returns:
- The list of sub-adapters.
- Throws:
IllegalActionException
- Not thrown in this base class.
-
getParseTree
protected ASTPtRootNode getParseTree(Attribute attribute) throws IllegalActionException
Return the ASTPtRootNode for the specified Attribute.- Parameters:
attribute
- The specified attribute.- Returns:
- The ASTPtRootNode for the specified Attribute.
- Throws:
IllegalActionException
- Thrown ifOntologySolverBase.getParseTree(Attribute)
throws it.
-
putAttribute
protected void putAttribute(ASTPtRootNode node, Attribute attribute)
Record the association between the specified ASTPtRootNode and the specified Attribute.- Parameters:
node
- The specified ASTPtRootNode.attribute
- The specified Attribute.
-
-