001 /*
002 * Copyright 2002 - 2007 JEuclid, http://jeuclid.sf.net
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017 /* $Id: PartialTextImpl.java 310 2007-05-18 20:26:36Z maxberger $ */
018
019 package net.sourceforge.jeuclid.dom;
020
021 import org.w3c.dom.Node;
022 import org.w3c.dom.Text;
023
024 /**
025 * Partial implementation of org.w3c.dom.Text.
026 * <p>
027 * This implements only the functions necessary for MathElements. Feel free to
028 * implement whatever functions you need.
029 *
030 * @author Max Berger
031 * @version $Revision: 310 $
032 */
033 public class PartialTextImpl extends AbstractPartialNodeImpl implements Text {
034
035 private String content;
036
037 /**
038 * Constructor.
039 *
040 * @param text
041 * text content for this node.
042 */
043 public PartialTextImpl(final String text) {
044 this.content = text;
045 }
046
047 /** {@inheritDoc} */
048 public String getWholeText() {
049 return this.content;
050 }
051
052 /** {@inheritDoc} */
053 public boolean isElementContentWhitespace() {
054 throw new UnsupportedOperationException();
055 }
056
057 /** {@inheritDoc} */
058 public Text replaceWholeText(final String newContent) {
059 this.content = newContent;
060 return this;
061 }
062
063 /** {@inheritDoc} */
064 public Text splitText(final int offset) {
065 throw new UnsupportedOperationException();
066 }
067
068 /** {@inheritDoc} */
069 public void appendData(final String arg) {
070 this.content = this.content + arg;
071 }
072
073 /** {@inheritDoc} */
074 public void deleteData(final int offset, final int count) {
075 throw new UnsupportedOperationException();
076 }
077
078 /** {@inheritDoc} */
079 public String getData() {
080 return this.content;
081 }
082
083 /** {@inheritDoc} */
084 public int getLength() {
085 return this.content.length();
086 }
087
088 /** {@inheritDoc} */
089 public void insertData(final int offset, final String arg) {
090 throw new UnsupportedOperationException();
091 }
092
093 /** {@inheritDoc} */
094 public void replaceData(final int offset, final int count,
095 final String arg) {
096 throw new UnsupportedOperationException();
097 }
098
099 /** {@inheritDoc} */
100 public void setData(final String data) {
101 this.content = data;
102 }
103
104 /** {@inheritDoc} */
105 public String substringData(final int offset, final int count) {
106 throw new UnsupportedOperationException();
107 }
108
109 /** {@inheritDoc} */
110 public String getNodeName() {
111 return "#text";
112 }
113
114 /** {@inheritDoc} */
115 public short getNodeType() {
116 return Node.TEXT_NODE;
117 }
118
119 /** {@inheritDoc} */
120 @Override
121 public String getNodeValue() {
122 return this.content;
123 }
124
125 /** {@inheritDoc} */
126 @Override
127 public void setTextContent(final String newTextContent) {
128 this.content = newTextContent;
129 }
130
131 /** {@inheritDoc} */
132 @Override
133 public String getTextContent() {
134 return this.content;
135 }
136
137 }