Java Code Examples for com.sun.org.apache.xml.internal.dtm.Axis#CHILD

The following examples show how to use com.sun.org.apache.xml.internal.dtm.Axis#CHILD . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SAXImpl.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * Do not think that this returns an iterator for the namespace axis.
 * It returns an iterator with nodes that belong in a certain namespace,
 * such as with <xsl:apply-templates select="blob/foo:*"/>
 * The 'axis' specifies the axis for the base iterator from which the
 * nodes are taken, while 'ns' specifies the namespace URI type.
 */
public DTMAxisIterator getNamespaceAxisIterator(int axis, int ns)
{
    if (ns == NO_TYPE) {
        return EMPTYITERATOR;
    }
    else {
        switch (axis) {
            case Axis.CHILD:
                return new NamespaceChildrenIterator(ns);
            case Axis.ATTRIBUTE:
                return new NamespaceAttributeIterator(ns);
            default:
                return new NamespaceWildcardIterator(axis, ns);
        }
    }
}
 
Example 2
Source File: SAXImpl.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
/**
 * Do not think that this returns an iterator for the namespace axis.
 * It returns an iterator with nodes that belong in a certain namespace,
 * such as with <xsl:apply-templates select="blob/foo:*"/>
 * The 'axis' specifies the axis for the base iterator from which the
 * nodes are taken, while 'ns' specifies the namespace URI type.
 */
public DTMAxisIterator getNamespaceAxisIterator(int axis, int ns)
{
    if (ns == NO_TYPE) {
        return EMPTYITERATOR;
    }
    else {
        switch (axis) {
            case Axis.CHILD:
                return new NamespaceChildrenIterator(ns);
            case Axis.ATTRIBUTE:
                return new NamespaceAttributeIterator(ns);
            default:
                return new NamespaceWildcardIterator(axis, ns);
        }
    }
}
 
Example 3
Source File: MultiDOM.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public DTMAxisIterator setStartNode(final int node) {
    if (node == DTM.NULL) {
        return this;
    }

    int dom = node >>> DTMManager.IDENT_DTM_NODE_BITS;

    // Get a new source first time and when mask changes
    if (_source == null || _dtmId != dom) {
        if (_type == NO_TYPE) {
            _source = _adapters[dom].getAxisIterator(_axis);
        } else if (_axis == Axis.CHILD) {
            _source = _adapters[dom].getTypedChildren(_type);
        } else {
            _source = _adapters[dom].getTypedAxisIterator(_axis, _type);
        }
    }

    _dtmId = dom;
    _source.setStartNode(node);
    return this;
}
 
Example 4
Source File: SimpleResultTreeImpl.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public DTMAxisIterator getAxisIterator(final int axis)
{
    switch (axis)
    {
        case Axis.CHILD:
        case Axis.DESCENDANT:
            return new SimpleIterator(SimpleIterator.DIRECTION_DOWN);
        case Axis.PARENT:
        case Axis.ANCESTOR:
            return new SimpleIterator(SimpleIterator.DIRECTION_UP);
        case Axis.ANCESTORORSELF:
            return (new SimpleIterator(SimpleIterator.DIRECTION_UP)).includeSelf();
        case Axis.DESCENDANTORSELF:
            return (new SimpleIterator(SimpleIterator.DIRECTION_DOWN)).includeSelf();
        case Axis.SELF:
            return new SingletonIterator();
        default:
            return EMPTY_ITERATOR;
    }
}
 
Example 5
Source File: MultiDOM.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public DTMAxisIterator setStartNode(final int node) {
    if (node == DTM.NULL) {
        return this;
    }

    int dom = node >>> DTMManager.IDENT_DTM_NODE_BITS;

    // Get a new source first time and when mask changes
    if (_source == null || _dtmId != dom) {
        if (_type == NO_TYPE) {
            _source = _adapters[dom].getAxisIterator(_axis);
        } else if (_axis == Axis.CHILD) {
            _source = _adapters[dom].getTypedChildren(_type);
        } else {
            _source = _adapters[dom].getTypedAxisIterator(_axis, _type);
        }
    }

    _dtmId = dom;
    _source.setStartNode(node);
    return this;
}
 
