286N/A/*
286N/A * reserved comment block
286N/A * DO NOT REMOVE OR ALTER!
286N/A */
286N/A/*
286N/A * Copyright 1999-2004 The Apache Software Foundation.
286N/A *
286N/A * Licensed under the Apache License, Version 2.0 (the "License");
286N/A * you may not use this file except in compliance with the License.
286N/A * You may obtain a copy of the License at
286N/A *
286N/A * http://www.apache.org/licenses/LICENSE-2.0
286N/A *
286N/A * Unless required by applicable law or agreed to in writing, software
286N/A * distributed under the License is distributed on an "AS IS" BASIS,
286N/A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
286N/A * See the License for the specific language governing permissions and
286N/A * limitations under the License.
286N/A */
286N/A/*
286N/A * $Id: DTMAxisTraverser.java,v 1.2.4.1 2005/09/15 08:14:52 suresh_emailid Exp $
286N/A */
286N/Apackage com.sun.org.apache.xml.internal.dtm;
286N/A
286N/A/**
286N/A * A class that implements traverses DTMAxisTraverser interface can traverse
286N/A * a set of nodes, usually as defined by an XPath axis. It is different from
286N/A * an iterator, because it does not need to hold state, and, in fact, must not
286N/A * hold any iteration-based state. It is meant to be implemented as an inner
286N/A * class of a DTM, and returned by the getAxisTraverser(final int axis)
286N/A * function.
286N/A *
286N/A * <p>A DTMAxisTraverser can probably not traverse a reverse axis in
286N/A * document order.</p>
286N/A *
286N/A * <p>Typical usage:</p>
286N/A * <pre><code>
286N/A * for(int nodeHandle=myTraverser.first(myContext);
286N/A * nodeHandle!=DTM.NULL;
286N/A * nodeHandle=myTraverser.next(myContext,nodeHandle))
286N/A * { ... processing for node indicated by nodeHandle goes here ... }
286N/A * </code></pre>
286N/A *
286N/A * @author Scott Boag
286N/A */
286N/Apublic abstract class DTMAxisTraverser
286N/A{
286N/A
286N/A /**
286N/A * By the nature of the stateless traversal, the context node can not be
286N/A * returned or the iteration will go into an infinate loop. So to traverse
286N/A * an axis, the first function must be used to get the first node.
286N/A *
286N/A * <p>This method needs to be overloaded only by those axis that process
286N/A * the self node. <\p>
286N/A *
286N/A * @param context The context node of this traversal. This is the point
286N/A * that the traversal starts from.
286N/A * @return the first node in the traversal.
286N/A */
286N/A public int first(int context)
286N/A {
286N/A return next(context, context);
286N/A }
286N/A
286N/A /**
286N/A * By the nature of the stateless traversal, the context node can not be
286N/A * returned or the iteration will go into an infinate loop. So to traverse
286N/A * an axis, the first function must be used to get the first node.
286N/A *
286N/A * <p>This method needs to be overloaded only by those axis that process
286N/A * the self node. <\p>
286N/A *
286N/A * @param context The context node of this traversal. This is the point
286N/A * of origin for the traversal -- its "root node" or starting point.
286N/A * @param extendedTypeID The extended type ID that must match.
286N/A *
286N/A * @return the first node in the traversal.
286N/A */
286N/A public int first(int context, int extendedTypeID)
286N/A {
286N/A return next(context, context, extendedTypeID);
286N/A }
286N/A
286N/A /**
286N/A * Traverse to the next node after the current node.
286N/A *
286N/A * @param context The context node of this traversal. This is the point
286N/A * of origin for the traversal -- its "root node" or starting point.
286N/A * @param current The current node of the traversal. This is the last known
286N/A * location in the traversal, typically the node-handle returned by the
286N/A * previous traversal step. For the first traversal step, context
286N/A * should be set equal to current. Note that in order to test whether
286N/A * context is in the set, you must use the first() method instead.
286N/A *
286N/A * @return the next node in the iteration, or DTM.NULL.
286N/A * @see #first(int)
286N/A */
286N/A public abstract int next(int context, int current);
286N/A
286N/A /**
286N/A * Traverse to the next node after the current node that is matched
286N/A * by the extended type ID.
286N/A *
286N/A * @param context The context node of this traversal. This is the point
286N/A * of origin for the traversal -- its "root node" or starting point.
286N/A * @param current The current node of the traversal. This is the last known
286N/A * location in the traversal, typically the node-handle returned by the
286N/A * previous traversal step. For the first traversal step, context
286N/A * should be set equal to current. Note that in order to test whether
286N/A * context is in the set, you must use the first() method instead.
286N/A * @param extendedTypeID The extended type ID that must match.
286N/A *
286N/A * @return the next node in the iteration, or DTM.NULL.
286N/A * @see #first(int,int)
286N/A */
286N/A public abstract int next(int context, int current, int extendedTypeID);
286N/A}