1 /* $Id: PortNode.java 1 2010-02-24 13:03:05Z haidw $ */
2 package dol.datamodel.architecture;
4 import dol.visitor.ArchiVisitor;
7 * This class represents a port of an architectural node.
9 public class PortNode implements Cloneable {
11 * Constructor to create a PortNode with a name.
13 public PortNode(String name) {
21 * Constructor to create a PortNode with a name and a type.
23 public PortNode(String name, boolean type) {
25 _isInPort = (type == INPORT);
26 _isOutPort = (type == OUTPORT);
27 _isInOutPort = (type == INOUTPORT);
33 * @param x visitor object
35 public void accept(ArchiVisitor x) {
36 x.visitComponent(this);
42 * @return new instance of the PortNode
44 public Object clone() {
46 PortNode newObj = (PortNode) super.clone();
47 newObj.setName(_name);
48 newObj.setBasename(_basename);
49 newObj.setPeerPort(_peerPort);
50 newObj.setPeerResource(_peerResource);
51 newObj.setPeerNode(_peerNode);
52 newObj.setResource(_resource );
53 newObj.setNode(_node);
55 } catch (CloneNotSupportedException e) {
56 System.out.println("Error Clone not Supported");
62 * Check whether this port is an inport.
64 * @return true if this port is an inport, otherwise false
66 public boolean isInPort() {
71 * Check whether this port is an outport.
73 * @return true if this port is an outport, otherwise false
75 public boolean isOutPort() {
80 * Check whether this port is an inoutport.
82 * @return true if this port is an inoutport, otherwise false
84 public boolean isInOutPort() {
89 * Get the name of this port.
91 * @return name of the port
93 public String getName() {
98 * Set the name of this port.
100 * @param name name of the port
102 public void setName(String name) {
106 public void setBasename(String basename) { _basename = basename; }
107 public String getBasename() { return _basename; }
110 * Get the range of this port.
112 * @return range of the port
114 public String getRange() {
119 * Set the range of this port.
121 * @param range range of the port
123 public void setRange(String range) {
128 * Get the resource/node of this port.
130 * @return the resource/node
132 public ArchiResource getResource() {
135 public Node getNode() {
140 * Set the resource/node of this port.
144 public void setResource(ArchiResource resource) {
145 _resource = resource;
147 public void setNode(Node node) {
152 * Set the peer resource/node/port of this port.
154 * @param peer The new node
156 public void setPeerPort(PortNode peer) { _peerPort = peer; }
161 public void setPeerResource(ArchiResource n) { _peerResource = n; }
166 public void setPeerNode(Node n) { _peerNode = n; }
169 * Get the peer resource/node/port of this port.
171 * @return the peer resource/node/port
173 public PortNode getPeerPort(){ return _peerPort; }
178 public ArchiResource getPeerResource() { return _peerResource; }
183 public Node getPeerNode() { return _peerNode; }
186 * Get the type of this port.
188 * @return type of this port
190 public String getType() {
191 if (_isInPort) return "input";
192 if (_isOutPort) return "output";
193 if (_isInOutPort) return "duplex";
194 return "type not set.";
198 * Return a string representation of the port.
200 * @return string representation of the port
202 public String toString() {
203 return "PortNode: " + _name;
206 /** constant for inport for usage in the constructor **/
207 public static final boolean INPORT = true;
209 /** constant for outport for usage in the constructor **/
210 public static final boolean OUTPORT = false;
212 /** constant for inoutport for usage in the constructor **/
213 public static final boolean INOUTPORT = false;
215 /** defines whether this port is an inport **/
216 protected boolean _isInPort = false;
218 /** defines whether this port is an outport **/
219 protected boolean _isOutPort = false;
221 /** defines whether this port is an inout **/
222 protected boolean _isInOutPort = false;
224 /** name of the port */
225 protected String _name = null;
227 /** basename of the resource, if no basename, store the name */
228 protected String _basename = null;
230 /** resource (process or channel) this port belongs to */
231 protected ArchiResource _resource = null;
233 /** node this port belongs to */
234 protected Node _node = null;
236 /** resource which peerPort belongs to */
237 protected ArchiResource _peerResource = null;
239 /** node which peerPort belongs to */
240 protected Node _peerNode = null;
242 /** connected peer port name */
243 protected PortNode _peerPort = null;
245 /** peer channel name */
246 protected String _channelName = null;
249 * Range of the iterator when the instance belongs to an iterated
252 protected String _range = null;