+/* $Id: PortNode.java 1 2010-02-24 13:03:05Z haidw $ */
+package dol.datamodel.architecture;
+
+import dol.visitor.ArchiVisitor;
+
+/**
+ * This class represents a port of an architectural node.
+ */
+public class PortNode implements Cloneable {
+ /**
+ * Constructor to create a PortNode with a name.
+ */
+ public PortNode(String name) {
+ _name = name;
+ _isInPort = false;
+ _isOutPort = false;
+ _isInOutPort = false;
+ }
+
+ /**
+ * Constructor to create a PortNode with a name and a type.
+ */
+ public PortNode(String name, boolean type) {
+ _name = name;
+ _isInPort = (type == INPORT);
+ _isOutPort = (type == OUTPORT);
+ _isInOutPort = (type == INOUTPORT);
+ }
+
+ /**
+ * Accept a visitor.
+ *
+ * @param x visitor object
+ */
+ public void accept(ArchiVisitor x) {
+ x.visitComponent(this);
+ }
+
+ /**
+ * Clone this PortNode
+ *
+ * @return new instance of the PortNode
+ */
+ public Object clone() {
+ try {
+ PortNode newObj = (PortNode) super.clone();
+ newObj.setName(_name);
+ newObj.setBasename(_basename);
+ newObj.setPeerPort(_peerPort);
+ newObj.setPeerResource(_peerResource);
+ newObj.setPeerNode(_peerNode);
+ newObj.setResource(_resource );
+ newObj.setNode(_node);
+ return (newObj);
+ } catch (CloneNotSupportedException e) {
+ System.out.println("Error Clone not Supported");
+ }
+ return null;
+ }
+
+ /**
+ * Check whether this port is an inport.
+ *
+ * @return true if this port is an inport, otherwise false
+ */
+ public boolean isInPort() {
+ return _isInPort;
+ }
+
+ /**
+ * Check whether this port is an outport.
+ *
+ * @return true if this port is an outport, otherwise false
+ */
+ public boolean isOutPort() {
+ return _isOutPort;
+ }
+
+ /**
+ * Check whether this port is an inoutport.
+ *
+ * @return true if this port is an inoutport, otherwise false
+ */
+ public boolean isInOutPort() {
+ return _isInOutPort;
+ }
+
+ /**
+ * Get the name of this port.
+ *
+ * @return name of the port
+ */
+ public String getName() {
+ return _name;
+ }
+
+ /**
+ * Set the name of this port.
+ *
+ * @param name name of the port
+ */
+ public void setName(String name) {
+ _name = name;
+ }
+
+ public void setBasename(String basename) { _basename = basename; }
+ public String getBasename() { return _basename; }
+
+ /**
+ * Get the range of this port.
+ *
+ * @return range of the port
+ */
+ public String getRange() {
+ return _range;
+ }
+
+ /**
+ * Set the range of this port.
+ *
+ * @param range range of the port
+ */
+ public void setRange(String range) {
+ _range= range;
+ }
+
+ /**
+ * Get the resource/node of this port.
+ *
+ * @return the resource/node
+ */
+ public ArchiResource getResource() {
+ return _resource;
+ }
+ public Node getNode() {
+ return _node;
+ }
+
+ /**
+ * Set the resource/node of this port.
+ *
+ * @param resource
+ */
+ public void setResource(ArchiResource resource) {
+ _resource = resource;
+ }
+ public void setNode(Node node) {
+ _node = node;
+ }
+
+ /**
+ * Set the peer resource/node/port of this port.
+ *
+ * @param peer The new node
+ */
+ public void setPeerPort(PortNode peer) { _peerPort = peer; }
+
+ /**
+ *
+ */
+ public void setPeerResource(ArchiResource n) { _peerResource = n; }
+
+ /**
+ *
+ */
+ public void setPeerNode(Node n) { _peerNode = n; }
+
+ /**
+ * Get the peer resource/node/port of this port.
+ *
+ * @return the peer resource/node/port
+ */
+ public PortNode getPeerPort(){ return _peerPort; }
+
+ /**
+ *
+ */
+ public ArchiResource getPeerResource() { return _peerResource; }
+
+ /**
+ *
+ */
+ public Node getPeerNode() { return _peerNode; }
+
+ /**
+ * Get the type of this port.
+ *
+ * @return type of this port
+ */
+ public String getType() {
+ if (_isInPort) return "input";
+ if (_isOutPort) return "output";
+ if (_isInOutPort) return "duplex";
+ return "type not set.";
+ }
+
+ /**
+ * Return a string representation of the port.
+ *
+ * @return string representation of the port
+ */
+ public String toString() {
+ return "PortNode: " + _name;
+ }
+
+ /** constant for inport for usage in the constructor **/
+ public static final boolean INPORT = true;
+
+ /** constant for outport for usage in the constructor **/
+ public static final boolean OUTPORT = false;
+
+ /** constant for inoutport for usage in the constructor **/
+ public static final boolean INOUTPORT = false;
+
+ /** defines whether this port is an inport **/
+ protected boolean _isInPort = false;
+
+ /** defines whether this port is an outport **/
+ protected boolean _isOutPort = false;
+
+ /** defines whether this port is an inout **/
+ protected boolean _isInOutPort = false;
+
+ /** name of the port */
+ protected String _name = null;
+
+ /** basename of the resource, if no basename, store the name */
+ protected String _basename = null;
+
+ /** resource (process or channel) this port belongs to */
+ protected ArchiResource _resource = null;
+
+ /** node this port belongs to */
+ protected Node _node = null;
+
+ /** resource which peerPort belongs to */
+ protected ArchiResource _peerResource = null;
+
+ /** node which peerPort belongs to */
+ protected Node _peerNode = null;
+
+ /** connected peer port name */
+ protected PortNode _peerPort = null;
+
+ /** peer channel name */
+ protected String _channelName = null;
+
+ /**
+ * Range of the iterator when the instance belongs to an iterated
+ * series of ports.
+ */
+ protected String _range = null;
+}