001: /*
002: * $Id: SOAPDocumentImpl.java,v 1.15 2006/01/27 12:49:29 vj135062 Exp $
003: */
004:
005: /*
006: * Copyright 2006 Sun Microsystems, Inc. All Rights Reserved.
007: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
008: *
009: * This code is free software; you can redistribute it and/or modify it
010: * under the terms of the GNU General Public License version 2 only, as
011: * published by the Free Software Foundation. Sun designates this
012: * particular file as subject to the "Classpath" exception as provided
013: * by Sun in the LICENSE file that accompanied this code.
014: *
015: * This code is distributed in the hope that it will be useful, but WITHOUT
016: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
017: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
018: * version 2 for more details (a copy is included in the LICENSE file that
019: * accompanied this code).
020: *
021: * You should have received a copy of the GNU General Public License version
022: * 2 along with this work; if not, write to the Free Software Foundation,
023: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
024: *
025: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
026: * CA 95054 USA or visit www.sun.com if you need additional information or
027: * have any questions.
028: */
029:
030: /**
031: *
032: * @author SAAJ RI Development Team
033: */package com.sun.xml.internal.messaging.saaj.soap;
034:
035: import java.util.logging.Logger;
036:
037: import com.sun.org.apache.xerces.internal.dom.DocumentImpl;
038: import org.w3c.dom.*;
039:
040: import com.sun.xml.internal.messaging.saaj.soap.impl.*;
041: import com.sun.xml.internal.messaging.saaj.soap.name.NameImpl;
042: import com.sun.xml.internal.messaging.saaj.util.LogDomainConstants;
043:
044: public class SOAPDocumentImpl extends DocumentImpl implements
045: SOAPDocument {
046:
047: protected static Logger log = Logger.getLogger(
048: LogDomainConstants.SOAP_DOMAIN,
049: "com.sun.xml.internal.messaging.saaj.soap.LocalStrings");
050:
051: SOAPPartImpl enclosingSOAPPart;
052:
053: public SOAPDocumentImpl(SOAPPartImpl enclosingDocument) {
054: this .enclosingSOAPPart = enclosingDocument;
055: }
056:
057: // public SOAPDocumentImpl(boolean grammarAccess) {
058: // super(grammarAccess);
059: // }
060: //
061: // public SOAPDocumentImpl(DocumentType doctype) {
062: // super(doctype);
063: // }
064: //
065: // public SOAPDocumentImpl(DocumentType doctype, boolean grammarAccess) {
066: // super(doctype, grammarAccess);
067: // }
068:
069: public SOAPPartImpl getSOAPPart() {
070: if (enclosingSOAPPart == null) {
071: log.severe("SAAJ0541.soap.fragment.not.bound.to.part");
072: throw new RuntimeException(
073: "Could not complete operation. Fragment not bound to SOAP part.");
074: }
075: return enclosingSOAPPart;
076: }
077:
078: public SOAPDocumentImpl getDocument() {
079: return this ;
080: }
081:
082: public DocumentType getDoctype() {
083: // SOAP means no DTD, No DTD means no doctype (SOAP 1.2 only?)
084: return null;
085: }
086:
087: public DOMImplementation getImplementation() {
088: return super .getImplementation();
089: }
090:
091: public Element getDocumentElement() {
092: // This had better be an Envelope!
093: getSOAPPart().doGetDocumentElement();
094: return doGetDocumentElement();
095: }
096:
097: protected Element doGetDocumentElement() {
098: return super .getDocumentElement();
099: }
100:
101: public Element createElement(String tagName) throws DOMException {
102: return ElementFactory.createElement(this , NameImpl
103: .getLocalNameFromTagName(tagName), NameImpl
104: .getPrefixFromTagName(tagName), null);
105: }
106:
107: public DocumentFragment createDocumentFragment() {
108: return new SOAPDocumentFragment(this );
109: }
110:
111: public org.w3c.dom.Text createTextNode(String data) {
112: return new TextImpl(this , data);
113: }
114:
115: public Comment createComment(String data) {
116: return new CommentImpl(this , data);
117: }
118:
119: public CDATASection createCDATASection(String data)
120: throws DOMException {
121: return new CDATAImpl(this , data);
122: }
123:
124: public ProcessingInstruction createProcessingInstruction(
125: String target, String data) throws DOMException {
126: log
127: .severe("SAAJ0542.soap.proc.instructions.not.allowed.in.docs");
128: throw new UnsupportedOperationException(
129: "Processing Instructions are not allowed in SOAP documents");
130: }
131:
132: public Attr createAttribute(String name) throws DOMException {
133: return super .createAttribute(name);
134: }
135:
136: public EntityReference createEntityReference(String name)
137: throws DOMException {
138: log.severe("SAAJ0543.soap.entity.refs.not.allowed.in.docs");
139: throw new UnsupportedOperationException(
140: "Entity References are not allowed in SOAP documents");
141: }
142:
143: public NodeList getElementsByTagName(String tagname) {
144: return super .getElementsByTagName(tagname);
145: }
146:
147: public org.w3c.dom.Node importNode(Node importedNode, boolean deep)
148: throws DOMException {
149: return super .importNode(importedNode, deep);
150: }
151:
152: public Element createElementNS(String namespaceURI,
153: String qualifiedName) throws DOMException {
154: return ElementFactory.createElement(this , NameImpl
155: .getLocalNameFromTagName(qualifiedName), NameImpl
156: .getPrefixFromTagName(qualifiedName), namespaceURI);
157: }
158:
159: public Attr createAttributeNS(String namespaceURI,
160: String qualifiedName) throws DOMException {
161: return super .createAttributeNS(namespaceURI, qualifiedName);
162: }
163:
164: public NodeList getElementsByTagNameNS(String namespaceURI,
165: String localName) {
166: return super .getElementsByTagNameNS(namespaceURI, localName);
167: }
168:
169: public Element getElementById(String elementId) {
170: return super .getElementById(elementId);
171: }
172:
173: public Node cloneNode(boolean deep) {
174: SOAPPartImpl newSoapPart = getSOAPPart().doCloneNode();
175: super .cloneNode(newSoapPart.getDocument(), deep);
176: return newSoapPart;
177: }
178:
179: public void cloneNode(SOAPDocumentImpl newdoc, boolean deep) {
180: super.cloneNode(newdoc, deep);
181: }
182: }
|