Source Code Cross Referenced for FormCriterion.java in  » J2EE » Mdarad » org » mdarad » framework » util » struts » criteria » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » J2EE » Mdarad » org.mdarad.framework.util.struts.criteria 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:            Mdarad-Toolobox is a collection of tools for Architected RAD
003:            (Rapid Application Development) based on an MDA approach.
004:            The toolbox contains frameworks and generators for many environments
005:            (JAVA, J2EE, Hibernate, .NET, C++, etc.) which allow to generate
006:            applications from a design Model
007:            Copyright (C) 2004-2005  Elapse Technologies Inc.
008:
009:            This library is free software; you can redistribute it and/or
010:            modify it under the terms of the GNU General Public
011:            License as published by the Free Software Foundation; either
012:            version 2.1 of the License, or (at your option) any later version.
013:
014:            This library is distributed in the hope that it will be useful,
015:            but WITHOUT ANY WARRANTY; without even the implied warranty of
016:            MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
017:            General Public License for more details.
018:
019:            You should have received a copy of the GNU General Public
020:            License along with this library; if not, write to the Free Software
021:            Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
022:         */
023:        package org.mdarad.framework.util.struts.criteria;
024:
025:        import java.io.Serializable;
026:        import java.util.Locale;
027:
028:        import org.mdarad.framework.expr.Criterion;
029:        import org.mdarad.framework.resources.ResourceMapped;
030:        import org.mdarad.framework.resources.ResourcesUtils;
031:
032:        /**
033:         * This abstract class represents a search criterion in a search interface
034:         * USAGE: To use a search criterion, derive from  <code>FormCriterion</code> and implement
035:         * the following methods : {@link #getFormPattern() getFormPattern},
036:         * {@link #getHBCriterion() getHBCriterion}, {@link #getObjectType() getObjectType} et 
037:         * {@link #setPropertyValue(String) setPropertyValue}
038:         * @author Philippe Brouillette
039:         * @version 1.0
040:         */
041:        public abstract class FormCriterion implements  Serializable,
042:                ResourceMapped {
043:
044:            /**
045:             * Constructor that takes all the properties to initialize a search
046:             * criterion.  By default, the criterion is dynamic.
047:             * @param name name of the criterion.  This name must be unique
048:             *             as it is a key in a map.
049:             * @param associatedEntity class type associated to this criterion
050:             * @param property property used for the query criterion
051:             * @param bundleName bundle name
052:             * @param locale locale information
053:             */
054:            public FormCriterion(String name, Class associatedEntity,
055:                    CriterionProperty property, String bundleName, Locale locale) {
056:                this (name, associatedEntity, property, bundleName, locale, true);
057:            }
058:
059:            /**
060:             * Constructor that takes all the properties to initialize a search
061:             * criterion.
062:             * @param name name of the criterion.  This name must be unique
063:             *             as it is a key in a map.
064:             * @param associatedEntity class type associated to this criterion
065:             * @param property property used for the query criterion
066:             * @param bundleName bundle name
067:             * @param locale locale information
068:             * @param dynamic boolean that indicates if the criterion is dynamic
069:             */
070:            public FormCriterion(String name, Class associatedEntity,
071:                    CriterionProperty property, String bundleName,
072:                    Locale locale, boolean isDynamic) {
073:                if (associatedEntity == null || property == null) {
074:                    throw new IllegalArgumentException(
075:                            "The associatedEntity class or "
076:                                    + "the property should never be null");
077:                }
078:
079:                this .name = name;
080:                this .property = property;
081:                this .associatedEntity = associatedEntity;
082:                setLocale(locale);
083:                setBundle(bundleName);
084:                setDynamic(new Boolean(isDynamic));
085:            }
086:
087:            /**
088:             * Constructor that clones a query criterion.  This constructor is used
089:             * to instanciate a criterion in a search form when the form
090:             * contains dynamic criteria.
091:             * @param criterion query criterion that must be of
092:             *                  type <code>FormCriterion</code>
093:             * @exception CriterionException lancé si le critère à copier est nul.
094:             */
095:            public FormCriterion(FormCriterion criterion) {
096:                // s'assurer que le critère n'est pas nul
097:                if (criterion == null) {
098:                    throw new CriterionException(
099:                            "The criterion parameter should not be null");
100:                }
101:                setName(criterion.getName());
102:                setProperty(criterion.getProperty());
103:                setLocale(criterion.getLocale());
104:                setBundle(criterion.getBundle());
105:                setAssociatedEntity(criterion.getAssociatedEntity());
106:            }
107:
108:            /**
109:             * Property that keeps the property associated to the search
110:             * criterion.
111:             */
112:            private CriterionProperty property;
113:
114:            public CriterionProperty getProperty() {
115:                return property;
116:            }
117:
118:            public void setProperty(CriterionProperty property) {
119:                this .property = property;
120:            }
121:
122:            /**
123:             * Value assigns to the search criterion.  The type of value must be specified
124:             * in the implementation of the method
125:             * {@link #getObjectType() getObjectType}
126:             */
127:            private Object value;
128:
129:            protected Object getValue() {
130:                return value;
131:            }
132:
133:            protected void setValue(Object object) {
134:                setValue(object, getObjectType());
135:            }
136:
137:            /**
138:             * Setter of the value of the search criterion
139:             * @param object value associated to the criterion
140:             * @param type class type of the value object
141:             */
142:            protected void setValue(Object object, Class type) {
143:                if (!object.getClass().isAssignableFrom(type)) {
144:                    throw new CriterionException(
145:                            "The value of the criterion is of the wrong type, it must be "
146:                                    + type.getName());
147:                }
148:                value = object;
149:            }
150:
151:            /**
152:             * Method used by the form to set the value of the object.
153:             * The arg is a string because the forms cannot use <code>Object</code>
154:             * @param object value of the property
155:             */
156:            public abstract void setPropertyValue(String object);
157:
158:            /**
159:             * Method that returns the value associated to the search criterion.
160:             * The return value is a string to be used with the forms.  By default,
161:             * the <code>toString()</code> method is called.
162:             * @return value used by the criterion.
163:             */
164:            public String getPropertyValue() {
165:                if (getValue() != null) {
166:                    return getValue().toString();
167:                }
168:
169:                return "";
170:            }
171:
172:            /**
173:             * Abstract method to be implemented and that is used to
174:             * specifies the type of the value object of the criterion.
175:             * EX: for numeric property, the typical implementation should be
176:             * the following :
177:             *  public Class getObjectType() {
178:             *      return Integer.class;
179:             *  }
180:             * @return the class type of the value object
181:             */
182:            public abstract Class getObjectType();
183:
184:            /**
185:             * Property that keeps the name of the criterion.  This name must
186:             * be unique as it is used in a map class.
187:             */
188:            private String name;
189:
190:            public String getName() {
191:                return name;
192:            }
193:
194:            public void setName(String name) {
195:                this .name = name;
196:            }
197:
198:            /**
199:             * Abstract method that should return the display pattern of the search
200:             * criterion.  The patterns are documented in the class 
201:             * {@link CriterionFormPatterns CriterionFormPatterns}
202:             *
203:             * To implement, use the <code>CriterionFormPatterns</code> class to
204:             * obtain an object of type : 
205:             * {@link CriterionFormPattern CriterionFormPattern}
206:             * @return return the display pattern
207:             */
208:            public abstract CriterionFormPattern getFormPattern();
209:
210:            /**
211:             * Abstract method that returns the criterion from the expression
212:             * framework.  ({@link Criterion})
213:             * <p><b>NOTE:</b> The implementation must take care of the type
214:             * of operator that is used to determine the criterion to use.
215:             * @return the criterion
216:             */
217:            public abstract Criterion getExprCriterion();
218:
219:            /**
220:             * Property that keeps the locale informations.
221:             */
222:            private Locale locale;
223:
224:            public Locale getLocale() {
225:                return locale;
226:            }
227:
228:            public void setLocale(Locale locale) {
229:                this .locale = locale;
230:            }
231:
232:            /**
233:             * Property that keeps the bundle name.
234:             */
235:            private String bundleName = "";
236:
237:            public String getBundle() {
238:                return bundleName;
239:            }
240:
241:            public void setBundle(String bundle) {
242:                this .bundleName = bundle;
243:            }
244:
245:            /**
246:             * Method that return the label of the property associated to the
247:             * search criterion.
248:             * 
249:             * @return property label.
250:             */
251:            public String getPropertyLabel() {
252:                return ResourcesUtils.getMessage(getBundle(),
253:                        property.getKey(), getLocale());
254:            }
255:
256:            /**
257:             * Property that indicates if the criterion is dynamic.  By default, it is
258:             * dynamic
259:             */
260:            private Boolean dynamic = Boolean.TRUE;
261:
262:            public Boolean getDynamic() {
263:                return dynamic;
264:            }
265:
266:            public void setDynamic(Boolean dynamic) {
267:                this .dynamic = dynamic;
268:            }
269:
270:            /**
271:             * Attribute that keeps the object type associated to the search
272:             * criterion.  Ex : a criterion that search in the name property of the
273:             * Product class must pass the Procuct class.
274:             */
275:            private Class associatedEntity;
276:
277:            public Class getAssociatedEntity() {
278:                return this .associatedEntity;
279:            }
280:
281:            public void setAssociatedEntity(Class class1) {
282:                associatedEntity = class1;
283:            }
284:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.