Example 6
Source File: SimpleResultTreeImpl.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
public DTMAxisIterator getTypedAxisIterator(final int axis, final int type)
{
    switch (axis)
    {
        case Axis.CHILD:
        case Axis.DESCENDANT:
            return new SimpleIterator(SimpleIterator.DIRECTION_DOWN, type);
        case Axis.PARENT:
        case Axis.ANCESTOR:
            return new SimpleIterator(SimpleIterator.DIRECTION_UP, type);
        case Axis.ANCESTORORSELF:
            return (new SimpleIterator(SimpleIterator.DIRECTION_UP, type)).includeSelf();
        case Axis.DESCENDANTORSELF:
            return (new SimpleIterator(SimpleIterator.DIRECTION_DOWN, type)).includeSelf();
        case Axis.SELF:
            return new SingletonIterator(type);
        default:
            return EMPTY_ITERATOR;
    }
}
 
Example 7
Source File: SAXImpl.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
/**
 * Similar to getAxisIterator, but this one returns an iterator
 * containing nodes of a typed axis (ex.: child::foo)
 */
public DTMAxisIterator getTypedAxisIterator(int axis, int type)
{
    // Most common case handled first
    if (axis == Axis.CHILD) {
        return new TypedChildrenIterator(type);
    }

    if (type == NO_TYPE) {
        return(EMPTYITERATOR);
    }

    switch (axis)
    {
        case Axis.SELF:
            return new TypedSingletonIterator(type);
        case Axis.CHILD:
            return new TypedChildrenIterator(type);
        case Axis.PARENT:
            return new ParentIterator().setNodeType(type);
        case Axis.ANCESTOR:
            return new TypedAncestorIterator(type);
        case Axis.ANCESTORORSELF:
            return (new TypedAncestorIterator(type)).includeSelf();
        case Axis.ATTRIBUTE:
            return new TypedAttributeIterator(type);
        case Axis.DESCENDANT:
            return new TypedDescendantIterator(type);
        case Axis.DESCENDANTORSELF:
            return (new TypedDescendantIterator(type)).includeSelf();
        case Axis.FOLLOWING:
            return new TypedFollowingIterator(type);
        case Axis.PRECEDING:
            return new TypedPrecedingIterator(type);
        case Axis.FOLLOWINGSIBLING:
            return new TypedFollowingSiblingIterator(type);
        case Axis.PRECEDINGSIBLING:
            return new TypedPrecedingSiblingIterator(type);
        case Axis.NAMESPACE:
            return  new TypedNamespaceIterator(type);
        case Axis.ROOT:
            return new TypedRootIterator(type);
        default:
            BasisLibrary.runTimeError(BasisLibrary.TYPED_AXIS_SUPPORT_ERR,
                    Axis.getNames(axis));
    }
    return null;
}
 
