public class Port extends NamedObj
A Port can link to any instance of Relation. Derived classes may wish
to constrain links to a subclass of Relation. To do this, subclasses
should override the protected method _checkLink(Relation)
to
throw an exception if its argument is a relation that is not of the
appropriate subclass. Similarly, if a subclass wishes to constrain
the containers of the port to be of a subclass of Entity, they should
override the protected method _checkContainer(Entity)
.
NamedObj.ContainedObjectsIterator
Modifier and Type | Field and Description |
---|---|
protected CrossRefList |
_insideLinks
The list of inside relations for this port.
|
protected CrossRefList |
_relationsList
The list of relations for this port.
|
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
Constructor and Description |
---|
Port()
Construct a port in the default workspace with an empty string
as its name.
|
Port(Entity container,
java.lang.String name)
Construct a port with the given name contained by the specified
entity.
|
Port(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)
Check that the specified container is of a suitable class for
this port.
|
protected void |
_checkLink(Relation relation)
Check that this port is compatible with the specified relation,
that it has a container.
|
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 port 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.
|
java.util.List |
connectedPortList()
List the connected ports.
|
java.util.Enumeration |
connectedPorts()
Deprecated.
Use connectedPortList() instead.
|
NamedObj |
getContainer()
Get the container entity.
|
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.
|
boolean |
isGroupLinked(Relation r)
Return true if the given relation or one in its relation
group is linked to this port.
|
boolean |
isLinked(Relation r)
Return true if the given relation is linked to this port.
|
void |
link(Relation relation)
Link this port with a relation, and notify the container by
calling its connectionsChanged() method.
|
java.util.List |
linkedRelationList()
List the linked relations.
|
java.util.Enumeration |
linkedRelations()
Enumerate the linked relations.
|
int |
moveDown()
Move this object down by one in the list of ports of
its container.
|
int |
moveToFirst()
Move this object to the first position in the list
of ports of the container.
|
int |
moveToIndex(int index)
Move this object to the specified position in the list
of ports of the container.
|
int |
moveToLast()
Move this object to the last position in the list
of ports of the container.
|
int |
moveUp()
Move this object up by one in the list of
ports of the container.
|
int |
numLinks()
Return the number of links to relations.
|
void |
setContainer(Entity entity)
Specify the container entity, adding the port to the list of ports
in the container.
|
void |
setName(java.lang.String name)
Set the name of the port.
|
void |
unlink(int index)
Unlink whatever relation is currently linked at the specified index
number.
|
void |
unlink(Relation relation)
Unlink the specified Relation.
|
void |
unlinkAll()
Unlink all relations.
|
_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
protected CrossRefList _insideLinks
protected CrossRefList _relationsList
public Port()
public Port(Workspace workspace)
workspace
- The workspace that will list the port.public Port(Entity container, java.lang.String name) throws IllegalActionException, NameDuplicationException
container
- The parent 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 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 java.util.List connectedPortList()
@Deprecated public java.util.Enumeration connectedPorts()
public NamedObj getContainer()
getContainer
in interface Nameable
getContainer
in class NamedObj
setContainer(Entity)
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 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, or if the port is contained
by a class definition.public boolean isGroupLinked(Relation r)
r
- The relation.isLinked(Relation)
public boolean isLinked(Relation r)
r
- The relation.isGroupLinked(Relation)
public void link(Relation relation) throws IllegalActionException
If the argument is null, then create a null link. 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.
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, or if the port is contained
by a class definition.public java.util.List linkedRelationList()
public java.util.Enumeration linkedRelations()
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 int numLinks()
public void setContainer(Entity entity) throws IllegalActionException, NameDuplicationException
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, or if
a contained Settable becomes invalid and the error handler
throws it, or if this port is a class element and the argument
does not match the current container.NameDuplicationException
- If the container already has
a port with the name of this port.getContainer()
,
_checkContainer(Entity)
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 port
with the same name in the container.NamedObj.getName()
,
NamedObj.getName(NamedObj)
public void unlink(int index)
index
- The index number of the link to remove.public void unlink(Relation relation)
relation
- The relation to unlink.public void unlinkAll()
protected void _checkContainer(Entity 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 _checkLink(Relation relation) throws IllegalActionException
relation
- The relation to link to.IllegalActionException
- If this port has no container,
or if this port is not an acceptable port 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
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 Entity.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.