src/share/classes/com/sun/xml/internal/messaging/saaj/soap/SOAPDocumentImpl.java

Mon, 04 May 2009 21:10:41 -0700

author
tbell
date
Mon, 04 May 2009 21:10:41 -0700
changeset 50
42dfec6871f6
parent 45
31822b475baa
child 78
860b95cc8d1d
permissions
-rw-r--r--

6658158: Mutable statics in SAAJ (findbugs)
6658163: txw2.DatatypeWriter.BUILDIN is a mutable static (findbugs)
Reviewed-by: darcy

duke@1 1 /*
tbell@45 2 * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
duke@1 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@1 4 *
duke@1 5 * This code is free software; you can redistribute it and/or modify it
duke@1 6 * under the terms of the GNU General Public License version 2 only, as
duke@1 7 * published by the Free Software Foundation. Sun designates this
duke@1 8 * particular file as subject to the "Classpath" exception as provided
duke@1 9 * by Sun in the LICENSE file that accompanied this code.
duke@1 10 *
duke@1 11 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@1 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@1 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@1 14 * version 2 for more details (a copy is included in the LICENSE file that
duke@1 15 * accompanied this code).
duke@1 16 *
duke@1 17 * You should have received a copy of the GNU General Public License version
duke@1 18 * 2 along with this work; if not, write to the Free Software Foundation,
duke@1 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@1 20 *
duke@1 21 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
duke@1 22 * CA 95054 USA or visit www.sun.com if you need additional information or
duke@1 23 * have any questions.
duke@1 24 */
tbell@45 25 /*
tbell@50 26 *
tbell@45 27 */
tbell@45 28
tbell@45 29
duke@1 30
duke@1 31 /**
duke@1 32 *
duke@1 33 * @author SAAJ RI Development Team
duke@1 34 */
duke@1 35 package com.sun.xml.internal.messaging.saaj.soap;
duke@1 36
duke@1 37 import java.util.logging.Logger;
duke@1 38
duke@1 39 import com.sun.org.apache.xerces.internal.dom.DocumentImpl;
duke@1 40 import org.w3c.dom.*;
duke@1 41
duke@1 42 import com.sun.xml.internal.messaging.saaj.soap.impl.*;
duke@1 43 import com.sun.xml.internal.messaging.saaj.soap.name.NameImpl;
duke@1 44 import com.sun.xml.internal.messaging.saaj.util.LogDomainConstants;
duke@1 45
duke@1 46 public class SOAPDocumentImpl extends DocumentImpl implements SOAPDocument {
duke@1 47
tbell@50 48 protected static final Logger log =
duke@1 49 Logger.getLogger(LogDomainConstants.SOAP_DOMAIN,
duke@1 50 "com.sun.xml.internal.messaging.saaj.soap.LocalStrings");
duke@1 51
duke@1 52 SOAPPartImpl enclosingSOAPPart;
duke@1 53
duke@1 54 public SOAPDocumentImpl(SOAPPartImpl enclosingDocument) {
duke@1 55 this.enclosingSOAPPart = enclosingDocument;
duke@1 56 }
duke@1 57
duke@1 58 // public SOAPDocumentImpl(boolean grammarAccess) {
duke@1 59 // super(grammarAccess);
duke@1 60 // }
duke@1 61 //
duke@1 62 // public SOAPDocumentImpl(DocumentType doctype) {
duke@1 63 // super(doctype);
duke@1 64 // }
duke@1 65 //
duke@1 66 // public SOAPDocumentImpl(DocumentType doctype, boolean grammarAccess) {
duke@1 67 // super(doctype, grammarAccess);
duke@1 68 // }
duke@1 69
duke@1 70 public SOAPPartImpl getSOAPPart() {
duke@1 71 if (enclosingSOAPPart == null) {
duke@1 72 log.severe("SAAJ0541.soap.fragment.not.bound.to.part");
duke@1 73 throw new RuntimeException("Could not complete operation. Fragment not bound to SOAP part.");
duke@1 74 }
duke@1 75 return enclosingSOAPPart;
duke@1 76 }
duke@1 77
duke@1 78 public SOAPDocumentImpl getDocument() {
duke@1 79 return this;
duke@1 80 }
duke@1 81
duke@1 82 public DocumentType getDoctype() {
duke@1 83 // SOAP means no DTD, No DTD means no doctype (SOAP 1.2 only?)
duke@1 84 return null;
duke@1 85 }
duke@1 86
duke@1 87 public DOMImplementation getImplementation() {
duke@1 88 return super.getImplementation();
duke@1 89 }
duke@1 90
duke@1 91 public Element getDocumentElement() {
duke@1 92 // This had better be an Envelope!
duke@1 93 getSOAPPart().doGetDocumentElement();
duke@1 94 return doGetDocumentElement();
duke@1 95 }
duke@1 96
duke@1 97 protected Element doGetDocumentElement() {
duke@1 98 return super.getDocumentElement();
duke@1 99 }
duke@1 100
duke@1 101 public Element createElement(String tagName) throws DOMException {
duke@1 102 return ElementFactory.createElement(
duke@1 103 this,
duke@1 104 NameImpl.getLocalNameFromTagName(tagName),
duke@1 105 NameImpl.getPrefixFromTagName(tagName),
duke@1 106 null);
duke@1 107 }
duke@1 108
duke@1 109 public DocumentFragment createDocumentFragment() {
duke@1 110 return new SOAPDocumentFragment(this);
duke@1 111 }
duke@1 112
duke@1 113 public org.w3c.dom.Text createTextNode(String data) {
duke@1 114 return new TextImpl(this, data);
duke@1 115 }
duke@1 116
duke@1 117 public Comment createComment(String data) {
duke@1 118 return new CommentImpl(this, data);
duke@1 119 }
duke@1 120
duke@1 121 public CDATASection createCDATASection(String data) throws DOMException {
duke@1 122 return new CDATAImpl(this, data);
duke@1 123 }
duke@1 124
duke@1 125 public ProcessingInstruction createProcessingInstruction(
duke@1 126 String target,
duke@1 127 String data)
duke@1 128 throws DOMException {
duke@1 129 log.severe("SAAJ0542.soap.proc.instructions.not.allowed.in.docs");
duke@1 130 throw new UnsupportedOperationException("Processing Instructions are not allowed in SOAP documents");
duke@1 131 }
duke@1 132
duke@1 133 public Attr createAttribute(String name) throws DOMException {
duke@1 134 return super.createAttribute(name);
duke@1 135 }
duke@1 136
duke@1 137 public EntityReference createEntityReference(String name)
duke@1 138 throws DOMException {
duke@1 139 log.severe("SAAJ0543.soap.entity.refs.not.allowed.in.docs");
duke@1 140 throw new UnsupportedOperationException("Entity References are not allowed in SOAP documents");
duke@1 141 }
duke@1 142
duke@1 143 public NodeList getElementsByTagName(String tagname) {
duke@1 144 return super.getElementsByTagName(tagname);
duke@1 145 }
duke@1 146
duke@1 147 public org.w3c.dom.Node importNode(Node importedNode, boolean deep)
duke@1 148 throws DOMException {
duke@1 149 return super.importNode(importedNode, deep);
duke@1 150 }
duke@1 151
duke@1 152 public Element createElementNS(String namespaceURI, String qualifiedName)
duke@1 153 throws DOMException {
duke@1 154 return ElementFactory.createElement(
duke@1 155 this,
duke@1 156 NameImpl.getLocalNameFromTagName(qualifiedName),
duke@1 157 NameImpl.getPrefixFromTagName(qualifiedName),
duke@1 158 namespaceURI);
duke@1 159 }
duke@1 160
duke@1 161 public Attr createAttributeNS(String namespaceURI, String qualifiedName)
duke@1 162 throws DOMException {
duke@1 163 return super.createAttributeNS(namespaceURI, qualifiedName);
duke@1 164 }
duke@1 165
duke@1 166 public NodeList getElementsByTagNameNS(
duke@1 167 String namespaceURI,
duke@1 168 String localName) {
duke@1 169 return super.getElementsByTagNameNS(namespaceURI, localName);
duke@1 170 }
duke@1 171
duke@1 172 public Element getElementById(String elementId) {
duke@1 173 return super.getElementById(elementId);
duke@1 174 }
duke@1 175
duke@1 176 public Node cloneNode(boolean deep) {
duke@1 177 SOAPPartImpl newSoapPart = getSOAPPart().doCloneNode();
duke@1 178 super.cloneNode(newSoapPart.getDocument(), deep);
duke@1 179 return newSoapPart;
duke@1 180 }
duke@1 181
duke@1 182 public void cloneNode(SOAPDocumentImpl newdoc, boolean deep) {
duke@1 183 super.cloneNode(newdoc, deep);
duke@1 184 }
duke@1 185 }

mercurial