KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > jcorporate > expresso > core > dataobjects > DataFieldMetaData


1 /* ====================================================================
2  * The Jcorporate Apache Style Software License, Version 1.2 05-07-2002
3  *
4  * Copyright (c) 1995-2002 Jcorporate Ltd. All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  *
13  * 2. Redistributions in binary form must reproduce the above copyright
14  * notice, this list of conditions and the following disclaimer in
15  * the documentation and/or other materials provided with the
16  * distribution.
17  *
18  * 3. The end-user documentation included with the redistribution,
19  * if any, must include the following acknowledgment:
20  * "This product includes software developed by Jcorporate Ltd.
21  * (http://www.jcorporate.com/)."
22  * Alternately, this acknowledgment may appear in the software itself,
23  * if and wherever such third-party acknowledgments normally appear.
24  *
25  * 4. "Jcorporate" and product names such as "Expresso" must
26  * not be used to endorse or promote products derived from this
27  * software without prior written permission. For written permission,
28  * please contact info@jcorporate.com.
29  *
30  * 5. Products derived from this software may not be called "Expresso",
31  * or other Jcorporate product names; nor may "Expresso" or other
32  * Jcorporate product names appear in their name, without prior
33  * written permission of Jcorporate Ltd.
34  *
35  * 6. No product derived from this software may compete in the same
36  * market space, i.e. framework, without prior written permission
37  * of Jcorporate Ltd. For written permission, please contact
38  * partners@jcorporate.com.
39  *
40  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
41  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
42  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
43  * DISCLAIMED. IN NO EVENT SHALL JCORPORATE LTD OR ITS CONTRIBUTORS
44  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
45  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
46  * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
47  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
48  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
49  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
50  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51  * SUCH DAMAGE.
52  * ====================================================================
53  *
54  * This software consists of voluntary contributions made by many
55  * individuals on behalf of the Jcorporate Ltd. Contributions back
56  * to the project(s) are encouraged when you make modifications.
57  * Please send them to support@jcorporate.com. For more information
58  * on Jcorporate Ltd. and its products, please see
59  * <http://www.jcorporate.com/>.
60  *
61  * Portions of this software are based upon other open source
62  * products and are subject to their respective licenses.
63  */

64
65 package com.jcorporate.expresso.core.dataobjects;
66
67 import org.apache.oro.text.regex.Pattern;
68
69 import java.util.Iterator JavaDoc;
70
71 /**
72  * This interface will eventually have the same public functionality as
73  * <code>DBField</code>. It is just used as &quot;Interface&quote; glue right
74  * now. It will be fleshed out significantly in future versions.
75  * <p/>
76  * This interface represents the descriptive data for a particular DataField.
77  * </p>
78  *
79  * @author Michael Rimov
80  * @since Expresso 5.0
81  */

