01: /*
02: * $Id: TextImpl.java,v 1.19 2006/01/27 12:49:36 vj135062 Exp $
03: * $Revision: 1.19 $
04: * $Date: 2006/01/27 12:49:36 $
05: */
06:
07: /*
08: * Copyright 2006 Sun Microsystems, Inc. All Rights Reserved.
09: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
10: *
11: * This code is free software; you can redistribute it and/or modify it
12: * under the terms of the GNU General Public License version 2 only, as
13: * published by the Free Software Foundation. Sun designates this
14: * particular file as subject to the "Classpath" exception as provided
15: * by Sun in the LICENSE file that accompanied this code.
16: *
17: * This code is distributed in the hope that it will be useful, but WITHOUT
18: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20: * version 2 for more details (a copy is included in the LICENSE file that
21: * accompanied this code).
22: *
23: * You should have received a copy of the GNU General Public License version
24: * 2 along with this work; if not, write to the Free Software Foundation,
25: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
26: *
27: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
28: * CA 95054 USA or visit www.sun.com if you need additional information or
29: * have any questions.
30: */
31: package com.sun.xml.internal.messaging.saaj.soap.impl;
32:
33: import java.util.logging.Logger;
34:
35: import javax.xml.soap.SOAPElement;
36: import javax.xml.soap.SOAPException;
37:
38: import com.sun.xml.internal.messaging.saaj.soap.SOAPDocumentImpl;
39: import com.sun.xml.internal.messaging.saaj.util.LogDomainConstants;
40:
41: public class TextImpl extends
42: com.sun.org.apache.xerces.internal.dom.TextImpl implements
43: javax.xml.soap.Text, org.w3c.dom.Text {
44:
45: protected static Logger log = Logger
46: .getLogger(LogDomainConstants.SOAP_IMPL_DOMAIN,
47: "com.sun.xml.internal.messaging.saaj.soap.impl.LocalStrings");
48:
49: public TextImpl(SOAPDocumentImpl ownerDoc, String text) {
50: super (ownerDoc, text);
51: }
52:
53: public String getValue() {
54: String nodeValue = getNodeValue();
55: return (nodeValue.equals("") ? null : nodeValue);
56: }
57:
58: public void setValue(String text) {
59: setNodeValue(text);
60: }
61:
62: public void setParentElement(SOAPElement parent)
63: throws SOAPException {
64: if (parent == null) {
65: log.severe("SAAJ0126.impl.cannot.locate.ns");
66: throw new SOAPException(
67: "Cannot pass NULL to setParentElement");
68: }
69: ((ElementImpl) parent).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: String txt = getNodeValue();
92:
93: return txt.startsWith("<!--") && txt.endsWith("-->");
94: }
95: }
|