KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > opencms > file > CmsPropertyDefinition


1 /*
2  * File : $Source: /usr/local/cvs/opencms/src/org/opencms/file/CmsPropertyDefinition.java,v $
3  * Date : $Date: 2006/03/28 12:14:36 $
4  * Version: $Revision: 1.15 $
5  *
6  * This library is part of OpenCms -
7  * the Open Source Content Mananagement System
8  *
9  * Copyright (c) 2005 Alkacon Software GmbH (http://www.alkacon.com)
10  *
11  * This library is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Lesser General Public
13  * License as published by the Free Software Foundation; either
14  * version 2.1 of the License, or (at your option) any later version.
15  *
16  * This library is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  * Lesser General Public License for more details.
20  *
21  * For further information about Alkacon Software GmbH, please see the
22  * company website: http://www.alkacon.com
23  *
24  * For further information about OpenCms, please see the
25  * project website: http://www.opencms.org
26  *
27  * You should have received a copy of the GNU Lesser General Public
28  * License along with this library; if not, write to the Free Software
29  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30  */

31
32 package org.opencms.file;
33
34 import org.opencms.main.CmsIllegalArgumentException;
35 import org.opencms.util.CmsStringUtil;
36 import org.opencms.util.CmsUUID;
37
38 /**
39  * Defines a property name, so that <code>{@link CmsProperty}</code> instances can be created with that name.<p>
40  *
41  * @author Alexander Kandzior
42  *
43  * @version $Revision: 1.15 $
44  *
45  * @since 6.0.0
46  */

