View Javadoc

1   /*
2    * Copyright (c) 2001 - 2005 ivata limited.
3    * All rights reserved.
4    * -----------------------------------------------------------------------------
5    * ivata masks may be redistributed under the GNU General Public
6    * License as published by the Free Software Foundation;
7    * version 2 of the License.
8    *
9    * These programs are free software; you can redistribute them and/or
10   * modify them under the terms of the GNU General Public License
11   * as published by the Free Software Foundation; version 2 of the License.
12   *
13   * These programs are distributed in the hope that they will be useful,
14   * but WITHOUT ANY WARRANTY; without even the implied warranty of
15   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16   *
17   * See the GNU General Public License in the file LICENSE.txt for more
18   * details.
19   *
20   * If you would like a copy of the GNU General Public License write to
21   *
22   * Free Software Foundation, Inc.
23   * 59 Temple Place - Suite 330
24   * Boston, MA 02111-1307, USA.
25   *
26   *
27   * To arrange commercial support and licensing, contact ivata at
28   *                  http://www.ivata.com/contact.jsp
29   * -----------------------------------------------------------------------------
30   * $Log: Field.java,v $
31   * Revision 1.7  2005/04/11 12:27:02  colinmacleod
32   * Added preliminary support for filters.
33   * Added FieldValueConvertor factor interface
34   * to split off value convertors for reuse.
35   *
36   * Revision 1.6  2005/04/09 18:04:14  colinmacleod
37   * Changed copyright text to GPL v2 explicitly.
38   *
39   * Revision 1.5  2005/03/10 10:19:24  colinmacleod
40   * Added getLabelKey().
41   *
42   * Revision 1.4  2005/01/19 12:35:04  colinmacleod
43   * Added hidden fields.
44   *
45   * Revision 1.3  2005/01/06 22:13:21  colinmacleod
46   * Moved up a version number.
47   * Changed copyright notices to 2005.
48   * Updated the documentation:
49   *   - started working on multiproject:site docu.
50   *   - changed the logo.
51   * Added checkstyle and fixed LOADS of style issues.
52   * Added separate thirdparty subproject.
53   * Added struts (in web), util and webgui (in webtheme) from ivata op.
54   *
55   * Revision 1.2  2004/12/30 20:14:08  colinmacleod
56   * Added comment for isMandatory.
57   *
58   * Revision 1.1  2004/12/29 20:07:07  colinmacleod
59   * Renamed subproject masks to mask.
60   *
61   * Revision 1.2  2004/11/11 13:31:36  colinmacleod
62   * Added mask.
63   *
64   * Revision 1.1.1.1  2004/05/16 20:40:31  colinmacleod
65   * Ready for 0.1 release
66   * -----------------------------------------------------------------------------
67   */
68  package com.ivata.mask.field;
69  import java.util.List;
70  import java.util.Properties;
71  import com.ivata.mask.Mask;
72  /***
73   * Defines a single field within a mask or group of masks.
74   *
75   * @since ivata masks 0.1 (2004-02-26)
76   * @author Colin MacLeod
77   * <a href='mailto:colin.macleod@ivata.com'>colin.macleod@ivata.com</a>
78   */
79  public interface Field {
80      /***
81       * Indicates the fields contents should be formatted as an amount.
82       */
83      String TYPE_AMOUNT = "amount";
84      /***
85       * Indicates the fields contents should be formatted as a date.
86       */
87      String TYPE_DATE = "date";
88      /***
89       * Indicates the fields contents should be formatted as a number.
90       */
91      String TYPE_NUMBER = "number";
92      /***
93       * Indicates the field is an option to be displayed as a radio button.
94       */
95      String TYPE_RADIO = "radio";
96      /***
97       * Indicates the field is displayed as a choice combo box.
98       */
99      String TYPE_SELECT = "select";
100     /***
101      * Indicates the field is displayed as a short text.
102      */
103     String TYPE_STRING = "string";
104     /***
105      * Indicates the field is displayed as a long text.
106      */
107     String TYPE_TEXTAREA = "textarea";
108     /***
109      * If this field represents a combo (select) type, returns the choices as a
110      * <code>Properties</code> instance.
111      *
112      * @return <code>Properties</code> instance representing the possible
113      *         values.
114      */
115     Properties getChoiceProperties();
116     /***
117      * If this field represents a combo (select) type, returns the choice keys
118      * as a <code>List</code> of <code>String</code> instances.
119      *
120      * @return <code>List</code> of <code>String</code> instances
121      *         representing the key values of all choice options.
122      */
123     List getChoicePropertyKeys();
124     /***
125      * Get the default value for this field. If no default has been defined for
126      * this field, is <code>null</code>.
127      *
128      * @return default value for this field, or <code>null</code> if none is
129      *         defined.
130      */
131     String getDefaultValue();
132     /***
133      * Get the data object class for this field, if appropriate.
134      *
135      * @return data object class if this field links to a data object, otherwise
136      *         <code>null</code>.
137      */
138     Class getDOClass();
139     /***
140      * Id of just this field.
141      *
142      * @return Id of just this field.
143      */
144     String getName();
145     /***
146      * <p>
147      * Get the field which contains this one.
148      * </p>
149      *
150      * @return Field which contains this field, or <code>null</code> if this
151      *         is a top-level field.
152      */
153     Field getParent();
154     /***
155      * <p>
156      * Return the full path to this field, including the names of parent fields
157      * separated by '.' characters. </p >
158      *
159      * @return Full path to this field, to uniquely identify it within the
160      *         system.
161      */
162     String getPath();
163     /***
164      * Indicates what sort of data this field should hold.
165      *
166      * @return type of the field, from one of the <code>TYPE_</code> values in
167      *         this interface.
168      */
169     String getType();
170     /***
171      * <p>
172      * If this field represents a value object, get the mask associated with
173      * this value object. <b>Note: </b> this is not the mask the field is in!.
174      * </p>
175      *
176      * @return Mask associated with this value object or <code>null</code> if
177      *         this field is not a value object.
178      */
179     Mask getValueObjectMask();
180     /***
181      * Get whether or not this field can be amended. Useful for automatically
182      * generated fields such as timestamps.
183      * @return <code>true</code> if the field <u>cannot</u> be manually changed.
184      */
185     boolean isDisplayOnly();
186     /***
187      * <p>
188      * Is this field hidden or displayed?
189      * </p>
190      *
191      * @return <code>true</code> if this field is hidden.
192      */
193     boolean isHidden();
194     /***
195      * <p>
196      * Is this field required or optional?
197      * </p>
198      *
199      * @return <code>true</code> if this field is required and must have a
200      *         non- <code>null</code>, non-empty value. Otherwise,
201      *         <code>false</code> for an optional field.
202      */
203     boolean isMandatory();
204     /***
205      * If this field represents another value object, but the relationship with
206      * its container is one-to-one, then it can be included in the parent's
207      * mask directly.
208      *
209      * @return <code>true</code> if this field should be displayed directly
210      * in the mask of the parent field.
211      */
212     boolean isOneToOne();
213 }