View Javadoc

    1   /*
    2    * $Id: SimpleTextNode.java 471756 2006-11-06 15:01:43Z husted $
    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  package org.apache.struts2.views.xslt;
    22
    23  import org.apache.struts2.StrutsException;
    24  import org.w3c.dom.DOMException;
    25  import org.w3c.dom.Node;
    26  import org.w3c.dom.Text;
    27
    28
    29  /***
    30   *
    31   */
    32  public class SimpleTextNode extends AbstractAdapterNode implements Node, Text {
    33
    34      public SimpleTextNode(AdapterFactory rootAdapterFactory, AdapterNode parent, String propertyName, Object value) {
    35          setContext(rootAdapterFactory, parent, propertyName, value);
    36      }
    37
    38      protected String getStringValue() {
    39          return getPropertyValue().toString();
    40      }
    41
    42      public void setData(String string) throws DOMException {
    43          throw new StrutsException("Operation not supported");
    44      }
    45
    46      public String getData() throws DOMException {
    47          return getStringValue();
    48      }
    49
    50      public int getLength() {
    51          return getStringValue().length();
    52      }
    53
    54      public String getNodeName() {
    55          return "#text";
    56      }
    57
    58      public short getNodeType() {
    59          return Node.TEXT_NODE;
    60      }
    61
    62      public String getNodeValue() throws DOMException {
    63          return getStringValue();
    64      }
    65
    66      public void appendData(String string) throws DOMException {
    67          throw new StrutsException("Operation not supported");
    68      }
    69
    70      public void deleteData(int i, int i1) throws DOMException {
    71          throw new StrutsException("Operation not supported");
    72      }
    73
    74      public void insertData(int i, String string) throws DOMException {
    75          throw new StrutsException("Operation not supported");
    76      }
    77
    78      public void replaceData(int i, int i1, String string) throws DOMException {
    79          throw new StrutsException("Operation not supported");
    80      }
    81
    82      public Text splitText(int i) throws DOMException {
    83          throw new StrutsException("Operation not supported");
    84      }
    85
    86      public String substringData(int beginIndex, int endIndex) throws DOMException {
    87          return getStringValue().substring(beginIndex, endIndex);
    88      }
    89
    90      // DOM level 3
    91
    92      public boolean isElementContentWhitespace() {
    93          throw operationNotSupported();
    94      }
    95
    96      public String getWholeText() {
    97          throw operationNotSupported();
    98      }
    99
    100     public Text replaceWholeText(String string) throws DOMException {
    101         throw operationNotSupported();
    102     }
    103     // end DOM level 3
    104
    105 }