Example 8
Source File: ParentLocationPath.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public void translateStep(ClassGenerator classGen, MethodGenerator methodGen) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    // Backwards branches are prohibited if an uninitialized object is
    // on the stack by section 4.9.4 of the JVM Specification, 2nd Ed.
    // We don't know whether this code might contain backwards branches
    // so we mustn't create the new object until after we've created
    // the suspect arguments to its constructor.  Instead we calculate
    // the values of the arguments to the constructor first, store them
    // in temporary variables, create the object and reload the
    // arguments from the temporaries to avoid the problem.

    LocalVariableGen pathTemp
            = methodGen.addLocalVariable("parent_location_path_tmp1",
                                     Util.getJCRefType(NODE_ITERATOR_SIG),
                                     null, null);
    pathTemp.setStart(il.append(new ASTORE(pathTemp.getIndex())));

    _step.translate(classGen, methodGen);
    LocalVariableGen stepTemp
            = methodGen.addLocalVariable("parent_location_path_tmp2",
                                     Util.getJCRefType(NODE_ITERATOR_SIG),
                                     null, null);
    stepTemp.setStart(il.append(new ASTORE(stepTemp.getIndex())));

    // Create new StepIterator
    final int initSI = cpg.addMethodref(STEP_ITERATOR_CLASS,
                                        "<init>",
                                        "("
                                        +NODE_ITERATOR_SIG
                                        +NODE_ITERATOR_SIG
                                        +")V");
    il.append(new NEW(cpg.addClass(STEP_ITERATOR_CLASS)));
    il.append(DUP);

    pathTemp.setEnd(il.append(new ALOAD(pathTemp.getIndex())));
    stepTemp.setEnd(il.append(new ALOAD(stepTemp.getIndex())));

    // Initialize StepIterator with iterators from the stack
    il.append(new INVOKESPECIAL(initSI));

    // This is a special case for the //* path with or without predicates
    Expression stp = _step;
    if (stp instanceof ParentLocationPath)
        stp = ((ParentLocationPath)stp).getStep();

    if ((_path instanceof Step) && (stp instanceof Step)) {
        final int path = ((Step)_path).getAxis();
        final int step = ((Step)stp).getAxis();
        if ((path == Axis.DESCENDANTORSELF && step == Axis.CHILD) ||
            (path == Axis.PRECEDING        && step == Axis.PARENT)) {
            final int incl = cpg.addMethodref(NODE_ITERATOR_BASE,
                                              "includeSelf",
                                              "()" + NODE_ITERATOR_SIG);
            il.append(new INVOKEVIRTUAL(incl));
        }
    }

    /*
     * If this pattern contains a sequence of descendant iterators we
     * run the risk of returning the same node several times. We put
     * a new iterator on top of the existing one to assure node order
     * and prevent returning a single node multiple times.
     */
    if (_orderNodes) {
        final int order = cpg.addInterfaceMethodref(DOM_INTF,
                                                    ORDER_ITERATOR,
                                                    ORDER_ITERATOR_SIG);
        il.append(methodGen.loadDOM());
        il.append(SWAP);
        il.append(methodGen.loadContextNode());
        il.append(new INVOKEINTERFACE(order, 3));
    }
}
 
Example 9
Source File: WalkerFactory.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Get a corresponding BIT_XXX from an axis.
 * @param axis One of Axis.ANCESTOR, etc.
 * @return One of BIT_ANCESTOR, etc.
 */
static public int getAnalysisBitFromAxes(int axis)
{
  switch (axis) // Generate new traverser
    {
    case Axis.ANCESTOR :
      return BIT_ANCESTOR;
    case Axis.ANCESTORORSELF :
      return BIT_ANCESTOR_OR_SELF;
    case Axis.ATTRIBUTE :
      return BIT_ATTRIBUTE;
    case Axis.CHILD :
      return BIT_CHILD;
    case Axis.DESCENDANT :
      return BIT_DESCENDANT;
    case Axis.DESCENDANTORSELF :
      return BIT_DESCENDANT_OR_SELF;
    case Axis.FOLLOWING :
      return BIT_FOLLOWING;
    case Axis.FOLLOWINGSIBLING :
      return BIT_FOLLOWING_SIBLING;
    case Axis.NAMESPACE :
    case Axis.NAMESPACEDECLS :
      return BIT_NAMESPACE;
    case Axis.PARENT :
      return BIT_PARENT;
    case Axis.PRECEDING :
      return BIT_PRECEDING;
    case Axis.PRECEDINGSIBLING :
      return BIT_PRECEDING_SIBLING;
    case Axis.SELF :
      return BIT_SELF;
    case Axis.ALLFROMNODE :
      return BIT_DESCENDANT_OR_SELF;
      // case Axis.PRECEDINGANDANCESTOR :
    case Axis.DESCENDANTSFROMROOT :
    case Axis.ALL :
    case Axis.DESCENDANTSORSELFFROMROOT :
      return BIT_ANY_DESCENDANT_FROM_ROOT;
    case Axis.ROOT :
      return BIT_ROOT;
    case Axis.FILTEREDLIST :
      return BIT_FILTER;
    default :
      return BIT_FILTER;
  }
}
 
