KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sslexplorer > properties > attributes > AttributeDefinition


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.properties.attributes;
21
22 import com.sslexplorer.boot.PropertyClass;
23 import com.sslexplorer.boot.PropertyClassManager;
24 import com.sslexplorer.boot.PropertyDefinition;
25
26 /**
27  * Extension of the default {@link com.sslexplorer.boot.PropertyDefinition}
28  * implementation, instances of which may be created and maintained by the
29  * administrator to provide details for <i>Attributes</i>.
30  * <p>
31  * An attribute definition may have one of
32  * 4 visibilities. This may be one of {@link #USER_OVERRIDABLE_ATTRIBUTE},
33  * {@link #USER_VIEWABLE_ATTRIBUTE}, {@link #USER_USEABLE_ATTRIBUTE} or
34  * {@link #USER_CONFIDENTIAL_ATTRIBUTE}.
35  * <p>
36  * <i>User Confidential attributes</i> are encrypted using the users
37  * private key. See {@link com.sslexplorer.security.PublicKeyStore}.
38  *
39  * <p>
40  * Attribute definitions may be registered without being stored to the
41  * database by using
42  * {@link PropertyClass#registerPropertyDefinition(PropertyDefinition)} via
43  * {@link PropertyClassManager#getPropertyClass(String)}.
44  * <p>
45  * This is useful for plugins who may wish to attribute definitions without the
46  * user having to configure them. Such definitions cannot be edited or removed
47  * and should be marked as <i>System</i>.
48  * <p>
49  * In addition to the capabilities of a property definition, attribute
50  * definitions also require a label. Attributes registered as <i>System</i> may
51  * provide message resources that will be used in preference to the label field
52  * this class supports. This requires that the bundle ID has also been supplied.
53  * Message resources for labels should be specified as
54  * <i>userAttribte.[name].title</i>.
55  * <p>
56  * In the same way as labels, descriptions may also be supplied. This requires
57  * that the bundle ID has also been supplied and a message resource specified as
58  * <i>userAttribte.[name].description</i> exists.
59  * <p>
60  * Definitions may be categorised in one of two ways. Either a category ID that
61  * is a registered {@link com.sslexplorer.boot.PropertyDefinitionCategory}
62  * may be supplied, or a simple text label. The former is most likely to be used
63  * by attribute definitions registered by the core and plugins, the later for
64  * user defined definitions.
65  * <p>
66  * Attributes also have a <i>replaceable</i> attribute that determines if
67  * they may be used as replacement variables for attributes of the various
68  * different resource types.
69  *
70  * @author Brett Smith <a HREF="mailto: brett@3sp.com">&lt;brett@3sp.com&gt;</a>
71  * @see com.sslexplorer.security.UserDatabase
72  */

