Package org.apache.commons.jexl

Examples of org.apache.commons.jexl.JexlContext


            log.debug("Evaluating expression: " + expression);
        }

        Expression expr = ExpressionFactory.createExpression(expression);

        JexlContext ctx = JexlHelper.createContext();
        ctx.setVars(vars);

        Object result = expr.evaluate(ctx);
        if (debug) {
            log.debug("Result: " + result);
        }
View Full Code Here


    @SuppressWarnings("unchecked")
    public String resolve(String expression, ObjectModel objectModel) {
        Object o = null;
        try {
            Expression e = ExpressionFactory.createExpression(expression);
            JexlContext jc = JexlHelper.createContext();
            jc.getVars().putAll(objectModel.getParameters());

            o = e.evaluate(jc);
        } catch (Exception e1) {
            e1.printStackTrace();
        }
View Full Code Here

    // Expression interface
    //-------------------------------------------------------------------------
    public Object evaluate(JellyContext context) {
        try {
            JexlContext jexlContext = new JellyJexlContext( context );
            if (log.isDebugEnabled()) {
                log.debug("Evaluating EL: " + expression);
            }          
            return expression.evaluate(jexlContext);
        }
View Full Code Here

                                  Object returnValue,
                                  Throwable exceptionThrown) {
        StringBuilder retVal = new StringBuilder(text.length());

        //create a JexlContext to be used in all evaluations
        JexlContext jexlContext = new HashMapContext();
        for (int i = 0; i < args.length; i++) {
            jexlContext.getVars().put("$" + i, args[i]);
        }
        jexlContext.getVars().put("$methodName", methodName);
        jexlContext.getVars().put("$this", annotatedObject);
        jexlContext.getVars().put("$class", annotatedClass);
        jexlContext.getVars().put("$return", returnValue);
        jexlContext.getVars().put("$exception", exceptionThrown);

        // look for {expression} in the passed in text
        int bracketIndex;
        int lastCloseBracketIndex = -1;
        while ((bracketIndex = text.indexOf('{', lastCloseBracketIndex + 1)) >= 0) {
View Full Code Here

        }

        log.debug("Expect the CSV to have " + lastCsvIndex + " "
                + (lastCsvIndex != 1 ? "fields" : "field") + ".");

        JexlContext jexlContext = JexlHelper.createContext();
        jexlContext.getVars().put(csvMappingDefinition.getBeanVariableName(),
                object);
        if (csvMappingDefinition.getExtendedContext() != null) {
            Iterator<String> it = csvMappingDefinition.getExtendedContext()
                    .keySet().iterator();
            while (it.hasNext()) {
                String variableName = it.next();
                String valueExpression = csvMappingDefinition
                        .getExtendedContext().get(variableName);
                Expression preProcessing = ExpressionFactory
                        .createExpression(valueExpression);
                preProcessing.addPreResolver(new PoundDefineJexlResolver());
                jexlContext.getVars().put(variableName,
                        preProcessing.evaluate(jexlContext));
            }
        }

        for (int i = 0; i < lastCsvIndex; i++) {
View Full Code Here

      + " | "
      + (finalPropertyValue != null ? finalPropertyValue
        .getClass().getName() : "null"));

    if (propertyName.contains(ARGUMENT_TOKEN)) {
        JexlContext jexlContext = JexlHelper.createContext();
        jexlContext.getVars().put("generatedObject",
          generatedObject);
        jexlContext.getVars().put(ARGUMENT_VALUE,
          finalPropertyValue);
        String expressionString = propertyName.replace(
          ARGUMENT_TOKEN, ARGUMENT_VALUE);
        Expression expression = ExpressionFactory
          .createExpression("generatedObject."
View Full Code Here

     * @return boolean
     */
    public boolean matchMethodPointcut(final ClassMetaData classMetaData,
                                       final MethodMetaData methodMetaData) {
        try {
            JexlContext jexlContext = JexlHelper.createContext();

            matchMethodPointcutPatterns(jexlContext, classMetaData, methodMetaData);

            // evaluate the expression
            Boolean result = (Boolean)m_jexlExpr.evaluate(jexlContext);
View Full Code Here

     * @param classMetaData the class meta-data
     * @return boolean
     */
    public boolean matchSetFieldPointcut(final ClassMetaData classMetaData) {
        try {
            JexlContext jexlContext = JexlHelper.createContext();

            matchSetFieldPointcutPatterns(jexlContext, classMetaData);

            // evaluate the expression
            Boolean result = (Boolean)m_jexlExpr.evaluate(jexlContext);
View Full Code Here

     * @return boolean
     */
    public boolean matchSetFieldPointcut(final ClassMetaData classMetaData,
                                         final FieldMetaData fieldMetaData) {
        try {
            JexlContext jexlContext = JexlHelper.createContext();

            matchSetFieldPointcutPatterns(jexlContext, classMetaData, fieldMetaData);

            // evaluate the expression
            Boolean result = (Boolean)m_jexlExpr.evaluate(jexlContext);
View Full Code Here

     * @param classMetaData the class meta-data
     * @return boolean
     */
    public boolean matchGetFieldPointcut(final ClassMetaData classMetaData) {
        try {
            JexlContext jexlContext = JexlHelper.createContext();

            matchGetFieldPointcutPatterns(jexlContext, classMetaData);

            // evaluate the expression
            Boolean result = (Boolean)m_jexlExpr.evaluate(jexlContext);
View Full Code Here

TOP

Related Classes of org.apache.commons.jexl.JexlContext

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.