dol: initial dol commit
[jump.git] / dol / src / dol / datamodel / pn / Variable.java
diff --git a/dol/src/dol/datamodel/pn/Variable.java b/dol/src/dol/datamodel/pn/Variable.java
new file mode 100644 (file)
index 0000000..623a25c
--- /dev/null
@@ -0,0 +1,109 @@
+/* $Id: Variable.java 1 2010-02-24 13:03:05Z haidw $ */
+package dol.datamodel.pn;
+
+import dol.visitor.PNVisitor;
+
+/**
+ * This class represents a global variable in XML.
+ */
+public class Variable {
+
+    /**
+     * Constructor to create a Variable.
+     */
+    public Variable(String name) {
+        _name = name;
+    }
+
+    /**
+     * Accept a Visitor.
+     *
+     * @param x visitor object
+     */
+    public void accept(PNVisitor x) {
+        x.visitComponent(this);
+    }
+
+    /**
+     * Clone this Variable.
+     *
+     * @return new instance of the Variable.
+     */
+    public Object clone() {
+        try {
+            Variable newObj = (Variable) super.clone();
+            newObj.setName(_name);
+            return (newObj);
+        } catch (CloneNotSupportedException e) {
+            System.out.println("Error Clone not Supported");
+        }
+        return null;
+    }
+
+    /**
+     * Get the value of the Variable.
+     *
+     * @return the value of the variable
+     */
+    public int getValue() {
+        return _value;
+    }
+
+    /**
+     * Set the value of the Variable.
+     *
+     * @param value the value of the variable
+     */
+    public void setValue(int value) {
+        _value = value;
+    }
+
+    /**
+     * Get the name of this SourceCode.
+     *
+     * @return  the name
+     */
+    public String getName() {
+        return _name;
+    }
+
+    /**
+     * Set the name of this SourceCode.
+     *
+     * @param name name of the SourceCode
+     */
+    public void setName(String name) {
+        _name = name;
+    }
+
+    /**
+     * Get the hierarchical parent of this resource.
+     *
+     * @return parent of this resource
+     */
+     public Resource getParentResource() {
+        return _parentResource;
+    }
+
+    /**
+     * Set the hierarchical parent of this resource.
+     *
+     * @param parentResource new parent
+     */
+    public void setParentResource(Resource parentResource) {
+        _parentResource = parentResource;
+    }
+
+    /**
+     * Return a string representation of the Variable.
+     *
+     * @return string representation of the Variable
+     */
+    public String toString() {
+        return "Variable: " + getName();
+    }
+
+    protected int _value;
+    protected String _name = null;
+    protected Resource _parentResource = null;
+}