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