Source Code Cross Referenced for JXPathHelperConfiguration.java in  » Content-Management-System » apache-lenya-2.0 » org » apache » cocoon » components » modules » input » 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 » Content Management System » apache lenya 2.0 » org.apache.cocoon.components.modules.input 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         *
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:        package org.apache.cocoon.components.modules.input;
018:
019:        import org.apache.avalon.framework.configuration.Configuration;
020:        import org.apache.avalon.framework.configuration.ConfigurationException;
021:
022:        import org.apache.commons.jxpath.ClassFunctions;
023:        import org.apache.commons.jxpath.FunctionLibrary;
024:        import org.apache.commons.jxpath.PackageFunctions;
025:
026:        import java.util.HashMap;
027:        import java.util.Map;
028:
029:        /**
030:         * @author <a href="mailto:haul@apache.org">Christian Haul</a>
031:         * @author <a href="mailto:vgritsenko@apache.org">Vadim Gritsenko</a>
032:         * @version $Id: JXPathHelperConfiguration.java 433543 2006-08-22 06:22:54Z crossley $
033:         */
034:        public class JXPathHelperConfiguration {
035:
036:            /**
037:             * Contains all globally registered extension classes and
038:             * packages. Thus the lookup and loading of globally registered
039:             * extensions is done only once.
040:             */
041:            private FunctionLibrary library;
042:
043:            /**
044:             * Set lenient mode for jxpath
045:             * (i.e. throw an exception on unsupported attributes)?
046:             * Defaults to true.
047:             */
048:            private boolean lenient;
049:
050:            /**
051:             * Contains all registered namespace prefixes.
052:             */
053:            private Map namespaces;
054:
055:            /**
056:             * Create empty jxpath configuration
057:             */
058:            public JXPathHelperConfiguration() {
059:                this .lenient = true;
060:            }
061:
062:            /**
063:             * Create root jxpath configuration
064:             */
065:            public JXPathHelperConfiguration(Configuration config)
066:                    throws ConfigurationException {
067:                this .lenient = config.getChild("lenient").getValueAsBoolean(
068:                        true);
069:                this .library = new FunctionLibrary();
070:                setup(config);
071:
072:                // the following is necessary to be able to use methods on objects without
073:                // explicitely registering extension functions (see PackageFunctions javadoc)
074:                this .library.addFunctions(new PackageFunctions("", null));
075:            }
076:
077:            /**
078:             * Create child jxpath configuration
079:             */
080:            public JXPathHelperConfiguration(JXPathHelperConfiguration global,
081:                    Configuration config) throws ConfigurationException {
082:                this .lenient = global.lenient;
083:                this .library = new FunctionLibrary();
084:                this .library.addFunctions(global.getLibrary());
085:                if (global.getNamespaces() != null) {
086:                    this .namespaces = new HashMap(global.getNamespaces());
087:                }
088:                setup(config);
089:            }
090:
091:            public boolean isLenient() {
092:                return this .lenient;
093:            }
094:
095:            public FunctionLibrary getLibrary() {
096:                return this .library;
097:            }
098:
099:            public Map getNamespaces() {
100:                return this .namespaces;
101:            }
102:
103:            private void setup(Configuration config)
104:                    throws ConfigurationException {
105:                getFunctions(config);
106:                getPackages(config);
107:                getNamespaces(config);
108:            }
109:
110:            /**
111:             * Register all extension functions listed in the configuration
112:             * through <code>&lt;function name="fully.qualified.Class"
113:             * prefix="prefix"/&gt;</code> in the given FunctionLibrary.
114:             *
115:             * @param conf a <code>Configuration</code> value
116:             */
117:            private void getFunctions(Configuration conf) {
118:
119:                Configuration[] children = conf.getChildren("function");
120:                int i = children.length;
121:                while (i-- > 0) {
122:                    String clazzName = children[i].getAttribute("name", null);
123:                    String prefix = children[i].getAttribute("prefix", null);
124:                    if (clazzName != null && prefix != null) {
125:                        try {
126:                            Class clazz = Class.forName(clazzName);
127:                            this .library.addFunctions(new ClassFunctions(clazz,
128:                                    prefix));
129:                        } catch (ClassNotFoundException cnf) {
130:                            // ignore
131:                        }
132:                    }
133:                }
134:            }
135:
136:            /**
137:             * Register all extension packages listed in the configuration
138:             * through <code>&lt;package name="fully.qualified.package"
139:             * prefix="prefix"/&gt;</code> in the given FunctionLibrary.
140:             *
141:             * @param conf a <code>Configuration</code> value
142:             */
143:            private void getPackages(Configuration conf) {
144:
145:                Configuration[] children = conf.getChildren("package");
146:                int i = children.length;
147:                while (i-- > 0) {
148:                    String packageName = children[i].getAttribute("name", null);
149:                    String prefix = children[i].getAttribute("prefix", null);
150:                    if (packageName != null && prefix != null) {
151:                        this .library.addFunctions(new PackageFunctions(
152:                                packageName, prefix));
153:                    }
154:                }
155:            }
156:
157:            /**
158:             * Register all namespaces listed in the configuration
159:             * through <code>&lt;namespace uri="uri:foo"
160:             * prefix="bar"/&gt;</code> in the configuration.
161:             *
162:             * @param conf a <code>Configuration</code> value
163:             */
164:            private void getNamespaces(Configuration conf)
165:                    throws ConfigurationException {
166:
167:                Configuration[] children = conf.getChildren("namespace");
168:                int i = children.length;
169:                if (i > 0) {
170:                    this .namespaces = new HashMap(i + 2);
171:                }
172:                while (i-- > 0) {
173:                    String uri = children[i].getAttribute("uri");
174:                    String prefix = children[i].getAttribute("prefix");
175:                    if (uri != null && prefix != null) {
176:                        this.namespaces.put(prefix, uri);
177:                    }
178:                }
179:            }
180:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.