Example 10
Source File: LocationPathPattern.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
public int getAxis() {
    final StepPattern sp = getKernelPattern();
    return (sp != null) ? sp.getAxis() : Axis.CHILD;
}
 
Example 11
Source File: WalkerFactory.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
/**
 * Get a corresponding BIT_XXX from an axis.
 * @param axis One of Axis.ANCESTOR, etc.
 * @return One of BIT_ANCESTOR, etc.
 */
static public int getAnalysisBitFromAxes(int axis)
{
  switch (axis) // Generate new traverser
    {
    case Axis.ANCESTOR :
      return BIT_ANCESTOR;
    case Axis.ANCESTORORSELF :
      return BIT_ANCESTOR_OR_SELF;
    case Axis.ATTRIBUTE :
      return BIT_ATTRIBUTE;
    case Axis.CHILD :
      return BIT_CHILD;
    case Axis.DESCENDANT :
      return BIT_DESCENDANT;
    case Axis.DESCENDANTORSELF :
      return BIT_DESCENDANT_OR_SELF;
    case Axis.FOLLOWING :
      return BIT_FOLLOWING;
    case Axis.FOLLOWINGSIBLING :
      return BIT_FOLLOWING_SIBLING;
    case Axis.NAMESPACE :
    case Axis.NAMESPACEDECLS :
      return BIT_NAMESPACE;
    case Axis.PARENT :
      return BIT_PARENT;
    case Axis.PRECEDING :
      return BIT_PRECEDING;
    case Axis.PRECEDINGSIBLING :
      return BIT_PRECEDING_SIBLING;
    case Axis.SELF :
      return BIT_SELF;
    case Axis.ALLFROMNODE :
      return BIT_DESCENDANT_OR_SELF;
      // case Axis.PRECEDINGANDANCESTOR :
    case Axis.DESCENDANTSFROMROOT :
    case Axis.ALL :
    case Axis.DESCENDANTSORSELFFROMROOT :
      return BIT_ANY_DESCENDANT_FROM_ROOT;
    case Axis.ROOT :
      return BIT_ROOT;
    case Axis.FILTEREDLIST :
      return BIT_FILTER;
    default :
      return BIT_FILTER;
  }
}
 
Example 12
Source File: ParentLocationPath.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * This method is used to determine if this parent location path is a
 * combination of two step's with axes that will create duplicate or
 * unordered nodes.
 */
public boolean checkAxisMismatch() {

    int left = _path.getAxis();
    int right = ((Step)_step).getAxis();

    if (((left == Axis.ANCESTOR) || (left == Axis.ANCESTORORSELF)) &&
        ((right == Axis.CHILD) ||
         (right == Axis.DESCENDANT) ||
         (right == Axis.DESCENDANTORSELF) ||
         (right == Axis.PARENT) ||
         (right == Axis.PRECEDING) ||
         (right == Axis.PRECEDINGSIBLING)))
        return true;

    if ((left == Axis.CHILD) &&
        (right == Axis.ANCESTOR) ||
        (right == Axis.ANCESTORORSELF) ||
        (right == Axis.PARENT) ||
        (right == Axis.PRECEDING))
        return true;

    if ((left == Axis.DESCENDANT) || (left == Axis.DESCENDANTORSELF))
        return true;

    if (((left == Axis.FOLLOWING) || (left == Axis.FOLLOWINGSIBLING)) &&
        ((right == Axis.FOLLOWING) ||
         (right == Axis.PARENT) ||
         (right == Axis.PRECEDING) ||
         (right == Axis.PRECEDINGSIBLING)))
        return true;

    if (((left == Axis.PRECEDING) || (left == Axis.PRECEDINGSIBLING)) &&
        ((right == Axis.DESCENDANT) ||
         (right == Axis.DESCENDANTORSELF) ||
         (right == Axis.FOLLOWING) ||
         (right == Axis.FOLLOWINGSIBLING) ||
         (right == Axis.PARENT) ||
         (right == Axis.PRECEDING) ||
         (right == Axis.PRECEDINGSIBLING)))
        return true;

    if ((right == Axis.FOLLOWING) && (left == Axis.CHILD)) {
        // Special case for '@*/following::*' expressions. The resulting
        // iterator is initialised with the parent's first child, and this
        // can cause duplicates in the output if the parent has more than
        // one attribute that matches the left step.
        if (_path instanceof Step) {
            int type = ((Step)_path).getNodeType();
            if (type == DTM.ATTRIBUTE_NODE) return true;
        }
    }

    return false;
}
 
