Source Code Cross Referenced for FinderSetProperties.java in  » Library » Apache-commons-digester-1.8-src » org » apache » commons » digester » plugins » strategies » 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 » Library » Apache commons digester 1.8 src » org.apache.commons.digester.plugins.strategies 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


01:        /* $Id: FinderSetProperties.java 471661 2006-11-06 08:09:25Z skitching $
02:         *
03:         * Licensed to the Apache Software Foundation (ASF) under one or more
04:         * contributor license agreements.  See the NOTICE file distributed with
05:         * this work for additional information regarding copyright ownership.
06:         * The ASF licenses this file to You under the Apache License, Version 2.0
07:         * (the "License"); you may not use this file except in compliance with
08:         * the License.  You may obtain a copy of the License at
09:         * 
10:         *      http://www.apache.org/licenses/LICENSE-2.0
11:         * 
12:         * Unless required by applicable law or agreed to in writing, software
13:         * distributed under the License is distributed on an "AS IS" BASIS,
14:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15:         * See the License for the specific language governing permissions and
16:         * limitations under the License.
17:         */
18:
19:        package org.apache.commons.digester.plugins.strategies;
20:
21:        import java.util.Properties;
22:
23:        import org.apache.commons.digester.Digester;
24:        import org.apache.commons.digester.plugins.RuleFinder;
25:        import org.apache.commons.digester.plugins.RuleLoader;
26:
27:        /**
28:         * A rule-finding algorithm which expects the user to specify whether
29:         * "automatic property setting" is desired. If this class discovers that
30:         * this is in fact the case for a declaration, then a RuleLoader is returned
31:         * which, when invoked, adds a single SetPropertiesRule instance to the
32:         * digester.
33:         * <p>
34:         * This allows ordinary JavaBean classes to be used as plugins, and have
35:         * xml attributes be mapped to bean properties of the same name, without
36:         * any custom plugin rules being created for them.
37:         * <p>
38:         * This RuleFinder is typically used as the <i>last</i> RuleFinder, so that
39:         * automatic property setting only occurs if there is no other source of
40:         * custom rules available.
41:         *
42:         * @since 1.6
43:         */
44:
45:        public class FinderSetProperties extends RuleFinder {
46:            public static String DFLT_PROPS_ATTR = "setprops";
47:            public static String DFLT_FALSEVAL = "false";
48:
49:            private String propsAttr;
50:            private String falseval;
51:
52:            /** See {@link #findLoader}. */
53:            public FinderSetProperties() {
54:                this (DFLT_PROPS_ATTR, DFLT_FALSEVAL);
55:            }
56:
57:            /**
58:             * Create a rule-finder which will arrange for a SetPropertiesRule to
59:             * be defined for each instance of a plugin, so that xml attributes
60:             * map to bean properties.
61:             * <p>
62:             * Param falseval will commonly be the string "false" for config files 
63:             * written in English.
64:             *
65:             * @param propsAttr must be non-null.
66:             * @param falseval must be non-null.
67:             */
68:            public FinderSetProperties(String propsAttr, String falseval) {
69:                this .propsAttr = propsAttr;
70:                this .falseval = falseval;
71:            }
72:
73:            /**
74:             * Returns a RuleLoader <i>unless</i> the properties contain an entry
75:             * with the name matching constructor param propsAttr, and the value 
76:             * matching what is in falseval.
77:             * <p>
78:             * If no custom source of rules for a plugin is found, then the user
79:             * almost always wants xml attributes to map to java bean properties,
80:             * so this is the default behaviour unless the user explicitly indicates
81:             * that they do <i>not</i> want a SetPropertiesRule to be provided for
82:             * the plugged-in class.
83:             * <p>
84:             * The returned object (when non-null) will add a SetPropertiesRule to
85:             * the digester whenever its addRules method is invoked.
86:             */
87:            public RuleLoader findLoader(Digester d, Class pluginClass,
88:                    Properties p) {
89:                String state = p.getProperty(propsAttr);
90:                if ((state != null) && state.equals(falseval)) {
91:                    // user has explicitly disabled automatic setting of properties.
92:                    // this is not expected to be common, but allowed.
93:                    return null;
94:                }
95:
96:                return new LoaderSetProperties();
97:            }
98:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.