public class ComponentRelation extends Relation
Derived classes may wish to further constrain linked ports to a subclass of ComponentPort, or to disallow links under other circumstances, for example if the relation cannot support any more links. Such derived classes should override the protected method _checkPort() to throw an exception.
To link a ComponentPort to a ComponentRelation, use the link() or liberalLink() method in the ComponentPort class. To remove a link, use the unlink() method.
The container for instances of this class can only be instances of ComponentEntity. Derived classes may wish to further constrain the container to subclasses of ComponentEntity. To do this, they should override the protected _checkContainer() method.
Green (johnr) |
Green (eal) |
NamedObj.ContainedObjectsIterator
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
Constructor and Description |
---|
ComponentRelation()
Construct a relation in the default workspace with an empty string
as its name.
|
ComponentRelation(CompositeEntity container,
java.lang.String name)
Construct a relation with the given name contained by the specified
entity.
|
ComponentRelation(Workspace workspace)
Construct a relation in the specified workspace with an empty
string as a name.
|
Modifier and Type | Method and Description |
---|---|
protected void |
_checkContainer(CompositeEntity container)
Check that the specified container is of a suitable class for
this relation.
|
protected void |
_checkPort(Port port)
Throw an exception if the specified port cannot be linked to this
relation (is not of class ComponentPort).
|
protected void |
_checkRelation(Relation relation,
boolean symmetric)
Throw an exception if the specified relation is not an instance
of ComponentRelation.
|
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.
|
java.util.List |
deepLinkedPortList()
Deeply list the ports linked to this relation.
|
java.util.Enumeration |
deepLinkedPorts()
Deprecated.
Use deepLinkedPortList() instead.
|
NamedObj |
getContainer()
Get the container entity.
|
int |
moveDown()
Move this object down by one in the list of relations of
its container.
|
int |
moveToFirst()
Move this object to the first position in the list
of relations of the container.
|
int |
moveToIndex(int index)
Move this object to the specified position in the list
of relations of the container.
|
int |
moveToLast()
Move this object to the last position in the list
of relations of the container.
|
int |
moveUp()
Move this object up by one in the list of
relations of the container.
|
void |
setContainer(CompositeEntity container)
Specify the container entity, adding the relation to the list
of relations in the container.
|
void |
setName(java.lang.String name)
Set the name of the ComponentRelation.
|
void |
unlinkAll()
Override the base class to break inside links on ports as well
as outside lists.
|
_description, _getContainedObject, link, linkedObjectsList, linkedPortList, linkedPortList, linkedPorts, linkedPorts, numLinks, relationGroupList, unlink
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _containedDecorators, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _executeChangeRequests, _exportMoMLContents, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, _validateSettables, addChangeListener, addDebugListener, addHierarchyListener, attributeChanged, attributeDeleted, attributeList, attributeList, attributeTypeChanged, clone, containedObjectsIterator, decorators, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttribute, getAttributes, getChangeListeners, getClassName, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getDisplayName, getElementName, getFullName, getModelErrorHandler, getName, getName, getPrototypeList, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, notifyOfNameChange, propagateExistence, propagateValue, propagateValues, removeAttribute, removeChangeListener, removeDebugListener, removeHierarchyListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, uniqueName, validateSettables, workspace
public ComponentRelation()
public ComponentRelation(Workspace workspace)
workspace
- The workspace that will list the relation.public ComponentRelation(CompositeEntity container, java.lang.String name) throws IllegalActionException, NameDuplicationException
container
- The container.name
- The name of the relation.IllegalActionException
- If the container is incompatible
with this relation.NameDuplicationException
- If the name coincides with
a relation already in the container.public java.lang.Object clone(Workspace workspace) throws java.lang.CloneNotSupportedException
clone
in class Relation
workspace
- The workspace for the cloned object.java.lang.CloneNotSupportedException
- If one or more of the attributes
cannot be cloned.NamedObj.exportMoML(Writer, int, String)
,
NamedObj.setDeferringChangeRequests(boolean)
public java.util.List deepLinkedPortList()
@Deprecated public java.util.Enumeration deepLinkedPorts()
public NamedObj getContainer()
getContainer
in interface Nameable
getContainer
in class NamedObj
setContainer(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 void setContainer(CompositeEntity container) throws IllegalActionException, NameDuplicationException
container
- The proposed container.IllegalActionException
- If this entity and the container
are not in the same workspace, or if
a contained Settable becomes invalid and the error handler
throws it.NameDuplicationException
- If the name collides with a name
already on the contents list of 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 is already a relation
with the same name in the container.NamedObj.getName()
,
NamedObj.getName(NamedObj)
public void unlinkAll()
protected void _checkContainer(CompositeEntity container) throws IllegalActionException
container
- The proposed container.IllegalActionException
- If the container is not of
an acceptable class. Not thrown in this base class.protected void _checkPort(Port port) throws IllegalActionException
_checkPort
in class Relation
port
- The port to link to.IllegalActionException
- If the port is not a ComponentPort.protected void _checkRelation(Relation relation, boolean symmetric) throws IllegalActionException
_checkRelation
in class Relation
relation
- The relation to link to.symmetric
- If true, the call _checkRelation on the specified
relation with this as an argument.IllegalActionException
- If this port has no container,
or if this port is not an acceptable port for the specified
relation.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.