47 public class CmsPropertyDefinition implements Cloneable JavaDoc, Comparable JavaDoc {
48
49     /** The name constraints when generating new properties. */
50     public static final String JavaDoc NAME_CONSTRAINTS = "-._~$";
51
52     /** Property for the active method in the administration view. */
53     public static final String JavaDoc PROPERTY_ACTIV = "activemethod";
54
55     /** Property for the allowed set of locales. */
56     public static final String JavaDoc PROPERTY_AVAILABLE_LOCALES = "locale-available";
57
58     /** Property to control the Java class for body. */
59     public static final String JavaDoc PROPERTY_BODY_CLASS = "templateclass";
60
61     /** The name of the VFS property that controls the caching. */
62     public static final String JavaDoc PROPERTY_CACHE = "cache";
63
64     /** Property for the channel id. */
65     public static final String JavaDoc PROPERTY_CHANNELID = "ChannelId";
66
67     /** Property for the content conversion. */
68     public static final String JavaDoc PROPERTY_CONTENT_CONVERSION = "content-conversion";
69
70     /** Property for the content encoding. */
71     public static final String JavaDoc PROPERTY_CONTENT_ENCODING = "content-encoding";
72
73     /** Property for the default file in folders. */
74     public static final String JavaDoc PROPERTY_DEFAULT_FILE = "default-file";
75
76     /** Property for the description. */
77     public static final String JavaDoc PROPERTY_DESCRIPTION = "Description";
78
79     /** Property for the resource title. */
80     public static final String JavaDoc PROPERTY_ENABLE_NOTIFICATION = "enable-notification";
81
82     /** Property for the static export. */
83     public static final String JavaDoc PROPERTY_EXPORT = "export";
84
85     /** Property for the resource export name, during export this name is used instead of the resource name. */
86     public static final String JavaDoc PROPERTY_EXPORTNAME = "exportname";
87
88     /** Property for JSP additional suffix during static export, default is "html". */
89     public static final String JavaDoc PROPERTY_EXPORTSUFFIX = "exportsuffix";
90
91     /** Property to control the folders where templatea or default bodies should be available. */
92     public static final String JavaDoc PROPERTY_FOLDERS_AVAILABLE = "folders.available";
93
94     /** Property constant for <code>"image.size"</code>. */
95     public static final String JavaDoc PROPERTY_IMAGE_SIZE = "image.size";
96
97     /** Property for internal use (e.g. delete). */
98     public static final String JavaDoc PROPERTY_INTERNAL = "internal";
99
100     /** Property for the keywords. */
101     public static final String JavaDoc PROPERTY_KEYWORDS = "Keywords";
102
103     /** Property for the current locale. */
104     public static final String JavaDoc PROPERTY_LOCALE = "locale";
105
106     /** Property for the current locale. */
107     public static final String JavaDoc PROPERTY_LOCALE_DEFAULT = "locale-default";
108
109     /** Property for the login form. */
110     public static final String JavaDoc PROPERTY_LOGIN_FORM = "login-form";
111
112     /** Property constant for <code>"NavImage"</code>. */
113     public static final String JavaDoc PROPERTY_NAVIMAGE = "NavImage";
114
115     /** Property constant for <code>"NavInfo"</code>. */
116     public static final String JavaDoc PROPERTY_NAVINFO = "NavInfo";
117
118     /** Property for the navigation position. */
119     public static final String JavaDoc PROPERTY_NAVPOS = "NavPos";
120
121     /** Property for the navigation text. */
122     public static final String JavaDoc PROPERTY_NAVTEXT = "NavText";
123
124     /** Property for the resource title. */
125     public static final String JavaDoc PROPERTY_NOTIFICATION_INTERVAL = "notification-interval";
126
127     /** Property for the relative root link substitution. */
128     public static final String JavaDoc PROPERTY_RELATIVEROOT = "relativeroot";
129
130     /** Property name that defines the available resource types for the "new" dialog. */
131     public static final String JavaDoc PROPERTY_RESTYPES_AVAILABLE = "restypes.available";
132
133     /** Property to sort search results in categories. */
134     public static final String JavaDoc PROPERTY_SEARCH_CATEGORY = "category";
135
136     /** Property to define a bean for search content extraction. */
137     public static final String JavaDoc PROPERTY_SEARCH_EXTRACTIONCLASS = "search.extractionclass";
138
139     /** Property to boost certain search results. */
140     public static final String JavaDoc PROPERTY_SEARCH_PRIORITY = "search.priority";
141
142     /** Property for the secure transmission of resources. */
143     public static final String JavaDoc PROPERTY_SECURE = "secure";
144
145     /** Property for the stylesheet of files. */
146     public static final String JavaDoc PROPERTY_STYLESHEET = "stylesheet";
147
148     /** Property to control the template. */
149     public static final String JavaDoc PROPERTY_TEMPLATE = "template";
150
151     /** Property to control the template elements. */
152     public static final String JavaDoc PROPERTY_TEMPLATE_ELEMENTS = "template-elements";
153
154     /** Property for the resource title. */
155     public static final String JavaDoc PROPERTY_TITLE = "Title";
156
157     /** Property for the visible method in the administration view. */
158     public static final String JavaDoc PROPERTY_VISIBLE = "visiblemethod";
159
160     /** The propertydefinitiontype for resources. */
161     public static final int PROPERYDEFINITION_RESOURCE = 1;
162
163     /** The null property definition object. */
164     private static final CmsPropertyDefinition NULL_PROPERTY_DEFINITION = new CmsPropertyDefinition(
165         CmsUUID.getNullUUID(),
166         "");
167
168     /** The id of this property definition. */
169     private CmsUUID m_id;
170
171     /** The name of this property definition. */
172     private String JavaDoc m_name;
173
174     /**
175      * Creates a new CmsPropertydefinition.<p>
176      * @param id the id of the property definition
177      * @param name the name of the property definition
178      */

179     public CmsPropertyDefinition(CmsUUID id, String JavaDoc name) {
180
181         m_id = id;
182         m_name = name;
183     }
184
185     /**
186      * Checks if the provided property name is a valid property name,
187      * that is contains only valid characters.<p>
188      *
189      * A property name can only be composed of digits,
190      * standard ASCII letters and the symbols defined in {@link #NAME_CONSTRAINTS}.<p>
191      *
192      * @param name the property name to check
193      *
194      * @throws CmsIllegalArgumentException if the given property name is not valid
195      */

196     public static void checkPropertyName(String JavaDoc name) throws CmsIllegalArgumentException {
197
198         if (CmsStringUtil.isEmptyOrWhitespaceOnly(name)) {
199             throw new CmsIllegalArgumentException(Messages.get().container(Messages.ERR_BAD_PROPERTYNAME_EMPTY_0, name));
200         }
201
202         CmsStringUtil.checkName(name, NAME_CONSTRAINTS, Messages.ERR_BAD_PROPERTYNAME_4, Messages.get());
203     }
204
205     /**
206      * Returns the null property definition.<p>
207      *
208      * @return the null property definition
209      */

210     public static CmsPropertyDefinition getNullPropertyDefinition() {
211
212         return CmsPropertyDefinition.NULL_PROPERTY_DEFINITION;
213     }
214
215     /**
216      * Returns a clone of this Objects instance.<p>
217      *
218      * @return a clone of this instance
219      */

220     public Object JavaDoc clone() {
221
222         return new CmsPropertyDefinition(m_id, m_name);
223     }
224
225     /**
226      * @see java.lang.Comparable#compareTo(java.lang.Object)
227      */

228     public int compareTo(Object JavaDoc obj) {
229
230         if (obj == this) {
231             return 0;
232         }
233         if (obj instanceof CmsPropertyDefinition) {
234             return m_name.compareTo(((CmsPropertyDefinition)obj).m_name);
235         }
236         return 0;
237     }
238
239     /**
240      * @see java.lang.Object#equals(java.lang.Object)
241      */

242     public boolean equals(Object JavaDoc obj) {
243
244         if (obj == this) {
245             return true;
246         }
247         if (obj instanceof CmsPropertyDefinition) {
248             return ((CmsPropertyDefinition)obj).m_id.equals(m_id);
249         }
250         return false;
251     }
252
253     /**
254      * Returns the id of this property definition.<p>
255      *
256      * @return id the id of this Propertydefinition
257      */

258     public CmsUUID getId() {
259
260         return m_id;
261     }
262
263     /**
264      * Returns the name of this property definition.<p>
265      *
266      * @return name The name of this property definition
267      */

268     public String JavaDoc getName() {
269
270         return m_name;
271     }
272
273     /**
274      * @see java.lang.Object#hashCode()
275      */

276     public int hashCode() {
277
278         if (m_name != null) {
279             return m_name.hashCode();
280         }
281         return 0;
282     }
283
284     /**
285      * @see java.lang.Object#toString()
286      */

287     public String JavaDoc toString() {
288
289         StringBuffer JavaDoc result = new StringBuffer JavaDoc();
290         result.append("[Propertydefinition]");
291         result.append(" name:");
292         result.append(m_name);
293         result.append(" id:");
294         result.append(m_id);
295         return result.toString();
296     }
297 }
Popular Tags