01: /*
02: Mdarad-Toolobox is a collection of tools for Architected RAD
03: (Rapid Application Development) based on an MDA approach.
04: The toolbox contains frameworks and generators for many environments
05: (JAVA, J2EE, Hibernate, .NET, C++, etc.) which allow to generate
06: applications from a design Model
07: Copyright (C) 2004-2005 Elapse Technologies Inc.
08:
09: This library is free software; you can redistribute it and/or
10: modify it under the terms of the GNU General Public
11: License as published by the Free Software Foundation; either
12: version 2.1 of the License, or (at your option) any later version.
13:
14: This library is distributed in the hope that it will be useful,
15: but WITHOUT ANY WARRANTY; without even the implied warranty of
16: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17: General Public License for more details.
18:
19: You should have received a copy of the GNU General Public
20: License along with this library; if not, write to the Free Software
21: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22: */
23: package org.mdarad.framework.util.struts.criteria;
24:
25: import java.util.Collection;
26: import java.util.Locale;
27: import java.util.Vector;
28:
29: import org.mdarad.framework.resources.ResourceElement;
30:
31: /**
32: * This abstract class contains a collection of criteria that
33: * are displayed as a search profile. It is useful to
34: * groupe many criteria and display them at the same time.
35: *
36: * To implement this class the methods {@link refresh} and {@link initialize()}
37: * must be implemented.
38: *
39: * @author Philippe Brouillette
40: * @version 1.0
41: * @see FormCriterion
42: */
43: public abstract class CriteriaProfile extends ResourceElement {
44:
45: /**
46: * Collection of criteria that are in the profile
47: */
48: private Collection criteria;
49:
50: /**
51: * Constructor that takes alle the needed properties
52: */
53: public CriteriaProfile(String bundle, String key, Locale locale) {
54: super (bundle, key, locale);
55: criteria = new Vector();
56: initialize();
57: }
58:
59: /**
60: * Method used to add a criterion to the profile
61: * @param criterion object {@link FormCriterion} to be added
62: */
63: protected void addCriterion(FormCriterion criterion) {
64: if (criterion == null) {
65: throw new IllegalArgumentException(
66: "The criterion to be added is null");
67: }
68: criteria.add(criterion);
69: }
70:
71: /**
72: * Method that returns the instanciated criteria of
73: * this profile.
74: * @return {@link Collection} of instanciated criteria.
75: */
76: public Collection getCriteria() {
77: if (criteria != null) {
78: return criteria;
79: }
80: return new Vector();
81: }
82:
83: /**
84: * Method that is called to refresh the criteria
85: * of this profile.
86: */
87: abstract public void refresh();
88:
89: /**
90: * Method that initializes the criteria of
91: * the profile.
92: */
93: abstract public void initialize();
94: }
|