19f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson/* 29f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Licensed to the Apache Software Foundation (ASF) under one 39f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * or more contributor license agreements. See the NOTICE file 49f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * distributed with this work for additional information 59f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * regarding copyright ownership. The ASF licenses this file 69f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * to you under the Apache License, Version 2.0 (the "License"); 79f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * you may not use this file except in compliance with the License. 89f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * You may obtain a copy of the License at 99f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * http://www.apache.org/licenses/LICENSE-2.0 119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Unless required by applicable law or agreed to in writing, software 139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * distributed under the License is distributed on an "AS IS" BASIS, 149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * See the License for the specific language governing permissions and 169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * limitations under the License. 179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson/* 199f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * $Id: DTMNodeListBase.java 468653 2006-10-28 07:07:05Z minchau $ 209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 219f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonpackage org.apache.xml.dtm.ref; 229f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonimport org.w3c.dom.Node; 239f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 249f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson/** 259f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * <code>DTMNodeList</code> gives us an implementation of the DOM's 269f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * NodeList interface wrapped around a DTM Iterator. The author 279f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * considers this something of an abominations, since NodeList was not 289f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * intended to be a general purpose "list of nodes" API and is 299f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * generally considered by the DOM WG to have be a mistake... but I'm 309f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * told that some of the XPath/XSLT folks say they must have this 319f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * solution. 329f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 339f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Please note that this is not necessarily equivlaent to a DOM 349f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * NodeList operating over the same document. In particular: 359f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * <ul> 369f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 379f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * <li>If there are several Text nodes in logical succession (ie, 389f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * across CDATASection and EntityReference boundaries), we will return 399f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * only the first; the caller is responsible for stepping through 409f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * them. 419f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * (%REVIEW% Provide a convenience routine here to assist, pending 429f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * proposed DOM Level 3 getAdjacentText() operation?) </li> 439f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 449f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * <li>Since the whole XPath/XSLT architecture assumes that the source 459f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * document is not altered while we're working with it, we do not 469f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * promise to implement the DOM NodeList's "live view" response to 479f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * document mutation. </li> 489f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 499f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * </ul> 509f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 519f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * <p>State: In progress!!</p> 529f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 539f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 549f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonpublic class DTMNodeListBase implements org.w3c.dom.NodeList { 559f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public DTMNodeListBase() { 569f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 579f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 589f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson //================================================================ 599f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // org.w3c.dom.NodeList API follows 609f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 619f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 629f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Returns the <code>index</code>th item in the collection. If 639f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * <code>index</code> is greater than or equal to the number of nodes in 649f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * the list, this returns <code>null</code>. 659f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param index Index into the collection. 669f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @return The node at the <code>index</code>th position in the 679f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * <code>NodeList</code>, or <code>null</code> if that is not a valid 689f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * index. 699f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 709f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public Node item(int index) { 719f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return null; 729f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 739f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 749f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 759f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * The number of nodes in the list. The range of valid child node indices 769f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * is 0 to <code>length-1</code> inclusive. 779f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 789f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public int getLength() { 799f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return 0; 809f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 819f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson} 82