View Javadoc
1 /* 2 * @(#)HashMapNode.java 1.36 02/03/21 3 * 4 * Copyright 2002 Sun Microsystems, Inc. All rights reserved. 5 * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 6 */ 7 package org.enhydra.xml; 8 9 import java.util.ArrayList; 10 import java.util.List; 11 12 import org.w3c.dom.Attr; 13 import org.w3c.dom.Document; 14 import org.w3c.dom.Node; 15 import org.w3c.dom.NodeList; 16 17 18 19 /*** 20 * @author Tweety 21 * 22 * A class representing a node in a meta-data tree, which implements 23 * the <a href="../../../../api/org/w3c/dom/NodeList.html"> 24 * 25 * <p> Namespaces are ignored in this implementation. The terms "tag 26 * name" and "node name" are always considered to be synonymous. 27 * 28 * @version 1.0 29 */ 30 public class NodeListImpl implements NodeList { 31 32 /*** 33 * List of <code>Node</code>s. 34 */ 35 List nodes; 36 37 38 /*** 39 * Constructs an empty <code>NodeListImpl</code>. 40 */ 41 public NodeListImpl() { 42 this.nodes = new ArrayList(); 43 } 44 45 46 /*** 47 * Constructs <code>NodeListImpl</code> with the given list of nodes. 48 * 49 * @param nodes list of nodes. 50 */ 51 public NodeListImpl(List nodes) { 52 this.nodes = nodes; 53 } 54 55 56 /*** 57 * Returns the count of nodes. 58 * 59 * @return the count of nodes. 60 */ 61 public int getLength() { 62 return nodes.size(); 63 } 64 65 66 /*** 67 * Returns the <code>Node</code> with the given index. 68 * 69 * @param index node index. 70 * 71 * @return the <code>Node</code> with the given index. 72 */ 73 public Node item(int index) { 74 if (index < 0 || index > nodes.size()) { 75 return null; 76 } 77 return (Node) nodes.get(index); 78 } 79 80 81 /*** 82 * Appends the given list to the end of the existing one. 83 * 84 * @param list list to add, as <code>NodeListImpl</code>. 85 * 86 * @return this as </code>NodeList</code>. 87 */ 88 public NodeList append(NodeListImpl list) { 89 this.nodes.addAll(list.nodes); 90 return this; 91 } 92 93 }

This page automatically generated by Maven