View Javadoc

    1   /*
    2    * $Id: ProxyNamedNodeMap.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.w3c.dom.DOMException;
    24  import org.w3c.dom.NamedNodeMap;
    25  import org.w3c.dom.Node;
    26
    27  /***
    28   * A NamedNodeMap that wraps the Nodes returned in their proxies.
    29   *
    30   * Note: Since maps have no guaranteed order we don't need to worry about identity
    31   * here as we do with "child" adapters.  In that case we need to preserve identity
    32   * in order to support finding the next/previous siblings.
    33   */
    34  public class ProxyNamedNodeMap implements NamedNodeMap {
    35
    36      private NamedNodeMap nodes;
    37      private AdapterFactory adapterFactory;
    38      private AdapterNode parent;
    39
    40      public ProxyNamedNodeMap(AdapterFactory factory, AdapterNode parent, NamedNodeMap nodes) {
    41          this.nodes = nodes;
    42          this.adapterFactory = factory;
    43          this.parent = parent;
    44      }
    45
    46      protected Node wrap(Node node) {
    47          return adapterFactory.proxyNode(parent, node);
    48      }
    49
    50      public int getLength() {
    51          return nodes.getLength();
    52      }
    53
    54      public Node item(int index) {
    55          return wrap(nodes.item(index));
    56      }
    57
    58      public Node getNamedItem(String name) {
    59          return wrap(nodes.getNamedItem(name));
    60      }
    61
    62      public Node removeNamedItem(String name) throws DOMException {
    63          throw new UnsupportedOperationException();
    64      }
    65
    66      public Node setNamedItem(Node arg) throws DOMException {
    67          throw new UnsupportedOperationException();
    68      }
    69
    70      public Node setNamedItemNS(Node arg) throws DOMException {
    71          throw new UnsupportedOperationException();
    72      }
    73
    74      public Node getNamedItemNS(String namespaceURI, String localName) {
    75          return wrap(nodes.getNamedItemNS(namespaceURI, localName));
    76      }
    77
    78      public Node removeNamedItemNS(String namespaceURI, String localName) throws DOMException {
    79          throw new UnsupportedOperationException();
    80      }
    81  }