X-Git-Url: http://sraa.de/git/?a=blobdiff_plain;f=dol%2Fsrc%2Fdol%2Fdatamodel%2Farchitecture%2FNode.java;fp=dol%2Fsrc%2Fdol%2Fdatamodel%2Farchitecture%2FNode.java;h=89d51b8983b36abe80a58f1e6599941596a7da40;hb=8c411cf24ed0eb889191aaeafd8fa1e69081df42;hp=0000000000000000000000000000000000000000;hpb=dea7a4fb1ed110d3ce6e6d9255103d724bd66c0e;p=jump.git diff --git a/dol/src/dol/datamodel/architecture/Node.java b/dol/src/dol/datamodel/architecture/Node.java new file mode 100644 index 0000000..89d51b8 --- /dev/null +++ b/dol/src/dol/datamodel/architecture/Node.java @@ -0,0 +1,211 @@ +/* $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(); + } + + /** + * 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 getPortList() { + return _portList; + } + + /** + * Set the port list of a Node. + * + * @param portList The new list + */ + public void setPortList( Vector 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 _portList = null; +}