1 /* $Id: Node.java 1 2010-02-24 13:03:05Z haidw $ */
2 package dol.datamodel.architecture;
4 import java.util.Vector;
6 import dol.visitor.ArchiVisitor;
9 * This class represents a node in the archietcture.
11 public class Node implements Cloneable {
14 * Constructor to create a Node with a name and an empty
17 public Node(String name) {
20 _portList = new Vector<PortNode>();
25 * @param x A Visitor Object.
27 public void accept(ArchiVisitor x) {
28 x.visitComponent(this);
34 * @return a new instance of the Node.
36 public Object clone() {
38 Node newObj = (Node) super.clone();
39 newObj.setName(_name);
40 newObj.setBasename(_basename);
42 } catch (CloneNotSupportedException e) {
43 System.out.println("Error Clone not Supported");
49 * Get the range of this node.
53 public String getRange() {
58 * Set the range of this node.
60 * @param range new range value
62 public void setRange(String range) {
68 * Get the name of this node.
70 * @return name of the node
72 public String getName() {
77 * Set the name of this node.
79 * @param name name of the node
81 public void setName(String name) {
86 * Get the basename of this node.
88 * @return basename of the node
90 public String getBasename() {
95 * Set the basename of this node.
97 * @param basename name of the node
99 public void setBasename(String basename) {
100 _basename = basename;
104 * Has this node IN/OUT/INOUT ports?
106 * @return boolean value
108 public boolean hasInPorts() {
109 for (PortNode port : getPortList()) {
116 public boolean hasOutPorts() {
117 for (PortNode port : getPortList()) {
118 if (port.isOutPort())
124 public boolean hasInOutPorts() {
125 for (PortNode port : getPortList()) {
126 if (port.isInOutPort())
133 * Return a port which has a specific name. Return null when port
136 * @param name name of the port to search for
137 * @return port with the specified name
139 public PortNode getPort(String name) {
140 for (PortNode port : getPortList()) {
141 if (port.getName().equals(name)) {
149 * Return the first port on the List.
151 * @return first port element
153 public PortNode getFirstPort() {
154 return (PortNode) _portList.firstElement();
158 * Get the corresponding ArchiResource.
160 * @return the corresponding ArchiResource
162 public ArchiResource getCorrespResource() {
163 return _correspResource;
167 * Set the corresponding ArchiResource.
169 * @param correspResource new ArchiResource
171 public void setCorrespResource(ArchiResource correspResource) {
172 _correspResource = correspResource;
176 * Get the port list of a Node.
178 * @return the port list
180 public Vector<PortNode> getPortList() {
185 * Set the port list of a Node.
187 * @param portList The new list
189 public void setPortList( Vector<PortNode> portList ) {
190 _portList = portList;
194 * Return a description of the node.
196 * @return a description of the node.
198 public String toString() {
199 return "Node: " + getName();
203 * Range of the iterator when the instance belongs to an iterated
206 protected String _range;
207 protected String _name = null;
208 protected String _basename = null;
209 protected ArchiResource _correspResource = null;
210 protected Vector<PortNode> _portList = null;