82
83 public interface DataFieldMetaData {
84
85     /**
86      * Does this field allow nulls?
87      *
88      * @return boolean True if the field allows null, else false if it does not
89      */

90     public boolean allowsNull();
91
92
93     /**
94      * Retrieve the default value of the field.
95      *
96      * @return String java.lang.String
97      */

98     public String JavaDoc getDefaultValue();
99
100     /**
101      * Return the description of this field. This field name is not i18n'ized,
102      * use DataObjectMetaData with Locale parameter to get the i18n'ized escription
103      *
104      * @return String Description of the field
105      */

106     public String JavaDoc getDescription();
107
108     /**
109      * Return the length of this field as an integer
110      *
111      * @return int The length of this field in characters
112      */

113     public int getLengthInt();
114
115     /**
116      * Return the value for the lookupObject for this field
117      *
118      * @return String for the lookup object for this field
119      */

120     public String JavaDoc getLookupObject();
121
122     /**
123      * When you get a lookup object, to perform a complete mapping between the
124      * two, you need to know what field name in the remote object maps to this
125      * field.
126      *
127      * @return java.lang.String or null if there is no lookup field
128      * @throws IllegalArgumentException if the field name does not exist
129      */

130     public String JavaDoc getLookupField();
131
132     /**
133      * Future versions of Expresso will rely more on objects that are shown as
134      * unique by a combination of their classname and their definition names. All
135      * instances of Defineable must have a corresponding definition name.
136      *
137      * @return java.lang.String
138      */

139     public String JavaDoc getLookupDefinition();
140
141     /**
142      * Return the name of the field
143      *
144      * @return String The name of this field
145      */

146     public String JavaDoc getName();
147
148     /**
149      * Return the precision of this field as an integer
150      *
151      * @return int The precision of this field
152      */

153     public int getPrecision();
154
155     /**
156      * Return the database type of the field as specified with a
157      * string in the DBObject itself
158      *
159      * @return The type of this field
160      */

161     public String JavaDoc getTypeString();
162
163     /**
164      * Is this field a key field?
165      *
166      * @return true if this field is a key field
167      */

168     public boolean isKey();
169
170     /**
171      * Is this field multi-valued?
172      *
173      * @return boolean True if the field is multi-valued, else false
174      */

175     public boolean isMultiValued();
176
177     /**
178      * Return the field's read-only
179      *
180      * @return True if the field is readonly, else false if it is not
181      */

182     public boolean isReadOnly();
183
184     /**
185      * is the field a boolean?
186      * cache answer for efficiency, since field type is immutable
187      *
188      * @return True if the field is boolean
189      */

190     public boolean isBooleanType();
191
192     /**
193      * Is this field fall into the classification of a long character
194      * object?
195      *
196      * @return boolean true if it does
197      */

198     public boolean isCharacterLongObjectType();
199
200     /**
201      * Does this field fall into a class of BLOB object data types?
202      *
203      * @return boolean true if it does
204      */

205     public boolean isLongObjectType();
206
207     /**
208      * Is it a BLOB? This is calculated by if it is a long object
209      * and is NOT a character long object.
210      *
211      * @return boolean True if it is
212      */

213     public boolean isBinaryObjectType();
214
215     /**
216      * Is it a BLOB? This is calculated by if it is a long object
217      * and is NOT a character long object.
218      *
219      * @return boolean True if it is
220      */

221     public boolean isLongBinaryType();
222
223     /**
224      * Is it a BLOB? This is calculated by if it is a long object
225      * and is NOT a character long object.
226      *
227      * @return boolean True if it is
228      */

229     public boolean isLongCharacterType();
230
231     /**
232      * is the field a quoted text field?
233      * cache answer for efficiency, since field type is immutable
234      *
235      * @return True if the field is text field
236      */

237     public boolean isQuotedTextType();
238
239     /**
240      * is the field a numeric field?
241      * cache answer for efficiency, since field type is immutable
242      *
243      * @return true if the field is numberic field
244      */

245     public boolean isNumericType();
246
247     /**
248      * is the field a date or time field?
249      * cache answer for efficiency, since field type is immutable
250      *
251      * @return true if the field is date or time field
252      */

253     public boolean isDateType();
254
255     /**
256      * is the field a date or time field?
257      * cache answer for efficiency, since field type is immutable
258      * author Yves Henri AMAIZO
259      *
260      * @return true if the field is date field
261      */

262     public boolean isDateOnlyType();
263
264     public boolean isFloatingPointType();
265
266     /**
267      * is the field a date or time field?
268      * cache answer for efficiency, since field type is immutable
269      * author Yves Henri AMAIZO
270      *
271      * @return true if the field is time field
272      */

273     public boolean isTimeType();
274
275
276     /**
277      * is the field a date or time field?
278      * cache answer for efficiency, since field type is immutable
279      * author Yves Henri AMAIZO
280      *
281      * @return true if the field is dateTime or Timestamp field
282      */

283     public boolean isDateTimeType();
284
285     /**
286      * Return the field's secret status
287      *
288      * @return True if the field is secret, else false if it is not
289      */

290     public boolean isSecret();
291
292     /**
293      * Return the field's hashed status
294      *
295      * @return True if the field is secret, else false if it is not
296      * @todo This is not completely implemented yet.
297      */

298     public boolean isHashed();
299
300     /**
301      * Return the field's hashed status
302      *
303      * @return True if the field is secret, else false if it is not
304      * @todo This is not completely implemented yet.
305      */

306     public boolean isEncrypted();
307
308     /**
309      * Is this field a virtual field? E.g. not stored in the database
310      *
311      * @return boolean True if the field is virtual, else false
312      */

313     public boolean isVirtual();
314
315     /**
316      * Return boolean if the field has a mask set
317      *
318      * @return True if the field mask is set, else false if it is not
319      */

320     public boolean isMasked();
321
322     /**
323      * Set this field as a key field (or not)
324      *
325      * @param newKey Is this field a key?
326      */

327     public void setKey(boolean newKey);
328
329     /**
330      * Set the value for the "lookup object" for this field. This is
331      * a database object name which can be used to look up valid
332      * values for this field by the user. This is used by the standard
333      * maintenance forms to create a "Lookup" link alongside the
334      * field if this value is set
335      *
336      * @param objectName the classname of the lookup object
337      */

338     public void setLookupObject(String JavaDoc objectName);
339
340     /**
341      * Set this field to be "multi-valued". A multi-valued field has
342      * a specific set of valid values, often from another database
343      * object. Any multi-valued field may be used in a call to the
344      * getValues method, which will return a hashtable of the valid
345      * values for the field and descriptions for those values.
346      *
347      * @param newMulti True if the field is multi-valued, false if it is not
348      */

349     public void setMultiValued(boolean newMulti);
350
351     /**
352      * Set the field's hashed status. Only works if the field is a string
353      * data type (in the future CLOB should be ok too) [This is currently not
354      * yet implemented and tested]
355      *
356      * @param newValue true if you want this field hashed.
357      */

358     public void setHashed(boolean newValue);
359
360     /**
361      * Set the field's encrypted status
362      *
363      * @param newValue new value if you want an encrypted field
364      * @todo This is not completely implemented yet.
365      */

366     public void setEncrypted(boolean newValue);
367
368
369     /**
370      * Sets the new default value as a string for the field.
371      *
372      * @param newValue String
373      */

374     public void setDefaultValue(String JavaDoc newValue);
375
376     /**
377      * Set the field as a read-only field. Read only fields are still used
378      * against the database, but are not offered for updating when the
379      * automatic database maintenance servlet creates a form on the screen. Note
380      * this is different from the setAutoIncremented method below, which
381      * means this field will not participate in any add or update statement
382      * to the database.
383      */

384     public void setReadOnly();
385
386     /**
387      * Is this field an auto-incremented field?
388      *
389      * @return true if this field is autoincremented
390      */

391     public boolean isAutoIncremented();
392
393     /**
394      * Set the field as a 'secret' field. Secret fields are not shown
395      * in listings of data from this database object, and are only available
396      * to users with update, add or delete permissions
397      */

398     public void setSecret();
399
400     /**
401      * Set this field as a virtual field. A virtual field is part of the object
402      * but not stored in the database table.
403      *
404      * @param newVirtual True to make this object virtual, false if it is not
405      */

406     public void setVirtual(boolean newVirtual);
407
408     /**
409      * Set a regular expression "mask" for this field that specifies it's
410      * valid values. The mask should already be compiled by the regular
411      * expression compiler
412      *
413      * @param newMask The compiled regular expression mask
414      */

415     public void setMask(Pattern newMask);
416
417     /**
418      * Get the compiled regular expression for this field.
419      *
420      * @return the precompiled regular expression mask
421      */

422     public Pattern getMask();
423
424     /**
425      * Removes an attribute from this Field object.
426      *
427      * @param attribName The name of the attribute to remove from this field.
428      */

429     public void removeAttribute(String JavaDoc attribName);
430
431     /**
432      * Sets an attribute for this particular field.
433      *
434      * @param attribName the name of the attribute
435      * @param attribValue the value of the attribute by this name
436      */

437     public void setAttribute(String JavaDoc attribName, Object JavaDoc attribValue);
438
439
440     /**
441      * Returns an attribute keyed by name. An attribute is an arbitrary object
442      * you can associate with a particular db field.
443      *
444      * @param attribName the name of the attribute to get
445      * @return java.lang.Object the object associated with this attribute name
446      */

447     public Object JavaDoc getAttribute(String JavaDoc attribName);
448
449
450     /**
451      * Retrieve a list of all attribute names in the field
452      *
453      * @return java.util.Set
454      */

455     public java.util.Set JavaDoc getAllAttributes();
456
457     /**
458      * Returns a copy of all attributes associated with this field.
459      *
460      * @return a valid Iterator to a HashMap OR null if no attributes exist for
461      * this field
462      */

463     public Iterator JavaDoc getAttributesIterator();
464
465 }
466
Popular Tags