View Javadoc

1   /*
2    * $Id: SimpleTextNode.java 423995 2006-07-20 17:23:12Z hermanns $
3    *
4    * Copyright 2006 The Apache Software Foundation.
5    *
6    * Licensed under the Apache License, Version 2.0 (the "License");
7    * you may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    *
10   *      http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  package org.apache.struts2.views.xslt;
19  
20  import org.apache.struts2.StrutsException;
21  import org.w3c.dom.DOMException;
22  import org.w3c.dom.Node;
23  import org.w3c.dom.Text;
24  
25  
26  /***
27   * 
28   */
29  public class SimpleTextNode extends AbstractAdapterNode implements Node, Text {
30  
31      public SimpleTextNode(AdapterFactory rootAdapterFactory, AdapterNode parent, String propertyName, Object value) {
32          setContext(rootAdapterFactory, parent, propertyName, value);
33      }
34  
35      protected String getStringValue() {
36          return getPropertyValue().toString();
37      }
38  
39      public void setData(String string) throws DOMException {
40          throw new StrutsException("Operation not supported");
41      }
42  
43      public String getData() throws DOMException {
44          return getStringValue();
45      }
46  
47      public int getLength() {
48          return getStringValue().length();
49      }
50  
51      public String getNodeName() {
52          return "#text";
53      }
54  
55      public short getNodeType() {
56          return Node.TEXT_NODE;
57      }
58  
59      public String getNodeValue() throws DOMException {
60          return getStringValue();
61      }
62  
63      public void appendData(String string) throws DOMException {
64          throw new StrutsException("Operation not supported");
65      }
66  
67      public void deleteData(int i, int i1) throws DOMException {
68          throw new StrutsException("Operation not supported");
69      }
70  
71      public void insertData(int i, String string) throws DOMException {
72          throw new StrutsException("Operation not supported");
73      }
74  
75      public void replaceData(int i, int i1, String string) throws DOMException {
76          throw new StrutsException("Operation not supported");
77      }
78  
79      public Text splitText(int i) throws DOMException {
80          throw new StrutsException("Operation not supported");
81      }
82  
83      public String substringData(int beginIndex, int endIndex) throws DOMException {
84          return getStringValue().substring(beginIndex, endIndex);
85      }
86  
87      // DOM level 3
88  
89      public boolean isElementContentWhitespace() {
90          throw operationNotSupported();
91      }
92  
93      public String getWholeText() {
94          throw operationNotSupported();
95      }
96  
97      public Text replaceWholeText(String string) throws DOMException {
98          throw operationNotSupported();
99      }
100     // end DOM level 3
101 
102 }