Example 13
Source File: ParentLocationPath.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * This method is used to determine if this parent location path is a
 * combination of two step's with axes that will create duplicate or
 * unordered nodes.
 */
public boolean checkAxisMismatch() {

    int left = _path.getAxis();
    int right = ((Step)_step).getAxis();

    if (((left == Axis.ANCESTOR) || (left == Axis.ANCESTORORSELF)) &&
        ((right == Axis.CHILD) ||
         (right == Axis.DESCENDANT) ||
         (right == Axis.DESCENDANTORSELF) ||
         (right == Axis.PARENT) ||
         (right == Axis.PRECEDING) ||
         (right == Axis.PRECEDINGSIBLING)))
        return true;

    if ((left == Axis.CHILD) &&
        (right == Axis.ANCESTOR) ||
        (right == Axis.ANCESTORORSELF) ||
        (right == Axis.PARENT) ||
        (right == Axis.PRECEDING))
        return true;

    if ((left == Axis.DESCENDANT) || (left == Axis.DESCENDANTORSELF))
        return true;

    if (((left == Axis.FOLLOWING) || (left == Axis.FOLLOWINGSIBLING)) &&
        ((right == Axis.FOLLOWING) ||
         (right == Axis.PARENT) ||
         (right == Axis.PRECEDING) ||
         (right == Axis.PRECEDINGSIBLING)))
        return true;

    if (((left == Axis.PRECEDING) || (left == Axis.PRECEDINGSIBLING)) &&
        ((right == Axis.DESCENDANT) ||
         (right == Axis.DESCENDANTORSELF) ||
         (right == Axis.FOLLOWING) ||
         (right == Axis.FOLLOWINGSIBLING) ||
         (right == Axis.PARENT) ||
         (right == Axis.PRECEDING) ||
         (right == Axis.PRECEDINGSIBLING)))
        return true;

    if ((right == Axis.FOLLOWING) && (left == Axis.CHILD)) {
        // Special case for '@*/following::*' expressions. The resulting
        // iterator is initialised with the parent's first child, and this
        // can cause duplicates in the output if the parent has more than
        // one attribute that matches the left step.
        if (_path instanceof Step) {
            int type = ((Step)_path).getNodeType();
            if (type == DTM.ATTRIBUTE_NODE) return true;
        }
    }

    return false;
}
 
