dol: initial dol commit
[jump.git] / dol / src / dol / datamodel / mapping / MapResource.java
1 package dol.datamodel.mapping;
2
3 import dol.visitor.MapVisitor;
4
5 /**
6  * This class is the basic class which abstracts a mapping resource.
7  */
8 public class MapResource implements Cloneable {
9     /**
10      *  Constructor to create a mapping resource with a name.
11      */
12     public MapResource(String name) {
13         _name = name;
14         _basename = 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 mapping resource.
28      *
29      * @return new instance of the mapping resource.
30      */
31     public Object clone() {
32         try {
33             MapResource newObj = (MapResource) super.clone();
34             newObj.setName(_name);
35             newObj.setBasename(_basename);
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 name of this mapping resource.
45      *
46      * @return name of the mapping resource
47      */
48     public String getName() {
49         return _name;
50     }
51
52     /**
53      * Set the name of this mapping resource.
54      *
55      * @param name name of the mapping resource
56      */
57     public void setName(String name) {
58         _name = name;
59     }
60
61     /**
62      * Get the basename of this mapping resource.
63      *
64      * @return basename of the mapping resource
65      */
66     public String getBasename() {
67         return _basename;
68     }
69
70     /**
71      * Set the basename of this mapping resource.
72      *
73      * @param basename name of the mapping resource
74      */
75     public void setBasename(String basename) {
76         _basename = basename;
77     }
78
79     /**
80      * Get the hierarchical parent of this mapping resource.
81      *
82      * @return parent of this mapping resource
83      */
84      public MapResource getParentResource() {
85         return _parentResource;
86     }
87
88     /**
89      * Set the hierarchical parent of this mapping resource.
90      *
91      * @param parentResource new parent
92      */
93     public void setParentResource(MapResource parentResource) {
94         _parentResource = parentResource;
95     }
96     
97     /**
98      * Return a string representation of the architectural resource.
99      *
100      * @return string representation of the architectural resource
101      */
102     public String toString() {
103         return "MapResource: " + _name;
104     }
105
106     /** name of the architectural resource */
107     protected String _name = null;
108
109     /** basename of the architectural resource, if no basename, store the name */
110     protected String _basename = null;
111
112     /**
113      * parent resource of this architectural resource in a hierarchical architecture network
114      */
115     protected MapResource _parentResource = null;
116 }