Package org.jaxen

Examples of org.jaxen.ContextSupport


        return "/" + super.getText();
    }

    public Object evaluate(Context context) throws JaxenException
    {
        ContextSupport support = context.getContextSupport();
        Navigator      nav     = support.getNavigator();
        Context absContext = new Context( support );
        List contextNodes = context.getNodeSet();

        if ( contextNodes.isEmpty() )
        {
View Full Code Here


    public Object evaluate(Context context) throws JaxenException
    {
        List nodeSet = context.getNodeSet();
        List contextNodeSet = new ArrayList(nodeSet);
        ContextSupport support = context.getContextSupport();
        Context stepContext = new Context(support);
        Iterator stepIter = getSteps().iterator();
        while ( stepIter.hasNext() )
        {
            Step eachStep = (Step) stepIter.next();
            stepContext.setNodeSet(contextNodeSet);
            contextNodeSet = eachStep.evaluate(stepContext);
            // now we need to reverse the list if this is a reverse axis
            if (isReverseAxis(eachStep)) {
                Collections.reverse(contextNodeSet);
            }
        }
       
        if (getSteps().size() > 1) {
            Collections.sort(contextNodeSet, new NodeComparator(support.getNavigator()));
        }
       
        return contextNodeSet;
    }
View Full Code Here

    public ContextSupport getContextSupport()
    {
        if (this.contextSupport == null)
        {
            this.contextSupport = new ContextSupport(new SimpleNamespaceContext(),
                    XPathFunctionContext.getInstance(),
                    new SimpleVariableContext(),
                    getNavigator());
        }
        return this.contextSupport;
View Full Code Here

    public String toString() {
        return "[XPathPattern: text: " + text + " Pattern: " + pattern + "]";
    }

    protected ContextSupport getContextSupport() {
        return new ContextSupport(new SimpleNamespaceContext(),
                XPathFunctionContext.getInstance(),
                new SimpleVariableContext(), DocumentNavigator.getInstance());
    }
View Full Code Here

        int contextSize = contextNodeSet.size();
        // optimize for context size 0
        if (contextSize == 0) {
            return Collections.EMPTY_LIST;
        }
        ContextSupport support = context.getContextSupport();
        IterableAxis iterableAxis = getIterableAxis();
        boolean namedAccess = (!matchesAnyName && iterableAxis.supportsNamedAccess(support));
       
        // optimize for context size 1 (common case, avoids lots of object creation)
        if (contextSize == 1) {
            Object contextNode = contextNodeSet.get(0);
            if (namedAccess) {
                // get the iterator over the nodes and check it
                String uri = null;
                if (hasPrefix) {
                    uri = support.translateNamespacePrefixToUri(prefix);
                    if (uri == null) {
                        throw new UnresolvableException("XPath expression uses unbound namespace prefix " + prefix);
                    }
                }
                Iterator axisNodeIter = iterableAxis.namedAccessIterator(
                                contextNode, support, localName, prefix, uri);
                if (axisNodeIter == null || !axisNodeIter.hasNext()) {
                    return Collections.EMPTY_LIST;
                }

                // convert iterator to list for predicate test
                // no need to filter as named access guarantees this
                List newNodeSet = new ArrayList();
                while (axisNodeIter.hasNext()) {
                    newNodeSet.add(axisNodeIter.next());
                }
               
                // evaluate the predicates
                return getPredicateSet().evaluatePredicates(newNodeSet, support);
               
            }
            else {
                // get the iterator over the nodes and check it
                Iterator axisNodeIter = iterableAxis.iterator(contextNode, support);
                if (axisNodeIter == null || !axisNodeIter.hasNext()) {
                    return Collections.EMPTY_LIST;
                }

                // run through iterator, filtering using matches()
                // adding to list for predicate test
                List newNodeSet = new ArrayList(contextSize);
                while (axisNodeIter.hasNext()) {
                    Object eachAxisNode = axisNodeIter.next();
                    if (matches(eachAxisNode, support)) {
                        newNodeSet.add(eachAxisNode);
                    }
                }
               
                // evaluate the predicates
                return getPredicateSet().evaluatePredicates(newNodeSet, support);
            }
        }

        // full case
        IdentitySet unique = new IdentitySet();
        List interimSet = new ArrayList(contextSize);
        List newNodeSet = new ArrayList(contextSize);
       
        if (namedAccess) {
            String uri = null;
            if (hasPrefix) {
                uri = support.translateNamespacePrefixToUri(prefix);
                if (uri == null) {
                    throw new UnresolvableException("XPath expression uses unbound namespace prefix " + prefix);
                }
            }
            for (int i = 0; i < contextSize; ++i) {
View Full Code Here

        else
            xpathString = StringFunction.evaluate(arg, nav);

        try {
            XPath xpath = nav.parseXPath(xpathString);
            ContextSupport support = context.getContextSupport();
            xpath.setVariableContext( support.getVariableContext() );
            xpath.setFunctionContext( support.getFunctionContext() );
            xpath.setNamespaceContext( support.getNamespaceContext() );
            return xpath.selectNodes( context.duplicate() );
        }
        catch ( org.jaxen.saxpath.SAXPathException e ) {
            throw new FunctionCallException(e.toString());
        }
View Full Code Here

        // ???? try linked lists instead?
        // ???? initial size for these?
        final ArrayList interimSet = new ArrayList();
        final ArrayList newNodeSet = new ArrayList();
        final ContextSupport support = context.getContextSupport();
           
        // ???? use iterator instead
        for ( int i = 0 ; i < contextSize ; ++i )
        {
            Object eachContextNode = contextNodeSet.get( i );
View Full Code Here

        return "/" + super.getText();
    }

    public Object evaluate(Context context) throws JaxenException
    {
        ContextSupport support = context.getContextSupport();
        Navigator      nav     = support.getNavigator();
        Context absContext = new Context( support );
        List contextNodes = context.getNodeSet();

        if ( contextNodes.isEmpty() )
        {
View Full Code Here

    public Object evaluate(Context context) throws JaxenException
    {
        List nodeSet = context.getNodeSet();
        List contextNodeSet = new ArrayList(nodeSet);
        ContextSupport support = context.getContextSupport();
        Context stepContext = new Context(support);
        Iterator stepIter = getSteps().iterator();
        while ( stepIter.hasNext() )
        {
            Step eachStep = (Step) stepIter.next();
            stepContext.setNodeSet(contextNodeSet);
            contextNodeSet = eachStep.evaluate(stepContext);
            // now we need to reverse the list if this is a reverse axis
            if (isReverseAxis(eachStep)) {
                Collections.reverse(contextNodeSet);
            }
        }
       
        if (getSteps().size() > 1) {
            Collections.sort(contextNodeSet, new NodeComparator(support.getNavigator()));
        }
       
        return contextNodeSet;
    }
View Full Code Here

    public Object evaluate(Context context) throws JaxenException

    {

        ContextSupport support = context.getContextSupport();

        Navigator      nav     = support.getNavigator();



        Context absContext = new Context( support );
View Full Code Here

TOP

Related Classes of org.jaxen.ContextSupport

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.