KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sslexplorer > boot > PropertyDefinition


1 /*
2  * SSL-Explorer
3  *
4  * Copyright (C) 2003-2006 3SP LTD. All Rights Reserved
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2 of
9  * the License, or (at your option) any later version.
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public
16  * License along with this program; if not, write to the Free Software
17  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  */

19             
20 package com.sslexplorer.boot;
21
22
23 /**
24  * Each property that may be stored store is keyed by its <i>id</i>. For
25  * each unique <i>id</i> there must have been a single <i>Property Definition</i>
26  * registered with the property database using
27  * {@link com.sslexplorer.properties.PropertyDatabase#registerPropertyDefinition(PropertyDefinition)}
28  * <p>
29  * Each definition contains information about the value that will be stored
30  * against it. This includes the type of value (string, integer, boolean etc),
31  * the bundle in which the human readable name and description is held,
32  * its category ID and other information.
33  * <p>
34  * Every property definition consists of the following attributes :-
35  *
36  * <h3>Type</h3>
37  *
38  * This determines the type of values that will be stored against this definition.
39  * See {@link #getType()} for a list of the possible values. Properties
40  * are be stored as strings. The type is then used by the user interface to
41  * present to appropriate component and convert to and from strings.
42  *
43  * <h3>Name</h3>
44  *
45  * This is the unique identifier of the property and must be unique.
46  * All properties are keyed by their name (or ID as it is sometimes known).
47  *
48  * <h3>Default Value</h3>
49  *
50  * Every property must have a sane default value that is used when no
51  * value has been set.
52  *
53  * <h3>Type Meta</h3>
54  *
55  * Meta-data about the property. The contents and format of this string
56  * will vary depending on the type. For example, {@link #TYPE_TEXT_AREA}
57  * type meta may contains a string in the format '[rows]X[cols]' that
58  * specifies the size of the text area the UI should display.
59  *
60  * <h3>Category</h3>
61  *
62  * The category ID this property exists under. See {@link com.sslexplorer.properties.PropertyDatabase}
63  * for an explanation of categories.
64  *
65  * <h3>Sort Order</h3>
66  *
67  * A hint as to where the property should be placed in relation to others in
68  * the same category and visibility. The lower the value, the higher up the
69  * list. The two properties may exists with the same sort order but the
70  * behaviour is undefined.
71  *
72  * <h3>Message Resources Key</h3>
73  *
74  * The message resource bundle key as defined in the Struts configuation XML
75  * files (struts-config.xml).
76  *
77  * <h3>Restart Required</h3>
78  *
79  * A few properties may require that a restart is performed before they
80  * take effect. This flag provides a hint to this effect.
81  *
82  * @author Brett Smith <a HREF="mailto: brett@3sp.com">&lt;brett@3sp.com&gt;</a>
83  * @see com.sslexplorer.properties.PropertyDatabase
84  */

