001: /*
002: * Copyright (c) 2001 - 2005 ivata limited.
003: * All rights reserved.
004: * -----------------------------------------------------------------------------
005: * ivata masks may be redistributed under the GNU General Public
006: * License as published by the Free Software Foundation;
007: * version 2 of the License.
008: *
009: * These programs are free software; you can redistribute them and/or
010: * modify them under the terms of the GNU General Public License
011: * as published by the Free Software Foundation; version 2 of the License.
012: *
013: * These programs are distributed in the hope that they will be useful,
014: * but WITHOUT ANY WARRANTY; without even the implied warranty of
015: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
016: *
017: * See the GNU General Public License in the file LICENSE.txt for more
018: * details.
019: *
020: * If you would like a copy of the GNU General Public License write to
021: *
022: * Free Software Foundation, Inc.
023: * 59 Temple Place - Suite 330
024: * Boston, MA 02111-1307, USA.
025: *
026: *
027: * To arrange commercial support and licensing, contact ivata at
028: * http://www.ivata.com/contact.jsp
029: * -----------------------------------------------------------------------------
030: * $Log: Field.java,v $
031: * Revision 1.9 2005/09/29 12:12:30 colinmacleod
032: * Added password field type.
033: *
034: * Revision 1.8 2005/09/16 13:41:18 colinmacleod
035: * Created new convertor class to handle timestamps.
036: *
037: * Revision 1.7 2005/04/11 12:27:02 colinmacleod
038: * Added preliminary support for filters.
039: * Added FieldValueConvertor factor interface
040: * to split off value convertors for reuse.
041: *
042: * Revision 1.6 2005/04/09 18:04:14 colinmacleod
043: * Changed copyright text to GPL v2 explicitly.
044: *
045: * Revision 1.5 2005/03/10 10:19:24 colinmacleod
046: * Added getLabelKey().
047: *
048: * Revision 1.4 2005/01/19 12:35:04 colinmacleod
049: * Added hidden fields.
050: *
051: * Revision 1.3 2005/01/06 22:13:21 colinmacleod
052: * Moved up a version number.
053: * Changed copyright notices to 2005.
054: * Updated the documentation:
055: * - started working on multiproject:site docu.
056: * - changed the logo.
057: * Added checkstyle and fixed LOADS of style issues.
058: * Added separate thirdparty subproject.
059: * Added struts (in web), util and webgui (in webtheme) from ivata op.
060: *
061: * Revision 1.2 2004/12/30 20:14:08 colinmacleod
062: * Added comment for isMandatory.
063: *
064: * Revision 1.1 2004/12/29 20:07:07 colinmacleod
065: * Renamed subproject masks to mask.
066: *
067: * Revision 1.2 2004/11/11 13:31:36 colinmacleod
068: * Added mask.
069: *
070: * Revision 1.1.1.1 2004/05/16 20:40:31 colinmacleod
071: * Ready for 0.1 release
072: * -----------------------------------------------------------------------------
073: */
074: package com.ivata.mask.field;
075:
076: import java.util.List;
077: import java.util.Properties;
078:
079: import com.ivata.mask.Mask;
080:
081: /**
082: * Defines a single field within a mask or group of masks.
083: *
084: * @since ivata masks 0.1 (2004-02-26)
085: * @author Colin MacLeod
086: * <a href='mailto:colin.macleod@ivata.com'>colin.macleod@ivata.com</a>
087: */
088: public interface Field {
089: /**
090: * Indicates the fields contents should be formatted as an amount.
091: */
092: String TYPE_AMOUNT = "amount";
093: /**
094: * Indicates the fields contents should be formatted as a date.
095: */
096: String TYPE_DATE = "date";
097: /**
098: * Indicates the fields contents should be formatted as a number.
099: */
100: String TYPE_NUMBER = "number";
101: /**
102: * Indicates the field is an option to be displayed as a password field.
103: */
104: String TYPE_PASSWORD = "password";
105: /**
106: * Indicates the field is an option to be displayed as a radio button.
107: */
108: String TYPE_RADIO = "radio";
109: /**
110: * Indicates the field is displayed as a choice combo box.
111: */
112: String TYPE_SELECT = "select";
113: /**
114: * Indicates the field is displayed as a short text.
115: */
116: String TYPE_STRING = "string";
117: /**
118: * Indicates the field is displayed as a long text.
119: */
120: String TYPE_TEXTAREA = "textarea";
121: /**
122: * Indicates the fields contents should be formatted as a long timestamp.
123: */
124: String TYPE_TIMESTAMP = "timestamp";
125:
126: /**
127: * If this field represents a combo (select) type, returns the choices as a
128: * <code>Properties</code> instance.
129: *
130: * @return <code>Properties</code> instance representing the possible
131: * values.
132: */
133: Properties getChoiceProperties();
134:
135: /**
136: * If this field represents a combo (select) type, returns the choice keys
137: * as a <code>List</code> of <code>String</code> instances.
138: *
139: * @return <code>List</code> of <code>String</code> instances
140: * representing the key values of all choice options.
141: */
142: List getChoicePropertyKeys();
143:
144: /**
145: * Get the default value for this field. If no default has been defined for
146: * this field, is <code>null</code>.
147: *
148: * @return default value for this field, or <code>null</code> if none is
149: * defined.
150: */
151: String getDefaultValue();
152:
153: /**
154: * Get the data object class for this field, if appropriate.
155: *
156: * @return data object class if this field links to a data object, otherwise
157: * <code>null</code>.
158: */
159: Class getDOClass();
160:
161: /**
162: * Id of just this field.
163: *
164: * @return Id of just this field.
165: */
166: String getName();
167:
168: /**
169: * <p>
170: * Get the field which contains this one.
171: * </p>
172: *
173: * @return Field which contains this field, or <code>null</code> if this
174: * is a top-level field.
175: */
176: Field getParent();
177:
178: /**
179: * <p>
180: * Return the full path to this field, including the names of parent fields
181: * separated by '.' characters. </p >
182: *
183: * @return Full path to this field, to uniquely identify it within the
184: * system.
185: */
186: String getPath();
187:
188: /**
189: * Indicates what sort of data this field should hold.
190: *
191: * @return type of the field, from one of the <code>TYPE_</code> values in
192: * this interface.
193: */
194: String getType();
195:
196: /**
197: * <p>
198: * If this field represents a value object, get the mask associated with
199: * this value object. <b>Note: </b> this is not the mask the field is in!.
200: * </p>
201: *
202: * @return Mask associated with this value object or <code>null</code> if
203: * this field is not a value object.
204: */
205: Mask getValueObjectMask();
206:
207: /**
208: * Get whether or not this field can be amended. Useful for automatically
209: * generated fields such as timestamps.
210: * @return <code>true</code> if the field <u>cannot</u> be manually changed.
211: */
212: boolean isDisplayOnly();
213:
214: /**
215: * <p>
216: * Is this field hidden or displayed?
217: * </p>
218: *
219: * @return <code>true</code> if this field is hidden.
220: */
221: boolean isHidden();
222:
223: /**
224: * <p>
225: * Is this field required or optional?
226: * </p>
227: *
228: * @return <code>true</code> if this field is required and must have a
229: * non- <code>null</code>, non-empty value. Otherwise,
230: * <code>false</code> for an optional field.
231: */
232: boolean isMandatory();
233:
234: /**
235: * If this field represents another value object, but the relationship with
236: * its container is one-to-one, then it can be included in the parent's
237: * mask directly.
238: *
239: * @return <code>true</code> if this field should be displayed directly
240: * in the mask of the parent field.
241: */
242: boolean isOneToOne();
243: }
|