1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/messaging/saaj/soap/SOAPDocumentImpl.java Tue Mar 06 16:09:35 2012 -0800 1.3 @@ -0,0 +1,193 @@ 1.4 +/* 1.5 + * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. Oracle designates this 1.11 + * particular file as subject to the "Classpath" exception as provided 1.12 + * by Oracle in the LICENSE file that accompanied this code. 1.13 + * 1.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.17 + * version 2 for more details (a copy is included in the LICENSE file that 1.18 + * accompanied this code). 1.19 + * 1.20 + * You should have received a copy of the GNU General Public License version 1.21 + * 2 along with this work; if not, write to the Free Software Foundation, 1.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.23 + * 1.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1.25 + * or visit www.oracle.com if you need additional information or have any 1.26 + * questions. 1.27 + */ 1.28 + 1.29 +/** 1.30 +* 1.31 +* @author SAAJ RI Development Team 1.32 +*/ 1.33 +package com.sun.xml.internal.messaging.saaj.soap; 1.34 + 1.35 +import java.util.logging.Logger; 1.36 + 1.37 +import com.sun.org.apache.xerces.internal.dom.DocumentImpl; 1.38 +import org.w3c.dom.*; 1.39 + 1.40 +import com.sun.xml.internal.messaging.saaj.soap.impl.*; 1.41 +import com.sun.xml.internal.messaging.saaj.soap.name.NameImpl; 1.42 +import com.sun.xml.internal.messaging.saaj.util.LogDomainConstants; 1.43 + 1.44 +public class SOAPDocumentImpl extends DocumentImpl implements SOAPDocument { 1.45 + 1.46 + private static final String XMLNS = "xmlns".intern(); 1.47 + protected static final Logger log = 1.48 + Logger.getLogger(LogDomainConstants.SOAP_DOMAIN, 1.49 + "com.sun.xml.internal.messaging.saaj.soap.LocalStrings"); 1.50 + 1.51 + SOAPPartImpl enclosingSOAPPart; 1.52 + 1.53 + public SOAPDocumentImpl(SOAPPartImpl enclosingDocument) { 1.54 + this.enclosingSOAPPart = enclosingDocument; 1.55 + } 1.56 + 1.57 + // public SOAPDocumentImpl(boolean grammarAccess) { 1.58 + // super(grammarAccess); 1.59 + // } 1.60 + // 1.61 + // public SOAPDocumentImpl(DocumentType doctype) { 1.62 + // super(doctype); 1.63 + // } 1.64 + // 1.65 + // public SOAPDocumentImpl(DocumentType doctype, boolean grammarAccess) { 1.66 + // super(doctype, grammarAccess); 1.67 + // } 1.68 + 1.69 + public SOAPPartImpl getSOAPPart() { 1.70 + if (enclosingSOAPPart == null) { 1.71 + log.severe("SAAJ0541.soap.fragment.not.bound.to.part"); 1.72 + throw new RuntimeException("Could not complete operation. Fragment not bound to SOAP part."); 1.73 + } 1.74 + return enclosingSOAPPart; 1.75 + } 1.76 + 1.77 + public SOAPDocumentImpl getDocument() { 1.78 + return this; 1.79 + } 1.80 + 1.81 + public DocumentType getDoctype() { 1.82 + // SOAP means no DTD, No DTD means no doctype (SOAP 1.2 only?) 1.83 + return null; 1.84 + } 1.85 + 1.86 + public DOMImplementation getImplementation() { 1.87 + return super.getImplementation(); 1.88 + } 1.89 + 1.90 + public Element getDocumentElement() { 1.91 + // This had better be an Envelope! 1.92 + getSOAPPart().doGetDocumentElement(); 1.93 + return doGetDocumentElement(); 1.94 + } 1.95 + 1.96 + protected Element doGetDocumentElement() { 1.97 + return super.getDocumentElement(); 1.98 + } 1.99 + 1.100 + public Element createElement(String tagName) throws DOMException { 1.101 + return ElementFactory.createElement( 1.102 + this, 1.103 + NameImpl.getLocalNameFromTagName(tagName), 1.104 + NameImpl.getPrefixFromTagName(tagName), 1.105 + null); 1.106 + } 1.107 + 1.108 + public DocumentFragment createDocumentFragment() { 1.109 + return new SOAPDocumentFragment(this); 1.110 + } 1.111 + 1.112 + public org.w3c.dom.Text createTextNode(String data) { 1.113 + return new TextImpl(this, data); 1.114 + } 1.115 + 1.116 + public Comment createComment(String data) { 1.117 + return new CommentImpl(this, data); 1.118 + } 1.119 + 1.120 + public CDATASection createCDATASection(String data) throws DOMException { 1.121 + return new CDATAImpl(this, data); 1.122 + } 1.123 + 1.124 + public ProcessingInstruction createProcessingInstruction( 1.125 + String target, 1.126 + String data) 1.127 + throws DOMException { 1.128 + log.severe("SAAJ0542.soap.proc.instructions.not.allowed.in.docs"); 1.129 + throw new UnsupportedOperationException("Processing Instructions are not allowed in SOAP documents"); 1.130 + } 1.131 + 1.132 + public Attr createAttribute(String name) throws DOMException { 1.133 + boolean isQualifiedName = (name.indexOf(":") > 0); 1.134 + if (isQualifiedName) { 1.135 + String nsUri = null; 1.136 + String prefix = name.substring(0, name.indexOf(":")); 1.137 + //cannot do anything to resolve the URI if prefix is not 1.138 + //XMLNS. 1.139 + if (XMLNS.equals(prefix)) { 1.140 + nsUri = ElementImpl.XMLNS_URI; 1.141 + return createAttributeNS(nsUri, name); 1.142 + } 1.143 + } 1.144 + 1.145 + return super.createAttribute(name); 1.146 + } 1.147 + 1.148 + public EntityReference createEntityReference(String name) 1.149 + throws DOMException { 1.150 + log.severe("SAAJ0543.soap.entity.refs.not.allowed.in.docs"); 1.151 + throw new UnsupportedOperationException("Entity References are not allowed in SOAP documents"); 1.152 + } 1.153 + 1.154 + public NodeList getElementsByTagName(String tagname) { 1.155 + return super.getElementsByTagName(tagname); 1.156 + } 1.157 + 1.158 + public org.w3c.dom.Node importNode(Node importedNode, boolean deep) 1.159 + throws DOMException { 1.160 + return super.importNode(importedNode, deep); 1.161 + } 1.162 + 1.163 + public Element createElementNS(String namespaceURI, String qualifiedName) 1.164 + throws DOMException { 1.165 + return ElementFactory.createElement( 1.166 + this, 1.167 + NameImpl.getLocalNameFromTagName(qualifiedName), 1.168 + NameImpl.getPrefixFromTagName(qualifiedName), 1.169 + namespaceURI); 1.170 + } 1.171 + 1.172 + public Attr createAttributeNS(String namespaceURI, String qualifiedName) 1.173 + throws DOMException { 1.174 + return super.createAttributeNS(namespaceURI, qualifiedName); 1.175 + } 1.176 + 1.177 + public NodeList getElementsByTagNameNS( 1.178 + String namespaceURI, 1.179 + String localName) { 1.180 + return super.getElementsByTagNameNS(namespaceURI, localName); 1.181 + } 1.182 + 1.183 + public Element getElementById(String elementId) { 1.184 + return super.getElementById(elementId); 1.185 + } 1.186 + 1.187 + public Node cloneNode(boolean deep) { 1.188 + SOAPPartImpl newSoapPart = getSOAPPart().doCloneNode(); 1.189 + super.cloneNode(newSoapPart.getDocument(), deep); 1.190 + return newSoapPart; 1.191 + } 1.192 + 1.193 + public void cloneNode(SOAPDocumentImpl newdoc, boolean deep) { 1.194 + super.cloneNode(newdoc, deep); 1.195 + } 1.196 +}