Source Code Cross Referenced for SAXParserFactoryImpl.java in  » XML » xerces-2_9_1 » org » apache » xerces » 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 » xerces 2_9_1 » org.apache.xerces.jaxp 
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:
018:        package org.apache.xerces.jaxp;
019:
020:        import java.util.Hashtable;
021:
022:        import javax.xml.XMLConstants;
023:        import javax.xml.parsers.ParserConfigurationException;
024:        import javax.xml.parsers.SAXParser;
025:        import javax.xml.parsers.SAXParserFactory;
026:        import javax.xml.validation.Schema;
027:
028:        import org.apache.xerces.impl.Constants;
029:        import org.xml.sax.SAXException;
030:        import org.xml.sax.SAXNotRecognizedException;
031:        import org.xml.sax.SAXNotSupportedException;
032:
033:        /**
034:         * This is the implementation specific class for the
035:         * <code>javax.xml.parsers.SAXParserFactory</code>. This is the platform
036:         * default implementation for the platform.
037:         * 
038:         * @author Rajiv Mordani
039:         * @author Edwin Goei
040:         * 
041:         * @version $Id: SAXParserFactoryImpl.java 447237 2006-09-18 05:03:10Z mrglavas $
042:         */
043:        public class SAXParserFactoryImpl extends SAXParserFactory {
044:
045:            /** Feature identifier: namespaces. */
046:            private static final String NAMESPACES_FEATURE = Constants.SAX_FEATURE_PREFIX
047:                    + Constants.NAMESPACES_FEATURE;
048:
049:            /** Feature identifier: validation. */
050:            private static final String VALIDATION_FEATURE = Constants.SAX_FEATURE_PREFIX
051:                    + Constants.VALIDATION_FEATURE;
052:
053:            /** Feature identifier: XInclude processing */
054:            private static final String XINCLUDE_FEATURE = Constants.XERCES_FEATURE_PREFIX
055:                    + Constants.XINCLUDE_FEATURE;
056:
057:            private Hashtable features;
058:            private Schema grammar;
059:            private boolean isXIncludeAware;
060:
061:            /**
062:             * State of the secure processing feature, initially <code>false</code>
063:             */
064:            private boolean fSecureProcess = false;
065:
066:            /**
067:             * Creates a new instance of <code>SAXParser</code> using the currently
068:             * configured factory parameters.
069:             * @return javax.xml.parsers.SAXParser
070:             */
071:            public SAXParser newSAXParser() throws ParserConfigurationException {
072:
073:                SAXParser saxParserImpl;
074:                try {
075:                    saxParserImpl = new SAXParserImpl(this , features,
076:                            fSecureProcess);
077:                } catch (SAXException se) {
078:                    // Translate to ParserConfigurationException
079:                    throw new ParserConfigurationException(se.getMessage());
080:                }
081:                return saxParserImpl;
082:            }
083:
084:            /**
085:             * Common code for translating exceptions
086:             */
087:            private SAXParserImpl newSAXParserImpl()
088:                    throws ParserConfigurationException,
089:                    SAXNotRecognizedException, SAXNotSupportedException {
090:
091:                SAXParserImpl saxParserImpl;
092:                try {
093:                    saxParserImpl = new SAXParserImpl(this , features);
094:                } catch (SAXNotSupportedException e) {
095:                    throw e;
096:                } catch (SAXNotRecognizedException e) {
097:                    throw e;
098:                } catch (SAXException se) {
099:                    throw new ParserConfigurationException(se.getMessage());
100:                }
101:                return saxParserImpl;
102:            }
103:
104:            /**
105:             * Sets the particular feature in the underlying implementation of 
106:             * org.xml.sax.XMLReader.
107:             */
108:            public void setFeature(String name, boolean value)
109:                    throws ParserConfigurationException,
110:                    SAXNotRecognizedException, SAXNotSupportedException {
111:                if (name == null) {
112:                    throw new NullPointerException();
113:                }
114:                // If this is the secure processing feature, save it then return.
115:                if (name.equals(XMLConstants.FEATURE_SECURE_PROCESSING)) {
116:                    fSecureProcess = value;
117:                    return;
118:                }
119:                // Keep built-in settings in synch with the feature values.
120:                else if (name.equals(NAMESPACES_FEATURE)) {
121:                    setNamespaceAware(value);
122:                    return;
123:                } else if (name.equals(VALIDATION_FEATURE)) {
124:                    setValidating(value);
125:                    return;
126:                } else if (name.equals(XINCLUDE_FEATURE)) {
127:                    setXIncludeAware(value);
128:                    return;
129:                }
130:
131:                // XXX This is ugly.  We have to collect the features and then
132:                // later create an XMLReader to verify the features.
133:                if (features == null) {
134:                    features = new Hashtable();
135:                }
136:                features.put(name, value ? Boolean.TRUE : Boolean.FALSE);
137:
138:                // Test the feature by possibly throwing SAX exceptions
139:                try {
140:                    newSAXParserImpl();
141:                } catch (SAXNotSupportedException e) {
142:                    features.remove(name);
143:                    throw e;
144:                } catch (SAXNotRecognizedException e) {
145:                    features.remove(name);
146:                    throw e;
147:                }
148:            }
149:
150:            /**
151:             * returns the particular property requested for in the underlying 
152:             * implementation of org.xml.sax.XMLReader.
153:             */
154:            public boolean getFeature(String name)
155:                    throws ParserConfigurationException,
156:                    SAXNotRecognizedException, SAXNotSupportedException {
157:                if (name == null) {
158:                    throw new NullPointerException();
159:                }
160:                if (name.equals(XMLConstants.FEATURE_SECURE_PROCESSING)) {
161:                    return fSecureProcess;
162:                } else if (name.equals(NAMESPACES_FEATURE)) {
163:                    return isNamespaceAware();
164:                } else if (name.equals(VALIDATION_FEATURE)) {
165:                    return isValidating();
166:                } else if (name.equals(XINCLUDE_FEATURE)) {
167:                    return isXIncludeAware();
168:                }
169:                // Check for valid name by creating a dummy XMLReader to get
170:                // feature value
171:                return newSAXParserImpl().getXMLReader().getFeature(name);
172:            }
173:
174:            public Schema getSchema() {
175:                return grammar;
176:            }
177:
178:            public void setSchema(Schema grammar) {
179:                this .grammar = grammar;
180:            }
181:
182:            public boolean isXIncludeAware() {
183:                return this .isXIncludeAware;
184:            }
185:
186:            public void setXIncludeAware(boolean state) {
187:                this.isXIncludeAware = state;
188:            }
189:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.