85 public interface PropertyDefinition extends Comparable JavaDoc<PropertyDefinition> {
86
87     /**
88      * Undefined
89      */

90     public static final String JavaDoc UNDEFINED_PARAMETER = "UNDEFINED";
91
92     /**
93      * Simple text field
94      */

95     public final static int TYPE_STRING = 0;
96     
97     /**
98      * Integer only text field
99      */

100     public final static int TYPE_INTEGER = 1;
101     
102     /**
103      * Checkbox
104      */

105     public final static int TYPE_BOOLEAN = 2;
106     
107     /**
108      * Combo box
109      */

110     public final static int TYPE_LIST = 3;
111     
112     /**
113      * Password text field
114      */

115     public final static int TYPE_PASSWORD = 4;
116     
117     /**
118      * Multiple entry list.
119      */

120     public final static int TYPE_MULTI_ENTRY_LIST = 5;
121     
122     /**
123      * Text area. Type metadata provides text area size
124      */

125     public final static int TYPE_TEXT_AREA = 6;
126     
127     /**
128      * Time field. Meta data determines unit
129      */

130     public final static int TYPE_TIME_IN_MS = 7;
131     
132     /**
133      * Colour
134      */

135     public final static int TYPE_COLOR = 8;
136     
137     /**
138      * Multiple selection list. Type metadata provides a class name that
139      * implements
140      */

141     public final static int TYPE_MULTI_SELECT_LIST = 9;
142
143     /**
144      * Type value when undefined (e.g. during the creation of a user
145      * defined attribute)
146      */

147     public final static int TYPE_UNDEFINED = -1;
148
149     /**
150      * The type of the constraint. Can be one of
151      * <code>SystemPropertyDefinition.TYPE_STRING</code>,
152      * <code>SystemPropertyDefinition.TYPE_INTEGER</code>,
153      * <code>SystemPropertyDefinition.TYPE_BOOLEAN</code>,
154      * <code>SystemPropertyDefinition.TYPE_LIST</code>,
155      * <code>SystemPropertyDefinition.TYPE_PASSWORD</code>,
156      * <code>SystemPropertyDefinition.TYPE_MULTI_ENTRY_LIST</code>,
157      * <code>SystemPropertyDefinition.TYPE_TEXT_AREA</code>,
158      * <code>SystemPropertyDefinition.TYPE_TIME_IN_MS</code>,
159      * <code>SystemPropertyDefinition.TYPE_COLOR</code> or
160      * <code>SystemPropertyDefinition.TYPE_MULTI_SELECT_LIST</code>.
161      *
162      * @return type
163      */

164     public int getType();
165
166     /**
167      * Get name of the property this definition is to be applied to.
168      *
169      * @return name
170      */

171     public String JavaDoc getName();
172
173     /**
174      * The type may require additional information. For example, the
175      * TYPE_LIST constraint requires a list of valid values, which in this case
176      * would be provided as a comma separated string. A blank string indicates
177      * no additional information, <code>null</code> is never returned
178      *
179      * @return constraint type meta data
180      */

181     public String JavaDoc getTypeMeta();
182
183     /**
184      * The type may require additional information. For example, the
185      * TYPE_LIST constraint requires a list of valid values, which in this case
186      * would be provided as a comma separated string. If <code>null</code> is
187      * supplied it will be converted to a blank string
188      *
189      * @param typeMeta
190      * constraint type meta data
191      */

192     public void setTypeMeta(String JavaDoc typeMeta);
193
194     /**
195      * Get the default value for this property.
196      *
197      * @return default value
198      */

199     public String JavaDoc getDefaultValue();
200
201     /**
202      * Get the category for this property.
203      *
204      * @return category
205      */

206     public int getCategory();
207
208     /**
209      * Set the category for this property.
210      *
211      * @param category
212      */

213     public void setCategory(int category);
214
215     /**
216      * Get the sort order within the category
217      *
218      * @return sort order
219      */

220     public int getSortOrder();
221
222     /**
223      * Set the default value
224      *
225      * @param name
226      */

227     public void setDefaultValue(String JavaDoc name);
228
229     /**
230      * Some types may provide their meta data thru an object. This
231      * method should return that object
232      *
233      * @return type meta object
234      */

235     public Object JavaDoc getTypeMetaObject();
236
237     /**
238      * Get the key of the message resources bundle that contains the names
239      * and descriptions of this property
240      *
241      * @return messages resources key
242      */

243     public String JavaDoc getMessageResourcesKey();
244     
245     /**
246      * Get if this property is hidden
247      *
248      * @return hidden
249      */

250     public boolean isHidden();
251     
252     /**
253      * Validate a value for this property. The implementation would usually have
254      * a set of default {@link PropertyValidator} for the type and also allow
255      * customised validators. The SSL-Explorer core includes a default set of
256      * validators which may be useful.
257      *
258      * @param value value to validate
259      * @param classLoader class loader to get validators from
260      * @throws CodedException on any validation error
261      * @throws ClassNotFoundException if validator cannot be found
262      */

263     public void validate(String JavaDoc value, ClassLoader JavaDoc classLoader) throws CodedException, ClassNotFoundException JavaDoc;
264     
265     
266     /**
267      * This is a hack to get around the current validation framework.
268      * @param validationString
269      * @deprecated
270      */

271     public void setValidationString(String JavaDoc validationString);
272
273     /**
274      * Invoked when the definition is registered with its type.
275      *
276      * @param propertyClass property class
277      */

278     public void init(PropertyClass propertyClass);
279
280     /**
281      * Get the property class of this definition
282      *
283      * @return property class
284      */

285     public PropertyClass getPropertyClass();
286     
287     /**
288      * Get if changing this property will require a restart
289      * before the new value is used
290      *
291      * @return restart required
292      */

293     public boolean isRestartRequired();
294
295 }
Popular Tags