Package org.mvel2.compiler

Examples of org.mvel2.compiler.ExpressionCompiler


        return (Boolean) MVEL.executeExpression(expression,
                variables);
    }

    protected String getActual(VerifyField currentField) {
        Object actualValue = MVEL.executeExpression(new ExpressionCompiler("__fact__." + currentField.getFieldName()).compile(parserContext),
                variables);

        return (actualValue != null) ? actualValue.toString() : "";

    }
View Full Code Here


        }
        return sb.toString();
    }

    public Object eval(String str, Map vars) {
        ExpressionCompiler compiler = new ExpressionCompiler(str.trim());

        ParserContext context = new ParserContext();
        context.addPackageImport("org.drools.task");
        context.addPackageImport("org.drools.task.service");
        context.addPackageImport("org.drools.task.query");
        context.addPackageImport("java.util");

        vars.put("now", new Date());
        return MVEL.executeExpression(compiler.compile(context), vars);
    }
View Full Code Here

        return sb.toString();
    }

    @SuppressWarnings("unchecked")
  public static Object eval(String str, Map vars) {
        ExpressionCompiler compiler = new ExpressionCompiler( str.trim() );

        ParserContext context = new ParserContext();
        context.addPackageImport( "org.drools.task" );
        context.addPackageImport( "java.util" );
       
        context.addImport( "AccessType", AccessType.class );
        context.addImport( "AllowedToDelegate", AllowedToDelegate.class );
        context.addImport( "Attachment", Attachment.class );
        context.addImport( "BooleanExpression", BooleanExpression.class );
        context.addImport( "Comment", Comment.class );
        context.addImport( "Deadline", Deadline.class );
        context.addImport( "Deadlines", Deadlines.class );
        context.addImport( "Delegation", Delegation.class );
        context.addImport( "Escalation", Escalation.class );
        context.addImport( "Group", Group.class );
        context.addImport( "I18NText", I18NText.class );
        context.addImport( "Notification", Notification.class );
        context.addImport( "OrganizationalEntity", OrganizationalEntity.class );
        context.addImport( "PeopleAssignments", PeopleAssignments.class );
        context.addImport( "Reassignment", Reassignment.class );
        context.addImport( "Status", Status.class );
        context.addImport( "Task", Task.class );
        context.addImport( "TaskData", TaskData.class );
        context.addImport( "TaskSummary", TaskSummary.class );
        context.addImport( "User", User.class );

        return MVEL.executeExpression( compiler.compile( context ), vars );
    }
View Full Code Here

    }
    return sb.toString();
  }

  public Object eval(String str, Map<String, Object> vars) {
    ExpressionCompiler compiler = new ExpressionCompiler(str.trim());

    ParserContext context = new ParserContext();
    context.addPackageImport("org.drools.task");
    context.addPackageImport("org.drools.task.service");
    context.addPackageImport("org.drools.task.query");
    context.addPackageImport("java.util");

    vars.put("now", new Date());
    return MVEL.executeExpression(compiler.compile(context), vars);
  }
View Full Code Here

        final ParserContext parserContext = getParserContext( analysis,
                                                              outerDeclarations,
                                                              otherInputVariables,
                                                              context );

        ExpressionCompiler compiler = new ExpressionCompiler( text.trim() );

        synchronized ( COMPILER_LOCK ) {
            ClassLoader tempClassLoader = Thread.currentThread().getContextClassLoader();

            Thread.currentThread().setContextClassLoader( pkgBuilder.getRootClassLoader() );

            AbstractParser.setLanguageLevel( languageLevel );
            Serializable expr = compiler.compile( parserContext );

            Thread.currentThread().setContextClassLoader( tempClassLoader );

            return expr;
        }
