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

The following examples show how to use com.sun.org.apache.xml.internal.dtm.Axis#PARENT . 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: SimpleResultTreeImpl.java    From openjdk-jdk9 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 2
Source File: SimpleResultTreeImpl.java    From hottub with GNU General Public License v2.0 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 3
Source File: SimpleResultTreeImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 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 4
Source File: SimpleResultTreeImpl.java    From TencentKona-8 with GNU General Public License v2.0 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 5
Source File: SAXImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * This is a shortcut to the iterators that implement the
 * supported XPath axes (only namespace::) is not supported.
 * Returns a bare-bones iterator that must be initialized
 * with a start node (using iterator.setStartNode()).
 */
public DTMAxisIterator getAxisIterator(final int axis)
{
    switch (axis)
    {
        case Axis.SELF:
            return new SingletonIterator();
        case Axis.CHILD:
            return new ChildrenIterator();
        case Axis.PARENT:
            return new ParentIterator();
        case Axis.ANCESTOR:
            return new AncestorIterator();
        case Axis.ANCESTORORSELF:
            return (new AncestorIterator()).includeSelf();
        case Axis.ATTRIBUTE:
            return new AttributeIterator();
        case Axis.DESCENDANT:
            return new DescendantIterator();
        case Axis.DESCENDANTORSELF:
            return (new DescendantIterator()).includeSelf();
        case Axis.FOLLOWING:
            return new FollowingIterator();
        case Axis.PRECEDING:
            return new PrecedingIterator();
        case Axis.FOLLOWINGSIBLING:
            return new FollowingSiblingIterator();
        case Axis.PRECEDINGSIBLING:
            return new PrecedingSiblingIterator();
        case Axis.NAMESPACE:
            return new NamespaceIterator();
        case Axis.ROOT:
            return new RootIterator();
        default:
            BasisLibrary.runTimeError(BasisLibrary.AXIS_SUPPORT_ERR,
                    Axis.getNames(axis));
    }
    return null;
}
 
Example 6
Source File: WalkerFactory.java    From jdk8u60 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 7
Source File: SAXImpl.java    From jdk8u60 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 8
Source File: WalkerFactory.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
/**
 * Special purpose function to see if we can optimize the pattern for
 * a DescendantIterator.
 *
 * @param compiler non-null reference to compiler object that has processed
 *                 the XPath operations into an opcode map.
 * @param stepOpCodePos The opcode position for the step.
 *
 * @return 32 bits as an integer that give information about the location
 * path as a whole.
 *
 * @throws javax.xml.transform.TransformerException
 */
public static int getAxisFromStep(
        Compiler compiler, int stepOpCodePos)
          throws javax.xml.transform.TransformerException
{

  int stepType = compiler.getOp(stepOpCodePos);

  switch (stepType)
  {
  case OpCodes.FROM_FOLLOWING :
    return Axis.FOLLOWING;
  case OpCodes.FROM_FOLLOWING_SIBLINGS :
    return Axis.FOLLOWINGSIBLING;
  case OpCodes.FROM_PRECEDING :
    return Axis.PRECEDING;
  case OpCodes.FROM_PRECEDING_SIBLINGS :
    return Axis.PRECEDINGSIBLING;
  case OpCodes.FROM_PARENT :
    return Axis.PARENT;
  case OpCodes.FROM_NAMESPACE :
    return Axis.NAMESPACE;
  case OpCodes.FROM_ANCESTORS :
    return Axis.ANCESTOR;
  case OpCodes.FROM_ANCESTORS_OR_SELF :
    return Axis.ANCESTORORSELF;
  case OpCodes.FROM_ATTRIBUTES :
    return Axis.ATTRIBUTE;
  case OpCodes.FROM_ROOT :
    return Axis.ROOT;
  case OpCodes.FROM_CHILDREN :
    return Axis.CHILD;
  case OpCodes.FROM_DESCENDANTS_OR_SELF :
    return Axis.DESCENDANTORSELF;
  case OpCodes.FROM_DESCENDANTS :
    return Axis.DESCENDANT;
  case OpCodes.FROM_SELF :
    return Axis.SELF;
  case OpCodes.OP_EXTFUNCTION :
  case OpCodes.OP_FUNCTION :
  case OpCodes.OP_GROUP :
  case OpCodes.OP_VARIABLE :
    return Axis.FILTEREDLIST;
  }

  throw new RuntimeException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_NULL_ERROR_HANDLER, new Object[]{Integer.toString(stepType)})); //"Programmer's assertion: unknown opcode: "
                             //+ stepType);
 }
 
