Source Code Cross Referenced for ValidationFactoryConfig.java in  » Development » iScreen » org » iscreen » 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 » Development » iScreen » org.iscreen 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2006-2007 Dan Shellman
003:         *
004:         * Licensed under the Apache License, Version 2.0 (the "License");
005:         * you may not use this file except in compliance with the License.
006:         * You may obtain a copy of the License at
007:         *
008:         * http://www.apache.org/licenses/LICENSE-2.0
009:         *
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS,
012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         * See the License for the specific language governing permissions and
014:         * limitations under the License.
015:         */
016:        package org.iscreen;
017:
018:        import java.util.Map;
019:        import java.util.HashMap;
020:        import java.util.Locale;
021:
022:        /**
023:         * This JavaBean is purely for configuration.  It's used to retrieve an
024:         * instance of the ValidationFactory via a getter, as opposed to getting/building
025:         * one directly by calling the ValidationFactory.buildFactory() method.  Either
026:         * use the appropriate constructor, or call the appropriate setters, and then
027:         * retrieve the factory by calling the getFactory() method.  Note that the
028:         * default factory is the default XML one (so, you don't need to set that if
029:         * you plan to use the XML factory).  The location of the configuration file
030:         * is required, so if it's not set, an exception will be thrown.  Since services
031:         * are optional, they do not need to be set.
032:         *
033:         * @author Shellman, Dan
034:         */
035:        public class ValidationFactoryConfig {
036:            protected String factoryId = ValidationFactory.FACTORY_OGNL_XML;
037:            protected String configLocation;
038:            protected Locale defaultLocale = Locale.getDefault();
039:            protected Map services = new HashMap();
040:            protected ValidationFactory factory;
041:
042:            /**
043:             * Default constructor.
044:             */
045:            public ValidationFactoryConfig() {
046:            } //end ValidationFactoryConfig()
047:
048:            /**
049:             * Constructor that defines all available config properties.
050:             *
051:             * @param   theFactoryId The id of the factory to use (it must have been previously
052:             *                       registered.
053:             * @param   theConfigurationLocation The location of the configuration file.
054:             * @param   locale The default locale.
055:             * @param   theServices The set of services the factory requires.
056:             */
057:            public ValidationFactoryConfig(String theFactoryId,
058:                    String theConfigurationLocation, Locale locale,
059:                    Map theServices) {
060:                factoryId = theFactoryId;
061:                configLocation = theConfigurationLocation;
062:                defaultLocale = locale;
063:
064:                if (theServices != null) {
065:                    services.putAll(theServices);
066:                }
067:            } //end ValidationFactoryConfig()
068:
069:            /**
070:             * Constructor that defines all available config properties except services.
071:             *
072:             * @param   theFactoryId The id of the factory to use (it must have been previously
073:             *                       registered.
074:             * @param   theConfigurationLocation The location of the configuration file.
075:             */
076:            public ValidationFactoryConfig(String theFactoryId,
077:                    String theConfigurationLocation) {
078:                factoryId = theFactoryId;
079:                configLocation = theConfigurationLocation;
080:            } //end ValidationFactoryConfig()
081:
082:            /**
083:             * Constructor that defines only the configuration file.  The factory
084:             * will be the default XML one, and no services will be defined.
085:             *
086:             * @param   theConfigurationLocation The location of the configuration file.
087:             */
088:            public ValidationFactoryConfig(String theConfigurationLocation) {
089:                configLocation = theConfigurationLocation;
090:            } //end ValidationFactoryConfig()
091:
092:            /**
093:             * Constructor that defines only the configuration file.  The factory
094:             * will be the default XML one, and no services will be defined.
095:             *
096:             * @param   theConfigurationLocation The location of the configuration file.
097:             * @param   locale The default locale.
098:             */
099:            public ValidationFactoryConfig(String theConfigurationLocation,
100:                    Locale locale) {
101:                configLocation = theConfigurationLocation;
102:                defaultLocale = locale;
103:            } //end ValidationFactoryConfig()
104:
105:            /**
106:             * Constructor that defines only the configuration file.  The factory
107:             * will be the default XML one, and no services will be defined.
108:             *
109:             * @param   theConfigurationLocation The location of the configuration file.
110:             * @param   theServices The set of services the factory requires.
111:             */
112:            public ValidationFactoryConfig(String theConfigurationLocation,
113:                    Map theServices) {
114:                configLocation = theConfigurationLocation;
115:                services.putAll(theServices);
116:            } //end ValidationFactoryConfig()
117:
118:            /**
119:             * Defines the location of the configuration file.  This will override the
120:             * configuration location defined in the constructor (if it was).
121:             *
122:             * @param   location The location of the configuration file.
123:             */
124:            public void setConfigurationLocation(String location) {
125:                configLocation = location;
126:            } //end setConfigurationLocation()
127:
128:            /**
129:             * Sets the factory id.  This will override the factory id defined in the
130:             * constructor (if it was).
131:             *
132:             * @param   theFactoryId The id of the factory to use.
133:             */
134:            public void setFactoryId(String theFactoryId) {
135:                factoryId = theFactoryId;
136:            } //end setFactoryId()
137:
138:            /**
139:             * Sets the default locale for this factory.
140:             *
141:             * @param   locale The default locale.
142:             */
143:            public void setDefaultLocale(Locale locale) {
144:                defaultLocale = locale;
145:            } //end setDefaultLocale()
146:
147:            /**
148:             * Sets the services the factory will use.  This will remove any prior
149:             * defined services and replace them with those passed in.
150:             *
151:             * @param   theServices The services the factory requires.
152:             */
153:            public void setServices(Map theServices) {
154:                services.clear();
155:                services.putAll(theServices);
156:            } //end setServices()
157:
158:            /**
159:             * Adds a service to those already defined for the factory.
160:             *
161:             * @param   serviceId The id of the individual service.
162:             * @param   value The service object, itself.
163:             */
164:            public void addService(String serviceId, Object value) {
165:                services.put(serviceId, value);
166:            } //end addService()
167:
168:            /**
169:             * Builds and returns the factory based upon the configuration defined
170:             * within this configuration.  If some of the configuration is invalid
171:             * or missing (such as no configuration location), no exception will be
172:             * thrown, so ensure that all configuration has been set properly.<br />
173:             * <br />
174:             * If this method is called multiple times, a new factory is NOT constructed.
175:             * The same factory returned on the first call will be returned on
176:             * subsequent calls.
177:             *
178:             * @return Returns a built factory.
179:             */
180:            public ValidationFactory getFactory() {
181:                if (factory == null) {
182:                    factory = ValidationFactory.buildFactory(factoryId,
183:                            configLocation, defaultLocale, services);
184:                }
185:
186:                return factory;
187:            } //end getFactory()
188:        } //end ValidationFactoryConfig
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.