View Full Code Here

        return sb.toString();
    }

    @SuppressWarnings("unchecked")
  public static Object eval(String str, Map vars) {
        ExpressionCompiler compiler = new ExpressionCompiler( str.trim() );

        ParserContext context = new ParserContext();
        context.addPackageImport( "org.drools.task" );
        context.addPackageImport( "java.util" );
       
        context.addImport( "AccessType", AccessType.class );
        context.addImport( "AllowedToDelegate", AllowedToDelegate.class );
        context.addImport( "Attachment", Attachment.class );
        context.addImport( "BooleanExpression", BooleanExpression.class );
        context.addImport( "Comment", Comment.class );
        context.addImport( "Deadline", Deadline.class );
        context.addImport( "Deadlines", Deadlines.class );
        context.addImport( "Delegation", Delegation.class );
        context.addImport( "Escalation", Escalation.class );
        context.addImport( "Group", Group.class );
        context.addImport( "I18NText", I18NText.class );
        context.addImport( "Notification", Notification.class );
        context.addImport( "OrganizationalEntity", OrganizationalEntity.class );
        context.addImport( "PeopleAssignments", PeopleAssignments.class );
        context.addImport( "Reassignment", Reassignment.class );
        context.addImport( "Status", Status.class );
        context.addImport( "Task", Task.class );
        context.addImport( "TaskData", TaskData.class );
        context.addImport( "TaskSummary", TaskSummary.class );
        context.addImport( "User", User.class );

        return MVEL.executeExpression( compiler.compile( context ), vars );
    }
View Full Code Here

    }
    return sb.toString();
  }

  public Object eval(String str, Map<String, Object> vars) {
    ExpressionCompiler compiler = new ExpressionCompiler(str.trim());

    ParserContext context = new ParserContext();
    context.addPackageImport("org.drools.task");
    context.addPackageImport("org.drools.task.service");
    context.addPackageImport("org.drools.task.query");
    context.addPackageImport("java.util");

    vars.put("now", new Date());
    return MVEL.executeExpression(compiler.compile(context), vars);
  }
View Full Code Here

        }
        return sb.toString();
    }

    public Object eval(String str, Map vars) {
        ExpressionCompiler compiler = new ExpressionCompiler(str.trim());

        ParserContext context = new ParserContext();
        context.addPackageImport("org.drools.task");
        context.addPackageImport("org.drools.task.service");
        context.addPackageImport("org.drools.task.query");
        context.addPackageImport("java.util");

        vars.put("now", new Date());
        return MVEL.executeExpression(compiler.compile(context), vars);
    }
View Full Code Here

    context.addImport(Recipients.class);
    context.addImport(EmailMessage.class);

    OptimizerFactory.setDefaultOptimizer("ASM");

    ExpressionCompiler compiler = new ExpressionCompiler(text);
    Serializable execution = compiler.compile(context);

    assertEquals(msg,
        executeExpression(execution));
    assertEquals(msg,
        executeExpression(execution));
    assertEquals(msg,
        executeExpression(execution));

    OptimizerFactory.setDefaultOptimizer("reflective");

    context = new ParserContext(context.getParserConfiguration());
    compiler = new ExpressionCompiler(text);
    execution = compiler.compile(context);

    assertEquals(msg,
        executeExpression(execution));
    assertEquals(msg,
        executeExpression(execution));
View Full Code Here

    assertEquals("FoobarFoobar", MVEL.eval("function heyFoo() { return 'Foobar'; };\n"
        + "return heyFoo() + heyFoo();", new HashMap()));
  }

  public void testFunctionDefAndCall2() {
    ExpressionCompiler compiler = new ExpressionCompiler("function heyFoo() { return 'Foobar'; };\n" +
        "return heyFoo() + heyFoo();");

    Serializable s = compiler.compile();

    Map<String, Function> m = extractAllDeclaredFunctions((CompiledExpression) s);

    assertTrue(m.containsKey("heyFoo"));
View Full Code Here

TOP

Related Classes of org.mvel2.compiler.ExpressionCompiler

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.