1 /* $Id: Port.java 1 2010-02-24 13:03:05Z haidw $ */
2 package dol.datamodel.pn;
4 import dol.visitor.PNVisitor;
7 * This class represents a port of a process or channel.
12 * Constructor to create a Port with a name.
14 public Port(String name) {
20 public Port(String name, boolean type) {
22 _isInPort = (type == INPORT);
23 _isOutPort = (type == OUTPORT);
30 * @param x visitor object
32 public void accept(PNVisitor x) {
33 x.visitComponent(this);
39 * @return new instance of the Port
41 public Object clone() {
43 Port newObj = (Port) super.clone();
44 newObj.setName(_name);
45 newObj.setBasename(_basename);
46 newObj.setPeerPort(_peerPort);
47 newObj.setPeerResource(_peerResource);
48 newObj.setResource(_resource );
50 } catch (CloneNotSupportedException e) {
51 System.out.println("Error Clone not Supported");
57 * Check whether this port is an inport.
59 * @return true if this port is an inport, otherwise false
61 public boolean isInPort() {
66 * Check whether this port is an outport.
68 * @return true if this port is an outport, otherwise false
70 public boolean isOutPort() {
75 * Get the name of this port.
77 * @return name of the port
79 public String getName() {
84 * Set the name of this port.
86 * @param name name of the port
88 public void setName(String name) {
93 * Get the range of this port.
95 * @return range of the port
97 public String getRange() {
102 * Set the range of this port.
104 * @param range range of the port
106 public void setRange(String range) {
111 * Get the resource of this port.
113 * @return the resource
115 public Resource getResource() {
120 * Set the process of this port.
122 * @param resource The new resource
124 public void setResource(Resource resource) {
125 _resource = resource;
128 public void setBasename(String basename) { _basename = basename; }
129 public String getBasename() { return _basename; }
132 public void setPeerPort(Port peer) { _peerPort = peer; }
133 public Port getPeerPort() { return _peerPort; }
135 // for process port: peer channel name
136 public void setPeerResource(Resource n) { _peerResource = n; }
137 public Resource getPeerResource() { return _peerResource; }
139 public String getType() {
140 if (_isInPort) return "input";
141 else if (_isOutPort) return "output";
146 * Return a string representation of the port.
148 * @return string representation of the port
150 public String toString() {
151 return "Port: " + _name;
154 /** constant for inport for usage in the constructor **/
155 public static final boolean INPORT = true;
157 /** constant for outport for usage in the constructor **/
158 public static final boolean OUTPORT = false;
160 /** defines whether this port is an inport **/
161 protected boolean _isInPort = false;
163 /** defines whether this port is an outport **/
164 protected boolean _isOutPort = false;
166 /** name of the port */
167 protected String _name = null;
169 /** basename of the resource, if no basename, store the name */
170 protected String _basename = null;
172 /** resource (process or channel) this port belongs to */
173 protected Resource _resource = null;
175 /** resource which peerPort belongs to */
176 protected Resource _peerResource = null;
178 /** connected peer port name */
179 protected Port _peerPort = null;
181 /** peer channel name */
182 protected String _channelName = null;
185 * Range of the iterator when the instance belongs to an iterated
188 protected String _range = "";