Source Code Cross Referenced for JAXPPlatform.java in  » Database-ORM » toplink » oracle » toplink » essentials » platform » xml » 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 » Database ORM » toplink » oracle.toplink.essentials.platform.xml.jaxp 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003:         * 
004:         * // Copyright (c) 1998, 2007, Oracle. All rights reserved.
005:         * 
006:         *
007:         * The contents of this file are subject to the terms of either the GNU
008:         * General Public License Version 2 only ("GPL") or the Common Development
009:         * and Distribution License("CDDL") (collectively, the "License").  You
010:         * may not use this file except in compliance with the License. You can obtain
011:         * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
012:         * or glassfish/bootstrap/legal/LICENSE.txt.  See the License for the specific
013:         * language governing permissions and limitations under the License.
014:         * 
015:         * When distributing the software, include this License Header Notice in each
016:         * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
017:         * Sun designates this particular file as subject to the "Classpath" exception
018:         * as provided by Sun in the GPL Version 2 section of the License file that
019:         * accompanied this code.  If applicable, add the following below the License
020:         * Header, with the fields enclosed by brackets [] replaced by your own
021:         * identifying information: "Portions Copyrighted [year]
022:         * [name of copyright owner]"
023:         * 
024:         * Contributor(s):
025:         * 
026:         * If you wish your version of this file to be governed by only the CDDL or
027:         * only the GPL Version 2, indicate your decision by adding "[Contributor]
028:         * elects to include this software in this distribution under the [CDDL or GPL
029:         * Version 2] license."  If you don't indicate a single choice of license, a
030:         * recipient has the option to distribute your version of this file under
031:         * either the CDDL, the GPL Version 2 or to extend the choice of license to
032:         * its licensees as provided above.  However, if you add GPL Version 2 code
033:         * and therefore, elected the GPL Version 2 license, then the option applies
034:         * only if the new code is made subject to such option by the copyright
035:         * holder.
036:         */
037:        package oracle.toplink.essentials.platform.xml.jaxp;
038:
039:        import java.net.URL;
040:        import javax.xml.parsers.DocumentBuilder;
041:        import javax.xml.parsers.DocumentBuilderFactory;
042:        import oracle.toplink.essentials.platform.xml.XMLNamespaceResolver;
043:        import oracle.toplink.essentials.platform.xml.XMLParser;
044:        import oracle.toplink.essentials.platform.xml.XMLPlatform;
045:        import oracle.toplink.essentials.platform.xml.XMLPlatformException;
046:        import oracle.toplink.essentials.platform.xml.XMLTransformer;
047:        import org.w3c.dom.Attr;
048:        import org.w3c.dom.DOMImplementation;
049:        import org.w3c.dom.Document;
050:        import org.w3c.dom.DocumentType;
051:        import org.w3c.dom.Element;
052:        import org.w3c.dom.Node;
053:        import org.w3c.dom.NodeList;
054:        import org.w3c.dom.Text;
055:        import org.xml.sax.ErrorHandler;
056:
057:        public class JAXPPlatform implements  XMLPlatform {
058:            public JAXPPlatform() {
059:                super ();
060:            }
061:
062:            /**
063:             * Execute advanced XPath statements that are required for TopLink EIS.
064:             * @param  contextNode the node relative to which the XPath
065:             *         statement will be executed.
066:             *         xPath the XPath statement
067:             *         namespaceResolver used to resolve namespace prefixes
068:             *         to the corresponding namespace URI
069:             * @return the XPath result
070:             * @throws XMLPlatformException
071:             */
072:            public NodeList selectNodesAdvanced(Node contextNode, String xPath,
073:                    XMLNamespaceResolver xmlNamespaceResolver)
074:                    throws XMLPlatformException {
075:                throw oracle.toplink.essentials.exceptions.ValidationException
076:                        .operationNotSupported("selectNodesAdvanced");
077:            }
078:
079:            /**
080:             * Execute advanced XPath statements that are required for TopLink EIS.
081:             * @param contextNode
082:             * @param xPath
083:             * @param xmlNamespaceResolver
084:             * @return
085:             * @throws XMLPlatformException
086:             */
087:            public Node selectSingleNodeAdvanced(Node contextNode,
088:                    String xPath, XMLNamespaceResolver xmlNamespaceResolver)
089:                    throws XMLPlatformException {
090:                throw oracle.toplink.essentials.exceptions.ValidationException
091:                        .operationNotSupported("selectSingleNodeAdvanced");
092:            }
093:
094:            public boolean isWhitespaceNode(Text text) {
095:                String value = text.getNodeValue();
096:                if (null == value) {
097:                    return false;
098:                } else {
099:                    return value.trim().equals("");
100:                }
101:            }
102:
103:            public XMLParser newXMLParser() {
104:                return new JAXPParser();
105:            }
106:
107:            public XMLTransformer newXMLTransformer() {
108:                return new JAXPTransformer();
109:            }
110:
111:            public Document createDocument() throws XMLPlatformException {
112:                try {
113:                    DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory
114:                            .newInstance();
115:                    documentBuilderFactory.setNamespaceAware(true);
116:                    DocumentBuilder documentBuilder = documentBuilderFactory
117:                            .newDocumentBuilder();
118:                    return documentBuilder.newDocument();
119:                } catch (Exception e) {
120:                    throw XMLPlatformException
121:                            .xmlPlatformCouldNotCreateDocument(e);
122:                }
123:            }
124:
125:            public Document createDocumentWithPublicIdentifier(String name,
126:                    String publicIdentifier, String systemIdentifier)
127:                    throws XMLPlatformException {
128:                try {
129:                    if (null == publicIdentifier) {
130:                        return createDocumentWithSystemIdentifier(name,
131:                                systemIdentifier);
132:                    }
133:
134:                    DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory
135:                            .newInstance();
136:                    documentBuilderFactory.setNamespaceAware(true);
137:                    DocumentBuilder documentBuilder = documentBuilderFactory
138:                            .newDocumentBuilder();
139:                    DOMImplementation domImpl = documentBuilder
140:                            .getDOMImplementation();
141:                    DocumentType docType = domImpl.createDocumentType(name,
142:                            publicIdentifier, systemIdentifier);
143:                    Document document = domImpl.createDocument(null, name,
144:                            docType);
145:                    return document;
146:                } catch (Exception e) {
147:                    throw XMLPlatformException
148:                            .xmlPlatformCouldNotCreateDocument(e);
149:                }
150:            }
151:
152:            public Document createDocumentWithSystemIdentifier(String name,
153:                    String systemIdentifier) throws XMLPlatformException {
154:                try {
155:                    Document document = null;
156:
157:                    if (null == systemIdentifier) {
158:                        document = createDocument();
159:                        Element rootElement = document.createElement(name);
160:                        document.appendChild(rootElement);
161:                        return document;
162:                    }
163:
164:                    DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory
165:                            .newInstance();
166:                    documentBuilderFactory.setNamespaceAware(true);
167:                    DocumentBuilder documentBuilder = documentBuilderFactory
168:                            .newDocumentBuilder();
169:                    DOMImplementation domImpl = documentBuilder
170:                            .getDOMImplementation();
171:                    DocumentType docType = domImpl.createDocumentType(name,
172:                            null, systemIdentifier);
173:                    document = domImpl.createDocument(null, name, docType);
174:                    return document;
175:                } catch (Exception e) {
176:                    throw XMLPlatformException
177:                            .xmlPlatformCouldNotCreateDocument(e);
178:                }
179:            }
180:
181:            public String resolveNamespacePrefix(Node contextNode,
182:                    String namespacePrefix) throws XMLPlatformException {
183:                if (namespacePrefix.equals(contextNode.getPrefix())) {
184:                    return contextNode.getNamespaceURI();
185:                }
186:
187:                if (contextNode.getNodeType() == Node.ELEMENT_NODE) {
188:                    Element contextElement = (Element) contextNode;
189:                    Attr namespaceDeclaration = contextElement
190:                            .getAttributeNode("xmlns:" + namespacePrefix);
191:                    if (null != namespaceDeclaration) {
192:                        return namespaceDeclaration.getValue();
193:                    }
194:                }
195:
196:                Node parentNode = contextNode.getParentNode();
197:                if (parentNode.getNodeType() == Node.ELEMENT_NODE) {
198:                    return resolveNamespacePrefix((Element) parentNode,
199:                            namespacePrefix);
200:                }
201:
202:                return null;
203:            }
204:
205:            public boolean validateDocument(Document document,
206:                    URL xmlSchemaURL, ErrorHandler errorHandler)
207:                    throws XMLPlatformException {
208:                return true;
209:            }
210:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.