public class ComponentPort extends Port
A ComponentPort may be transparent or opaque. If it is transparent, then "deep" accesses of the topology see through the port. Methods that read the topology come in two versions, shallow and deep. The deep versions pass through transparent ports. This is done with a simple rule. If a transparent port is encountered from inside, then the traversal continues with its outside links. If it is encountered from outside, then the traversal continues with its inside links. A ComponentPort is opaque if its container is opaque. (its isOpaque() method returns true). Derived classes may use other strategies to specify whether a port is opaque.
Normally, links to a transparent port from the outside are to relations contained by the container of the container of the port. Links from the inside are to relations contained by the container of the port. That is, levels of the hierarchy are not crossed. For a few applications, links that cross levels of the hierarchy are needed. The links in these connections are created using the liberalLink() method. The link() method prohibits such links, throwing an exception if they are attempted (most applications will prohibit level-crossing connections by using only the link() method).
A ComponentPort can link to any instance of ComponentRelation. An attempt to link to an instance of Relation will trigger an exception. Derived classes may wish to further constrain links to a subclass of ComponentRelation. To do this, subclasses should override the protected methods _checkLink() and _checkLiberalLink() to throw an exception if their arguments are relations that are not of the appropriate subclass. Similarly, a ComponentPort can only be contained by a ComponentEntity, and an attempt to set the container to an instance of Entity will trigger an exception. If a subclass wishes to constrain the containers of the port to be of a subclass of ComponentEntity, they should override _checkContainer().
NamedObj.ContainedObjectsIterator
_insideLinks, _relationsList
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
Constructor and Description |
---|
ComponentPort()
Construct a port in the default workspace with an empty string
as its name.
|
ComponentPort(ComponentEntity container,
java.lang.String name)
Construct a port with the given name contained by the specified
entity.
|
ComponentPort(Workspace workspace)
Construct a port in the specified workspace with an empty
string as a name.
|
Modifier and Type | Method and Description |
---|---|
protected void |
_checkContainer(Entity container)
Override the base class to ensure that the proposed container is a
ComponentEntity.
|
protected void |
_checkLiberalLink(Relation relation)
Check the validity of a link.
|
protected void |
_checkLink(Relation relation)
Override the base class to throw an exception if the relation is
not a ComponentRelation, or if the container of the port or
relation is null, or if the container of this port is a class
definition and the link is not an inside link.
|
protected java.util.List |
_deepConnectedPortList(java.util.LinkedList path)
Deeply list the opaque ports connected to this port on the outside.
|
protected java.util.Enumeration |
_deepConnectedPorts(java.util.LinkedList path)
Deprecated.
Use _deepConnectedPortList() instead.
|
protected java.util.List |
_deepInsidePortList(java.util.LinkedList path)
If this port is transparent, then deeply list the ports
connected on the inside.
|
protected java.util.Enumeration |
_deepInsidePorts(java.util.LinkedList path)
Deprecated.
Use _deepInsidePortList() instead.
|
protected java.lang.String |
_description(int detail,
int indent,
int bracket)
Return a description of the object.
|
protected boolean |
_isInsideLinkable(Nameable entity)
Return true if this port is either a port of the specified entity,
or a port of an entity that (deeply) contains the specified entity.
|
java.lang.Object |
clone(Workspace workspace)
Clone the object into the specified workspace.
|
java.util.List |
deepConnectedPortList()
Deeply list the ports connected to this port on the outside.
|
java.util.Enumeration |
deepConnectedPorts()
Deprecated.
Use deepConnectedPortList() instead.
|
java.util.List |
deepInsidePortList()
Deeply list the ports connected on the inside.
|
java.util.Enumeration |
deepInsidePorts()
Deprecated.
Use deepInsidePortList() instead.
|
void |
insertInsideLink(int index,
Relation relation)
Insert a link to the specified relation at the specified index,
and notify the container by calling its connectionsChanged() method.
|
void |
insertLink(int index,
Relation relation)
Insert a link to the specified relation at the specified index,
and notify the container by calling its connectionsChanged() method.
|
java.util.List |
insidePortList()
List the ports connected on the inside to this port.
|
java.util.Enumeration |
insidePorts()
Deprecated.
Use insidePortList() instead.
|
java.util.List |
insideRelationList()
List the relations linked on the inside to this port.
|
java.util.Enumeration |
insideRelations()
Enumerate the relations linked on the inside to this port.
|
boolean |
isDeeplyConnected(ComponentPort port)
Return true the the given port is deeply connected with this port.
|
boolean |
isInsideGroupLinked(Relation r)
Return true if the given relation or one in its relation
group is linked to this port on the inside.
|
boolean |
isInsideLinked(Relation relation)
Return true if the given relation is linked from inside.
|
boolean |
isOpaque()
Return true if the container entity is opaque.
|
void |
liberalLink(ComponentRelation relation)
Link this port with the specified relation.
|
void |
link(Relation relation)
Link this port with the specified relation.
|
int |
numInsideLinks()
Return the number of inside links.
|
void |
setContainer(Entity entity)
Specify the container entity, adding the port to the list of ports
in the container.
|
void |
unlink(Relation relation)
Unlink the specified Relation.
|
void |
unlinkAll()
Unlink all outside links.
|
void |
unlinkAllInside()
Unlink all inside links.
|
void |
unlinkInside(int index)
Unlink whatever relation is currently linked on the inside
with the specified index number.
|
void |
unlinkInside(Relation relation)
Unlink the specified relation on the inside.
|
_getContainedObject, _propagateExistence, connectedPortList, connectedPorts, getContainer, isGroupLinked, isLinked, linkedRelationList, linkedRelations, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, numLinks, setName, 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 ComponentPort()
public ComponentPort(Workspace workspace)
workspace
- The workspace that will list the port.public ComponentPort(ComponentEntity container, java.lang.String name) throws IllegalActionException, NameDuplicationException
container
- The container entity.name
- The name of the port.IllegalActionException
- If the port is not of an acceptable
class for the container.NameDuplicationException
- If the name coincides with
a port already in the container.public java.lang.Object clone(Workspace workspace) throws java.lang.CloneNotSupportedException
clone
in class Port
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 deepConnectedPortList()
@Deprecated public java.util.Enumeration deepConnectedPorts()
public java.util.List deepInsidePortList()
@Deprecated public java.util.Enumeration deepInsidePorts()
public void insertInsideLink(int index, Relation relation) throws IllegalActionException
The specified index can be any non-negative integer. Any links with indices larger than or equal to the one specified here will henceforth have indices that are larger by one. If the index is larger than the number of existing links (as returned by numLinks()), then empty links are inserted (these will be null elements in the list returned by linkedRelationsList() or in the enumeration returned by linkedRelations()). If the specified relation is null, then an empty inside link is inserted at the specified index.
Note that a port may be linked to the same relation more than once, in which case the link will be reported more than once by the linkedRelations() method.
In derived classes, the relation may be required to be an instance of a particular subclass of Relation (this is checked by the _checkLink() protected method).
This method is write-synchronized on the workspace and increments its version number.
index
- The index at which to insert the link.relation
- The relation to link to this port.IllegalActionException
- If the link would cross levels of
the hierarchy, or the relation is incompatible,
or the port has no container, or the port is not in the
same workspace as the relation.public void insertLink(int index, Relation relation) throws IllegalActionException
The specified index can be any non-negative integer. Any links with indices larger than or equal to the one specified here will henceforth have indices that are larger by one. If the index is larger than the number of existing links (as returned by numLinks()), then empty links are inserted (these will be null elements in the list returned by linkedRelationsList() or in the enumeration returned by linkedRelations()). If the specified relation is null, then an empty outside link is inserted at the specified index.
Note that a port may be linked to the same relation more than once, in which case the link will be reported more than once by the linkedRelations() method.
In derived classes, the relation may be required to be an instance of a particular subclass of Relation (this is checked by the _checkLink() protected method).
This method is write-synchronized on the workspace and increments its version number.
insertLink
in class Port
index
- The index at which to insert the link.relation
- The relation to link to this port.IllegalActionException
- If the link would cross levels of
the hierarchy, or the relation is incompatible,
or the port has no container, or the port is not in the
same workspace as the relation.public java.util.List insidePortList()
@Deprecated public java.util.Enumeration insidePorts()
public java.util.List insideRelationList()
public java.util.Enumeration insideRelations()
public boolean isDeeplyConnected(ComponentPort port)
port
- The port that is checked for deep connectivity.public boolean isInsideGroupLinked(Relation r)
r
- The relation.Port.isLinked(Relation)
public boolean isInsideLinked(Relation relation)
relation
- The relation that is checked.public boolean isOpaque()
public void liberalLink(ComponentRelation relation) throws IllegalActionException
Both inside and outside links are supported. Note that a port may be linked to the same relation more than once, in which case the link will be reported more than once by the linkedRelations() method. If the relation argument is null, then create a null link (on the outside). This method is write-synchronized on the workspace and increments its version number.
relation
- The relation to link to.IllegalActionException
- If the relation does not share
the same workspace, or the port has no container.public void link(Relation relation) throws IllegalActionException
link
in class Port
relation
- The relation to link to.IllegalActionException
- If the link crosses levels of
the hierarchy, or the port has no container, or the relation
is not a ComponentRelation, or if the port is contained
by a class definition.public int numInsideLinks()
public void setContainer(Entity entity) throws IllegalActionException, NameDuplicationException
setContainer
in class Port
entity
- The container.IllegalActionException
- If this port is not of the
expected class for the container, or it has no name,
or the port and container are not in the same workspace.NameDuplicationException
- If the container already has
a port with the name of this port.Port.getContainer()
,
Port._checkContainer(Entity)
public void unlink(Relation relation)
public void unlinkAll()
public void unlinkAllInside()
public void unlinkInside(int index)
index
- The index number of the link to remove.public void unlinkInside(Relation relation)
relation
- The relation to unlink.protected void _checkContainer(Entity container) throws IllegalActionException
_checkContainer
in class Port
container
- The proposed container.IllegalActionException
- If the container is not a
ComponentEntity.protected void _checkLiberalLink(Relation relation) throws IllegalActionException
relation
- The relation to link to.IllegalActionException
- If this port has no container or
the relation is not a ComponentRelation, or the relation has
no container, or the link crosses levels of the hierarchy.protected void _checkLink(Relation relation) throws IllegalActionException
This method is used in a "strategy pattern," where the link methods call it to check the validity of a link, and derived classes perform more elaborate checks. This method is not synchronized on the workspace, so the caller should be. If the relation argument is null, do nothing.
_checkLink
in class Port
relation
- The relation to link to.IllegalActionException
- If this port has no container, or
the relation is not a ComponentRelation, or the relation has
no container, or the link crosses levels of the hierarchy, or
this port is not an acceptable port for the specified relation,
or if the container of this port is a class definition and the
link is not an inside link.protected java.util.List _deepConnectedPortList(java.util.LinkedList path)
path
- The list of ports on the path to this port in deeply
traversing the topology.@Deprecated protected java.util.Enumeration _deepConnectedPorts(java.util.LinkedList path)
path
- The list of ports on the path to this port in deeply
traversing the topology.protected java.util.List _deepInsidePortList(java.util.LinkedList path)
path
- The list of ports on the path to this port in deeply
traversing the topology.@Deprecated protected java.util.Enumeration _deepInsidePorts(java.util.LinkedList path)
path
- The list of ports on the path to this port in deeply
traversing the topology.protected java.lang.String _description(int detail, int indent, int bracket) throws IllegalActionException
_description
in class Port
detail
- The level of detail.indent
- The amount of indenting.bracket
- The number of surrounding brackets (0, 1, or 2).IllegalActionException
- If thrown by the parent class.protected boolean _isInsideLinkable(Nameable entity)
entity
- A possible container.