Example 14
Source File: ParentLocationPath.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public void translateStep(ClassGenerator classGen, MethodGenerator methodGen) {
    final ConstantPoolGen cpg = classGen.getConstantPool();
    final InstructionList il = methodGen.getInstructionList();

    // Backwards branches are prohibited if an uninitialized object is
    // on the stack by section 4.9.4 of the JVM Specification, 2nd Ed.
    // We don't know whether this code might contain backwards branches
    // so we mustn't create the new object until after we've created
    // the suspect arguments to its constructor.  Instead we calculate
    // the values of the arguments to the constructor first, store them
    // in temporary variables, create the object and reload the
    // arguments from the temporaries to avoid the problem.

    LocalVariableGen pathTemp
            = methodGen.addLocalVariable("parent_location_path_tmp1",
                                     Util.getJCRefType(NODE_ITERATOR_SIG),
                                     null, null);
    pathTemp.setStart(il.append(new ASTORE(pathTemp.getIndex())));

    _step.translate(classGen, methodGen);
    LocalVariableGen stepTemp
            = methodGen.addLocalVariable("parent_location_path_tmp2",
                                     Util.getJCRefType(NODE_ITERATOR_SIG),
                                     null, null);
    stepTemp.setStart(il.append(new ASTORE(stepTemp.getIndex())));

    // Create new StepIterator
    final int initSI = cpg.addMethodref(STEP_ITERATOR_CLASS,
                                        "<init>",
                                        "("
                                        +NODE_ITERATOR_SIG
                                        +NODE_ITERATOR_SIG
                                        +")V");
    il.append(new NEW(cpg.addClass(STEP_ITERATOR_CLASS)));
    il.append(DUP);

    pathTemp.setEnd(il.append(new ALOAD(pathTemp.getIndex())));
    stepTemp.setEnd(il.append(new ALOAD(stepTemp.getIndex())));

    // Initialize StepIterator with iterators from the stack
    il.append(new INVOKESPECIAL(initSI));

    // This is a special case for the //* path with or without predicates
    Expression stp = _step;
    if (stp instanceof ParentLocationPath)
        stp = ((ParentLocationPath)stp).getStep();

    if ((_path instanceof Step) && (stp instanceof Step)) {
        final int path = ((Step)_path).getAxis();
        final int step = ((Step)stp).getAxis();
        if ((path == Axis.DESCENDANTORSELF && step == Axis.CHILD) ||
            (path == Axis.PRECEDING        && step == Axis.PARENT)) {
            final int incl = cpg.addMethodref(NODE_ITERATOR_BASE,
                                              "includeSelf",
                                              "()" + NODE_ITERATOR_SIG);
            il.append(new INVOKEVIRTUAL(incl));
        }
    }

    /*
     * If this pattern contains a sequence of descendant iterators we
     * run the risk of returning the same node several times. We put
     * a new iterator on top of the existing one to assure node order
     * and prevent returning a single node multiple times.
     */
    if (_orderNodes) {
        final int order = cpg.addInterfaceMethodref(DOM_INTF,
                                                    ORDER_ITERATOR,
                                                    ORDER_ITERATOR_SIG);
        il.append(methodGen.loadDOM());
        il.append(SWAP);
        il.append(methodGen.loadContextNode());
        il.append(new INVOKEINTERFACE(order, 3));
    }
}
 
Example 15
Source File: MultiDOM.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public DTMAxisIterator getTypedChildren(final int type) {
    return new AxisIterator(Axis.CHILD, type);
}
 
Example 16
Source File: ProcessingInstructionPattern.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Handles calls with no parameter (current node is implicit parameter).
 */
public ProcessingInstructionPattern(String name) {
    super(Axis.CHILD, DTM.PROCESSING_INSTRUCTION_NODE, null);
    _name = name;
    //if (_name.equals("*")) _typeChecked = true; no wildcard allowed!
}
 
Example 17
Source File: ProcessingInstructionPattern.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Handles calls with no parameter (current node is implicit parameter).
 */
public ProcessingInstructionPattern(String name) {
    super(Axis.CHILD, DTM.PROCESSING_INSTRUCTION_NODE, null);
    _name = name;
    //if (_name.equals("*")) _typeChecked = true; no wildcard allowed!
}
 
Example 18
Source File: SAXImpl.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Similar to getAxisIterator, but this one returns an iterator
 * containing nodes of a typed axis (ex.: child::foo)
 */
public DTMAxisIterator getTypedAxisIterator(int axis, int type)
{
    // Most common case handled first
    if (axis == Axis.CHILD) {
        return new TypedChildrenIterator(type);
    }

    if (type == NO_TYPE) {
        return(EMPTYITERATOR);
    }

    switch (axis)
    {
        case Axis.SELF:
            return new TypedSingletonIterator(type);
        case Axis.CHILD:
            return new TypedChildrenIterator(type);
        case Axis.PARENT:
            return new ParentIterator().setNodeType(type);
        case Axis.ANCESTOR:
            return new TypedAncestorIterator(type);
        case Axis.ANCESTORORSELF:
            return (new TypedAncestorIterator(type)).includeSelf();
        case Axis.ATTRIBUTE:
            return new TypedAttributeIterator(type);
        case Axis.DESCENDANT:
            return new TypedDescendantIterator(type);
        case Axis.DESCENDANTORSELF:
            return (new TypedDescendantIterator(type)).includeSelf();
        case Axis.FOLLOWING:
            return new TypedFollowingIterator(type);
        case Axis.PRECEDING:
            return new TypedPrecedingIterator(type);
        case Axis.FOLLOWINGSIBLING:
            return new TypedFollowingSiblingIterator(type);
        case Axis.PRECEDINGSIBLING:
            return new TypedPrecedingSiblingIterator(type);
        case Axis.NAMESPACE:
            return  new TypedNamespaceIterator(type);
        case Axis.ROOT:
            return new TypedRootIterator(type);
        default:
            BasisLibrary.runTimeError(BasisLibrary.TYPED_AXIS_SUPPORT_ERR,
                    Axis.getNames(axis));
    }
    return null;
}
 
