|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectptolemy.kernel.util.NamedObj
ptolemy.kernel.InstantiableNamedObj
ptolemy.kernel.Entity
public class Entity
An Entity is a vertex in a generalized graph. It is an aggregation of ports. The ports can be linked to relations. The relations thus represent connections between ports, and hence, connections between entities. To add a port to an entity, simply set its container to the entity. To remove it, set its container to null, or to some other entity.
Entities are intended for flat graphs. Derived classes support hierarchy (clustered graphs) by defining entities that aggregate other entities.
An Entity can contain any instance of Port. Derived classes may wish to constrain to a subclass of Port. To do this, subclasses 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.
An Entity is created within a workspace. If the workspace is not specified as a constructor argument, then the default workspace is used. The workspace is used to synchronize simultaneous accesses to a topology from multiple threads. The workspace is immutable (it cannot be changed during the lifetime of the Entity).
Port
,
Relation
,
Serialized Form
Green (johnr) |
Green (eal) |
Nested Class Summary | |
---|---|
protected class |
Entity.ContainedObjectsIterator
This class is an iterator over all the contained objects (all instances of NamedObj). |
Field Summary | |
---|---|
private java.util.LinkedList |
_connectedPorts
|
private long |
_connectedPortsVersion
|
private java.util.LinkedList |
_linkedRelations
|
private long |
_linkedRelationsVersion
|
(package private) NamedList |
_portList
A list of Ports owned by this Entity. |
Fields inherited from class ptolemy.kernel.util.NamedObj |
---|
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS |
Constructor Summary | |
---|---|
Entity()
Construct an entity in the default workspace with an empty string as its name. |
|
Entity(java.lang.String name)
Construct an entity in the default workspace with the given name. |
|
Entity(Workspace workspace)
Construct an entity in the given workspace with an empty string as a name. |
|
Entity(Workspace workspace,
java.lang.String name)
Construct an entity in the given workspace with the given name. |
Method Summary | |
---|---|
protected void |
_addPort(Port port)
Add a port to this entity. |
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 plus the ports. |
protected void |
_removePort(Port port)
Remove the specified port. |
protected void |
_validateSettables(java.util.Collection attributesValidated)
Validate attributes deeply contained by this object if they implement the Settable interface by calling their validate() method. |
java.lang.Object |
clone(Workspace workspace)
Clone the object into the specified workspace. |
java.util.List |
connectedPortList()
Return a list of the ports that are connected to contained ports. |
java.util.Enumeration |
connectedPorts()
Deprecated. Use connectedPortList() instead. |
void |
connectionsChanged(Port port)
Notify this entity that the links to the specified port have been altered. |
java.util.Iterator |
containedObjectsIterator()
Return an iterator over contained objects. |
Attribute |
getAttribute(java.lang.String name)
Get the attribute with the given name. |
Port |
getPort(java.lang.String name)
Return the port contained by this entity that has the specified name. |
java.util.Enumeration |
getPorts()
Deprecated. Use portList() instead. |
java.util.List |
linkedRelationList()
Get all relations that are linked to ports contained by this entity. |
java.util.Enumeration |
linkedRelations()
Deprecated. Use linkedRelationList() instead. |
Port |
newPort(java.lang.String name)
Create a new port with the specified name. |
java.util.List |
portList()
Get the ports belonging to this entity. |
void |
removeAllPorts()
Remove all ports by setting their container to null. |
void |
setClassDefinition(boolean isClass)
Specify whether this object is a class definition. |
java.lang.String |
uniqueName(java.lang.String prefix)
Return a name that is guaranteed to not be the name of any contained attribute or port. |
Methods inherited from class ptolemy.kernel.InstantiableNamedObj |
---|
_setParent, exportMoML, getChildren, getElementName, getParent, getPrototypeList, instantiate, isClassDefinition, isWithinClassDefinition |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface ptolemy.kernel.util.Derivable |
---|
getDerivedLevel, getDerivedList, propagateExistence, propagateValue |
Methods inherited from interface ptolemy.kernel.util.Nameable |
---|
description, getContainer, getDisplayName, getFullName, getName, getName, setName |
Field Detail |
---|
NamedList _portList
private transient java.util.LinkedList _connectedPorts
private transient long _connectedPortsVersion
private transient java.util.LinkedList _linkedRelations
private transient long _linkedRelationsVersion
Constructor Detail |
---|
public Entity()
public Entity(java.lang.String name) throws IllegalActionException
name
- The name of this object.
IllegalActionException
- If the name has a period.public Entity(Workspace workspace)
workspace
- The workspace for synchronization and version tracking.public Entity(Workspace workspace, java.lang.String name) throws IllegalActionException
workspace
- The workspace for synchronization and version tracking.name
- The name of this object.
IllegalActionException
- If the name has a period.Method Detail |
---|
public java.lang.Object clone(Workspace workspace) throws java.lang.CloneNotSupportedException
clone
in class InstantiableNamedObj
workspace
- The workspace for the cloned object.
java.lang.CloneNotSupportedException
- If cloned ports cannot have
as their container the cloned entity (this should not occur), or
if one of the attributes cannot be cloned.NamedObj.exportMoML(Writer, int, String)
,
NamedObj.setDeferringChangeRequests(boolean)
public java.util.List connectedPortList()
public java.util.Enumeration connectedPorts()
public void connectionsChanged(Port port)
port
- The port to which connections have changed.public java.util.Iterator containedObjectsIterator()
containedObjectsIterator
in class NamedObj
public Attribute getAttribute(java.lang.String name)
getAttribute
in class NamedObj
name
- The name of the desired attribute.
public Port getPort(java.lang.String name)
name
- The name of the desired port.
public java.util.Enumeration getPorts()
public java.util.List linkedRelationList()
public java.util.Enumeration linkedRelations()
public Port newPort(java.lang.String name) throws IllegalActionException, NameDuplicationException
name
- The name to assign to the newly created port.
IllegalActionException
- If the port created is not
of an acceptable class (this is a programming
error; failed to override this method in derived classes).
NameDuplicationException
- If the entity already has a port
with the specified name.public java.util.List portList()
public void removeAllPorts()
public void setClassDefinition(boolean isClass) throws IllegalActionException
setClassDefinition
in class InstantiableNamedObj
isClass
- True to make this object a class definition.
IllegalActionException
- If the argument is true and
this entity contains ports with links.InstantiableNamedObj.isClassDefinition()
,
Instantiable
public java.lang.String uniqueName(java.lang.String prefix)
uniqueName
in class NamedObj
prefix
- A prefix for the name.
protected void _addPort(Port port) throws IllegalActionException, NameDuplicationException
port
- The port to add to this entity.
IllegalActionException
- If the port has no name.
NameDuplicationException
- If the port name collides with a
name already in the entity.protected java.lang.String _description(int detail, int indent, int bracket) throws IllegalActionException
_description
in class NamedObj
detail
- The level of detail.indent
- The amount of indenting.bracket
- The number of surrounding brackets (0, 1, or 2).
IllegalActionException
protected void _exportMoMLContents(java.io.Writer output, int depth) throws java.io.IOException
_exportMoMLContents
in class NamedObj
output
- The output to write to.depth
- The depth in the hierarchy, to determine indenting.
java.io.IOException
- If an I/O error occurs.NamedObj.exportMoML(Writer, int)
protected void _removePort(Port port)
port
- The port being removed from this entity.protected void _validateSettables(java.util.Collection attributesValidated) throws IllegalActionException
_validateSettables
in class NamedObj
attributesValidated
- A HashSet of Attributes that have
already been validated. For example, Settables that implement
the SharedSettable interface are validated only once.
IllegalActionException
- If the superclass throws it
or if handleModelError() throws it.NamedObj.handleModelError(NamedObj context, IllegalActionException exception)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |