Package org.drools.lang.descr

Examples of org.drools.lang.descr.PredicateDescr


        boolean strictMode = mvelDialect.isStrictMode();
        mvelDialect.setStrictMode( false );

        context.setDialect( mvelDialect );

        PredicateDescr predicateDescr = new PredicateDescr();
        MVELDumper dumper = new MVELDumper();
        predicateDescr.setContent( dumper.dump( fieldConstraintDescr ) );

        build( context,
               pattern,
               predicateDescr,
               container );
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

        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() );
    }
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

        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

        // analyze field type:
        Class resultType = getFieldReturnType( pattern,
                                               fieldConstraintDescr );
       
        PredicateDescr predicateDescr = new PredicateDescr();
        MVELDumper dumper = new MVELDumper();
        predicateDescr.setContent( dumper.dump( fieldConstraintDescr, Date.class.isAssignableFrom( resultType ) ) );

        build( context,
               pattern,
               predicateDescr,
               container );
View Full Code Here

                        final String localName,
                        final Attributes attrs) throws SAXException {
        this.xmlPackageReader.startConfiguration( localName,
                                                  attrs );

        final PredicateDescr predicateDescr = new PredicateDescr();

        return predicateDescr;
    }
View Full Code Here

    public Object end(final String uri,
                      final String localName) throws SAXException {
        final Configuration config = this.xmlPackageReader.endConfiguration();

        final PredicateDescr predicateDescr = (PredicateDescr) this.xmlPackageReader.getCurrent();

        final String expression = config.getText();

        if ( expression == null || expression.trim().equals( "" ) ) {
            throw new SAXParseException( "<predicate> must have some content",
                                         this.xmlPackageReader.getLocator() );
        }

        predicateDescr.setContent( expression );

        final LinkedList parents = this.xmlPackageReader.getParents();
        final ListIterator it = parents.listIterator( parents.size() );
        it.previous();
        final PatternDescr patternDescr = (PatternDescr) it.previous();
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.