Source Code Cross Referenced for XPathFactoryImpl.java in  » XML » xalan » org » apache » xpath » jaxp » 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 » XML » xalan » org.apache.xpath.jaxp 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 1999-2004 The Apache Software Foundation.
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:        // $Id: XPathFactoryImpl.java,v 1.1 2005/05/17 17:24:26 mkwan Exp $
017:        package org.apache.xpath.jaxp;
018:
019:        import org.apache.xpath.res.XPATHErrorResources;
020:        import org.apache.xalan.res.XSLMessages;
021:
022:        import javax.xml.XMLConstants;
023:        import javax.xml.xpath.XPathFactory;
024:        import javax.xml.xpath.XPathFactoryConfigurationException;
025:        import javax.xml.xpath.XPathFunctionResolver;
026:        import javax.xml.xpath.XPathVariableResolver;
027:
028:        /**
029:         * The XPathFactory builds XPaths.
030:         *
031:         * @version $Revision: 1.1 $
032:         * @author  Ramesh Mandava
033:         */
034:        public class XPathFactoryImpl extends XPathFactory {
035:
036:            /**
037:             * <p>Name of class as a constant to use for debugging.</p>
038:             */
039:            private static final String CLASS_NAME = "XPathFactoryImpl";
040:
041:            /**
042:             *<p>XPathFunctionResolver for this XPathFactory and created XPaths.</p>
043:             */
044:            private XPathFunctionResolver xPathFunctionResolver = null;
045:
046:            /**
047:             * <p>XPathVariableResolver for this XPathFactory and created XPaths</p>
048:             */
049:            private XPathVariableResolver xPathVariableResolver = null;
050:
051:            /**
052:             * <p>State of secure processing feature.</p>
053:             */
054:            private boolean featureSecureProcessing = false;
055:
056:            /**
057:             * <p>Is specified object model supported by this 
058:             * <code>XPathFactory</code>?</p>
059:             * 
060:             * @param objectModel Specifies the object model which the returned
061:             * <code>XPathFactory</code> will understand.
062:             *  
063:             * @return <code>true</code> if <code>XPathFactory</code> supports 
064:             * <code>objectModel</code>, else <code>false</code>.
065:             * 
066:             * @throws NullPointerException If <code>objectModel</code> is <code>null</code>.
067:             * @throws IllegalArgumentException If <code>objectModel.length() == 0</code>.
068:             */
069:            public boolean isObjectModelSupported(String objectModel) {
070:
071:                if (objectModel == null) {
072:                    String fmsg = XSLMessages.createXPATHMessage(
073:                            XPATHErrorResources.ER_OBJECT_MODEL_NULL,
074:                            new Object[] { this .getClass().getName() });
075:
076:                    throw new NullPointerException(fmsg);
077:                }
078:
079:                if (objectModel.length() == 0) {
080:                    String fmsg = XSLMessages.createXPATHMessage(
081:                            XPATHErrorResources.ER_OBJECT_MODEL_EMPTY,
082:                            new Object[] { this .getClass().getName() });
083:                    throw new IllegalArgumentException(fmsg);
084:                }
085:
086:                // know how to support default object model, W3C DOM
087:                if (objectModel.equals(XPathFactory.DEFAULT_OBJECT_MODEL_URI)) {
088:                    return true;
089:                }
090:
091:                // don't know how to support anything else
092:                return false;
093:            }
094:
095:            /**
096:             * <p>Returns a new <code>XPath</code> object using the underlying
097:             * object model determined when the factory was instantiated.</p>
098:             * 
099:             * @return New <code>XPath</code>
100:             */
101:            public javax.xml.xpath.XPath newXPath() {
102:                return new org.apache.xpath.jaxp.XPathImpl(
103:                        xPathVariableResolver, xPathFunctionResolver,
104:                        featureSecureProcessing);
105:            }
106:
107:            /**
108:             * <p>Set a feature for this <code>XPathFactory</code> and 
109:             * <code>XPath</code>s created by this factory.</p>
110:             * 
111:             * <p>
112:             * Feature names are fully qualified {@link java.net.URI}s.
113:             * Implementations may define their own features.
114:             * An {@link XPathFactoryConfigurationException} is thrown if this
115:             * <code>XPathFactory</code> or the <code>XPath</code>s
116:             *  it creates cannot support the feature.
117:             * It is possible for an <code>XPathFactory</code> to expose a feature
118:             * value but be unable to change its state.
119:             * </p>
120:             * 
121:             * <p>See {@link javax.xml.xpath.XPathFactory} for full documentation
122:             * of specific features.</p>
123:             * 
124:             * @param name Feature name.
125:             * @param value Is feature state <code>true</code> or <code>false</code>.
126:             *  
127:             * @throws XPathFactoryConfigurationException if this 
128:             * <code>XPathFactory</code> or the <code>XPath</code>s
129:             *   it creates cannot support this feature.
130:             * @throws NullPointerException if <code>name</code> is 
131:             * <code>null</code>.
132:             */
133:            public void setFeature(String name, boolean value)
134:                    throws XPathFactoryConfigurationException {
135:
136:                // feature name cannot be null
137:                if (name == null) {
138:                    String fmsg = XSLMessages.createXPATHMessage(
139:                            XPATHErrorResources.ER_FEATURE_NAME_NULL,
140:                            new Object[] { CLASS_NAME, new Boolean(value) });
141:                    throw new NullPointerException(fmsg);
142:                }
143:
144:                // secure processing?
145:                if (name.equals(XMLConstants.FEATURE_SECURE_PROCESSING)) {
146:
147:                    featureSecureProcessing = value;
148:
149:                    // all done processing feature
150:                    return;
151:                }
152:
153:                // unknown feature
154:                String fmsg = XSLMessages.createXPATHMessage(
155:                        XPATHErrorResources.ER_FEATURE_UNKNOWN, new Object[] {
156:                                name, CLASS_NAME, new Boolean(value) });
157:                throw new XPathFactoryConfigurationException(fmsg);
158:            }
159:
160:            /**
161:             * <p>Get the state of the named feature.</p>
162:             * 
163:             * <p>
164:             * Feature names are fully qualified {@link java.net.URI}s.
165:             * Implementations may define their own features.
166:             * An {@link XPathFactoryConfigurationException} is thrown if this
167:             * <code>XPathFactory</code> or the <code>XPath</code>s
168:             * it creates cannot support the feature.
169:             * It is possible for an <code>XPathFactory</code> to expose a feature 
170:             * value but be unable to change its state.
171:             * </p>
172:             * 
173:             * @param name Feature name.
174:             * 
175:             * @return State of the named feature.
176:             * 
177:             * @throws XPathFactoryConfigurationException if this 
178:             * <code>XPathFactory</code> or the <code>XPath</code>s
179:             *   it creates cannot support this feature.
180:             * @throws NullPointerException if <code>name</code> is 
181:             * <code>null</code>.
182:             */
183:            public boolean getFeature(String name)
184:                    throws XPathFactoryConfigurationException {
185:
186:                // feature name cannot be null
187:                if (name == null) {
188:                    String fmsg = XSLMessages.createXPATHMessage(
189:                            XPATHErrorResources.ER_GETTING_NULL_FEATURE,
190:                            new Object[] { CLASS_NAME });
191:                    throw new NullPointerException(fmsg);
192:                }
193:
194:                // secure processing?
195:                if (name.equals(XMLConstants.FEATURE_SECURE_PROCESSING)) {
196:                    return featureSecureProcessing;
197:                }
198:
199:                // unknown feature
200:                String fmsg = XSLMessages.createXPATHMessage(
201:                        XPATHErrorResources.ER_GETTING_UNKNOWN_FEATURE,
202:                        new Object[] { name, CLASS_NAME });
203:
204:                throw new XPathFactoryConfigurationException(fmsg);
205:            }
206:
207:            /**
208:             * <p>Establish a default function resolver.</p>
209:             * 
210:             * <p>Any <code>XPath</code> objects constructed from this factory will use
211:             * the specified resolver by default.</p>
212:             *
213:             * <p>A <code>NullPointerException</code> is thrown if 
214:             * <code>resolver</code> is <code>null</code>.</p>
215:             * 
216:             * @param resolver XPath function resolver.
217:             * 
218:             * @throws NullPointerException If <code>resolver</code> is 
219:             * <code>null</code>.
220:             */
221:            public void setXPathFunctionResolver(XPathFunctionResolver resolver) {
222:
223:                // resolver cannot be null
224:                if (resolver == null) {
225:                    String fmsg = XSLMessages
226:                            .createXPATHMessage(
227:                                    XPATHErrorResources.ER_NULL_XPATH_FUNCTION_RESOLVER,
228:                                    new Object[] { CLASS_NAME });
229:                    throw new NullPointerException(fmsg);
230:                }
231:
232:                xPathFunctionResolver = resolver;
233:            }
234:
235:            /**
236:             * <p>Establish a default variable resolver.</p>
237:             *
238:             * <p>Any <code>XPath</code> objects constructed from this factory will use
239:             * the specified resolver by default.</p>
240:             * 
241:             * <p>A <code>NullPointerException</code> is thrown if <code>resolver</code> is <code>null</code>.</p>
242:             * 
243:             * @param resolver Variable resolver.
244:             * 
245:             *  @throws NullPointerException If <code>resolver</code> is 
246:             * <code>null</code>.
247:             */
248:            public void setXPathVariableResolver(XPathVariableResolver resolver) {
249:
250:                // resolver cannot be null
251:                if (resolver == null) {
252:                    String fmsg = XSLMessages
253:                            .createXPATHMessage(
254:                                    XPATHErrorResources.ER_NULL_XPATH_VARIABLE_RESOLVER,
255:                                    new Object[] { CLASS_NAME });
256:                    throw new NullPointerException(fmsg);
257:                }
258:
259:                xPathVariableResolver = resolver;
260:            }
261:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.