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