KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mmbase > bridge > Field


1 /*
2
3 This software is OSI Certified Open Source Software.
4 OSI Certified is a certification mark of the Open Source Initiative.
5
6 The license (Mozilla version 1.0) can be read at the MMBase site.
7 See http://www.MMBase.org/license
8
9 */

10
11 package org.mmbase.bridge;
12
13 import org.mmbase.datatypes.DataType;
14
15 /**
16  * This interface represents a node's field type information object.
17  *
18  * @author Pierre van Rooden
19  * @author Jaco de Groot
20  * @version $Id: Field.java,v 1.36 2006/04/18 13:13:12 michiel Exp $
21  */

22 public interface Field extends Descriptor {
23
24     /** MMBase base type identifier for the String data type */
25     public final static int TYPE_STRING = 1;
26     /** MMBase base type identifier for the Integer data type */
27     public final static int TYPE_INTEGER = 2;
28     /** MMBase base type identifier for the binary (byte[]) data type */
29     public final static int TYPE_BINARY = 4;
30     /**
31      * MMBase base type identifier for the binary (byte[]) data type
32      * @deprecated use {@link #TYPE_BINARY}
33      */

34     public final static int TYPE_BYTE = TYPE_BINARY;
35     /** MMBase base type identifier for the Float data type */
36     public final static int TYPE_FLOAT = 5;
37     /** MMBase base type identifier for the Double data type */
38     public final static int TYPE_DOUBLE = 6;
39     /** MMBase base type identifier for the Long data type */
40     public final static int TYPE_LONG = 7;
41     /** MMBase base type identifier for the DOM Document data type */
42     public final static int TYPE_XML = 8;
43     /** MMBase base type identifier for the Node data type */
44     public final static int TYPE_NODE = 9;
45     /**
46      * MMBase base type identifier for the Date data type
47      * @since MMBase-1.8
48      */

49     public final static int TYPE_DATETIME = 10;
50     /**
51      * MMBase base type identifier for the Boolean data type
52      * @since MMBase-1.8
53      */

54     public final static int TYPE_BOOLEAN = 11;
55     /**
56      * MMBase base type identifier for the List data type
57      * @since MMBase-1.8
58      */

59     public final static int TYPE_LIST = 12;
60     /** MMBase base type identifier for data types whose type is unknown */
61     public final static int TYPE_UNKNOWN = -1;
62
63
64     /** A field's state is 'virtual' if it is not persistent in storage. */
65     public final static int STATE_VIRTUAL = 0;
66     /** A field's state is 'persistent' if it is persistent in storage, and editable. */
67     public final static int STATE_PERSISTENT = 2;
68     /** A field's state is 'system' if it is persistent in storage, but not editable by users. */
69     public final static int STATE_SYSTEM = 3;
70     /** A field's state is 'system virtual' if it is not persistent in storage, nor editable by users.
71      * @todo reserved but not used yet
72      */

73     public final static int STATE_SYSTEM_VIRTUAL = 4;
74     /** The field's state when it is not (yet) known. */
75     public final static int STATE_UNKNOWN = -1;
76
77
78     /**
79      * Returns the node manager this field belongs to.
80      *
81      * @return the node manager this field belongs to
82      */

83     public NodeManager getNodeManager();
84
85     /**
86      * Returns this field's state identifier (virtual, persistent, system, systemvirtual).
87      *
88      * @return an <code>int</code> which identifies the state of this field
89      */

90     public int getState();
91
92     /**
93      * Returns the data type this field contains.
94      *
95      * @return a <code>DataType</code> object describing the constraints on this field.
96      * @since MMBase-1.8
97      */

98     public DataType getDataType();
99
100     /**
101      * Returns whether this field is part of a unique key (a set of fields whose combined content should
102      * occur only once).
103      * Note that MMBase lets the storage layer handle this. If your storage implementation or configuration does
104      * not support this the uniqueness may not be enforced.
105      *
106      * @return <code>true</code> if the field is part of a unique key
107      * @since MMBase-1.6
108      */

109     public boolean isUnique();
110
111     /**
112      * Returns whether this field is a key field, meaning that the storage layer should define an index for it, allowing
113      * optimization with search and sort actions.
114      * Note that MMBase lets the storage layer decide whether an index is actually defined.
115      * Some implementations or configurations may not do this.
116      * Note: Currently, this method only returns true if the field is the primary key (number field) or a Node field.
117      *
118      * @return <code>true</code> if the field has a key defined
119      * @since MMBase-1.7
120      */

121     public boolean hasIndex();
122
123     /**
124      * Returns the identifier for the MMBase base type for this field.
125      * This represents one of field type constants. This basic type determines how data is stored in MMBase.
126      * Note that it is possible that the datatype for a field (used for validation and in/out put) can be of a different
127      * basic type than how it is stored in the database. This shoudl not occur often, but is possible in some cases, such
128      * as when you use older clod models (which used INTEGER fields for dates).
129      * In general this should not prove a [problem - however you shoudl not assumeto know the classtype iof data of a
130      * field based on this method.
131      * To acquire the datatype's type, use <code>getDataType.getBaseType()</code> instead.
132      * @return an <code>int</code> which identifies the base type
133      */

134     public int getType();
135
136     /**
137      * If the type of this field is TYPE_LIST, this method returns the MMBase base type for the list elements.
138      * This represents one of field type constants. This basic type determines how data is stored in MMBase.
139      * For any field types other that TYPE_LIST, this method returns TYPE_UNKNOWN.
140      * @return an <code>int</code> which identifies the base type
141      */

142     public int getListItemType();
143
144     /**
145      * Retrieve the position of the field when searching.
146      * A value of -1 indicates the field is unavailable during search.
147      * @since MMBase-1.8
148      */

149     public int getSearchPosition();
150
151     /**
152      * Retrieve the position of the field when listing.
153      * A value of -1 indicates the field is unavailable in a list.
154      * @since MMBase-1.8
155      */

156     public int getListPosition();
157
158     /**
159      * Retrieve the position of the field when editing.
160      * A value of -1 indicates the field cannot be edited.
161      * @since MMBase-1.8
162      */

163     public int getEditPosition();
164
165     /**
166      * Retrieve the position of the field in the database table.
167      * @since MMBase-1.8
168      */

169     public int getStoragePosition();
170
171     /**
172      * Returns the GUI name for the data type this field contains.
173      * @deprecated use {@link #getDataType } and {@link DataType#getName}
174      * @see #getDataType
175      */

176     public String JavaDoc getGUIType();
177
178     /**
179      * Returns whether this field is required (should have content).
180      * Note that MMBase does not generally enforce required fields to be filled -
181      * If not provided, a default value (generally an empty string or the integer value -1)
182      * is filled in by the system.
183      * As such, isRequired will mostly be used as an indicator for (generic) editors.
184      *
185      * @return <code>true</code> if the field is required
186      * @since MMBase-1.6
187      */

188     public boolean isRequired();
189
190     /**
191      * Returns the maximum length of data this field can contain.
192      * For example if a field contains characters the size indicates the
193      * maximum number of characters it can contain.
194      * If the field is a numeric field (such as an integer), the result is -1.
195      *
196      * @return the maximum length of data this field can contain
197      */

198     public int getMaxLength();
199
200     /**
201      * Checks whether a given value is valid for this field.
202      * @return Collection of error-strings (describing the problem) in the current locale, or an empty collection if the value is ok.
203      * @since MMBase-1.8
204      */

205     public java.util.Collection JavaDoc validate(Object JavaDoc value);
206
207     /**
208      * A field's state is 'virtual' if it is not persistent in storage.
209      * @return <code>true</code> when a field is virtual
210      * @since MMBase-1.8
211      */

212     public boolean isVirtual();
213
214     /**
215      * Returns whether a field is 'read only' - that is, a user cannot edit it.
216      * In general, fields with state SYSTEM or SYSTEM_VIRTUAL are defined as read only, while others are not.
217      * It is possible to override this behaviour per field.
218      * @return <code>true</code> when a field is read only
219      * @since MMBase-1.8
220      */

221     public boolean isReadOnly();
222
223 }
224
Popular Tags