Package org.drools.lang.descr

Examples of org.drools.lang.descr.PredicateDescr


        map.put( "b",
                 b );
        declarationResolver.setDeclarations( map );
        context.setDeclarationResolver( declarationResolver );

        final PredicateDescr predicateDescr = new PredicateDescr();
        predicateDescr.setContent( "a == b" );

        final MVELPredicateBuilder builder = new MVELPredicateBuilder();

        final List[] usedIdentifiers = new ArrayList[2];
        final List list = new ArrayList();
View Full Code Here


        AndDescr and = (AndDescr) col.getConstraint();
        assertEquals( 2,
                      and.getDescrs().size() );

        final FieldBindingDescr field = (FieldBindingDescr) and.getDescrs().get( 0 );
        final PredicateDescr pred = (PredicateDescr) and.getDescrs().get( 1 );
        assertEquals( "age",
                      field.getFieldName() );
        assertEquals( "$age2",
                      field.getIdentifier() );
        assertEqualsIgnoreWhitespace( "$age2 == $age1+2",
                                      (String) pred.getContent() );

        assertFalse( parser.getErrorMessages().toString(),
                     parser.hasErrors() );
    }
View Full Code Here

        final List constraints = pattern.getConstraint().getDescrs();
        assertEquals( 2,
                      constraints.size() );

        final FieldBindingDescr field = (FieldBindingDescr) constraints.get( 0 );
        final PredicateDescr predicate = (PredicateDescr) constraints.get( 1 );
        assertEquals( "$var",
                      field.getIdentifier() );
        assertEquals( "attr",
                      field.getFieldName() );
        assertEquals( " $var.equals(\"xyz\") ",
                      predicate.getContent() );
    }
View Full Code Here

        final List constraints = pattern.getConstraint().getDescrs();
        assertEquals( 1,
                      constraints.size() );

        final PredicateDescr predicate = (PredicateDescr) constraints.get( 0 );
        assertEquals( " $var.equals(\"xyz\") ",
                      predicate.getContent() );
    }
View Full Code Here

            return build(context, descr);
        }

        EvalDescr evalDescr = (EvalDescr) descr;

        PredicateDescr predicateDescr = new PredicateDescr( context.getRuleDescr().getResource(), evalDescr.getContent() );
        AnalysisResult analysis = buildAnalysis(context, prefixPattern, predicateDescr, null );

        Declaration[] declarations = getUsedDeclarations(context, prefixPattern, analysis);
        return buildEval(context, evalDescr, analysis, declarations);
    }
View Full Code Here

    public MVELCompilationUnit buildCompilationUnit(RuleBuildContext context, Pattern pattern, String expression, Map<String, OperatorDescr> aliases) {
        Dialect dialect = context.getDialect();
        context.setDialect( context.getDialect( "mvel" ) );

        PredicateDescr predicateDescr = new PredicateDescr( context.getRuleDescr().getResource(), expression );
        AnalysisResult analysis = buildAnalysis(context, pattern, predicateDescr, aliases);
        if ( analysis == null ) {
            // something bad happened
            return null;
        }
View Full Code Here

        if ( d instanceof AtomicExprDescr ) {
            Matcher m = evalRegexp.matcher( ((AtomicExprDescr) d).getExpression() );
            if ( m.find() ) {
                // MVELDumper already stripped the eval
                // this will build the eval using the specified dialect
                PredicateDescr pdescr = new PredicateDescr( context.getRuleDescr().getResource(), expr );
                pdescr.copyLocation( d );
                buildEval( context, pattern, pdescr, aliases, expr, true );
                return true;
            }
        }
        return false;
View Full Code Here

                                          Map<String, OperatorDescr> aliases ) {
        Dialect dialect = context.getDialect();
        MVELDialect mvelDialect = (MVELDialect) context.getDialect( "mvel" );
        context.setDialect( mvelDialect );

        PredicateDescr pdescr = new PredicateDescr( context.getRuleDescr().getResource(), expr );
        pdescr.copyParameters( base );
        pdescr.copyLocation( base );
        buildEval( context, pattern, pdescr, aliases, expr, false );

        // fall back to original dialect
        context.setDialect(dialect);
    }
View Full Code Here

        map.put( "b",
                 b );
        declarationResolver.setDeclarations( map );
        context.setDeclarationResolver( declarationResolver );

        final PredicateDescr predicateDescr = new PredicateDescr();
        predicateDescr.setContent( "a == b" );

       
       
        final MVELPredicateBuilder builder = new MVELPredicateBuilder();
        final Declaration[] previousDeclarations = new Declaration[]{a};
        final Declaration[] localDeclarations = new Declaration[]{b};

        final PredicateConstraint predicate = new PredicateConstraint( null,
                                                                       localDeclarations );
       
        AnalysisResult analysis = context.getDialect().analyzeExpression( context,
                                                                          predicateDescr,
                                                                          predicateDescr.getContent(),
                                                                          new BoundIdentifiers( declarationResolver.getDeclarationClasses( (Rule) null ), new HashMap(), null, Cheese.class ) );

        builder.build( context,
                       new BoundIdentifiers( declarationResolver.getDeclarationClasses( (Rule) null ), new HashMap() ),
                       previousDeclarations,
View Full Code Here

        if ( d instanceof AtomicExprDescr ) {
            Matcher m = evalRegexp.matcher( ((AtomicExprDescr) d).getExpression() );
            if ( m.find() ) {
                // MVELDumper already stripped the eval
                // this will build the eval using the specified dialect
                PredicateDescr pdescr = new PredicateDescr( expr );
                pdescr.copyLocation( d );
                buildEval( context,
                           pattern,
                           pdescr,
                           null,
                           aliases );
View Full Code Here

TOP

Related Classes of org.drools.lang.descr.PredicateDescr

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.