protected EvalContext createContextForStep()

in src/main/java/org/apache/commons/jxpath/ri/compiler/Path.java [133:172]


    protected EvalContext createContextForStep(final EvalContext context, final int axis, NodeTest nodeTest) {
        if (nodeTest instanceof NodeNameTest) {
            final QName qname = ((NodeNameTest) nodeTest).getNodeName();
            final String prefix = qname.getPrefix();
            if (prefix != null) {
                final String namespaceURI = context.getJXPathContext().getNamespaceURI(prefix);
                nodeTest = new NodeNameTest(qname, namespaceURI);
            }
        }
        switch (axis) {
        case Compiler.AXIS_ANCESTOR:
            return new AncestorContext(context, false, nodeTest);
        case Compiler.AXIS_ANCESTOR_OR_SELF:
            return new AncestorContext(context, true, nodeTest);
        case Compiler.AXIS_ATTRIBUTE:
            return new AttributeContext(context, nodeTest);
        case Compiler.AXIS_CHILD:
            return new ChildContext(context, nodeTest, false, false);
        case Compiler.AXIS_DESCENDANT:
            return new DescendantContext(context, false, nodeTest);
        case Compiler.AXIS_DESCENDANT_OR_SELF:
            return new DescendantContext(context, true, nodeTest);
        case Compiler.AXIS_FOLLOWING:
            return new PrecedingOrFollowingContext(context, nodeTest, false);
        case Compiler.AXIS_FOLLOWING_SIBLING:
            return new ChildContext(context, nodeTest, true, false);
        case Compiler.AXIS_NAMESPACE:
            return new NamespaceContext(context, nodeTest);
        case Compiler.AXIS_PARENT:
            return new ParentContext(context, nodeTest);
        case Compiler.AXIS_PRECEDING:
            return new PrecedingOrFollowingContext(context, nodeTest, true);
        case Compiler.AXIS_PRECEDING_SIBLING:
            return new ChildContext(context, nodeTest, true, true);
        case Compiler.AXIS_SELF:
            return new SelfContext(context, nodeTest);
        default:
            return null; // Never happens
        }
    }