001: /*
002: * Copyright (c) 1998-2008 Caucho Technology -- all rights reserved
003: *
004: * This file is part of Resin(R) Open Source
005: *
006: * Each copy or derived work must preserve the copyright notice and this
007: * notice unmodified.
008: *
009: * Resin Open Source is free software; you can redistribute it and/or modify
010: * it under the terms of the GNU General Public License as published by
011: * the Free Software Foundation; either version 2 of the License, or
012: * (at your option) any later version.
013: *
014: * Resin Open Source is distributed in the hope that it will be useful,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
017: * of NON-INFRINGEMENT. See the GNU General Public License for more
018: * details.
019: *
020: * You should have received a copy of the GNU General Public License
021: * along with Resin Open Source; if not, write to the
022: *
023: * Free Software Foundation, Inc.
024: * 59 Temple Place, Suite 330
025: * Boston, MA 02111-1307 USA
026: *
027: * @author Scott Ferguson
028: */
029:
030: package com.caucho.xml.saaj;
031:
032: import javax.xml.namespace.*;
033: import javax.xml.soap.*;
034: import java.util.*;
035:
036: public class TextImpl extends SOAPNodeImpl implements Text {
037: private static final NameImpl TEXT_NAME = new NameImpl("#text");
038: private StringBuilder _data;
039:
040: TextImpl(SOAPFactory factory, String data) {
041: super (factory, TEXT_NAME);
042:
043: _data = new StringBuilder(data);
044: }
045:
046: public boolean isComment() {
047: return _data.toString().startsWith("<!--");
048: }
049:
050: // org.w3c.dom.CharacterData
051:
052: public void appendData(String arg) {
053: _data.append(arg);
054: }
055:
056: public void deleteData(int offset, int count) {
057: _data.delete(offset, offset + count);
058: }
059:
060: public String getData() {
061: return _data.toString();
062: }
063:
064: public int getLength() {
065: return _data.length();
066: }
067:
068: public void insertData(int offset, String arg) {
069: _data.insert(offset, arg);
070: }
071:
072: public void replaceData(int offset, int count, String arg) {
073: _data.replace(offset, offset + count, arg);
074: }
075:
076: public void setData(String data) {
077: _data = new StringBuilder(data);
078: }
079:
080: public String substringData(int offset, int count) {
081: return _data.substring(offset, offset + count);
082: }
083:
084: // org.w3c.dom.Text
085:
086: public String getWholeText() {
087: throw new UnsupportedOperationException();
088: }
089:
090: public boolean isElementContentWhitespace() {
091: throw new UnsupportedOperationException();
092: }
093:
094: public Text replaceWholeText(String content) {
095: throw new UnsupportedOperationException();
096: }
097:
098: public Text splitText(int offset) {
099: throw new UnsupportedOperationException();
100: }
101:
102: // javax.xml.soap.Node
103:
104: public String getValue() {
105: return getData();
106: }
107:
108: public void setValue(String value) {
109: setData(value);
110: }
111:
112: public void recycleNode() {
113: // XXX
114: }
115:
116: // org.w3c.dom.Node
117:
118: public short getNodeType() {
119: return TEXT_NODE;
120: }
121:
122: public String getNodeValue() {
123: return getValue();
124: }
125:
126: public String getNodeName() {
127: return "#text";
128: }
129: }
|