KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mdarad > framework > util > struts > criteria > CriteriaProfile


1 /*
2     Mdarad-Toolobox is a collection of tools for Architected RAD
3     (Rapid Application Development) based on an MDA approach.
4     The toolbox contains frameworks and generators for many environments
5     (JAVA, J2EE, Hibernate, .NET, C++, etc.) which allow to generate
6     applications from a design Model
7     Copyright (C) 2004-2005 Elapse Technologies Inc.
8
9     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 JavaDoc;
26 import java.util.Locale JavaDoc;
27 import java.util.Vector JavaDoc;
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 JavaDoc criteria;
49
50     /**
51      * Constructor that takes alle the needed properties
52      */

53     public CriteriaProfile(String JavaDoc bundle, String JavaDoc key, Locale JavaDoc locale) {
54         super(bundle, key, locale);
55         criteria = new Vector JavaDoc();
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 JavaDoc("The criterion to be added is null");
66         }
67         criteria.add(criterion);
68     }
69
70     /**
71      * Method that returns the instanciated criteria of
72      * this profile.
73      * @return {@link Collection} of instanciated criteria.
74      */

75     public Collection JavaDoc getCriteria() {
76         if (criteria != null) {
77             return criteria;
78         }
79         return new Vector JavaDoc();
80     }
81
82     /**
83      * Method that is called to refresh the criteria
84      * of this profile.
85      */

86     abstract public void refresh();
87
88     /**
89      * Method that initializes the criteria of
90      * the profile.
91      */

92     abstract public void initialize();
93 }
Popular Tags