View Javadoc

1   /*
2    * $Id: ProxyTextNodeAdapter.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.w3c.dom.DOMException;
25  import org.w3c.dom.Text;
26  
27  /***
28   * ProxyTextNodeAdapter is a pass-through adapter for objects which already
29   * implement the Text interface.  All methods are proxied to the underlying
30   * Node except getParent(), getNextSibling() and getPreviousSibling(), which
31   * are implemented by the abstract adapter node to work with the parent adapter.
32   */
33  public class ProxyTextNodeAdapter extends ProxyNodeAdapter implements Text {
34  
35      public ProxyTextNodeAdapter(AdapterFactory factory, AdapterNode parent, Text value) {
36          super(factory, parent, value);
37      }
38  
39      // convenience
40      Text text() {
41          return (Text) getPropertyValue();
42      }
43  
44      public String toString() {
45          return "ProxyTextNode for: " + text();
46      }
47  
48      public Text splitText(int offset) throws DOMException {
49          throw new UnsupportedOperationException();
50      }
51  
52      public int getLength() {
53          return text().getLength();
54      }
55  
56      public void deleteData(int offset, int count) throws DOMException {
57          throw new UnsupportedOperationException();
58      }
59  
60      public String getData() throws DOMException {
61          return text().getData();
62      }
63  
64      public String substringData(int offset, int count) throws DOMException {
65          return text().substringData(offset, count);
66      }
67  
68      public void replaceData(int offset, int count, String arg) throws DOMException {
69          throw new UnsupportedOperationException();
70      }
71  
72      public void insertData(int offset, String arg) throws DOMException {
73          throw new UnsupportedOperationException();
74      }
75  
76      public void appendData(String arg) throws DOMException {
77          throw new UnsupportedOperationException();
78      }
79  
80      public void setData(String data) throws DOMException {
81          throw new UnsupportedOperationException();
82      }
83  
84      // DOM level 3
85  
86      public boolean isElementContentWhitespace() {
87          throw operationNotSupported();
88      }
89  
90      public String getWholeText() {
91          throw operationNotSupported();
92      }
93  
94      public Text replaceWholeText(String string) throws DOMException {
95          throw operationNotSupported();
96      }
97  }
98