Package aQute.bnd.osgi.resource

Examples of aQute.bnd.osgi.resource.FilterParser$Expression


     * @param req
     *            The requirement searched
     * @return a query string where p: is for package and bsn: is for bundle symbolic name.
     */
    public static String requirementToUrl(Requirement req) throws IOException {
        FilterParser fp = new FilterParser();
        Expression expression = fp.parse(req);

        String s = expression.query();

        return "http://jpm4j.org/#!/search?q=" + URLEncoder.encode(s, "UTF-8");
    }
View Full Code Here


                    String category = FilterParser.namespaceToCategory(namespace);
                    if (category != null && category.length() > 0)
                        label.append(category + ": ", StyledString.QUALIFIER_STYLER);
                }

                FilterParser fp = new FilterParser();
                String filterStr = requirement.getDirectives().get("filter");
                if (filterStr == null) {
                    label.append("<no filter>", UIConstants.ERROR_STYLER);
                } else {
                    Expression exp = fp.parse(filter);
                    if (exp instanceof WithRangeExpression) {
                        label.append(((WithRangeExpression) exp).printExcludingRange(), UIConstants.BOLD_STYLER);
                        RangeExpression range = ((WithRangeExpression) exp).getRangeExpression();
                        if (range != null)
                            label.append(" ").append(formatRangeString(range), StyledString.COUNTER_STYLER);
View Full Code Here

    public String evaluate(final String expression, final JexlContext jexlContext) {
        String result = "";

        if (StringUtils.isNotBlank(expression) && jexlContext != null) {
            try {
                Expression jexlExpression = jexlEngine.createExpression(expression);
                Object evaluated = jexlExpression.evaluate(jexlContext);
                if (evaluated != null) {
                    result = evaluated.toString();
                }
            } catch (JexlException e) {
                LOG.error("Invalid jexl expression: " + expression, e);
View Full Code Here

     */
    @Override
    public FeatureState process(final ContextManager contextManager)
    {
        final JexlEngine jexlEngine = new JexlEngine();
        Expression jexlExpression;
        if (expression != null) {
            jexlExpression = jexlEngine.createExpression(expression);
        } else {
            jexlExpression = getOldExpression(jexlEngine);
        }
       
        final Map<String, Object> contextMap = contextManager.getContext(context);
        final JexlContext jexlContext = new MapContext(contextMap);

        return Boolean.TRUE.equals(jexlExpression.evaluate(jexlContext)) ? FeatureState.ENABLED : FeatureState.DISABLED;
    }
View Full Code Here

     * @param expected is the expected value of the expression
     * @throws Exception if the expression could not be evaluationed or an assertion
     * fails
     */
    public void assertExpression(String expression, Object expected) throws Exception {
        Expression exp = engine.createExpression(expression);
        Object value = exp.evaluate(context);

        assertEquals("expression: " + expression, expected, value);
    }
View Full Code Here

    public void failExpression(String expression, String matchException) throws Exception {
        boolean[] flags = { engine.isLenient(), engine.isSilent() };
        try {
            engine.setLenient(false);
            engine.setSilent(false);
            Expression exp = engine.createExpression(expression);
            exp.evaluate(context);
            fail("expression: " + expression);
        } catch(JexlException xjexl) {
            if (matchException != null && !xjexl.getMessage().matches(matchException)) {
                fail("expression: " + expression + ", expected: " + matchException + ", got " + xjexl.getMessage());
            }
View Full Code Here

   
    /**
     * {@inheritDoc }
     */
    public Object evaluate(Object context, String expression) {
        Expression jexlExpression = engine.createExpression(expression);
        JexlContext jexlContext = new ObjectContext(engine, context);
       
        return jexlExpression.evaluate(jexlContext);
    }
View Full Code Here

    public Map<String, Object> getVariables() {
        return variables;
    }

    protected Expression createExpression(final String expression) throws Exception {
        Expression expr = engine.createExpression(expression);
        return expr;
    }
View Full Code Here

        if (expression == null) {
            throw new IllegalArgumentException("expression");
        }

        log.trace("Evaluating expression: {}", expression);
        Expression expr = createExpression(expression);
        Object obj = expr.evaluate(context);
        log.trace("Result: {}", obj);

        return obj;
    }
View Full Code Here

    private Object doEvaluate(final String expression) throws Exception {
        assert expression != null;

        log.debug("Evaluating expression: {}", expression);
       
        Expression expr = engine.createExpression(expression);

        JexlContext ctx = new MapContext(vars);

        Object result = expr.evaluate(ctx);
        log.debug("Result: {}", result);

        return result;
    }   
View Full Code Here

TOP

Related Classes of aQute.bnd.osgi.resource.FilterParser$Expression

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.