public class Entity<T extends Port> extends InstantiableNamedObj
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).
Modifier and Type | Class and Description |
---|---|
protected class |
Entity.ContainedObjectsIterator
This class is an iterator over all the contained objects
(all instances of NamedObj).
|
Modifier and Type | Field and Description |
---|---|
(package private) NamedList |
_portList
A list of Ports owned by this Entity.
|
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
Constructor and Description |
---|
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.
|
Modifier and Type | Method and Description |
---|---|
protected void |
_addPort(T 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<T> |
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<T> |
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.
|
_setParent, exportMoML, getChildren, getElementName, getParent, getPrototypeList, instantiate, isClassDefinition, isWithinClassDefinition
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _containedDecorators, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _executeChangeRequests, _getContainedObject, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _propagateExistence, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, addHierarchyListener, attributeChanged, attributeDeleted, attributeList, attributeList, attributeTypeChanged, clone, decorators, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttributes, getChangeListeners, getClassName, getContainer, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getDisplayName, getFullName, getModelErrorHandler, getName, getName, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, notifyOfNameChange, propagateExistence, propagateValue, propagateValues, removeAttribute, removeChangeListener, removeDebugListener, removeHierarchyListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setName, setPersistent, setSource, sortContainedObjects, toplevel, toString, validateSettables, workspace
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getDerivedLevel, getDerivedList, propagateExistence, propagateValue
description, getContainer, getDisplayName, getFullName, getName, getName, setName
NamedList _portList
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.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<T> connectedPortList()
@Deprecated 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.@Deprecated public java.util.Enumeration getPorts()
public java.util.List linkedRelationList()
@Deprecated 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<T> 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(T 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
- If there is a problem
accessing subcomponents of this object.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)