Example 19
Source File: WalkingIteratorSorted.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Tell if the nodeset can be walked in doc order, via static analysis.
 *
 *
 * @return true if the nodeset can be walked in doc order, without sorting.
 */
boolean canBeWalkedInNaturalDocOrderStatic()
{

  if (null != m_firstWalker)
  {
    AxesWalker walker = m_firstWalker;
    int prevAxis = -1;
    boolean prevIsSimpleDownAxis = true;

    for(int i = 0; null != walker; i++)
    {
      int axis = walker.getAxis();

      if(walker.isDocOrdered())
      {
        boolean isSimpleDownAxis = ((axis == Axis.CHILD)
                                 || (axis == Axis.SELF)
                                 || (axis == Axis.ROOT));
        // Catching the filtered list here is only OK because
        // FilterExprWalker#isDocOrdered() did the right thing.
        if(isSimpleDownAxis || (axis == -1))
          walker = walker.getNextWalker();
        else
        {
          boolean isLastWalker = (null == walker.getNextWalker());
          if(isLastWalker)
          {
            if(walker.isDocOrdered() && (axis == Axis.DESCENDANT ||
               axis == Axis.DESCENDANTORSELF || axis == Axis.DESCENDANTSFROMROOT
               || axis == Axis.DESCENDANTSORSELFFROMROOT) || (axis == Axis.ATTRIBUTE))
              return true;
          }
          return false;
        }
      }
      else
        return false;
    }
    return true;
  }
  return false;
}
 
Example 20
Source File: WalkerFactory.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Get a corresponding BIT_XXX from an axis.
 * @param axis One of Axis.ANCESTOR, etc.
 * @return One of BIT_ANCESTOR, etc.
 */
static public int getAnalysisBitFromAxes(int axis)
{
  switch (axis) // Generate new traverser
    {
    case Axis.ANCESTOR :
      return BIT_ANCESTOR;
    case Axis.ANCESTORORSELF :
      return BIT_ANCESTOR_OR_SELF;
    case Axis.ATTRIBUTE :
      return BIT_ATTRIBUTE;
    case Axis.CHILD :
      return BIT_CHILD;
    case Axis.DESCENDANT :
      return BIT_DESCENDANT;
    case Axis.DESCENDANTORSELF :
      return BIT_DESCENDANT_OR_SELF;
    case Axis.FOLLOWING :
      return BIT_FOLLOWING;
    case Axis.FOLLOWINGSIBLING :
      return BIT_FOLLOWING_SIBLING;
    case Axis.NAMESPACE :
    case Axis.NAMESPACEDECLS :
      return BIT_NAMESPACE;
    case Axis.PARENT :
      return BIT_PARENT;
    case Axis.PRECEDING :
      return BIT_PRECEDING;
    case Axis.PRECEDINGSIBLING :
      return BIT_PRECEDING_SIBLING;
    case Axis.SELF :
      return BIT_SELF;
    case Axis.ALLFROMNODE :
      return BIT_DESCENDANT_OR_SELF;
      // case Axis.PRECEDINGANDANCESTOR :
    case Axis.DESCENDANTSFROMROOT :
    case Axis.ALL :
    case Axis.DESCENDANTSORSELFFROMROOT :
      return BIT_ANY_DESCENDANT_FROM_ROOT;
    case Axis.ROOT :
      return BIT_ROOT;
    case Axis.FILTEREDLIST :
      return BIT_FILTER;
    default :
      return BIT_FILTER;
  }
}