dol: initial dol commit
[jump.git] / dol / src / dol / datamodel / pn / Variable.java
1 /* $Id: Variable.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 represents a global variable in XML.
8  */
9 public class Variable {
10
11     /**
12      * Constructor to create a Variable.
13      */
14     public Variable(String name) {
15         _name = name;
16     }
17
18     /**
19      * Accept a Visitor.
20      *
21      * @param x visitor object
22      */
23     public void accept(PNVisitor x) {
24         x.visitComponent(this);
25     }
26
27     /**
28      * Clone this Variable.
29      *
30      * @return new instance of the Variable.
31      */
32     public Object clone() {
33         try {
34             Variable newObj = (Variable) super.clone();
35             newObj.setName(_name);
36             return (newObj);
37         } catch (CloneNotSupportedException e) {
38             System.out.println("Error Clone not Supported");
39         }
40         return null;
41     }
42
43     /**
44      * Get the value of the Variable.
45      *
46      * @return the value of the variable
47      */
48     public int getValue() {
49         return _value;
50     }
51
52     /**
53      * Set the value of the Variable.
54      *
55      * @param value the value of the variable
56      */
57     public void setValue(int value) {
58         _value = value;
59     }
60
61     /**
62      * Get the name of this SourceCode.
63      *
64      * @return  the name
65      */
66     public String getName() {
67         return _name;
68     }
69
70     /**
71      * Set the name of this SourceCode.
72      *
73      * @param name name of the SourceCode
74      */
75     public void setName(String name) {
76         _name = name;
77     }
78
79     /**
80      * Get the hierarchical parent of this resource.
81      *
82      * @return parent of this resource
83      */
84      public Resource getParentResource() {
85         return _parentResource;
86     }
87
88     /**
89      * Set the hierarchical parent of this resource.
90      *
91      * @param parentResource new parent
92      */
93     public void setParentResource(Resource parentResource) {
94         _parentResource = parentResource;
95     }
96
97     /**
98      * Return a string representation of the Variable.
99      *
100      * @return string representation of the Variable
101      */
102     public String toString() {
103         return "Variable: " + getName();
104     }
105
106     protected int _value;
107     protected String _name = null;
108     protected Resource _parentResource = null;
109 }