View Javadoc

1   package pt.digitalis.dif.dem.objects;
2   
3   import pt.digitalis.dif.utils.ObjectFormatter;
4   
5   /**
6    * This class represents a ViewObject entity on the DEM.
7    * 
8    * @author Rodrigo Gonçalves <a href="mailto:rgoncalves@digitalis.pt">rgoncalves@digitalis.pt</a>
9    * @created 2007/04/24
10   */
11  public class ViewObject {
12  
13      /** The ViewObject's rendering engine. */
14      private String engine;
15  
16      /** The ViewObject's id. */
17      private String id = new String();
18  
19      /** Keeps record if this is the default ViewObject. */
20      private boolean isDefault = true;
21  
22      /** The ViewObject's name. */
23      private String name = new String();
24  
25      /** The ViewObject's path. */
26      private String target = new String();
27  
28      /** The ViewObject's type. */
29      private ViewType type = ViewType.NORMAL;
30  
31      /** Default constructor. */
32      public ViewObject()
33      {
34  
35      }
36  
37      /**
38       * ViewObject constructor.
39       * 
40       * @param engine
41       *            the view engine
42       * @param type
43       *            the view type
44       * @param target
45       *            the view target
46       * @param isDefault
47       *            T if it's the default view, F otherwise
48       */
49      public ViewObject(String engine, ViewType type, String target, boolean isDefault)
50      {
51          this.engine = engine;
52          this.type = type;
53          this.target = target;
54          this.isDefault = isDefault;
55      }
56  
57      /**
58       * Returns the rendering engine defined for the ViewObject.
59       * 
60       * @return the rendering engine defined for the ViewObject
61       */
62      public String getEngine()
63      {
64          return engine;
65      }
66  
67      /**
68       * Returns the ViewObject's id.
69       * 
70       * @return the ViewObject's id
71       */
72      public String getId()
73      {
74          return id;
75      }
76  
77      /**
78       * Returns the ViewObject's name.
79       * 
80       * @return the ViewObject's name
81       */
82      public String getName()
83      {
84          return name;
85      }
86  
87      /**
88       * Returns the ViewObject's path.
89       * 
90       * @return the ViewObject's path
91       */
92      public String getTarget()
93      {
94          return target;
95      }
96  
97      /**
98       * Returns the ViewObject's type.
99       * 
100      * @return the ViewObject's type
101      */
102     public ViewType getType()
103     {
104         return type;
105     }
106 
107     /**
108      * Returns information on whether the ViewObject is the default ViewObject
109      * 
110      * @return T if this is the default ViewObject, F otherwise
111      */
112     public boolean isDefault()
113     {
114         return isDefault;
115     }
116 
117     /**
118      * Sets the ViewObject as the default ViewObject.
119      * 
120      * @param isDefault
121      *            new ViewObject default state
122      */
123     public void setDefault(boolean isDefault)
124     {
125         this.isDefault = isDefault;
126     }
127 
128     /**
129      * Sets the ViewObject's rendering engine.
130      * 
131      * @param newEngine
132      *            the new rendering engine
133      */
134     public void setEngine(String newEngine)
135     {
136         this.engine = newEngine;
137     }
138 
139     /**
140      * Sets the ViewObject's ID.
141      * 
142      * @param newID
143      *            the ViewObject's new ID
144      */
145     public void setId(String newID)
146     {
147         this.id = newID;
148     }
149 
150     /**
151      * Sets the ViewObject's name.
152      * 
153      * @param newName
154      *            the ViewObject's name
155      */
156     public void setName(String newName)
157     {
158         this.name = newName;
159     }
160 
161     /**
162      * Sets the ViewObject' path.
163      * 
164      * @param newTarget
165      *            the ViewObject's new path
166      */
167     public void setTarget(String newTarget)
168     {
169         this.target = newTarget;
170     }
171 
172     /**
173      * Sets the ViewObject's type.
174      * 
175      * @param newType
176      *            The ViewObject's new type
177      */
178     public void setType(ViewType newType)
179     {
180         this.type = newType;
181     }
182 
183     /**
184      * Prints the ViewObject object in a human-readable form. Overrides java.lang.Object#toString().
185      * 
186      * @see java.lang.Object#toString()
187      */
188     @Override
189     public String toString()
190     {
191         ObjectFormatter formatter = new ObjectFormatter();
192         formatter.addItem("ID", id);
193         formatter.addItem("Name", name);
194         formatter.addItem("Type", type);
195         formatter.addItem("Default", isDefault);
196         formatter.addItem("Engine", engine);
197         formatter.addItem("Target", target);
198 
199         return formatter.getFormatedObject();
200     }
201 }