001: /*
002: * $Id: CommentImpl.java,v 1.17 2006/01/27 12:49:34 vj135062 Exp $
003: * $Revision: 1.17 $
004: * $Date: 2006/01/27 12:49:34 $
005: */
006:
007: /*
008: * Copyright 2006 Sun Microsystems, Inc. All Rights Reserved.
009: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
010: *
011: * This code is free software; you can redistribute it and/or modify it
012: * under the terms of the GNU General Public License version 2 only, as
013: * published by the Free Software Foundation. Sun designates this
014: * particular file as subject to the "Classpath" exception as provided
015: * by Sun in the LICENSE file that accompanied this code.
016: *
017: * This code is distributed in the hope that it will be useful, but WITHOUT
018: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
019: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
020: * version 2 for more details (a copy is included in the LICENSE file that
021: * accompanied this code).
022: *
023: * You should have received a copy of the GNU General Public License version
024: * 2 along with this work; if not, write to the Free Software Foundation,
025: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
026: *
027: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
028: * CA 95054 USA or visit www.sun.com if you need additional information or
029: * have any questions.
030: */
031: package com.sun.xml.internal.messaging.saaj.soap.impl;
032:
033: import java.util.ResourceBundle;
034: import java.util.logging.Logger;
035:
036: import javax.xml.soap.SOAPElement;
037: import javax.xml.soap.SOAPException;
038:
039: import org.w3c.dom.DOMException;
040: import org.w3c.dom.Text;
041:
042: import com.sun.xml.internal.messaging.saaj.soap.SOAPDocumentImpl;
043: import com.sun.xml.internal.messaging.saaj.util.LogDomainConstants;
044:
045: public class CommentImpl extends
046: com.sun.org.apache.xerces.internal.dom.CommentImpl implements
047: javax.xml.soap.Text, org.w3c.dom.Comment {
048:
049: protected static Logger log = Logger
050: .getLogger(LogDomainConstants.SOAP_IMPL_DOMAIN,
051: "com.sun.xml.internal.messaging.saaj.soap.impl.LocalStrings");
052: protected static ResourceBundle rb = log.getResourceBundle();
053:
054: public CommentImpl(SOAPDocumentImpl ownerDoc, String text) {
055: super (ownerDoc, text);
056: }
057:
058: public String getValue() {
059: String nodeValue = getNodeValue();
060: return (nodeValue.equals("") ? null : nodeValue);
061: }
062:
063: public void setValue(String text) {
064: setNodeValue(text);
065: }
066:
067: public void setParentElement(SOAPElement element)
068: throws SOAPException {
069: if (element == null) {
070: log.severe("SAAJ0112.impl.no.null.to.parent.elem");
071: throw new SOAPException(
072: "Cannot pass NULL to setParentElement");
073: }
074: ((ElementImpl) element).addNode(this );
075: }
076:
077: public SOAPElement getParentElement() {
078: return (SOAPElement) getParentNode();
079: }
080:
081: public void detachNode() {
082: org.w3c.dom.Node parent = getParentNode();
083: if (parent != null) {
084: parent.removeChild(this );
085: }
086: }
087:
088: public void recycleNode() {
089: detachNode();
090: // TBD
091: // - add this to the factory so subsequent
092: // creations can reuse this object.
093: }
094:
095: public boolean isComment() {
096: return true;
097: }
098:
099: public Text splitText(int offset) throws DOMException {
100: log.severe("SAAJ0113.impl.cannot.split.text.from.comment");
101: throw new UnsupportedOperationException(
102: "Cannot split text from a Comment Node.");
103: }
104:
105: public Text replaceWholeText(String content) throws DOMException {
106: log
107: .severe("SAAJ0114.impl.cannot.replace.wholetext.from.comment");
108: throw new UnsupportedOperationException(
109: "Cannot replace Whole Text from a Comment Node.");
110: }
111:
112: public String getWholeText() {
113: //TODO: maybe we have to implement this in future.
114: throw new UnsupportedOperationException("Not Supported");
115: }
116:
117: public boolean isElementContentWhitespace() {
118: //TODO: maybe we have to implement this in future.
119: throw new UnsupportedOperationException("Not Supported");
120: }
121:
122: }
|