Package org.drools.lang.descr

Examples of org.drools.lang.descr.ReturnValueRestrictionDescr


                      fld.getFieldName() );
    }

    public void testChunkWithoutParens() throws Exception {
        String input = "( foo )";
        ReturnValueRestrictionDescr returnData = (ReturnValueRestrictionDescr) parse( "paren_chunk",
                                                                                      "fact_expression",
                                                                                      input );

        assertEquals( "( foo )",
                      input.substring( returnData.getStartCharacter(),
                                       returnData.getEndCharacter() ) );
    }
View Full Code Here


                                       returnData.getEndCharacter() ) );
    }

    public void testChunkWithParens() throws Exception {
        String input = "(fnord())";
        ReturnValueRestrictionDescr returnData = (ReturnValueRestrictionDescr) parse( "paren_chunk",
                                                                                      "fact_expression",
                                                                                      input );

        assertEquals( "(fnord())",
                      input.substring( returnData.getStartCharacter(),
                                       returnData.getEndCharacter() ) );
    }
View Full Code Here

                                       returnData.getEndCharacter() ) );
    }

    public void testChunkWithParensAndQuotedString() throws Exception {
        String input = "( fnord( \"cheese\" ) )";
        ReturnValueRestrictionDescr returnData = (ReturnValueRestrictionDescr) parse( "paren_chunk",
                                                                                      "fact_expression",
                                                                                      input );

        assertEquals( "( fnord( \"cheese\" ) )",
                      input.substring( returnData.getStartCharacter(),
                                       returnData.getEndCharacter() ) );
    }
View Full Code Here

                                       returnData.getEndCharacter() ) );
    }

    public void testChunkWithRandomCharac5ters() throws Exception {
        String input = "( %*9dkj)";
        ReturnValueRestrictionDescr returnData = (ReturnValueRestrictionDescr) parse( "paren_chunk",
                                                                                      "fact_expression",
                                                                                      input );

        assertEquals( "( %*9dkj)",
                      input.substring( returnData.getStartCharacter(),
                                       returnData.getEndCharacter() ) );
    }
View Full Code Here

        assertEquals( 1,
                      col.getConstraint().getDescrs().size() );
        assertEquals( "Foo",
                      col.getObjectType() );
        final FieldConstraintDescr fld = (FieldConstraintDescr) col.getConstraint().getDescrs().get( 0 );
        final ReturnValueRestrictionDescr retval = (ReturnValueRestrictionDescr) fld.getRestrictions().get( 0 );

        assertEquals( "a + b",
                      retval.getContent() );
        assertEquals( "name",
                      fld.getFieldName() );
        assertEquals( "==",
                      retval.getEvaluator() );
    }
View Full Code Here

                // execute it as a return value
                restriction = buildRestriction( context,
                                                (Pattern) context.getBuildStack().peek(),
                                                extractor,
                                                new ReturnValueRestrictionDescr( operator,
                                                                                 relDescr.isNegated(),
                                                                                 relDescr.getParametersText(),
                                                                                 rightValue ),
                                                aliases );
                // fall back to original dialect
View Full Code Here

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

        final ReturnValueRestrictionDescr returnValueDescr = new ReturnValueRestrictionDescr( "=" );
        returnValueDescr.setContent( "a + b" );

        final MVELReturnValueBuilder builder = new MVELReturnValueBuilder();

        final Declaration[] previousDeclarations = new Declaration[]{a, b};
        final Declaration[] localDeclarations = new Declaration[]{};
        final String[] requiredGlobals = new String[]{};

        final ReturnValueRestriction returnValue = new ReturnValueRestriction( extractor,
                                                                               previousDeclarations,
                                                                               localDeclarations,
                                                                               requiredGlobals,
                                                                               context.getConfiguration().getEvaluatorRegistry().getEvaluator( ValueType.PINTEGER_TYPE,
                                                                                                                                               Operator.EQUAL ) );
        AnalysisResult analysis = context.getDialect().analyzeExpression( context,
                                                                          returnValueDescr,
                                                                          returnValueDescr.getContent(),
                                                                          new BoundIdentifiers( declarationResolver.getDeclarationClasses( (Rule) null ), new HashMap(), null, Cheese.class ) );
        context.getBuildStack().push( patternB );
        builder.build( context,
                       analysis.getBoundIdentifiers(),
                       previousDeclarations,
View Full Code Here

        assertEquals( "!=",
                      litDescr.getEvaluator() );
        assertEquals( "zzz",
                      litDescr.getText() );
       
        ReturnValueRestrictionDescr retDescr = (ReturnValueRestrictionDescr) restrictionList.get( 2 );
        assertEquals( "!=",
                      retDescr.getEvaluator() );
       
        LispForm lispForm = ( LispForm ) retDescr.getContent();
        assertEquals("(+ 2 3)", lispForm.toString() );                        

        // ----------------
        // this is how it would be compatible to our core engine
        PredicateDescr predicateDescr = (PredicateDescr) colList.get( 2 );
View Full Code Here

        assertEquals( "!=",
                      litDescr.getEvaluator() );
        assertEquals( "zzz",
                      litDescr.getText() );
       
        ReturnValueRestrictionDescr retDescr = (ReturnValueRestrictionDescr) restrictionList.get( 2 );
        assertEquals( "!=",
                      retDescr.getEvaluator() );
       
        LispForm lispForm = ( LispForm ) retDescr.getContent();
        assertEquals("(+ 2 3)", lispForm.toString() );

        // ----------------
        // this is how it would be compatible to our core engine
        PredicateDescr predicateDescr = (PredicateDescr) colList.get( 2 );
View Full Code Here

        assertEquals( "!=",
                      litDescr.getEvaluator() );
        assertEquals( "zzz",
                      litDescr.getText() );
       
        ReturnValueRestrictionDescr retDescr = (ReturnValueRestrictionDescr) restrictionList.get( 2 );
        assertEquals( "!=",
                      retDescr.getEvaluator() );
       
        LispForm lispForm = ( LispForm ) retDescr.getContent();
        assertEquals("(+ 2 3)", lispForm.toString() );                        

        // ----------------
        // this is how it would be compatible to our core engine
        PredicateDescr predicateDescr = (PredicateDescr) colList.get( 2 );
View Full Code Here

TOP

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

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.