duke@1: /* duke@1: * $Id: SOAPDocumentImpl.java,v 1.15 2006/01/27 12:49:29 vj135062 Exp $ duke@1: */ duke@1: duke@1: /* duke@1: * Copyright 2006 Sun Microsystems, Inc. All Rights Reserved. duke@1: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. duke@1: * duke@1: * This code is free software; you can redistribute it and/or modify it duke@1: * under the terms of the GNU General Public License version 2 only, as duke@1: * published by the Free Software Foundation. Sun designates this duke@1: * particular file as subject to the "Classpath" exception as provided duke@1: * by Sun in the LICENSE file that accompanied this code. duke@1: * duke@1: * This code is distributed in the hope that it will be useful, but WITHOUT duke@1: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or duke@1: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License duke@1: * version 2 for more details (a copy is included in the LICENSE file that duke@1: * accompanied this code). duke@1: * duke@1: * You should have received a copy of the GNU General Public License version duke@1: * 2 along with this work; if not, write to the Free Software Foundation, duke@1: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. duke@1: * duke@1: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, duke@1: * CA 95054 USA or visit www.sun.com if you need additional information or duke@1: * have any questions. duke@1: */ duke@1: duke@1: /** duke@1: * duke@1: * @author SAAJ RI Development Team duke@1: */ duke@1: package com.sun.xml.internal.messaging.saaj.soap; duke@1: duke@1: import java.util.logging.Logger; duke@1: duke@1: import com.sun.org.apache.xerces.internal.dom.DocumentImpl; duke@1: import org.w3c.dom.*; duke@1: duke@1: import com.sun.xml.internal.messaging.saaj.soap.impl.*; duke@1: import com.sun.xml.internal.messaging.saaj.soap.name.NameImpl; duke@1: import com.sun.xml.internal.messaging.saaj.util.LogDomainConstants; duke@1: duke@1: public class SOAPDocumentImpl extends DocumentImpl implements SOAPDocument { duke@1: duke@1: protected static Logger log = duke@1: Logger.getLogger(LogDomainConstants.SOAP_DOMAIN, duke@1: "com.sun.xml.internal.messaging.saaj.soap.LocalStrings"); duke@1: duke@1: SOAPPartImpl enclosingSOAPPart; duke@1: duke@1: public SOAPDocumentImpl(SOAPPartImpl enclosingDocument) { duke@1: this.enclosingSOAPPart = enclosingDocument; duke@1: } duke@1: duke@1: // public SOAPDocumentImpl(boolean grammarAccess) { duke@1: // super(grammarAccess); duke@1: // } duke@1: // duke@1: // public SOAPDocumentImpl(DocumentType doctype) { duke@1: // super(doctype); duke@1: // } duke@1: // duke@1: // public SOAPDocumentImpl(DocumentType doctype, boolean grammarAccess) { duke@1: // super(doctype, grammarAccess); duke@1: // } duke@1: duke@1: public SOAPPartImpl getSOAPPart() { duke@1: if (enclosingSOAPPart == null) { duke@1: log.severe("SAAJ0541.soap.fragment.not.bound.to.part"); duke@1: throw new RuntimeException("Could not complete operation. Fragment not bound to SOAP part."); duke@1: } duke@1: return enclosingSOAPPart; duke@1: } duke@1: duke@1: public SOAPDocumentImpl getDocument() { duke@1: return this; duke@1: } duke@1: duke@1: public DocumentType getDoctype() { duke@1: // SOAP means no DTD, No DTD means no doctype (SOAP 1.2 only?) duke@1: return null; duke@1: } duke@1: duke@1: public DOMImplementation getImplementation() { duke@1: return super.getImplementation(); duke@1: } duke@1: duke@1: public Element getDocumentElement() { duke@1: // This had better be an Envelope! duke@1: getSOAPPart().doGetDocumentElement(); duke@1: return doGetDocumentElement(); duke@1: } duke@1: duke@1: protected Element doGetDocumentElement() { duke@1: return super.getDocumentElement(); duke@1: } duke@1: duke@1: public Element createElement(String tagName) throws DOMException { duke@1: return ElementFactory.createElement( duke@1: this, duke@1: NameImpl.getLocalNameFromTagName(tagName), duke@1: NameImpl.getPrefixFromTagName(tagName), duke@1: null); duke@1: } duke@1: duke@1: public DocumentFragment createDocumentFragment() { duke@1: return new SOAPDocumentFragment(this); duke@1: } duke@1: duke@1: public org.w3c.dom.Text createTextNode(String data) { duke@1: return new TextImpl(this, data); duke@1: } duke@1: duke@1: public Comment createComment(String data) { duke@1: return new CommentImpl(this, data); duke@1: } duke@1: duke@1: public CDATASection createCDATASection(String data) throws DOMException { duke@1: return new CDATAImpl(this, data); duke@1: } duke@1: duke@1: public ProcessingInstruction createProcessingInstruction( duke@1: String target, duke@1: String data) duke@1: throws DOMException { duke@1: log.severe("SAAJ0542.soap.proc.instructions.not.allowed.in.docs"); duke@1: throw new UnsupportedOperationException("Processing Instructions are not allowed in SOAP documents"); duke@1: } duke@1: duke@1: public Attr createAttribute(String name) throws DOMException { duke@1: return super.createAttribute(name); duke@1: } duke@1: duke@1: public EntityReference createEntityReference(String name) duke@1: throws DOMException { duke@1: log.severe("SAAJ0543.soap.entity.refs.not.allowed.in.docs"); duke@1: throw new UnsupportedOperationException("Entity References are not allowed in SOAP documents"); duke@1: } duke@1: duke@1: public NodeList getElementsByTagName(String tagname) { duke@1: return super.getElementsByTagName(tagname); duke@1: } duke@1: duke@1: public org.w3c.dom.Node importNode(Node importedNode, boolean deep) duke@1: throws DOMException { duke@1: return super.importNode(importedNode, deep); duke@1: } duke@1: duke@1: public Element createElementNS(String namespaceURI, String qualifiedName) duke@1: throws DOMException { duke@1: return ElementFactory.createElement( duke@1: this, duke@1: NameImpl.getLocalNameFromTagName(qualifiedName), duke@1: NameImpl.getPrefixFromTagName(qualifiedName), duke@1: namespaceURI); duke@1: } duke@1: duke@1: public Attr createAttributeNS(String namespaceURI, String qualifiedName) duke@1: throws DOMException { duke@1: return super.createAttributeNS(namespaceURI, qualifiedName); duke@1: } duke@1: duke@1: public NodeList getElementsByTagNameNS( duke@1: String namespaceURI, duke@1: String localName) { duke@1: return super.getElementsByTagNameNS(namespaceURI, localName); duke@1: } duke@1: duke@1: public Element getElementById(String elementId) { duke@1: return super.getElementById(elementId); duke@1: } duke@1: duke@1: public Node cloneNode(boolean deep) { duke@1: SOAPPartImpl newSoapPart = getSOAPPart().doCloneNode(); duke@1: super.cloneNode(newSoapPart.getDocument(), deep); duke@1: return newSoapPart; duke@1: } duke@1: duke@1: public void cloneNode(SOAPDocumentImpl newdoc, boolean deep) { duke@1: super.cloneNode(newdoc, deep); duke@1: } duke@1: }