dol: initial dol commit
[jump.git] / dol / src / dol / datamodel / pn / Connection.java
1 /* $Id: Connection.java 1 2010-02-24 13:03:05Z haidw $ */
2 package dol.datamodel.pn;
3
4 import dol.visitor.PNVisitor;
5
6 /**
7  * This class defines a connection.
8  * A connection contains one origin and one target resource and the
9  * according ports.
10  */
11 public class Connection extends Resource {
12
13     /**
14      * Constructor to create a Connection with a name,
15      * empty process list and empty channel list.
16      */
17     public Connection(String name) {
18       super(name);
19     }
20
21     /**
22      * Accept a Visitor.
23      *
24      * @param x visitor object
25      */
26     public void accept(PNVisitor x) {
27         x.visitComponent(this);
28     }
29
30     /**
31      * Clone this Connection.
32      *
33      * @return  a new instance of the Connection.
34      */
35     public Object clone() {
36         Connection newObj = (Connection) super.clone();
37         newObj.setOrigin(_origin);
38         newObj.setOriginPort(_originPort);
39         newObj.setTarget(_target);
40         newObj.setTargetPort(_targetPort);
41         return (newObj);
42     }
43
44     /**
45      * Return a string representation of the connection.
46      *
47      * @return string representation of the connection
48      */
49     public String toString() {
50         return "Connection: " + getName();
51     }
52
53
54     /**
55      * Get the origin resource of his connection.
56      *
57      * @return origin resource
58      */
59     public Resource getOrigin() {
60         return _origin;
61     }
62
63     /**
64      * Set the origin resource of this connection.
65      *
66      * @param origin origin resource
67      */
68     public void setOrigin(Resource origin) {
69         _origin = origin;
70     }
71
72     /**
73      * Get the origin port of this connection.
74      *
75      * @return origin port
76      */
77     public Port getOriginPort() {
78         return _originPort;
79     }
80
81     /**
82      * Set the origin port of this connection.
83      *
84      * @param port origin port
85      */
86     public void setOriginPort(Port port) {
87         _originPort = port;
88     }
89
90     /**
91      * Get the target resource of his connection.
92      *
93      * @return target resource
94      */
95     public Resource getTarget() {
96         return _target;
97     }
98
99     /**
100      * Set the target resource of this connection.
101      *
102      * @param target target resource
103      */
104     public void setTarget(Resource target) {
105         _target = target;
106     }
107
108     /**
109      * Get the target port of this connection.
110      *
111      * @return target port
112      */
113     public Port getTargetPort() {
114         return _targetPort;
115     }
116
117     /**
118      * Set the target port of this connection.
119      *
120      * @param port target port
121      */
122     public void setTargetPort(Port port) {
123         _targetPort = port;
124     }
125
126     protected Resource _origin;
127     protected Port _originPort;
128     protected Resource _target;
129     protected Port _targetPort;
130 }