+/* $Id: Node.java 1 2010-02-24 13:03:05Z haidw $ */
+package dol.datamodel.architecture;
+
+import java.util.Vector;
+
+import dol.visitor.ArchiVisitor;
+
+/**
+ * This class represents a node in the archietcture.
+ */
+public class Node implements Cloneable {
+
+ /**
+ * Constructor to create a Node with a name and an empty
+ * portList.
+ */
+ public Node(String name) {
+ _name = name;
+ _basename = name;
+ _portList = new Vector<PortNode>();
+ }
+
+ /**
+ * Accept a Visitor
+ * @param x A Visitor Object.
+ */
+ public void accept(ArchiVisitor x) {
+ x.visitComponent(this);
+ }
+
+ /**
+ * Clone this Node
+ *
+ * @return a new instance of the Node.
+ */
+ public Object clone() {
+ try {
+ Node newObj = (Node) super.clone();
+ newObj.setName(_name);
+ newObj.setBasename(_basename);
+ return (newObj);
+ } catch (CloneNotSupportedException e) {
+ System.out.println("Error Clone not Supported");
+ }
+ return null;
+ }
+
+ /**
+ * Get the range of this node.
+ *
+ * @return range
+ */
+ public String getRange() {
+ return _range;
+ }
+
+ /**
+ * Set the range of this node.
+ *
+ * @param range new range value
+ */
+ public void setRange(String range) {
+ _range= range;
+ }
+
+
+ /**
+ * Get the name of this node.
+ *
+ * @return name of the node
+ */
+ public String getName() {
+ return _name;
+ }
+
+ /**
+ * Set the name of this node.
+ *
+ * @param name name of the node
+ */
+ public void setName(String name) {
+ _name = name;
+ }
+
+ /**
+ * Get the basename of this node.
+ *
+ * @return basename of the node
+ */
+ public String getBasename() {
+ return _basename;
+ }
+
+ /**
+ * Set the basename of this node.
+ *
+ * @param basename name of the node
+ */
+ public void setBasename(String basename) {
+ _basename = basename;
+ }
+
+ /**
+ * Has this node IN/OUT/INOUT ports?
+ *
+ * @return boolean value
+ */
+ public boolean hasInPorts() {
+ for (PortNode port : getPortList()) {
+ if (port.isInPort())
+ return true;
+ }
+ return false;
+ }
+
+ public boolean hasOutPorts() {
+ for (PortNode port : getPortList()) {
+ if (port.isOutPort())
+ return true;
+ }
+ return false;
+ }
+
+ public boolean hasInOutPorts() {
+ for (PortNode port : getPortList()) {
+ if (port.isInOutPort())
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Return a port which has a specific name. Return null when port
+ * cannot be found.
+ *
+ * @param name name of the port to search for
+ * @return port with the specified name
+ */
+ public PortNode getPort(String name) {
+ for (PortNode port : getPortList()) {
+ if (port.getName().equals(name)) {
+ return port;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Return the first port on the List.
+ *
+ * @return first port element
+ */
+ public PortNode getFirstPort() {
+ return (PortNode) _portList.firstElement();
+ }
+
+ /**
+ * Get the corresponding ArchiResource.
+ *
+ * @return the corresponding ArchiResource
+ */
+ public ArchiResource getCorrespResource() {
+ return _correspResource;
+ }
+
+ /**
+ * Set the corresponding ArchiResource.
+ *
+ * @param correspResource new ArchiResource
+ */
+ public void setCorrespResource(ArchiResource correspResource) {
+ _correspResource = correspResource;
+ }
+
+ /**
+ * Get the port list of a Node.
+ *
+ * @return the port list
+ */
+ public Vector<PortNode> getPortList() {
+ return _portList;
+ }
+
+ /**
+ * Set the port list of a Node.
+ *
+ * @param portList The new list
+ */
+ public void setPortList( Vector<PortNode> portList ) {
+ _portList = portList;
+ }
+
+ /**
+ * Return a description of the node.
+ *
+ * @return a description of the node.
+ */
+ public String toString() {
+ return "Node: " + getName();
+ }
+
+ /**
+ * Range of the iterator when the instance belongs to an iterated
+ * series of nodes.
+ */
+ protected String _range;
+ protected String _name = null;
+ protected String _basename = null;
+ protected ArchiResource _correspResource = null;
+ protected Vector<PortNode> _portList = null;
+}