Example 9
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 10
Source File: Step.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * True if this step is the abbreviated step '..'
 */
public boolean isAbbreviatedDDot() {
    return _nodeType == NodeTest.ANODE && _axis == Axis.PARENT;
}
 
Example 11
Source File: WalkerFactory.java    From hottub 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 12
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;
  }
}
 
Example 13
Source File: WalkerFactory.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Special purpose function to see if we can optimize the pattern for
 * a DescendantIterator.
 *
 * @param compiler non-null reference to compiler object that has processed
 *                 the XPath operations into an opcode map.
 * @param stepOpCodePos The opcode position for the step.
 *
 * @return 32 bits as an integer that give information about the location
 * path as a whole.
 *
 * @throws javax.xml.transform.TransformerException
 */
public static int getAxisFromStep(
        Compiler compiler, int stepOpCodePos)
          throws javax.xml.transform.TransformerException
{

  int stepType = compiler.getOp(stepOpCodePos);

  switch (stepType)
  {
  case OpCodes.FROM_FOLLOWING :
    return Axis.FOLLOWING;
  case OpCodes.FROM_FOLLOWING_SIBLINGS :
    return Axis.FOLLOWINGSIBLING;
  case OpCodes.FROM_PRECEDING :
    return Axis.PRECEDING;
  case OpCodes.FROM_PRECEDING_SIBLINGS :
    return Axis.PRECEDINGSIBLING;
  case OpCodes.FROM_PARENT :
    return Axis.PARENT;
  case OpCodes.FROM_NAMESPACE :
    return Axis.NAMESPACE;
  case OpCodes.FROM_ANCESTORS :
    return Axis.ANCESTOR;
  case OpCodes.FROM_ANCESTORS_OR_SELF :
    return Axis.ANCESTORORSELF;
  case OpCodes.FROM_ATTRIBUTES :
    return Axis.ATTRIBUTE;
  case OpCodes.FROM_ROOT :
    return Axis.ROOT;
  case OpCodes.FROM_CHILDREN :
    return Axis.CHILD;
  case OpCodes.FROM_DESCENDANTS_OR_SELF :
    return Axis.DESCENDANTORSELF;
  case OpCodes.FROM_DESCENDANTS :
    return Axis.DESCENDANT;
  case OpCodes.FROM_SELF :
    return Axis.SELF;
  case OpCodes.OP_EXTFUNCTION :
  case OpCodes.OP_FUNCTION :
  case OpCodes.OP_GROUP :
  case OpCodes.OP_VARIABLE :
    return Axis.FILTEREDLIST;
  }

  throw new RuntimeException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_NULL_ERROR_HANDLER, new Object[]{Integer.toString(stepType)})); //"Programmer's assertion: unknown opcode: "
                             //+ stepType);
 }
 
Example 14
Source File: Step.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
/**
 * True if this step is the abbreviated step '..'
 */
public boolean isAbbreviatedDDot() {
    return _nodeType == NodeTest.ANODE && _axis == Axis.PARENT;
}
 
Example 15
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 16
Source File: SAXImpl.java    From openjdk-jdk8u 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 17
Source File: WalkerFactory.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Special purpose function to see if we can optimize the pattern for
 * a DescendantIterator.
 *
 * @param compiler non-null reference to compiler object that has processed
 *                 the XPath operations into an opcode map.
 * @param stepOpCodePos The opcode position for the step.
 *
 * @return 32 bits as an integer that give information about the location
 * path as a whole.
 *
 * @throws javax.xml.transform.TransformerException
 */
