001: /*
002: * ====================================================================
003: * JAFFA - Java Application Framework For All
004: *
005: * Copyright (C) 2002 JAFFA Development Group
006: *
007: * This library is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU Lesser General Public
009: * License as published by the Free Software Foundation; either
010: * version 2.1 of the License, or (at your option) any later version.
011: *
012: * This library is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this library; if not, write to the Free Software
019: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
020: *
021: * Redistribution and use of this software and associated documentation ("Software"),
022: * with or without modification, are permitted provided that the following conditions are met:
023: * 1. Redistributions of source code must retain copyright statements and notices.
024: * Redistributions must also contain a copy of this document.
025: * 2. Redistributions in binary form must reproduce the above copyright notice,
026: * this list of conditions and the following disclaimer in the documentation
027: * and/or other materials provided with the distribution.
028: * 3. The name "JAFFA" must not be used to endorse or promote products derived from
029: * this Software without prior written permission. For written permission,
030: * please contact mail to: jaffagroup@yahoo.com.
031: * 4. Products derived from this Software may not be called "JAFFA" nor may "JAFFA"
032: * appear in their names without prior written permission.
033: * 5. Due credit should be given to the JAFFA Project (http://jaffa.sourceforge.net).
034: *
035: * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
036: * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
037: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
038: * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
039: * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
040: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
041: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
042: * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
043: * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
044: * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
045: * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
046: * SUCH DAMAGE.
047: * ====================================================================
048: */
049:
050: package org.jaffa.components.codehelper.dto;
051:
052: import java.util.*;
053:
054: /** The input to the ICodeHelper, will consist of a List of instances of this class.
055: * The ICodeHelper will query the 'domainClassName' and use reflection to determine the fields to return.
056: * Additional criteria can be specified using instances of CriteriaElementDto.
057: * The properties domainClassName, codeFieldName and the descriptionFieldName are mandatory, for the ICodeHelper to work correctly.
058: *
059: * @author GautamJ
060: */
061: public class CodeHelperInElementDto {
062:
063: /** Holds value of property code. */
064: private String code;
065:
066: /** Holds value of property domainClassName. */
067: private String domainClassName;
068:
069: /** Holds value of property codeFieldName. */
070: private String codeFieldName;
071:
072: /** Holds value of property descriptionFieldName. */
073: private String descriptionFieldName;
074:
075: /** Holds value of property criteriaFields. */
076: private List criteriaFields;
077:
078: /** Holds value of property appendCodeAndDescription. */
079: private boolean appendCodeAndDescription;
080:
081: /** Holds value of property appendBeginMarker. */
082: private String appendBeginMarker;
083:
084: /** Holds value of property appendEndMarker. */
085: private String appendEndMarker;
086:
087: /** Creates new CodeHelperInElementDto */
088: public CodeHelperInElementDto() {
089: }
090:
091: /** Getter for property code.
092: * @return Value of property code.
093: */
094: public String getCode() {
095: return code;
096: }
097:
098: /** Setter for property code.
099: * @param code New value of property code.
100: */
101: public void setCode(String code) {
102: this .code = code;
103: }
104:
105: /** Getter for property domainClassName.
106: * @return Value of property domainClassName.
107: */
108: public String getDomainClassName() {
109: return domainClassName;
110: }
111:
112: /** Setter for property domainClassName.
113: * @param domainClassName New value of property domainClassName.
114: */
115: public void setDomainClassName(String domainClassName) {
116: this .domainClassName = domainClassName;
117: }
118:
119: /** Getter for property codeFieldName.
120: * @return Value of property codeFieldName.
121: */
122: public String getCodeFieldName() {
123: return codeFieldName;
124: }
125:
126: /** Setter for property codeFieldName.
127: * @param codeFieldName New value of property codeFieldName.
128: */
129: public void setCodeFieldName(String codeFieldName) {
130: this .codeFieldName = codeFieldName;
131: }
132:
133: /** Getter for property descriptionFieldName.
134: * @return Value of property descriptionFieldName.
135: */
136: public String getDescriptionFieldName() {
137: return descriptionFieldName;
138: }
139:
140: /** Setter for property descriptionFieldName.
141: * @param descriptionFieldName New value of property descriptionFieldName.
142: */
143: public void setDescriptionFieldName(String descriptionFieldName) {
144: this .descriptionFieldName = descriptionFieldName;
145: }
146:
147: /** Add a criteriaField to the list
148: * @param criteriaField A criteriaField
149: */
150: public void addCriteriaField(CriteriaElementDto criteriaField) {
151: if (criteriaFields == null)
152: criteriaFields = new ArrayList();
153: criteriaFields.add(criteriaField);
154: }
155:
156: /** Add a criteriaField at the specified position in the list
157: * @param criteriaField A criteriaField
158: * @param index The position in the list
159: */
160: public void setCriteriaField(CriteriaElementDto criteriaField,
161: int index) {
162: if (criteriaFields == null)
163: criteriaFields = new ArrayList();
164:
165: //-- check bounds for index
166: if (index < 0 || index > criteriaFields.size())
167: throw new IndexOutOfBoundsException();
168:
169: criteriaFields.set(index, criteriaField);
170: }
171:
172: /** Recreate the internal list with the input array of criteriaField
173: * @param criteriaFields An array of criteriaField
174: */
175: public void setCriteriaFields(CriteriaElementDto[] criteriaFields) {
176: this .criteriaFields = Arrays.asList(criteriaFields);
177: }
178:
179: /** Clear the list of criteriaField
180: */
181: public void clearCriteriaFields() {
182: if (criteriaFields != null)
183: criteriaFields.clear();
184: }
185:
186: /** Remove a criteriaField from the list
187: * @param criteriaField The criteriaField to be removed
188: * @return true if this list contained the specified element
189: */
190: public boolean removeCriteriaField(CriteriaElementDto criteriaField) {
191: if (criteriaFields != null)
192: return criteriaFields.remove(criteriaField);
193: else
194: return false;
195: }
196:
197: /** Return a criteriaField at the specified position in the list
198: * @param index The position in the list
199: * @return The criteriaField
200: */
201: public CriteriaElementDto getCriteriaField(int index) {
202: //-- check bounds for index
203: if (criteriaFields == null || index < 0
204: || index > criteriaFields.size())
205: throw new IndexOutOfBoundsException();
206:
207: return (CriteriaElementDto) criteriaFields.get(index);
208: }
209:
210: /** Returns an array of criteriaField
211: * @return An array of criteriaField
212: */
213: public CriteriaElementDto[] getCriteriaFields() {
214: if (criteriaFields != null)
215: return (CriteriaElementDto[]) criteriaFields
216: .toArray(new CriteriaElementDto[0]);
217: else
218: return null;
219: }
220:
221: /** Returns the number of criteriaField in the list
222: * @return The number of criteriaField in the list
223: */
224: public int getCriteriaFieldCount() {
225: if (criteriaFields != null)
226: return criteriaFields.size();
227: else
228: return 0;
229: }
230:
231: /** Getter for property appendCodeAndDescription.
232: * @return Value of property appendCodeAndDescription.
233: */
234: public boolean isAppendCodeAndDescription() {
235: return this .appendCodeAndDescription;
236: }
237:
238: /** Setter for property appendCodeAndDescription.
239: * @param appendCodeAndDescription New value of property appendCodeAndDescription.
240: */
241: public void setAppendCodeAndDescription(
242: boolean appendCodeAndDescription) {
243: this .appendCodeAndDescription = appendCodeAndDescription;
244: }
245:
246: /** Getter for property appendBeginMarker.
247: * @return Value of property appendBeginMarker.
248: */
249: public String getAppendBeginMarker() {
250: return this .appendBeginMarker;
251: }
252:
253: /** Setter for property appendBeginMarker.
254: * @param appendBeginMarker New value of property appendBeginMarker.
255: */
256: public void setAppendBeginMarker(String appendBeginMarker) {
257: this .appendBeginMarker = appendBeginMarker;
258: }
259:
260: /** Getter for property appendEndMarker.
261: * @return Value of property appendEndMarker.
262: */
263: public String getAppendEndMarker() {
264: return this .appendEndMarker;
265: }
266:
267: /** Setter for property appendEndMarker.
268: * @param appendEndMarker New value of property appendEndMarker.
269: */
270: public void setAppendEndMarker(String appendEndMarker) {
271: this .appendEndMarker = appendEndMarker;
272: }
273:
274: /** Returns diagnostic information.
275: * @return diagnostic information.
276: */
277: public String toString() {
278: StringBuffer buf = new StringBuffer();
279: buf.append("<CodeHelperInElementDto>");
280: buf.append("<code>");
281: if (code != null)
282: buf.append(code);
283: buf.append("</code>");
284: buf.append("<domainClassName>");
285: if (domainClassName != null)
286: buf.append(domainClassName);
287: buf.append("</domainClassName>");
288: buf.append("<codeFieldName>");
289: if (codeFieldName != null)
290: buf.append(codeFieldName);
291: buf.append("</codeFieldName>");
292: buf.append("<descriptionFieldName>");
293: if (descriptionFieldName != null)
294: buf.append(descriptionFieldName);
295: buf.append("</descriptionFieldName>");
296: buf.append("<appendCodeAndDescription>");
297: buf.append(appendCodeAndDescription);
298: buf.append("</appendCodeAndDescription>");
299: buf.append("<appendBeginMarker>");
300: if (appendBeginMarker != null)
301: buf.append(appendBeginMarker);
302: buf.append("</appendBeginMarker>");
303: buf.append("<appendEndMarker>");
304: if (appendEndMarker != null)
305: buf.append(appendEndMarker);
306: buf.append("</appendEndMarker>");
307:
308: buf.append("<criteriaFields>");
309: if (criteriaFields != null) {
310: for (Iterator i = criteriaFields.iterator(); i.hasNext();)
311: buf.append(i.next());
312: }
313: buf.append("</criteriaFields>");
314:
315: buf.append("</CodeHelperInElementDto>");
316: return buf.toString();
317: }
318: }
|