|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--ptolemy.kernel.util.NamedObj
|
+--ptolemy.kernel.Entity
|
+--ptolemy.kernel.ComponentEntity
|
+--ptolemy.kernel.CompositeEntity
A CompositeEntity is a cluster in a clustered graph. I.e., it is a non-atomic entity, in that it can contain other entities and relations. It supports transparent ports, where, in effect, the port of a contained entity is represented by a port of this entity. Methods that "deeply" traverse the topology see right through transparent ports. It may be opaque, in which case its ports are opaque and methods that "deeply" traverse the topology do not see through them. For instance, deepEntityList() returns the opaque entities directly or indirectly contained by this entity.
To add an entity or relation to this composite, call its setContainer() method with this composite as an argument. To remove it, call its setContainer() method with a null argument (or another container). The entity must be an instance of ComponentEntity and the relation of ComponentRelation or an exception is thrown. Derived classes may further constrain these to subclasses. To do that, they should override the protected methods _addEntity() and _addRelation() and the public member newRelation().
A CompositeEntity may be contained by another CompositeEntity. To set that up, call the setContainer() method of the inside entity. Derived classes may further constrain the container to be a subclass of CompositeEntity. To do this, they should override setContainer() to throw an exception. Recursive containment structures, where an entity directly or indirectly contains itself, are disallowed, and an exception is thrown on an attempt to set up such a structure.
A CompositeEntity can contain instances of ComponentPort. By default these ports will be transparent, although subclasses of CompositeEntity can make them opaque by overriding the isOpaque() method to return true. Derived classes may further constrain the ports to a subclass of ComponentPort. To do this, they should override the public method newPort() to create a port of the appropriate subclass, and the protected method _addPort() to throw an exception if its argument is a port that is not of the appropriate subclass.
| Inner classes inherited from class ptolemy.kernel.util.NamedObj |
NamedObj.MoMLInfo |
| Field Summary | |
protected NamedList |
_containedEntities
|
| Fields inherited from class ptolemy.kernel.util.NamedObj |
_changeListeners, _debugging, _debugListeners, _uniqueNameIndex, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS |
| Constructor Summary | |
CompositeEntity()
Construct an entity in the default workspace with an empty string as its name. |
|
CompositeEntity(CompositeEntity container,
java.lang.String name)
Create an object with a name and a container. |
|
CompositeEntity(Workspace workspace)
Construct an entity in the specified workspace with an empty string as a name. |
|
| Method Summary | |
protected void |
_addEntity(ComponentEntity entity)
Add an entity to this container. |
protected void |
_addRelation(ComponentRelation relation)
Add a relation to this container. |
protected java.lang.String |
_description(int detail,
int indent,
int bracket)
Return a description of the object. |
protected void |
_exportMoMLContents(java.io.Writer output,
int depth)
Write a MoML description of the contents of this object, which in this class are the attributes, ports, contained relations, and contained entities, plus all links. |
protected void |
_removeEntity(ComponentEntity entity)
Remove the specified entity. |
protected void |
_removeRelation(ComponentRelation relation)
Remove the specified relation. |
java.util.List |
allAtomicEntityList()
Return a list that consists of all the atomic entities in a model. |
void |
allowLevelCrossingConnect(boolean boole)
Allow or disallow connections that are created using the connect() method to cross levels of the hierarchy. |
java.lang.Object |
clone(Workspace workspace)
Clone the object into the specified workspace. |
ComponentRelation |
connect(ComponentPort port1,
ComponentPort port2)
Create a new relation and use it to connect two ports. |
ComponentRelation |
connect(ComponentPort port1,
ComponentPort port2,
java.lang.String relationName)
Create a new relation with the specified name and use it to connect two ports. |
java.util.List |
deepEntityList()
List the opaque entities that are directly or indirectly contained by this entity. |
java.util.Enumeration |
deepGetEntities()
Deprecated. Use deepEntityList() instead. |
java.util.List |
entityList()
List the contained entities in the order they were added (using their setContainer() method). |
java.util.List |
entityList(java.lang.Class filter)
Return a list of the component entities contained by this object that are instances of the specified class. |
java.lang.String |
exportLinks(int indentation,
java.util.Collection filter)
Return a sequence of MoML link attributes that describe any link between objects (ports, entities, and relations) that are present in the filter argument. |
Attribute |
getAttribute(java.lang.String name)
Get the attribute with the given name. |
java.util.Enumeration |
getEntities()
Deprecated. Use entityList() instead. |
ComponentEntity |
getEntity(java.lang.String name)
Get a contained entity by name. |
Port |
getPort(java.lang.String name)
Get a contained port by name. |
ComponentRelation |
getRelation(java.lang.String name)
Get a contained relation by name. |
java.util.Enumeration |
getRelations()
Deprecated. Use relationList() instead. |
boolean |
isAtomic()
Return false since CompositeEntities are not atomic. |
boolean |
isOpaque()
Return false. |
ComponentRelation |
newRelation(java.lang.String name)
Create a new relation with the specified name, add it to the relation list, and return it. |
int |
numEntities()
Return the number of contained entities. |
int |
numRelations()
Return the number of contained relations. |
java.util.List |
relationList()
List the relations contained by this entity. |
void |
removeAllEntities()
Remove all contained entities and unlink them from all relations. |
void |
removeAllRelations()
Remove all contained relations and unlink them from everything. |
java.lang.String |
uniqueName(java.lang.String prefix)
Return a name that is guaranteed to not be the name of any contained attribute, port, entity, or relation. |
| Methods inherited from class ptolemy.kernel.ComponentEntity |
_addPort, _checkContainer, getContainer, newPort, setContainer, setName |
| Methods inherited from class ptolemy.kernel.Entity |
_removePort, connectedPortList, connectedPorts, connectionsChanged, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts |
| Methods inherited from class ptolemy.kernel.util.NamedObj |
_addAttribute, _attachText, _debug, _debug, _debug, _debug, _debug, _getIndentPrefix, _removeAttribute, _splitName, addChangeListener, addDebugListener, attributeChanged, attributeList, attributeList, attributeTypeChanged, clone, deepContains, depthInHierarchy, description, description, exportMoML, exportMoML, exportMoML, exportMoML, exportMoML, getAttribute, getAttributes, getFullName, getMoMLInfo, getName, getName, removeChangeListener, removeDebugListener, requestChange, setDeferMoMLDefinitionTo, toplevel, toString, workspace |
| Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
protected NamedList _containedEntities
| Constructor Detail |
public CompositeEntity()
public CompositeEntity(Workspace workspace)
workspace - The workspace that will list the entity.
public CompositeEntity(CompositeEntity container,
java.lang.String name)
throws IllegalActionException,
NameDuplicationException
container - The container entity.name - The name of the entity.IllegalActionException - If the container is incompatible
with this entity.NameDuplicationException - If the name coincides with
an entity already in the container.| Method Detail |
public java.util.List allAtomicEntityList()
public void allowLevelCrossingConnect(boolean boole)
boole - True to allow level-crossing connections.
public java.lang.Object clone(Workspace workspace)
throws java.lang.CloneNotSupportedException
clone in class ComponentEntityworkspace - The workspace for the cloned object.java.lang.CloneNotSupportedException - If the entity contains
level crossing transitions so that its connections cannot be cloned,
or if one of the attributes cannot be cloned.
public ComponentRelation connect(ComponentPort port1,
ComponentPort port2)
throws IllegalActionException
port1 - The first port to connect.port2 - The second port to connect.IllegalActionException - If one of the arguments is null, or
if a disallowed level-crossing connection would result.
public ComponentRelation connect(ComponentPort port1,
ComponentPort port2,
java.lang.String relationName)
throws IllegalActionException,
NameDuplicationException
port1 - The first port to connect.port2 - The second port to connect.relationName - The name of the new relation.IllegalActionException - If one of the arguments is null, or
if a disallowed level-crossing connection would result, or if the two
ports are not in the same workspace as this entity.NameDuplicationException - If there is already a relation with
the specified name in this entity.public java.util.List deepEntityList()
public java.util.Enumeration deepGetEntities()
public java.util.List entityList()
public java.util.List entityList(java.lang.Class filter)
filter - The class of ComponentEntity of interest.
public java.lang.String exportLinks(int indentation,
java.util.Collection filter)
throws java.io.IOException
If the argument is null, then return all the links that this composite is responsible for (i.e., apply no filtering). If the argument is an empty collection, then return none of the links. The links that this entity is responsible for is the inside links of its ports, and links on ports contained by contained entities.
indentation - The depth at which the output should be indented.filter - A collection of ports, parameters, and entities, or
null to apply no filtering.java.io.IOException - If an I/O error occurs.public Attribute getAttribute(java.lang.String name)
getAttribute in class Entityname - The name of the desired attribute.public ComponentEntity getEntity(java.lang.String name)
name - The name of the desired entity.public java.util.Enumeration getEntities()
public Port getPort(java.lang.String name)
getPort in class Entityname - The name of the desired port.public ComponentRelation getRelation(java.lang.String name)
name - The name of the desired relation.public java.util.Enumeration getRelations()
public final boolean isAtomic()
isAtomic in class ComponentEntitypublic boolean isOpaque()
isOpaque in class ComponentEntityCompositeEntity
public ComponentRelation newRelation(java.lang.String name)
throws IllegalActionException,
NameDuplicationException
name - The name of the new relation.IllegalActionException - If name argument is null.NameDuplicationException - If name collides with a name
already in the container.public int numEntities()
public int numRelations()
public java.util.List relationList()
public void removeAllEntities()
public void removeAllRelations()
public java.lang.String uniqueName(java.lang.String prefix)
uniqueName in class Entityprefix - A prefix for the name.
protected void _addEntity(ComponentEntity entity)
throws IllegalActionException,
NameDuplicationException
entity - Entity to contain.IllegalActionException - If the entity has no name, or the
action would result in a recursive containment structure.NameDuplicationException - If the name collides with a name
already in the entity.
protected void _addRelation(ComponentRelation relation)
throws IllegalActionException,
NameDuplicationException
relation - Relation to contain.IllegalActionException - If the relation has no name.NameDuplicationException - If the name collides with a name
already on the contained relations list.
protected java.lang.String _description(int detail,
int indent,
int bracket)
_description in class Entitydetail - The level of detail.indent - The amount of indenting.bracket - The number of surrounding brackets (0, 1, or 2).
protected void _exportMoMLContents(java.io.Writer output,
int depth)
throws java.io.IOException
_exportMoMLContents in class Entityoutput - The output to write to.depth - The depth in the hierarchy, to determine indenting.java.io.IOException - If an I/O error occurs.protected void _removeEntity(ComponentEntity entity)
entity - The entity to remove.protected void _removeRelation(ComponentRelation relation)
relation - The relation to remove.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||