Package org.drools.lang.descr

Examples of org.drools.lang.descr.ExprConstraintDescr


       
        if ( op instanceof PatternDescr ) {
            StringBuilder sb = new StringBuilder();
            c.buildExpression( sb );
                 
            ExprConstraintDescr expr = new ExprConstraintDescr( );
            expr.setExpression( sb.toString() );
             
            final PatternDescr patternDescr = (PatternDescr)op; 
            patternDescr.addConstraint( expr );   
        } else {       
            ConnectiveDescr p = (ConnectiveDescr)op;
View Full Code Here


        emptyContentCheck( localName, expression, parser );
       
       
        PatternDescr p = (PatternDescr) parser.getParent();
       
        ExprConstraintDescr descr = new ExprConstraintDescr( expression );
       
        p.getConstraint().addDescr( descr );

        return descr;  
    }
View Full Code Here

        Object p = parser.getParent();
        if ( p instanceof PatternDescr ) {
            StringBuilder sb = new StringBuilder();
            c.buildExpression( sb );

            ExprConstraintDescr expr = new ExprConstraintDescr();
            expr.setExpression( sb.toString() );

            final PatternDescr patternDescr = (PatternDescr) parser.getParent();
            patternDescr.addConstraint( expr );

        } else if ( p instanceof ConnectiveDescr ) {
View Full Code Here

                                         parser.getLocator() );
        }

        final PatternDescr patternDescr = (PatternDescr) parser.getParent();
       
        ExprConstraintDescr expr = new ExprConstraintDescr("eval(" + expression + ")");

        patternDescr.addConstraint( expr );

        return expr;
    }
View Full Code Here

        descr.setQuery( query );
        return this;
    }

    public PatternDescrBuilder<P> constraint( String constraint ) {
        ExprConstraintDescr constr = new ExprConstraintDescr( constraint );
        constr.setType( ExprConstraintDescr.Type.NAMED );
        constr.setPosition( descr.getConstraint().getDescrs().size() );
        descr.addConstraint( constr );
        return this;
    }
View Full Code Here

        return this;
    }

    public PatternDescrBuilder<P> constraint( String constraint,
                                              boolean positional ) {
        ExprConstraintDescr constr = new ExprConstraintDescr( constraint );
        constr.setType( positional ? ExprConstraintDescr.Type.POSITIONAL : ExprConstraintDescr.Type.NAMED );
        constr.setPosition( descr.getConstraint().getDescrs().size() );
        descr.addConstraint( constr );
        return this;
    }
View Full Code Here

            boolean isPositional = false;
            if ( b instanceof BindingDescr ) {
                BindingDescr bind = (BindingDescr) b;
                expression = bind.getVariable() + (bind.isUnification() ? " := " : " : ") + bind.getExpression();
            } else if ( b instanceof ExprConstraintDescr ) {
                ExprConstraintDescr descr = (ExprConstraintDescr) b;
                expression = descr.getExpression();
                isPositional = descr.getType() == ExprConstraintDescr.Type.POSITIONAL;
            } else {
                expression = b.getText();
            }

            ConstraintConnectiveDescr result = parseExpression( context,
View Full Code Here

                bind = (BindingDescr) base;
                expression = bind.getVariable() + (bind.isUnification() ? " := " : " : ") + bind.getExpression();
                isBinding = true;
            } else {
                if ( base instanceof ExprConstraintDescr ) {
                    ExprConstraintDescr ecd = (ExprConstraintDescr) base;
                    expression = ecd.getExpression();
                    isPositional = ecd.getType() == ExprConstraintDescr.Type.POSITIONAL;

                } else {
                    expression = base.getText();
                }
View Full Code Here

                                              "type" ) );

        pattern = new PatternDescr( "query1" );
        pattern.setQuery( true );
        lhs.addDescr( pattern );
        ExprConstraintDescr expr = new ExprConstraintDescr("'bobba'");
        expr.setPosition( 0 );
        expr.setType( Type.POSITIONAL );
        pattern.addConstraint(expr);
       
        expr = new ExprConstraintDescr("$age");
        expr.setPosition( 1 );
        expr.setType( Type.POSITIONAL );
        pattern.addConstraint( expr );
       
        expr = new ExprConstraintDescr("$type");
        expr.setPosition( 2 );
        expr.setType( Type.POSITIONAL );       
        pattern.addConstraint( expr );
        ruleDescr.setConsequence( "System.out.println(\"age: \" + $age);" );

        builder.addPackage( packageDescr );
        assertLength( 0,
View Full Code Here

        final PatternDescr pattern = new PatternDescr( Cheese.class.getName(),
                                                       "stilton" );
        lhs.addDescr( pattern );

        pattern.addConstraint( new ExprConstraintDescr("type == $type") );

        // Another query, no parameters
        QueryDescr queryDescr2 = new QueryDescr( "query2" );
        packageDescr.addRule( queryDescr2 );
        AndDescr lhs2 = new AndDescr();
View Full Code Here

TOP

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

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.