public class ComponentEntity<T extends ComponentPort> extends Entity<T>
Derived classes may further constrain the container to be a subclass of CompositeEntity. To do this, they should override the protected method _checkContainer() to throw an exception.
A ComponentEntity can contain instances of ComponentPort. Derived classes may further constrain 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.
Entity.ContainedObjectsIterator
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
Constructor and Description |
---|
ComponentEntity()
Construct an entity in the default workspace with an empty string
The object is added to the workspace directory.
|
ComponentEntity(CompositeEntity container,
java.lang.String name)
Construct an entity with the given name contained by the specified
entity.
|
ComponentEntity(Workspace workspace)
Construct an entity in the specified workspace with an empty
string as a name.
|
Modifier and Type | Method and Description |
---|---|
protected void |
_adjustDeferrals()
Adjust the deferrals in this object.
|
protected void |
_checkContainer(InstantiableNamedObj container)
Check the specified container.
|
protected NamedObj |
_getContainedObject(NamedObj container,
java.lang.String relativeName)
Get an entity with the specified name in the specified container.
|
protected NamedObj |
_propagateExistence(NamedObj container)
Propagate existence of this object to the
specified object.
|
java.lang.Object |
clone(Workspace workspace)
Clone the object into the specified workspace.
|
NamedObj |
getContainer()
Get the container entity.
|
Instantiable |
instantiate(NamedObj container,
java.lang.String name)
Create an instance by cloning this object and then adjusting
the parent-child relationships between the clone and its parent.
|
boolean |
isAtomic()
Return true if the entity is atomic.
|
boolean |
isOpaque()
Return true if the entity is opaque.
|
int |
moveDown()
Move this object down by one in the list of entities of
its container.
|
int |
moveToFirst()
Move this object to the first position in the list
of entities of the container.
|
int |
moveToIndex(int index)
Move this object to the specified position in the list
of entities of the container.
|
int |
moveToLast()
Move this object to the last position in the list
of entities of the container.
|
int |
moveUp()
Move this object up by one in the list of
entities of the container.
|
Port |
newPort(java.lang.String name)
Create a new port with the specified name.
|
java.util.List |
propagateExistence()
Propagate the existence of this object.
|
void |
setContainer(CompositeEntity container)
Specify the container, adding the entity to the list
of entities in the container.
|
void |
setName(java.lang.String name)
Set the name of the ComponentEntity.
|
_addPort, _description, _exportMoMLContents, _removePort, _validateSettables, connectedPortList, connectedPorts, connectionsChanged, containedObjectsIterator, getAttribute, getPort, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts, setClassDefinition, uniqueName
_setParent, exportMoML, getChildren, getElementName, getParent, getPrototypeList, isClassDefinition, isWithinClassDefinition
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _containedDecorators, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _executeChangeRequests, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _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, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getDisplayName, getFullName, getModelErrorHandler, getName, getName, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, notifyOfNameChange, propagateValue, propagateValues, removeAttribute, removeChangeListener, removeDebugListener, removeHierarchyListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, validateSettables, workspace
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getDerivedLevel, getDerivedList, propagateValue
description, getDisplayName, getFullName, getName, getName
public ComponentEntity()
public ComponentEntity(Workspace workspace)
workspace
- The workspace that will list the entity.public ComponentEntity(CompositeEntity container, java.lang.String name) throws IllegalActionException, NameDuplicationException
container
- The container entity.name
- The name of the entity.IllegalActionException
- If the entity cannot be contained
by the proposed container.NameDuplicationException
- If the name coincides with
an entity already in the container.public java.lang.Object clone(Workspace workspace) throws java.lang.CloneNotSupportedException
clone
in class Entity<T extends ComponentPort>
workspace
- The workspace for the cloned object.java.lang.CloneNotSupportedException
- If one of the attributes
cannot be cloned.NamedObj.exportMoML(Writer, int, String)
,
NamedObj.setDeferringChangeRequests(boolean)
public NamedObj getContainer()
getContainer
in interface Nameable
getContainer
in class NamedObj
setContainer(CompositeEntity)
public Instantiable instantiate(NamedObj container, java.lang.String name) throws java.lang.CloneNotSupportedException, IllegalActionException, NameDuplicationException
The new object is not a class definition (it is by default an "instance" rather than a "class"). To make it a class definition (a "subclass"), call setClassDefinition(true).
This method overrides the base class to use setContainer() to specify the container.
instantiate
in interface Instantiable
instantiate
in class InstantiableNamedObj
container
- The container for the instance, or null
to instantiate it at the top level.name
- The name for the clone.java.lang.CloneNotSupportedException
- If this object
cannot be cloned.IllegalActionException
- If this object is not a
class definition
or the proposed container is not acceptable.NameDuplicationException
- If the name collides with
an object already in the container.Entity.setClassDefinition(boolean)
public boolean isAtomic()
CompositeEntity
public boolean isOpaque()
CompositeEntity
public int moveDown() throws IllegalActionException
moveDown
in interface Moveable
moveDown
in class NamedObj
IllegalActionException
- If this object has
no container.public int moveToFirst() throws IllegalActionException
moveToFirst
in interface Moveable
moveToFirst
in class NamedObj
IllegalActionException
- If this object has
no container.public int moveToIndex(int index) throws IllegalActionException
moveToIndex
in interface Moveable
moveToIndex
in class NamedObj
index
- The position to move this object to.IllegalActionException
- If this object has
no container or if the index is out of bounds.public int moveToLast() throws IllegalActionException
moveToLast
in interface Moveable
moveToLast
in class NamedObj
IllegalActionException
- If this object has
no container.public int moveUp() throws IllegalActionException
moveUp
in interface Moveable
moveUp
in class NamedObj
IllegalActionException
- If this object has
no container.public Port newPort(java.lang.String name) throws IllegalActionException, NameDuplicationException
newPort
in class Entity<T extends ComponentPort>
name
- The new port name.IllegalActionException
- If the argument is null.NameDuplicationException
- If this entity already has a
port with the specified name.public java.util.List propagateExistence() throws IllegalActionException
propagateExistence
in interface Derivable
propagateExistence
in class NamedObj
IllegalActionException
- If the object does
not exists and cannot be created.Derivable
,
NamedObj.setDerivedLevel(int)
public void setContainer(CompositeEntity container) throws IllegalActionException, NameDuplicationException
Note that for entities that are created by parsing MoML, it may be necessary to call MoMLParser.purgeModelRecord(). This is especially critical when the MoML file imports MoML classes. See Effigy.setContainer() for details.
Derived classes may further constrain the container to subclasses of CompositeEntity by overriding the protected method _checkContainer(). This method validates all deeply contained instances of Settable, since they may no longer be valid in the new context. This method is write-synchronized to the workspace and increments its version number.
container
- The proposed container.IllegalActionException
- If the action would result in a
recursive containment structure, or if
this entity and container are not in the same workspace, or
if the protected method _checkContainer() throws it, or if
a contained Settable becomes invalid and the error handler
throws it.NameDuplicationException
- If the name of this entity
collides with a name already in the container.getContainer()
public void setName(java.lang.String name) throws IllegalActionException, NameDuplicationException
setName
in interface Nameable
setName
in class NamedObj
name
- The new name.IllegalActionException
- If the name has a period.NameDuplicationException
- If there already is an entity
in the container with the same name.NamedObj.getName()
,
NamedObj.getName(NamedObj)
protected void _adjustDeferrals() throws IllegalActionException
Derived classes that contain other objects should recursively call this method on contained objects.
IllegalActionException
- If the class found in scope
cannot be set.protected void _checkContainer(InstantiableNamedObj container) throws IllegalActionException
container
- The proposed container.IllegalActionException
- If the container is not an
instance of CompositeEntity, or if the proposed container is
null and there are other objects that defer their definitions
to this one.protected NamedObj _getContainedObject(NamedObj container, java.lang.String relativeName) throws IllegalActionException
_getContainedObject
in class NamedObj
relativeName
- The name relative to the container.container
- The container expected to contain the object, which
must be an instance of CompositeEntity.IllegalActionException
- If the object exists
and has the wrong class, or if the specified container is not
an instance of CompositeEntity.protected NamedObj _propagateExistence(NamedObj container) throws IllegalActionException
_propagateExistence
in class NamedObj
container
- Object to contain the new object.IllegalActionException
- If the object
cannot be cloned.