001: /*
002: * Copyright (c) 2001 - 2005 ivata limited.
003: * All rights reserved.
004: * -----------------------------------------------------------------------------
005: * ivata groupware 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: FieldInfo.java,v $
031: * Revision 1.3 2005/10/03 10:21:15 colinmacleod
032: * Fixed some style and javadoc issues.
033: *
034: * Revision 1.2 2005/10/02 14:08:59 colinmacleod
035: * Added/improved log4j logging.
036: *
037: * Revision 1.1 2005/09/29 13:06:05 colinmacleod
038: * First version of setting subproject.
039: * Existing classes restructured, new setting user interface created.
040: * Flexible XML UI configuration makes it easy to reuse the same web pages in
041: * other projects.
042: * Web files work as stand-alone webapp for testing.
043: *
044: */
045: package com.ivata.groupware.admin.setting.struts;
046:
047: import org.apache.log4j.Logger;
048:
049: import java.util.List;
050:
051: /**
052: * Used to set additional information about a setting field's display character.
053: *
054: * @since ivata groupware 1.0 (21-Sep-2005)
055: * @author Colin MacLeod <colin.macleod@ivata.com>
056: * @version $Revision: 1.3 $
057: */
058:
059: public class FieldInfo {
060: /**
061: * Logger for this class.
062: */
063: private static final Logger logger = Logger
064: .getLogger(FieldInfo.class);
065:
066: /**
067: * Indiates the field should be generated as a date format. The
068: * data element will contain a list of <code>String</code>
069: * instances, with default values.
070: */
071: public static String TYPE_DATE_FORMAT = "dateFormat";
072: /**
073: * Indiates the field should be generated as a selection of values. The
074: * data element will contain a list of <code>LabelValueBean</code>
075: * instances.
076: */
077: public static String TYPE_SELECT = "select";
078: /**
079: * Indiates the field should be generated as a default text field (default).
080: */
081: public static String TYPE_TEXT = "text";
082: /**
083: * Indiates the field should be generated as a large text area.
084: */
085: public static String TYPE_TEXTAREA = "textarea";
086: /**
087: * Indiates the field should be generated as a boolean (checkbox).
088: */
089: public static String TYPE_BOOLEAN = "boolean";
090: /**
091: * Indiates the field should be generated as a timezone - a list of all
092: * available timezones is shown.
093: */
094: public static String TYPE_TIMEZONE = "timezone";
095: /**
096: * Indiates a label from the message resources.
097: */
098: public static String TYPE_LABEL = "label";
099: /**
100: * For a date field, this stores sample formats; for a select fields, it
101: * stores LabelValueBean instances for the select options.
102: */
103: private List data;
104: /**
105: * Indicates the type of field. Set to one of the TYPE... constants.
106: */
107: private String type;
108:
109: /**
110: * Construct a field info instance with default text type.
111: */
112: public FieldInfo() {
113: this (TYPE_TEXT);
114: }
115:
116: /**
117: * Construct a field info instance with the given type.
118: * @param typeParam
119: * <copyDoc>Refer to {@link #getType}.</copyDoc>
120: */
121: public FieldInfo(final String typeParam) {
122: this (typeParam, null);
123: }
124:
125: /**
126: * Construct a field info instance with the given type and default data.
127: *
128: * @param typeParam
129: * <copyDoc>Refer to {@link #getType}.</copyDoc>
130: * @param dataParam
131: * <copyDoc>Refer to {@link #getData}.</copyDoc>
132: */
133: public FieldInfo(final String typeParam, final List dataParam) {
134: this .type = typeParam;
135: this .data = dataParam;
136: }
137:
138: /**
139: * For a date field, this stores sample formats; for a select fields, it
140: * stores LabelValueBean instances for the select options.
141: * @return Returns the data.
142: */
143: public List getData() {
144: if (logger.isDebugEnabled()) {
145: logger.debug("getData() - start");
146: }
147:
148: if (logger.isDebugEnabled()) {
149: logger.debug("getData() - end - return value = " + data);
150: }
151: return data;
152: }
153:
154: /**
155: * Indicates the type of field. Set to one of the TYPE... constants.
156: * @return Returns the type.
157: */
158: public String getType() {
159: if (logger.isDebugEnabled()) {
160: logger.debug("getType() - start");
161: }
162:
163: if (logger.isDebugEnabled()) {
164: logger.debug("getType() - end - return value = " + type);
165: }
166: return type;
167: }
168: }
|