jaxws/src/java.xml.soap/share/classes/com/sun/xml/internal/messaging/saaj/soap/impl/SOAPCommentImpl.java
changeset 28977 d7609b65606b
parent 28976 8c912c147654
parent 28344 722378bc599e
child 28978 8431abc709c0
equal deleted inserted replaced
28976:8c912c147654 28977:d7609b65606b
     1 /*
       
     2  * Copyright (c) 1997, 2014, Oracle and/or its affiliates. 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.  Oracle designates this
       
     8  * particular file as subject to the "Classpath" exception as provided
       
     9  * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
       
    22  * or visit www.oracle.com if you need additional information or have any
       
    23  * questions.
       
    24  */
       
    25 
       
    26 package com.sun.xml.internal.messaging.saaj.soap.impl;
       
    27 
       
    28 import java.util.ResourceBundle;
       
    29 import java.util.logging.Logger;
       
    30 
       
    31 import javax.xml.soap.SOAPElement;
       
    32 import javax.xml.soap.SOAPException;
       
    33 
       
    34 import org.w3c.dom.DOMException;
       
    35 import org.w3c.dom.Text;
       
    36 
       
    37 import com.sun.xml.internal.messaging.saaj.soap.SOAPDocumentImpl;
       
    38 import com.sun.xml.internal.messaging.saaj.util.LogDomainConstants;
       
    39 
       
    40 public class SOAPCommentImpl
       
    41     extends com.sun.org.apache.xerces.internal.dom.CommentImpl
       
    42     implements javax.xml.soap.Text, org.w3c.dom.Comment {
       
    43 
       
    44     protected static final Logger log =
       
    45         Logger.getLogger(LogDomainConstants.SOAP_IMPL_DOMAIN,
       
    46                          "com.sun.xml.internal.messaging.saaj.soap.impl.LocalStrings");
       
    47     protected static ResourceBundle rb =
       
    48         log.getResourceBundle();
       
    49 
       
    50     public SOAPCommentImpl(SOAPDocumentImpl ownerDoc, String text) {
       
    51         super(ownerDoc, text);
       
    52     }
       
    53 
       
    54     public String getValue() {
       
    55         String nodeValue = getNodeValue();
       
    56         return (nodeValue.equals("") ? null : nodeValue);
       
    57     }
       
    58 
       
    59     public void setValue(String text) {
       
    60         setNodeValue(text);
       
    61     }
       
    62 
       
    63 
       
    64     public void setParentElement(SOAPElement element) throws SOAPException {
       
    65         if (element == null) {
       
    66             log.severe("SAAJ0112.impl.no.null.to.parent.elem");
       
    67             throw new SOAPException("Cannot pass NULL to setParentElement");
       
    68         }
       
    69         ((ElementImpl) element).addNode(this);
       
    70     }
       
    71 
       
    72     public SOAPElement getParentElement() {
       
    73         return (SOAPElement) getParentNode();
       
    74     }
       
    75 
       
    76     public void detachNode() {
       
    77         org.w3c.dom.Node parent = getParentNode();
       
    78         if (parent != null) {
       
    79             parent.removeChild(this);
       
    80         }
       
    81     }
       
    82 
       
    83     public void recycleNode() {
       
    84         detachNode();
       
    85         // TBD
       
    86         //  - add this to the factory so subsequent
       
    87         //    creations can reuse this object.
       
    88     }
       
    89 
       
    90     public boolean isComment() {
       
    91         return true;
       
    92     }
       
    93 
       
    94     public Text splitText(int offset) throws DOMException {
       
    95         log.severe("SAAJ0113.impl.cannot.split.text.from.comment");
       
    96         throw new UnsupportedOperationException("Cannot split text from a Comment Node.");
       
    97     }
       
    98 
       
    99     public Text replaceWholeText(String content) throws DOMException {
       
   100         log.severe("SAAJ0114.impl.cannot.replace.wholetext.from.comment");
       
   101         throw new UnsupportedOperationException("Cannot replace Whole Text from a Comment Node.");
       
   102     }
       
   103 
       
   104     public String getWholeText() {
       
   105         //TODO: maybe we have to implement this in future.
       
   106         throw new UnsupportedOperationException("Not Supported");
       
   107     }
       
   108 
       
   109     public boolean isElementContentWhitespace() {
       
   110         //TODO: maybe we have to implement this in future.
       
   111         throw new UnsupportedOperationException("Not Supported");
       
   112     }
       
   113 
       
   114 }