View Javadoc

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