001: /*
002: * $Id: SimpleTextNode.java 471756 2006-11-06 15:01:43Z husted $
003: *
004: * Licensed to the Apache Software Foundation (ASF) under one
005: * or more contributor license agreements. See the NOTICE file
006: * distributed with this work for additional information
007: * regarding copyright ownership. The ASF licenses this file
008: * to you under the Apache License, Version 2.0 (the
009: * "License"); you may not use this file except in compliance
010: * with the License. You may obtain a copy of the License at
011: *
012: * http://www.apache.org/licenses/LICENSE-2.0
013: *
014: * Unless required by applicable law or agreed to in writing,
015: * software distributed under the License is distributed on an
016: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017: * KIND, either express or implied. See the License for the
018: * specific language governing permissions and limitations
019: * under the License.
020: */
021: package org.apache.struts2.views.xslt;
022:
023: import org.apache.struts2.StrutsException;
024: import org.w3c.dom.DOMException;
025: import org.w3c.dom.Node;
026: import org.w3c.dom.Text;
027:
028: /**
029: *
030: */
031: public class SimpleTextNode extends AbstractAdapterNode implements
032: Node, Text {
033:
034: public SimpleTextNode(AdapterFactory rootAdapterFactory,
035: AdapterNode parent, String propertyName, Object value) {
036: setContext(rootAdapterFactory, parent, propertyName, value);
037: }
038:
039: protected String getStringValue() {
040: return getPropertyValue().toString();
041: }
042:
043: public void setData(String string) throws DOMException {
044: throw new StrutsException("Operation not supported");
045: }
046:
047: public String getData() throws DOMException {
048: return getStringValue();
049: }
050:
051: public int getLength() {
052: return getStringValue().length();
053: }
054:
055: public String getNodeName() {
056: return "#text";
057: }
058:
059: public short getNodeType() {
060: return Node.TEXT_NODE;
061: }
062:
063: public String getNodeValue() throws DOMException {
064: return getStringValue();
065: }
066:
067: public void appendData(String string) throws DOMException {
068: throw new StrutsException("Operation not supported");
069: }
070:
071: public void deleteData(int i, int i1) throws DOMException {
072: throw new StrutsException("Operation not supported");
073: }
074:
075: public void insertData(int i, String string) throws DOMException {
076: throw new StrutsException("Operation not supported");
077: }
078:
079: public void replaceData(int i, int i1, String string)
080: throws DOMException {
081: throw new StrutsException("Operation not supported");
082: }
083:
084: public Text splitText(int i) throws DOMException {
085: throw new StrutsException("Operation not supported");
086: }
087:
088: public String substringData(int beginIndex, int endIndex)
089: throws DOMException {
090: return getStringValue().substring(beginIndex, endIndex);
091: }
092:
093: // DOM level 3
094:
095: public boolean isElementContentWhitespace() {
096: throw operationNotSupported();
097: }
098:
099: public String getWholeText() {
100: throw operationNotSupported();
101: }
102:
103: public Text replaceWholeText(String string) throws DOMException {
104: throw operationNotSupported();
105: }
106: // end DOM level 3
107:
108: }
|