Package com.envoisolutions.sxc.xpath

Examples of com.envoisolutions.sxc.xpath.XPathBuilder$ExpressionState


              public void onMatch(XPathEvent event) throws XMLStreamException {
                matchTL.set(true);
              }
          };
         
          XPathBuilder builder = new XPathBuilder();
        builder.addAllPrefixes(namespaceContext.getPrefixToURI());
          builder.listen(expression, matchIdHandler);

          evaluator = builder.compile();
        }
View Full Code Here


    private synchronized void doInitialize()
    {
        if (evaluator == null)
        {
            builder = new XPathBuilder();
            builder.setNamespaceContext(namespaces);
            addEventHandlers(builder, getFilter());

            evaluator = builder.compile();
        }
View Full Code Here

        super.initialise();

        transformer.setReversible(true);
        transformer.initialise();

        builder = new XPathBuilder();
        builder.setNamespaceContext(namespaces);
        addEventHandlers(builder, getFilter());

        evaluator = builder.compile();
    }
View Full Code Here

    public void setXPathEventHandler(XPathEventHandler xPathEventHandler) {
        this.xPathEventHandler = xPathEventHandler;
    }

    public XPathEvaluator create() throws Exception {
        XPathBuilder builder = new XPathBuilder();
        for (Map.Entry<String, String> entry : prefixes.entrySet()) {
            builder.addPrefix(entry.getKey(), entry.getValue());
        }
        if (workingMemory == null && ruleBase == null && packageStream == null) {
            throw new RuntimeException("You must set either the WorkingMemory, RuleBase, or PackageStream properties.");
        }
        if (packageStream != null) {
            // process package stream
            ruleBase = RuleBaseFactory.newRuleBase();
            final PackageBuilder packageBuilder = new PackageBuilder();
            packageBuilder.addPackageFromDrl(new InputStreamReader(packageStream));
            ruleBase.addPackage(packageBuilder.getPackage());
            workingMemory = ruleBase.newWorkingMemory(true);
        } else {
            if (ruleBase != null) {
                // process rule base
                workingMemory = ruleBase.newWorkingMemory(true);
            } else {
                // process working memory
                ruleBase = workingMemory.getRuleBase();
            }
        }
        assert (ruleBase != null);
        assert (workingMemory != null);

        final org.drools.rule.Package[] packages = ruleBase.getPackages();
        final Set<String> xPathStrings = new HashSet<String>();
        for (final org.drools.rule.Package aPackage : packages) {
            final Rule[] rules = aPackage.getRules();
            for (final Rule rule : rules) {
                final And lhs = rule.getLhs();
                final List list = lhs.getChildren();
                processList(list, xPathStrings);
            }

        }
        if (xPathEventHandler == null) {
            // allow them to pass in their own
            xPathEventHandler = new DroolsXPathEventHandler(workingMemory, fireAllInOnMatch);
        }
        for (String xPathString : xPathStrings) {
            builder.listen(xPathString, xPathEventHandler);
        }

        return builder.compile();
    }
View Full Code Here

                invCount[0]++;
            }

        };
   
    XPathBuilder builder = new XPathBuilder();
        builder.listen(target, eventHandler);

        XPathEvaluator evaluator = builder.compile();

        for(int i = 0; i < NUM_WARMUPS; i++) {
            evaluator.evaluate(getMessageReader(message));
        }
View Full Code Here

    public void setXPathEventHandler(XPathEventHandler xPathEventHandler) {
        this.xPathEventHandler = xPathEventHandler;
    }

    public XPathEvaluator create() throws Exception {
        XPathBuilder builder = new XPathBuilder();
        for (Map.Entry<String, String> entry : prefixes.entrySet()) {
            builder.addPrefix(entry.getKey(), entry.getValue());
        }
        if (workingMemory == null && ruleBase == null && packageStream == null) {
            throw new RuntimeException("You must set either the WorkingMemory, RuleBase, or PackageStream properties.");
        }
        if (packageStream != null) {
            // process package stream
            ruleBase = RuleBaseFactory.newRuleBase();
            final PackageBuilder packageBuilder = new PackageBuilder();
            packageBuilder.addPackageFromDrl(new InputStreamReader(packageStream));
            ruleBase.addPackage(packageBuilder.getPackage());
            workingMemory = ruleBase.newStatefulSession(true);
        } else {
            if (ruleBase != null) {
                // process rule base
                workingMemory = ruleBase.newStatefulSession(true);
            } else {
                // process working memory
                ruleBase = workingMemory.getRuleBase();
            }
        }
        assert (ruleBase != null);
        assert (workingMemory != null);

        final org.drools.rule.Package[] packages = ruleBase.getPackages();
        final Set<String> xPathStrings = new HashSet<String>();
        for (final org.drools.rule.Package aPackage : packages) {
            final Rule[] rules = aPackage.getRules();
            for (final Rule rule : rules) {
                final GroupElement lhs = rule.getLhs();
                final List list = lhs.getChildren();
                processList(list, xPathStrings);
            }

        }
        if (xPathEventHandler == null) {
            // allow them to pass in their own
            xPathEventHandler = new DroolsXPathEventHandler(workingMemory, fireAllInOnMatch);
        }
        for (String xPathString : xPathStrings) {
            builder.listen(xPathString, xPathEventHandler);
        }

        return builder.compile();
    }
View Full Code Here

TOP

Related Classes of com.envoisolutions.sxc.xpath.XPathBuilder$ExpressionState

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.