Package org.jaxen

Examples of org.jaxen.Context


        public List selectNodes(Object object, NamespaceContext namespaces)
        throws
            TemplateModelException
        {
            Context context = getContext(object);
            context.getContextSupport().setNamespaceContext(namespaces);
            try {
                return selectNodesForContext(context);
            }
            catch(Exception e) {
                throw new TemplateModelException(e);
View Full Code Here


        public List selectNodes(Object object, NamespaceContext namespaces)
        throws
            TemplateModelException
        {
            Context context = getContext(object);
            context.getContextSupport().setNamespaceContext(namespaces);
            try {
                return selectNodesForContext(context);
            }
            catch(Exception e) {
                throw new TemplateModelException(e);
View Full Code Here

        public List selectNodes(Object object, NamespaceContext namespaces)
        throws
            TemplateModelException
        {
            Context context = getContext(object);
            context.getContextSupport().setNamespaceContext(namespaces);
            try {
                return selectNodesForContext(context);
            }
            catch(Exception e) {
                throw new TemplateModelException(e);
View Full Code Here

        public List selectNodes(Object object, Map namespaces)
        throws
            JaxenException
        {
            Context context = getContext(object);
            context.getContextSupport().setNamespaceContext(new NamespaceContextImpl(namespaces));
            return selectNodesForContext(context);
        }
View Full Code Here

    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() )
        {
            return Collections.EMPTY_LIST;
        }

        Object firstNode = contextNodes.get( 0 );

        Object docNode   = nav.getDocumentNode( firstNode );

        if ( docNode == null )
        {
            return Collections.EMPTY_LIST;
        }

        List list = new ArrayList(1);

        list.add( docNode );

        absContext.setNodeSet( list );

        return super.evaluate( absContext );
    }
View Full Code Here

       
        Predicate eachPred    = null;
        Object    contextNode = null;

        Object predResult  = null;
        Context predContext = new Context( support );

  // Filter the 'filterSet' against all predicates. This has been
  // tuned for performance, so there are two separate loops

  // In the first run, all nodes matching the first predicate will
  // be copied from contextNodeSet to newNodeSet

  // In the second loop, newNodeSet is filtered progressively against
  // the remaining predicates, eliminating any non-matching nodes

  if ( predIter.hasNext() )
        {
            eachPred = (Predicate) predIter.next();

            int filterSize = filterSet.size();

            for ( int i = 0 ; i < filterSize ; ++i )
            {
                contextNode = filterSet.get( i );

                List list = new ArrayList( 1 );

                list.add( contextNode );

                predContext.setNodeSet( list );

                predContext.setPosition( i + 1 );
                predContext.setSize( filterSize );

                predResult = eachPred.evaluate( predContext );

                if ( predResult instanceof Number )
                {
                    int proximity = ((Number)predResult).intValue();

                    if ( proximity == ( i + 1 ) )
                    {
                        newNodeSet.add( contextNode );
                    }
                }
                else
                {
                    Boolean includes = BooleanFunction.evaluate( predResult, predContext.getNavigator() );

                    if ( includes.booleanValue() )
                    {
                        newNodeSet.add( contextNode );
                    }
                }
            }
        }


  // This will be true if any filtering takes place from here on

  boolean nodesFiltered = false;

  // Second loop: Filter filterSet until no more predicates are left

  filterSet = newNodeSet;

  while ( predIter.hasNext() )
        {
            eachPred = (Predicate) predIter.next();


      int filterSize = filterSet.size();

            for ( int i = 0 ; i < filterSize ; ++i )
            {
                contextNode = filterSet.get(i);

    // Check if a node has been eliminated already

    if (contextNode == null) continue;

                List list = new ArrayList( 1 );

                list.add( contextNode );

                predContext.setNodeSet( list );

                predContext.setPosition( i + 1 );
                predContext.setSize( filterSize );

                predResult = eachPred.evaluate( predContext );

                if ( predResult instanceof Number )
                {
                    int proximity = ((Number)predResult).intValue();

                    if ( proximity != ( i + 1 ) )
                    {
                        filterSet.set(i,null);
      nodesFiltered = true;
                    }
                }
                else
                {
                    Boolean includes = BooleanFunction.evaluate( predResult, predContext.getNavigator() );

                    if ( !includes.booleanValue() )
                    {
                        filterSet.set(i,null);
      nodesFiltered = true;
View Full Code Here

    }

    public List evaluate(OExpression cexp, EvaluationContext ctx) throws FaultException, EvaluationException {
        try {
            XPath compiledXPath = compile((OXPath10Expression) cexp);
            Context context = createContext((OXPath10Expression) cexp, ctx);

            List retVal = compiledXPath.selectNodes(context);

            if ((retVal.size() == 1) && !(retVal.get(0) instanceof Node)) {
                Document d = DOMUtils.newDocument();
View Full Code Here

    private Context createContext(OXPath10Expression oxpath, EvaluationContext ctx) {
        JaxenContexts bpelSupport = new JaxenContexts(oxpath, _extensionFunctions, ctx);
        ContextSupport support = new ContextSupport(new JaxenNamespaceContextAdapter(oxpath.namespaceCtx), bpelSupport,
                bpelSupport, new BpelDocumentNavigator(ctx.getRootNode()));
        Context jctx = new Context(support);

        if (ctx.getRootNode() != null)
            jctx.setNodeSet(Collections.singletonList(ctx.getRootNode()));

        return jctx;
    }
View Full Code Here

                "      ## SKIPPED -- Unsupported Axis ");
        }
    }

    protected Context getContext(Object contextNode) {
        Context context = new Context(getContextSupport());
        List list = new ArrayList(1);
        list.add(contextNode);
        context.setNodeSet(list);
        return context;
    }
View Full Code Here

        }
    }

    protected Context getContext(Object contextNode)
    {
        Context context = new Context(getContextSupport());
        List list = new ArrayList(1);
        list.add(contextNode);
        context.setNodeSet(list);
        return context;
    }
View Full Code Here

TOP

Related Classes of org.jaxen.Context

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.