public static int getAxisFromStep(
        Compiler compiler, int stepOpCodePos)
          throws javax.xml.transform.TransformerException
{

  int stepType = compiler.getOp(stepOpCodePos);

  switch (stepType)
  {
  case OpCodes.FROM_FOLLOWING :
    return Axis.FOLLOWING;
  case OpCodes.FROM_FOLLOWING_SIBLINGS :
    return Axis.FOLLOWINGSIBLING;
  case OpCodes.FROM_PRECEDING :
    return Axis.PRECEDING;
  case OpCodes.FROM_PRECEDING_SIBLINGS :
    return Axis.PRECEDINGSIBLING;
  case OpCodes.FROM_PARENT :
    return Axis.PARENT;
  case OpCodes.FROM_NAMESPACE :
    return Axis.NAMESPACE;
  case OpCodes.FROM_ANCESTORS :
    return Axis.ANCESTOR;
  case OpCodes.FROM_ANCESTORS_OR_SELF :
    return Axis.ANCESTORORSELF;
  case OpCodes.FROM_ATTRIBUTES :
    return Axis.ATTRIBUTE;
  case OpCodes.FROM_ROOT :
    return Axis.ROOT;
  case OpCodes.FROM_CHILDREN :
    return Axis.CHILD;
  case OpCodes.FROM_DESCENDANTS_OR_SELF :
    return Axis.DESCENDANTORSELF;
  case OpCodes.FROM_DESCENDANTS :
    return Axis.DESCENDANT;
  case OpCodes.FROM_SELF :
    return Axis.SELF;
  case OpCodes.OP_EXTFUNCTION :
  case OpCodes.OP_FUNCTION :
  case OpCodes.OP_GROUP :
  case OpCodes.OP_VARIABLE :
    return Axis.FILTEREDLIST;
  }

  throw new RuntimeException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_NULL_ERROR_HANDLER, new Object[]{Integer.toString(stepType)})); //"Programmer's assertion: unknown opcode: "
                             //+ stepType);
 }
 
Example 18
Source File: ParentLocationPath.java    From Bytecoder with Apache License 2.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 19
Source File: WalkerFactory.java    From JDKSourceCode1.8 with MIT License 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 20
Source File: WalkerFactory.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Special purpose function to see if we can optimize the pattern for
 * a DescendantIterator.
 *
 * @param compiler non-null reference to compiler object that has processed
 *                 the XPath operations into an opcode map.
 * @param stepOpCodePos The opcode position for the step.
 *
 * @return 32 bits as an integer that give information about the location
 * path as a whole.
 *
 * @throws javax.xml.transform.TransformerException
 */
public static int getAxisFromStep(
        Compiler compiler, int stepOpCodePos)
          throws javax.xml.transform.TransformerException
{

  int stepType = compiler.getOp(stepOpCodePos);

  switch (stepType)
  {
  case OpCodes.FROM_FOLLOWING :
    return Axis.FOLLOWING;
  case OpCodes.FROM_FOLLOWING_SIBLINGS :
    return Axis.FOLLOWINGSIBLING;
  case OpCodes.FROM_PRECEDING :
    return Axis.PRECEDING;
  case OpCodes.FROM_PRECEDING_SIBLINGS :
    return Axis.PRECEDINGSIBLING;
  case OpCodes.FROM_PARENT :
    return Axis.PARENT;
  case OpCodes.FROM_NAMESPACE :
    return Axis.NAMESPACE;
  case OpCodes.FROM_ANCESTORS :
    return Axis.ANCESTOR;
  case OpCodes.FROM_ANCESTORS_OR_SELF :
    return Axis.ANCESTORORSELF;
  case OpCodes.FROM_ATTRIBUTES :
    return Axis.ATTRIBUTE;
  case OpCodes.FROM_ROOT :
    return Axis.ROOT;
  case OpCodes.FROM_CHILDREN :
    return Axis.CHILD;
  case OpCodes.FROM_DESCENDANTS_OR_SELF :
    return Axis.DESCENDANTORSELF;
  case OpCodes.FROM_DESCENDANTS :
    return Axis.DESCENDANT;
  case OpCodes.FROM_SELF :
    return Axis.SELF;
  case OpCodes.OP_EXTFUNCTION :
  case OpCodes.OP_FUNCTION :
  case OpCodes.OP_GROUP :
  case OpCodes.OP_VARIABLE :
    return Axis.FILTEREDLIST;
  }

  throw new RuntimeException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_NULL_ERROR_HANDLER, new Object[]{Integer.toString(stepType)})); //"Programmer's assertion: unknown opcode: "
                             //+ stepType);
 }