73 public interface AttributeDefinition extends PropertyDefinition {
74
75     /*
76      * Visibilities
77      */

78
79     /**
80      * The property may be set by an administrator and viewed, used and
81      * overridden by a user
82      */

83     public final static int USER_OVERRIDABLE_ATTRIBUTE = 4;
84
85     /**
86      * The property may be set by an administrator and viewed / used by a user
87      */

88     public final static int USER_VIEWABLE_ATTRIBUTE = 5;
89
90     /**
91      * The property may be set by an administrator and used by a user
92      */

93     public final static int USER_USEABLE_ATTRIBUTE = 6;
94
95     /**
96      * The property may be set and used only by a user. The value will
97      * be encrypted with the users private key
98      */

99     public final static int USER_CONFIDENTIAL_ATTRIBUTE = 7;
100
101     /**
102      * Visiblity is unknown
103      */

104     public static final int UNKNOWN = -1;
105
106     /**
107      * Get if this is a <i>System</i> attribute definition. If it is then
108      * the def. cannot be edited or removed
109      *
110      * @return system definition
111      */

112     public boolean isSystem();
113
114     /**
115      * Set if this is a <i>System</i> attribute definition. If it is then
116      * the def. cannot be edited or removed
117      *
118      * @param system system definition
119      */

120     public void setSystem(boolean system);
121
122     /**
123      * Get the label for this attribute. If an empty string is supplied the
124      * name will be used as the label in the user interface. Note that the
125      * actual label displayed to the use may be different if a message
126      * resource exists (see class documentation).
127      *
128      * @return label
129      */

130     public String JavaDoc getLabel();
131
132     /**
133      * Set the label for this attribute. If an empty string is supplied the
134      * name will be used as the label in the user interface. Note that the
135      * actual label displayed to the use may be different if a message
136      * resource exists (see class documentation).
137      *
138      * @param label label
139      */

140     public void setLabel(String JavaDoc label);
141
142     /**
143      * Get the category label. If this is not <code>null</code> then the
144      * category ID will be used to derive the category label from message
145      * resources.
146      *
147      * @return category label
148      */

149     public String JavaDoc getCategoryLabel();
150
151     /**
152      * Set the category label. If this is not <code>null</code> then the
153      * category ID will be used to derive the category label from message
154      * resources.
155      *
156      * @param categoryLabel category label
157      */

158     public void setCategoryLabel(String JavaDoc categoryLabel);
159
160     /**
161      * Set the label for this attribute. If an empty string is supplied the
162      * name will be used as the label in the user interface. Note that the
163      * actual description displayed to the use may be different if a message
164      * resource exists (see class documentation).
165      *
166      * @return description
167      */

168     public String JavaDoc getDescription();
169
170     /**
171      * Set the label for this attribute. If an empty string is supplied the
172      * name will be used as the label in the user interface. Note that the
173      * actual label displayed to the use may be different if there
174      *
175      * @param description description
176      */

177     public void setDescription(String JavaDoc description);
178     
179     /**
180      * Set whether this this attribute may be used for replacements.
181      *
182      * @param replaceable replaceable
183      */

184     public void setReplaceable(boolean replaceable);
185     
186     /**
187      * Get whether this this attribute may be used for replacements.
188      *
189      * @return replaceable
190      */

191     public boolean isReplaceable();
192
193     /**
194      * Set the validation string.
195      *
196      * @param validationString validation string
197      */

198     public void setValidationString(String JavaDoc validationString);
199
200     /**
201      * Get the validation string.
202      *
203      * @return validation string
204      */

205     public String JavaDoc getValidationString();
206
207
208     /**
209      * Get the value of this item as it should be stored as an attribute.
210      *
211      * @param value value to format
212      * @return formatted attribute value
213      */

214     public String JavaDoc formatAttributeValue(Object JavaDoc value);
215
216     /**
217      * Get the appropriate object for this type.
218      *
219      * @param value
220      * @return typed value
221      */

222     public Object JavaDoc parseValue(String JavaDoc value);
223
224     /**
225      * Set the sort order
226      *
227      * @param sortOrder sort order
228      * @see PropertyDefinition#getSortOrder()
229      */

230     public void setSortOrder(int sortOrder);
231
232     /**
233      * Set the visibility. This should only be called on initial creation.
234      *
235      * @param visibility
236      * @throws IllegalArgumentException if visibility has already been set
237      */

238     public void setVisibility(int visibility);
239
240     /**
241      * Get the visibility.
242      *
243      * @return visibility
244      */

245     public int getVisibility();
246
247     /**
248      * Set the name of the attribute. This should only be called on initial creation.
249      *
250      * @param string
251      * @throws IllegalStateException if name has already been set
252      */

253     public void setName(String JavaDoc string);
254
255     /**
256      * Set the type. This should only be called on initial creation.
257      *
258      * @param type
259      * @see PropertyDefinition#getType()
260      * @throws IllegalArgumentException if type has already been set
261      */

262     public void setType(int type);
263
264 }
265
Popular Tags