dol: initial dol commit
[jump.git] / dol / src / dol / datamodel / mapping / MapResource.java
diff --git a/dol/src/dol/datamodel/mapping/MapResource.java b/dol/src/dol/datamodel/mapping/MapResource.java
new file mode 100644 (file)
index 0000000..2aa9cf8
--- /dev/null
@@ -0,0 +1,116 @@
+package dol.datamodel.mapping;
+
+import dol.visitor.MapVisitor;
+
+/**
+ * This class is the basic class which abstracts a mapping resource.
+ */
+public class MapResource implements Cloneable {
+    /**
+     *  Constructor to create a mapping resource with a name.
+     */
+    public MapResource(String name) {
+        _name = name;
+        _basename = name;
+    }
+
+    /**
+     * Accept a Visitor
+     *
+     * @param x visitor object
+     */
+    public void accept(MapVisitor x) {
+        x.visitComponent(this);
+    }
+
+    /**
+     * Clone this mapping resource.
+     *
+     * @return new instance of the mapping resource.
+     */
+    public Object clone() {
+        try {
+            MapResource newObj = (MapResource) super.clone();
+            newObj.setName(_name);
+            newObj.setBasename(_basename);
+            return (newObj);
+        } catch (CloneNotSupportedException e) {
+            System.out.println("Error Clone not Supported");
+        }
+        return null;
+    }
+
+    /**
+     * Get the name of this mapping resource.
+     *
+     * @return name of the mapping resource
+     */
+    public String getName() {
+        return _name;
+    }
+
+    /**
+     * Set the name of this mapping resource.
+     *
+     * @param name name of the mapping resource
+     */
+    public void setName(String name) {
+        _name = name;
+    }
+
+    /**
+     * Get the basename of this mapping resource.
+     *
+     * @return basename of the mapping resource
+     */
+    public String getBasename() {
+        return _basename;
+    }
+
+    /**
+     * Set the basename of this mapping resource.
+     *
+     * @param basename name of the mapping resource
+     */
+    public void setBasename(String basename) {
+        _basename = basename;
+    }
+
+    /**
+     * Get the hierarchical parent of this mapping resource.
+     *
+     * @return parent of this mapping resource
+     */
+     public MapResource getParentResource() {
+        return _parentResource;
+    }
+
+    /**
+     * Set the hierarchical parent of this mapping resource.
+     *
+     * @param parentResource new parent
+     */
+    public void setParentResource(MapResource parentResource) {
+        _parentResource = parentResource;
+    }
+    
+    /**
+     * Return a string representation of the architectural resource.
+     *
+     * @return string representation of the architectural resource
+     */
+    public String toString() {
+        return "MapResource: " + _name;
+    }
+
+    /** name of the architectural resource */
+    protected String _name = null;
+
+    /** basename of the architectural resource, if no basename, store the name */
+    protected String _basename = null;
+
+    /**
+     * parent resource of this architectural resource in a hierarchical architecture network
+     */
+    protected MapResource _parentResource = null;
+}