dol: initial dol commit
[jump.git] / dol / src / dol / datamodel / pn / Connection.java
diff --git a/dol/src/dol/datamodel/pn/Connection.java b/dol/src/dol/datamodel/pn/Connection.java
new file mode 100644 (file)
index 0000000..3830f96
--- /dev/null
@@ -0,0 +1,130 @@
+/* $Id: Connection.java 1 2010-02-24 13:03:05Z haidw $ */
+package dol.datamodel.pn;
+
+import dol.visitor.PNVisitor;
+
+/**
+ * This class defines a connection.
+ * A connection contains one origin and one target resource and the
+ * according ports.
+ */
+public class Connection extends Resource {
+
+    /**
+     * Constructor to create a Connection with a name,
+     * empty process list and empty channel list.
+     */
+    public Connection(String name) {
+      super(name);
+    }
+
+    /**
+     * Accept a Visitor.
+     *
+     * @param x visitor object
+     */
+    public void accept(PNVisitor x) {
+        x.visitComponent(this);
+    }
+
+    /**
+     * Clone this Connection.
+     *
+     * @return  a new instance of the Connection.
+     */
+    public Object clone() {
+        Connection newObj = (Connection) super.clone();
+        newObj.setOrigin(_origin);
+        newObj.setOriginPort(_originPort);
+        newObj.setTarget(_target);
+        newObj.setTargetPort(_targetPort);
+        return (newObj);
+    }
+
+    /**
+     * Return a string representation of the connection.
+     *
+     * @return string representation of the connection
+     */
+    public String toString() {
+        return "Connection: " + getName();
+    }
+
+
+    /**
+     * Get the origin resource of his connection.
+     *
+     * @return origin resource
+     */
+    public Resource getOrigin() {
+        return _origin;
+    }
+
+    /**
+     * Set the origin resource of this connection.
+     *
+     * @param origin origin resource
+     */
+    public void setOrigin(Resource origin) {
+        _origin = origin;
+    }
+
+    /**
+     * Get the origin port of this connection.
+     *
+     * @return origin port
+     */
+    public Port getOriginPort() {
+        return _originPort;
+    }
+
+    /**
+     * Set the origin port of this connection.
+     *
+     * @param port origin port
+     */
+    public void setOriginPort(Port port) {
+        _originPort = port;
+    }
+
+    /**
+     * Get the target resource of his connection.
+     *
+     * @return target resource
+     */
+    public Resource getTarget() {
+        return _target;
+    }
+
+    /**
+     * Set the target resource of this connection.
+     *
+     * @param target target resource
+     */
+    public void setTarget(Resource target) {
+        _target = target;
+    }
+
+    /**
+     * Get the target port of this connection.
+     *
+     * @return target port
+     */
+    public Port getTargetPort() {
+        return _targetPort;
+    }
+
+    /**
+     * Set the target port of this connection.
+     *
+     * @param port target port
+     */
+    public void setTargetPort(Port port) {
+        _targetPort = port;
+    }
+
+    protected Resource _origin;
+    protected Port _originPort;
+    protected Resource _target;
+    protected Port _targetPort;
+}