Package org.drools.lang.descr

Examples of org.drools.lang.descr.VariableRestrictionDescr


        if ( identifier == null || identifier.trim().equals( "" ) ) {
            throw new SAXParseException( "<bound-variable>  requires an 'identifier' attribute",
                                         this.xmlPackageReader.getLocator() );
        }

        final VariableRestrictionDescr variableDescr = new VariableRestrictionDescr( evaluator,
                                                                                     identifier );

        return variableDescr;
    }
View Full Code Here


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

        final VariableRestrictionDescr variableDescr = (VariableRestrictionDescr) this.xmlPackageReader.getCurrent();

        final LinkedList parents = this.xmlPackageReader.getParents();
        final ListIterator it = parents.listIterator( parents.size() );
        it.previous();
View Full Code Here

        AndDescr lhs = new AndDescr();
        queryDescr.setLhs( lhs );
        PatternDescr pattern = new PatternDescr( Person.class.getName() );
        lhs.addDescr( pattern );
        FieldConstraintDescr literalDescr = new FieldConstraintDescr( "name" );
        literalDescr.addRestriction( new VariableRestrictionDescr( "==",
                                                                   "$name" ) );
        pattern.addConstraint( literalDescr );
       
        literalDescr = new FieldConstraintDescr( "age" );
        literalDescr.addRestriction( new VariableRestrictionDescr( "==",
                                                                   "$age" ) );
        pattern.addConstraint( literalDescr );
       
        literalDescr = new FieldConstraintDescr( "likes" );
        literalDescr.addRestriction( new VariableRestrictionDescr( "==",
                                                                   "$likes" ) );
        pattern.addConstraint( literalDescr );       
       
        RuleDescr ruleDescr = new RuleDescr( "rule-1" );
        packageDescr.addRule( ruleDescr );
View Full Code Here

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

        final FieldConstraintDescr literalDescr = new FieldConstraintDescr( "type" );
        literalDescr.addRestriction( new VariableRestrictionDescr( "==",
                                                                   "$type" ) );

        pattern.addConstraint( literalDescr );

        builder.addPackage( packageDescr );
View Full Code Here

        assertEquals( "==",
                      returnValueDescr.getEvaluator() );
        assertEquals( "1==1",
                      returnValueDescr.getContent() );

        final VariableRestrictionDescr variableDescr = (VariableRestrictionDescr) fieldConstraintDescr.getRestrictions().get( 2 );
        assertEquals( "==",
                      variableDescr.getEvaluator() );
        assertEquals( "var1",
                      variableDescr.getIdentifier() );

        final PredicateDescr predicateDescr = (PredicateDescr) pattern3.getDescrs().get( 1 );
        assertEquals( "1==1",
                      predicateDescr.getContent() );
View Full Code Here

        assertEquals( 2,
                      descrs.getDescrs().size() );
        PatternDescr pat = (PatternDescr) descrs.getDescrs().get( 1 );
        FieldConstraintDescr fieldConstr = (FieldConstraintDescr) pat.getConstraint().getDescrs().get( 0 );
        VariableRestrictionDescr restr = (VariableRestrictionDescr) fieldConstr.getRestrictions().get( 0 );

        assertEquals( "memberOf",
                      restr.getEvaluator() );
        assertEquals( "$cities",
                      restr.getIdentifier() );
    }
View Full Code Here

        assertEquals( 2,
                      descrs.getDescrs().size() );
        PatternDescr pat = (PatternDescr) descrs.getDescrs().get( 1 );
        FieldConstraintDescr fieldConstr = (FieldConstraintDescr) pat.getConstraint().getDescrs().get( 0 );
        VariableRestrictionDescr restr = (VariableRestrictionDescr) fieldConstr.getRestrictions().get( 0 );

        assertEquals( "not memberOf",
                      restr.getEvaluator() );
        assertEquals( "$cities",
                      restr.getIdentifier() );
    }
View Full Code Here

        assertEquals( 2,
                      descrs.getDescrs().size() );
        PatternDescr pat = (PatternDescr) descrs.getDescrs().get( 1 );
        FieldConstraintDescr fieldConstr = (FieldConstraintDescr) pat.getConstraint().getDescrs().get( 0 );
        VariableRestrictionDescr restr = (VariableRestrictionDescr) fieldConstr.getRestrictions().get( 0 );

        assertEquals( "not contains",
                      restr.getEvaluator() );
        assertEquals( "$city",
                      restr.getIdentifier() );
    }
View Full Code Here

                      literalDescr.getEvaluator() );
        assertEquals( "bob",
                      literalDescr.getText() );

        fld = (FieldConstraintDescr) person.getConstraint().getDescrs().get( 2 );
        final VariableRestrictionDescr variableDescr = (VariableRestrictionDescr) fld.getRestrictions().get( 0 );

        assertEquals( "likes",
                      fld.getFieldName() );
        assertEquals( "==",
                      variableDescr.getEvaluator() );
        assertEquals( "$type",
                      variableDescr.getIdentifier() );

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

        final NotDescr not = (NotDescr) rule.getLhs().getDescrs().get( 1 );
        pattern = (PatternDescr) not.getDescrs().get( 0 );

        final FieldConstraintDescr fld = (FieldConstraintDescr) pattern.getConstraint().getDescrs().get( 0 );
        final VariableRestrictionDescr boundVariable = (VariableRestrictionDescr) fld.getRestrictions().get( 0 );

        assertEquals( "type",
                      fld.getFieldName() );
        assertEquals( "==",
                      boundVariable.getEvaluator() );
        assertEquals( "$likes",
                      boundVariable.getIdentifier() );

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

TOP

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

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.