Package org.mvel2

Examples of org.mvel2.ParserContext


                        throw new IllegalArgumentException( "Unable to resolve import: "+imp);
                    }
                }
            }
            for ( String[] str : args ) {
                Serializable expr = MVEL.compileExpression( Arrays.asList( str ).toString(), new ParserContext(conf) );
                List< ? > objects = (List< ? >) MVEL.executeExpression( expr );
                for ( Object object : objects ) {
                    FactHandle handle = wm.insert( object );
                    handles.add( handle );
                }
View Full Code Here


        // add import for JUnit assert class
        pconf.addImport( "Assert",
                         Assert.class );

        // compile MVEL expression
        ParserContext mvelctx = new ParserContext( pconf );
        String expression;
        if ( cmd.length == 3 ) {
            expression = "Assert.assertTrue( " + cmd[2].replaceAll( "h(\\d+)",
                                                                    "Handles[$1]" ) + " );";
        } else {
View Full Code Here

        // add import for JUnit assert class
        pconf.addImport( "Assert",
                         Assert.class );

        // compile MVEL expression
        ParserContext mvelctx = new ParserContext( pconf );
        String expression = cmd[3].replaceAll( "h(\\d+)",
                                               "Handles[$1]" );
        try {
            Serializable compiled = MVEL.compileExpression( expression,
                                                            mvelctx );
View Full Code Here

        // add import for JUnit assert class
        pconf.addImport( "Assert",
                         Assert.class );

        // compile MVEL expression
        ParserContext mvelctx = new ParserContext( pconf );
        String expression;
        if ( cmd.length == 3 ) {
            expression = "Assert.assertTrue( " + cmd[2].replaceAll( "h(\\d+)",
                                                                    "Handles[$1]" ) + " );";
        } else {
View Full Code Here

        // add import for JUnit assert class
        pconf.addImport( "Assert",
                         Assert.class );

        // compile MVEL expression
        ParserContext mvelctx = new ParserContext( pconf );
        String expression = cmd[3].replaceAll( "h(\\d+)",
                                               "Handles[$1]" );
        try {
            Serializable compiled = MVEL.compileExpression( expression,
                                                            mvelctx );
View Full Code Here

            vars.putAll( this.context );
            vars.put( "tuple",
                      ((LeftTuple)tuple).toFactHandles() );

            // compile MVEL expression
            ParserContext mvelctx = new ParserContext();
            Serializable compiled = MVEL.compileExpression( this.expr,
                                                            mvelctx );
            // execute the expression
            Boolean result = (Boolean) MVEL.executeExpression( compiled,
                                                               vars );
View Full Code Here

    }

    public Void execute(Context context) {
        //ParserContext ctx = new Parser
       
        ParserContext parserCtx = new ParserContext( );
        String t = headerText + text;
        MVEL.compileExpression( t, parserCtx );
       
        Map<String, Class> inputs = parserCtx.getInputs();
               
        Map<String, Object> vars = new HashMap<String, Object>();
       
        for ( String name : inputs.keySet() ) {
            vars.put( name, context.get( name ) );
View Full Code Here

        try {           
            cls = runtimeData.getRootClassLoader().loadClass( target.getClassName() );
        } catch ( ClassNotFoundException e ) {
            throw new IllegalStateException( "Unable to compile as Class could not be found '" + target.getClassName() + "'");
        }
        ParserContext context = new ParserContext(runtimeData.getParserConfiguration());
        context.addInput( "this", cls );
        context.setStrongTyping( target.isTypeSafe() )
       
        MVEL.COMPILER_OPT_ALLOW_NAKED_METH_CALL = true;
        MVEL.COMPILER_OPT_ALLOW_OVERRIDE_ALL_PROPHANDLING = true;
        MVEL.COMPILER_OPT_ALLOW_RESOLVE_INNERCLASSES_WITH_DOTNOTATION = true;
        MVEL.COMPILER_OPT_SUPPORT_JAVA_STYLE_CLASS_LITERALS = true;
View Full Code Here

    public MvelConditionEvaluator(ParserConfiguration configuration, String expression, Declaration[] declarations, String conditionClass) {
        this.declarations = declarations;
        this.conditionClass = conditionClass;
        this.parserConfiguration = configuration;
        executableStatement = (ExecutableStatement)MVEL.compileExpression(expression, new ParserContext(parserConfiguration));
    }
View Full Code Here

        readLocalsFromTuple = in.readBoolean();
    }   

    public Serializable getCompiledExpression(MVELDialectRuntimeData runtimeData ) {       
        ParserConfiguration conf = runtimeData.getParserConfiguration();
        final ParserContext parserContext = new ParserContext( conf );
        if ( MVELDebugHandler.isDebugMode() ) {
            parserContext.setDebugSymbols( true );
        }

        parserContext.setStrictTypeEnforcement( strictMode );
        parserContext.setStrongTyping( strictMode );
        parserContext.setIndexAllocation( true );

        if ( INTERCEPTORS != null ) {
            parserContext.setInterceptors(INTERCEPTORS);
        }

        parserContext.addIndexedInput( inputIdentifiers );
               
        String identifier = null;
        String type = null;
        try {
            for ( int i = 0, length = inputIdentifiers.length; i < length; i++ ) {
                identifier = inputIdentifiers[i];
                type = inputTypes[i];
                Class< ? > cls = loadClass( runtimeData.getRootClassLoader(),
                                            inputTypes[i] );
                parserContext.addInput( inputIdentifiers[i],
                                        cls );
            }
        } catch ( ClassNotFoundException e ) {
            throw new RuntimeDroolsException( "Unable to resolve class '" + type + "' for identifier '" + identifier );
        }

        parserContext.setSourceFile( name );

        String[] varNames = parserContext.getIndexedVarNames();
       
        ExecutableStatement stmt = (ExecutableStatement) compile( expression,
                                                                  runtimeData.getRootClassLoader(),
                                                                  parserContext,
                                                                  languageLevel );
       
        Set<String> localNames = parserContext.getVariables().keySet();

        parserContext.addIndexedLocals(localNames);

        String[] locals = localNames.toArray(new String[localNames.size()]);
        String[] allVars = new String[varNames.length + locals.length];

        System.arraycopy(varNames, 0, allVars, 0, varNames.length);
View Full Code Here

TOP

Related Classes of org.mvel2.ParserContext

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.