Package org.mvel2.compiler

Examples of org.mvel2.compiler.AccessorNode


            Accessor accessor = node.getAccessor();

            EvaluatedExpression expression = new EvaluatedExpression();
            expression.firstExpression = analyzeNode(main);
            if (accessor instanceof DynamicGetAccessor) {
                AccessorNode accessorNode = (AccessorNode)((DynamicGetAccessor)accessor).getAccessor();
                expression.addInvocation(analyzeAccessor(accessorNode, null));
            } else if (accessor instanceof AccessorNode) {
                expression.addInvocation(analyzeAccessor((AccessorNode)accessor, null));
            } else {
                throw new RuntimeException("Unexpected accessor: " + accessor);
            }
            return expression;
        }

        Accessor accessor = node.getAccessor();

        if (accessor instanceof IndexedVariableAccessor) {
            String variableName = node.getName();
            int dot = variableName.indexOf('.');
            if (dot > 0) {
                variableName = variableName.substring(0, dot);
            }
            Class<?> variableType = getVariableType(variableName);
            return new VariableExpression(variableName,
                                          analyzeExpressionNode(((IndexedVariableAccessor) accessor).getNextNode()),
                                          variableType != null ? variableType : node.getEgressType());
        }

        if (accessor == null && node instanceof NewObjectNode) {
            accessor = ((NewObjectNode)node).getNewObjectOptimizer();
        }

        if (accessor instanceof VariableAccessor) {
            VariableAccessor variableAccessor = (VariableAccessor)accessor;
            AccessorNode accessorNode = variableAccessor.getNextNode();
            if (accessorNode == null || !isStaticAccessor(accessorNode)) {
                String variableName = (String)(variableAccessor.getProperty());
                Class<?> variableType = getVariableType(variableName);
                if (variableType != null) {
                    return new VariableExpression(variableName, analyzeExpressionNode(accessorNode), variableType);
View Full Code Here


        return analyzeAccessor(accessor);
    }

    private Expression analyzeAccessor(Accessor accessor) {
        AccessorNode accessorNode;
        if (accessor instanceof DynamicGetAccessor) {
            accessorNode = (AccessorNode)((DynamicGetAccessor)accessor).getAccessor();
        } else if (accessor instanceof AccessorNode) {
            accessorNode = (AccessorNode)accessor;
        } else if (accessor instanceof CompiledExpression) {
            return analyzeNode(((CompiledExpression)accessor).getFirstNode());
        } else if (accessor instanceof ListCreator) {
            return analyzeListCreation(((ListCreator) accessor));
        } else {
            throw new RuntimeException("Unknown accessor type: " + accessor);
        }

        if (accessorNode != null && accessorNode instanceof VariableAccessor) {
            if (isStaticAccessor(accessorNode)) {
                while (accessorNode != null && accessorNode instanceof VariableAccessor) {
                    accessorNode = accessorNode.getNextNode();
                }
            } else {
                return analyzeAccessor(accessorNode);
            }
        }

        while (accessorNode instanceof StaticReferenceAccessor) {
            StaticReferenceAccessor staticReferenceAccessor = ((StaticReferenceAccessor)accessorNode);
            Object literal = staticReferenceAccessor.getLiteral();
            accessorNode = accessorNode.getNextNode();
            if (accessorNode == null) {
                return new FixedExpression(literal.getClass(), literal);
            }
        }
View Full Code Here

        if (setExpression != null) {
            SetterAccessor setterAccessor = (SetterAccessor)((CompiledAccExpression) setExpression).getAccessor();
            return setterAccessor.getMethod();
        } else {
            ExecutableAccessor accessor = (ExecutableAccessor)parmValuePair.getStatement();
            AccessorNode accessorNode = (AccessorNode)accessor.getNode().getAccessor();
            MethodAccessor methodAccessor = (MethodAccessor)accessorNode.getNextNode();
            return methodAccessor.getMethod();
        }
    }
View Full Code Here

        parserContext.setSourceFile( name );

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

        Content content = null;
        if ( taskData.getDocumentAccessType() == AccessType.Inline ) {
            content = em.find( Content.class,
                               taskData.getDocumentContentId() );
        }
        ExpressionCompiler compiler = new ExpressionCompiler( new String( content.getContent() ) );
        Serializable expr = compiler.compile();
        Object object = MVEL.executeExpression( expr );
       
        Map<String, Object> vars = new HashMap<String, Object>();
        vars.put( docVar, object );
        // for now will have to assume the recipient is a User, we need to figure out if Groups have an alias
View Full Code Here

        Map<String, Object> doc = null;
        if ( taskData != null ) {
            Content content = em.find( Content.class,
                                       taskData.getDocumentContentId() );
            if ( content != null ) {
                ExpressionCompiler compiler = new ExpressionCompiler( new String( content.getContent() ) );
                doc = (Map<String, Object>) MVEL.executeExpression( compiler.compile() );
            } else {
                doc = Collections.emptyMap();
            }
        }
View Full Code Here

                        if (actionString == null) {
                            errors.add(new ProcessValidationErrorImpl(process,
                                "Action node '" + node.getName() + "' [" + node.getId() + "] has empty action."));
                        } else if( "mvel".equals( droolsAction.getDialect() ) ) {
                            try {
                                ExpressionCompiler compiler = new ExpressionCompiler(actionString);
                                compiler.setVerifying(true);
                                ParserContext parserContext = new ParserContext();
                                //parserContext.setStrictTypeEnforcement(true);
                                compiler.compile(parserContext);
                                List<ErrorDetail> mvelErrors = parserContext.getErrorList();
                                if (mvelErrors != null) {
                                    for (Iterator<ErrorDetail> iterator = mvelErrors.iterator(); iterator.hasNext(); ) {
                                        ErrorDetail error = iterator.next();
                                        errors.add(new ProcessValidationErrorImpl(process,
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.jbpm.task");
        context.addPackageImport("org.jbpm.task.service");
        context.addPackageImport("org.jbpm.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 static Object eval(String str, Map vars) {
        ExpressionCompiler compiler = new ExpressionCompiler( str.trim() );

        ParserContext context = new ParserContext();
        context.addPackageImport( "org.jbpm.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

TOP

Related Classes of org.mvel2.compiler.AccessorNode

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.