public class Relation extends NamedObj
Relations can also be linked to other Relations. To create such a link, use the link() method of this class. To remove such a link, use the unlink() method. A group of linked relations behaves exactly as if it were one relation directly linked to all the ports linked to by each relation. In particular, the connectedPortList() method of the Port class returns the same list whether a single relation is used or a relation group. The order in which the ports are listed is the order in which links were made between the port and relations in the relation group. It is not relevant which relation in a relation group the port links to.
Derived classes may wish to disallow links under certain circumstances, for example if the proposed port is not an instance of an appropriate subclass of Port, or if the relation cannot support any more links. Such derived classes should override the protected method _checkPort() or _checkRelation() to throw an exception.
NamedObj.ContainedObjectsIterator
Modifier and Type | Field and Description |
---|---|
protected CrossRefList |
_linkList
The list of Ports and Relations that are linked to this Relation.
|
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
Constructor and Description |
---|
Relation()
Construct a relation in the default workspace with an empty string
as its name.
|
Relation(java.lang.String name)
Construct a relation in the default workspace with the given name.
|
Relation(Workspace workspace)
Construct a relation in the given workspace with an empty string
as a name.
|
Relation(Workspace workspace,
java.lang.String name)
Construct a relation in the given workspace with the given name.
|
Modifier and Type | Method and Description |
---|---|
protected void |
_checkPort(Port port)
Throw an exception if the specified port cannot be linked to this
relation.
|
protected void |
_checkRelation(Relation relation,
boolean symmetric)
Check that this relation is compatible with the specified relation.
|
protected java.lang.String |
_description(int detail,
int indent,
int bracket)
Return a description of the object.
|
protected NamedObj |
_getContainedObject(NamedObj container,
java.lang.String relativeName)
Get a relation with the specified name in the specified container.
|
java.lang.Object |
clone(Workspace workspace)
Clone the object into the specified workspace.
|
void |
link(Relation relation)
Link this relation with another relation.
|
java.util.List |
linkedObjectsList()
Return a list of the objects directly linked to this
relation (ports and relations).
|
java.util.List |
linkedPortList()
List the ports linked to any relation in this relation's
group.
|
java.util.List |
linkedPortList(Port except)
List the ports linked to any relation in this relation's
group except the specified port.
|
java.util.Enumeration |
linkedPorts()
Deprecated.
Use linkedPortList() instead.
|
java.util.Enumeration |
linkedPorts(Port except)
Deprecated.
Use linkedPortList(Port) instead.
|
int |
numLinks()
Return the number of links to ports, either directly
or indirectly via other relations in the relation
group.
|
java.util.List |
relationGroupList()
Return the list of relations in the relation group containing
this relation.
|
void |
unlink(Relation relation)
Unlink the specified Relation.
|
void |
unlinkAll()
Unlink all ports and relations that are directly linked
to this relation.
|
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _containedDecorators, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _executeChangeRequests, _exportMoMLContents, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _propagateExistence, _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, getContainer, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getDisplayName, getElementName, getFullName, getModelErrorHandler, getName, getName, getPrototypeList, 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, uniqueName, validateSettables, workspace
protected CrossRefList _linkList
public Relation()
public Relation(java.lang.String name) throws IllegalActionException
name
- Name of this object.IllegalActionException
- If the name has a period.public Relation(Workspace workspace)
workspace
- The workspace for synchronization and version tracking.public Relation(Workspace workspace, java.lang.String name) throws IllegalActionException
workspace
- Workspace for synchronization and version trackingname
- 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 NamedObj
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 void link(Relation relation) throws IllegalActionException
relation
- The relation to link to this relation.IllegalActionException
- If the link would cross levels of
the hierarchy, or the relation is incompatible,
or this relation has no container, or this relation is not in the
same workspace as the relation.public java.util.List linkedObjectsList()
public java.util.List linkedPortList()
public java.util.List linkedPortList(Port except)
except
- Port to exclude from the list.@Deprecated public java.util.Enumeration linkedPorts()
@Deprecated public java.util.Enumeration linkedPorts(Port except)
except
- Port to exclude from the enumeration.public int numLinks()
linkedPortList()
public java.util.List relationGroupList()
public void unlink(Relation relation)
relation
- The relation to unlink.public void unlinkAll()
protected void _checkPort(Port port) throws IllegalActionException
port
- The port to link to.IllegalActionException
- Not thrown in this base class.protected void _checkRelation(Relation relation, boolean symmetric) throws IllegalActionException
relation
- The relation to link to.symmetric
- If true, the call _checkRelation on the specified
relation with this as an argument.IllegalActionException
- If this relation has no container,
or if this relation is not an acceptable relation for the specified
relation.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 thrown while getting the
description of subcomponents.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.