KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jahia > services > homepages > JahiaHomepage


1 //
2
// ____.
3
// __/\ ______| |__/\. _______
4
// __ .____| | \ | +----+ \
5
// _______| /--| | | - \ _ | : - \_________
6
// \\______: :---| : : | : | \________>
7
// |__\---\_____________:______: :____|____:_____\
8
// /_____|
9
//
10
// . . . i n j a h i a w e t r u s t . . .
11
//
12
//
13
// NK - 17 Dec. 2001 :
14
//
15

16 package org.jahia.services.homepages;
17
18
19 import java.util.Comparator JavaDoc;
20 import java.util.Hashtable JavaDoc;
21
22 import org.jahia.exceptions.JahiaException;
23
24
25 /**
26  * Abstract class for all jahia homepage definitions.
27  * Bean of these classes holds information used to define different type of
28  * homepage definition.
29  *
30  * @author Khue ng
31  * @version 1.0
32  */

33 public abstract class JahiaHomepage implements Cloneable JavaDoc, Comparator JavaDoc
34 {
35
36     protected int id = -1;
37     protected String JavaDoc name;
38     protected String JavaDoc descr;
39     protected int type;
40     protected String JavaDoc siteKey;
41     protected int aclID;
42
43     protected Hashtable JavaDoc props = new Hashtable JavaDoc();
44
45
46     /**
47      * Constructor
48      */

49     private JahiaHomepage(){};
50
51
52     /**
53      * Constructor, subclass must have exact constructor signature.
54      *
55      * @param Integer id, the unique identifier
56      * @param String name, the name
57      * @param String descr, the descr
58      * @param Integer type, the type
59      * @param String sitekey, the site key
60      * @param Hashtable props, the properties
61      * @param Integer aclID, the acl
62      */

63     JahiaHomepage( Integer JavaDoc id,
64                     String JavaDoc name,
65                     String JavaDoc descr,
66                     Integer JavaDoc type,
67                     String JavaDoc siteKey,
68                     Hashtable JavaDoc props,
69                     Integer JavaDoc aclID ){
70
71         this.id = id.intValue();
72         this.name = name;
73         this.descr = descr;
74         this.type = type.intValue();
75         this.siteKey = siteKey;
76         if ( props != null )
77             this.props = props;
78         this.aclID = aclID.intValue();
79     }
80
81     //-------------------------------------------------------------------------
82
/**
83      * Set the home page unique identifier.
84      *
85      * @param int id, the id.
86      */

87     void setID(int id){
88         this.id = id;
89     }
90
91
92     //-------------------------------------------------------------------------
93
/**
94      * Return the homepage unique identifier.
95      *
96      * @return int the id.
97      */

98     public int getID(){
99         return id;
100     }
101
102     //-------------------------------------------------------------------------
103
/**
104      * Return the homepage name
105      *
106      * @return String the home page name.
107      */

108     public String JavaDoc getName(){
109         return name;
110     }
111
112     //-------------------------------------------------------------------------
113
/**
114      * Set the homepage name
115      *
116      * @param String the home page name.
117      */

118     public void setName(String JavaDoc name){
119         this.name = name;
120     }
121
122     //-------------------------------------------------------------------------
123
/**
124      * Return the homepage descr
125      *
126      * @return String the home page descr.
127      */

128     public String JavaDoc getDescr(){
129         return descr;
130     }
131
132     //-------------------------------------------------------------------------
133
/**
134      * Set the homepage descr
135      *
136      * @param String the home page descr.
137      */

138     public void setDescr(String JavaDoc descr){
139         this.descr = descr;
140     }
141
142     //-------------------------------------------------------------------------
143
/**
144      * Return the homepage type.
145      *
146      * @return int the home page type.
147      */

148     public int getType(){
149         return type;
150     }
151
152     //-------------------------------------------------------------------------
153
/**
154      * Return the homepage Site's key.
155      *
156      * @return String the site key.
157      */

158     public String JavaDoc getSiteKey(){
159         return siteKey;
160     }
161
162     //-------------------------------------------------------------------------
163
/**
164      * Set the acl ID.
165      *
166      * @param int id, the acl id.
167      */

168     void setAclID(int id){
169         this.aclID = id;
170     }
171
172     //-------------------------------------------------------------------------
173
/**
174      * Return the acl id
175      *
176      * @return int, the acl ID.
177      */

178     public int getAclID(){
179         return aclID;
180     }
181
182     //--------------------------------------------------------------------------
183
/**
184      * Get home page's properties list.
185      *
186      * @return Hashtable Return a reference on the homepage's properties list, or null if no
187      * property is present.
188      */

189     public Hashtable JavaDoc getProperties (){
190         return props;
191     }
192
193     //--------------------------------------------------------------------------
194
/**
195      * Set home page's properties list.
196      *
197      * @param Hashtable .
198      */

199     void setProperties (Hashtable JavaDoc props){
200         if ( props == null )
201             return;
202         this.props = props;
203     }
204
205     //--------------------------------------------------------------------------
206
/**
207      * Retrieve the requested home page property.
208      *
209      * @param key Property's name.
210      *
211      * @return Return the property's value of the specified key, or null if the
212      * property does not exist.
213      */

214     Object JavaDoc getProperty (String JavaDoc key){
215         return props.get(key);
216     }
217
218
219     //--------------------------------------------------------------------------
220
/**
221      * Remove the specified property from the properties list.
222      *
223      * @param key Property's name.
224      */

225     void removeProperty (String JavaDoc key){
226         props.remove(key);
227     }
228
229
230     //--------------------------------------------------------------------------
231
/**
232      * Add (or update if not already in the property list)
233      *
234      * @param String Property's name.
235      * @param Object Property's value.
236      */

237     void setProperty (String JavaDoc key, Object JavaDoc value){
238         props.put(key,value);
239     }
240
241     //--------------------------------------------------------------------------
242
/**
243      * Save its state.
244      *
245      */

246     abstract void save()
247     throws JahiaException ;
248
249     //--------------------------------------------------------------------------
250
/**
251      * Delete.
252      *
253      */

254     abstract void delete()
255     throws JahiaException ;
256
257     //-------------------------------------------------------------------------
258
/**
259      * Load extra properties from storage
260      *
261      * @param int the template id
262      */

263     abstract void loadProperties()
264     throws JahiaException;
265
266     //-------------------------------------------------------------------------
267
/**
268      * Save extra properties in storage
269      *
270      */

271     abstract void saveProperties() throws JahiaException;
272
273     //--------------------------------------------------------------------------
274
/**
275      * Return a string representation of the home page and it's internal state.
276      *
277      * @return A string representation of this home page.
278      */

279     public abstract String JavaDoc toString ();
280
281     //--------------------------------------------------------------------------
282
/**
283      * Return a cloje object
284      *
285      * @return Object the clone.
286      */

287     public abstract Object JavaDoc clone ();
288
289
290     //-------------------------------------------------------------------------
291
/**
292      * Compare between two objects, sort by their name
293      *
294      * @param Object
295      * @param Object
296      */

297     public int compare(Object JavaDoc c1, Object JavaDoc c2) throws ClassCastException JavaDoc {
298
299         return ((JahiaHomepage)c1)
300                     .getName().compareToIgnoreCase(((JahiaHomepage)c2).getName().toLowerCase());
301
302     }
303
304
305
306 }
307
Popular Tags