FileDocCategorySizeDatePackage
DTMDefaultBaseTraversers.javaAPI DocJava SE 5 API53246Fri Aug 26 14:56:00 BST 2005com.sun.org.apache.xml.internal.dtm.ref

DTMDefaultBaseTraversers

public abstract class DTMDefaultBaseTraversers extends DTMDefaultBase
This class implements the traversers for DTMDefaultBase. PLEASE NOTE that the public interface for all traversers should be in terms of DTM Node Handles... but they may use the internal node identity indices within their logic, for efficiency's sake. Be very careful to avoid confusing these when maintaining this code.

Fields Summary
Constructors Summary
public DTMDefaultBaseTraversers(DTMManager mgr, Source source, int dtmIdentity, DTMWSFilter whiteSpaceFilter, XMLStringFactory xstringfactory, boolean doIndexing)
Construct a DTMDefaultBaseTraversers object from a DOM node.

param
mgr The DTMManager who owns this DTM.
param
domSource the DOM source that this DTM will wrap.
param
source The object that is used to specify the construction source.
param
dtmIdentity The DTM identity ID for this DTM.
param
whiteSpaceFilter The white space filter for this DTM, which may be null.
param
xstringfactory The factory to use for creating XMLStrings.
param
doIndexing true if the caller considers it worth it to use indexing schemes.

    super(mgr, source, dtmIdentity, whiteSpaceFilter, xstringfactory,
          doIndexing);
  
public DTMDefaultBaseTraversers(DTMManager mgr, Source source, int dtmIdentity, DTMWSFilter whiteSpaceFilter, XMLStringFactory xstringfactory, boolean doIndexing, int blocksize, boolean usePrevsib, boolean newNameTable)
Construct a DTMDefaultBaseTraversers object from a DOM node.

param
mgr The DTMManager who owns this DTM.
param
domSource the DOM source that this DTM will wrap.
param
source The object that is used to specify the construction source.
param
dtmIdentity The DTM identity ID for this DTM.
param
whiteSpaceFilter The white space filter for this DTM, which may be null.
param
xstringfactory The factory to use for creating XMLStrings.
param
doIndexing true if the caller considers it worth it to use indexing schemes.
param
blocksize The block size of the DTM.
param
usePrevsib true if we want to build the previous sibling node array.
param
newNameTable true if we want to use a new ExpandedNameTable for this DTM.

    super(mgr, source, dtmIdentity, whiteSpaceFilter, xstringfactory,
          doIndexing, blocksize, usePrevsib, newNameTable);
  
Methods Summary
public com.sun.org.apache.xml.internal.dtm.DTMAxisTraversergetAxisTraverser(int axis)
This returns a stateless "traverser", that can navigate over an XPath axis, though perhaps not in document order.

param
axis One of Axes.ANCESTORORSELF, etc.
return
A DTMAxisTraverser, or null if the given axis isn't supported.


    DTMAxisTraverser traverser;

    if (null == m_traversers)  // Cache of stateless traversers for this DTM
    {
      m_traversers = new DTMAxisTraverser[Axis.names.length];
      traverser = null;
    }
    else
    {
      traverser = m_traversers[axis];  // Share/reuse existing traverser

      if (traverser != null)
        return traverser;
    }

    switch (axis)  // Generate new traverser
    {
    case Axis.ANCESTOR :
      traverser = new AncestorTraverser();
      break;
    case Axis.ANCESTORORSELF :
      traverser = new AncestorOrSelfTraverser();
      break;
    case Axis.ATTRIBUTE :
      traverser = new AttributeTraverser();
      break;
    case Axis.CHILD :
      traverser = new ChildTraverser();
      break;
    case Axis.DESCENDANT :
      traverser = new DescendantTraverser();
      break;
    case Axis.DESCENDANTORSELF :
      traverser = new DescendantOrSelfTraverser();
      break;
    case Axis.FOLLOWING :
      traverser = new FollowingTraverser();
      break;
    case Axis.FOLLOWINGSIBLING :
      traverser = new FollowingSiblingTraverser();
      break;
    case Axis.NAMESPACE :
      traverser = new NamespaceTraverser();
      break;
    case Axis.NAMESPACEDECLS :
      traverser = new NamespaceDeclsTraverser();
      break;
    case Axis.PARENT :
      traverser = new ParentTraverser();
      break;
    case Axis.PRECEDING :
      traverser = new PrecedingTraverser();
      break;
    case Axis.PRECEDINGSIBLING :
      traverser = new PrecedingSiblingTraverser();
      break;
    case Axis.SELF :
      traverser = new SelfTraverser();
      break;
    case Axis.ALL :
      traverser = new AllFromRootTraverser();
      break;
    case Axis.ALLFROMNODE :
      traverser = new AllFromNodeTraverser();
      break;
    case Axis.PRECEDINGANDANCESTOR :
      traverser = new PrecedingAndAncestorTraverser();
      break;
    case Axis.DESCENDANTSFROMROOT :
      traverser = new DescendantFromRootTraverser();
      break;
    case Axis.DESCENDANTSORSELFFROMROOT :
      traverser = new DescendantOrSelfFromRootTraverser();
      break;
    case Axis.ROOT :
      traverser = new RootTraverser();
      break;
    case Axis.FILTEREDLIST :
      return null; // Don't want to throw an exception for this one.
    default :
      throw new DTMException(XMLMessages.createXMLMessage(XMLErrorResources.ER_UNKNOWN_AXIS_TYPE, new Object[]{Integer.toString(axis)})); //"Unknown axis traversal type: "+axis);
    }

    if (null == traverser)
      throw new DTMException(XMLMessages.createXMLMessage(XMLErrorResources.ER_AXIS_TRAVERSER_NOT_SUPPORTED, new Object[]{Axis.names[axis]}));
      // "Axis traverser not supported: "
      //                       + Axis.names[axis]);

    m_traversers[axis] = traverser;

    return traverser;