Examples of Extractor


Examples of org.drools.spi.Extractor

    public void testIsNullValue() {
        try {
            Assert.assertFalse( this.extractor.isNullValue( null,
                                                            this.person ) );

            Extractor nullExtractor = ClassFieldExtractorCache.getInstance().getExtractor( Person.class,
                                                                                           "addresses['business'].phone",
                                                                                           getClass().getClassLoader() );
            Assert.assertTrue( nullExtractor.isNullValue( null,
                                                          this.person ) );
        } catch ( final Exception e ) {
            fail( "Should not throw an exception" );
        }
    }
View Full Code Here

Examples of org.drools.spi.Extractor

    public void testIsNullValue() {
        try {
            Assert.assertFalse( this.extractor.isNullValue( null, this.bean ) );

            Extractor nullExtractor = ClassFieldExtractorCache.getExtractorTestBean.class,
                                                                              "nullAttr",
                                                                              getClass().getClassLoader() );
            Assert.assertTrue( nullExtractor.isNullValue( null, this.bean ) );
        } catch ( final Exception e ) {
            fail( "Should not throw an exception" );
        }
    }
View Full Code Here

Examples of org.drools.spi.Extractor

    public void testIsNullValue() {
        try {
            Assert.assertFalse( this.extractor.isNullValue( null, this.person ) );

            Extractor nullExtractor = ClassFieldExtractorCache.getExtractor( Person.class,
                                                                             "addresses['business'].phone",
                                                                             getClass().getClassLoader() );
            Assert.assertTrue( nullExtractor.isNullValue( null, this.person ) );
        } catch ( final Exception e ) {
            fail( "Should not throw an exception" );
        }
    }
View Full Code Here

Examples of org.drools.spi.Extractor

     * @param data The data to try out : Array of {arg1, operator, arg2}
     * @param valueType The Evaluator.**_TYPE to test
     */
    private void runEvaluatorTest(final Object[][] data,
                                  final ValueType valueType) {
        final Extractor extractor = new MockExtractor();
        for ( int i = 0; i < data.length; i++ ) {
            final Object[] row = data[i];
            final Evaluator evaluator = valueType.getEvaluator( Operator.determineOperator( (String) row[1] ) );
            checkEvaluatorMethodWithFieldValue( valueType,
                                                extractor,
View Full Code Here

Examples of org.drools.spi.Extractor

       
        Set inputs = compiler.getParserContextState().getInputs().keySet();
        for( Iterator it = inputs.iterator(); it.hasNext(); ) {
            String basefield = (String) it.next();
                       
            Extractor extr = ClassFieldExtractorCache.getInstance().getExtractorclazz, basefield, classLoader );
            this.extractors.put( basefield, extr );
        }
    }
View Full Code Here

Examples of org.drools.spi.Extractor

                                                                    ValueType.STRING_TYPE.getEvaluator( Operator.EQUAL ),
                                                                    field );
        // adds appropriate constraint to the pattern
        pattern.addConstraint( constraint );

        Extractor arrayExtractor = null;
        try {
            arrayExtractor = context.getDialect().getClassFieldExtractorCache().getExtractor( ((ClassObjectType) objectType).getClassType(),
                                                                                              "arguments",
                                                                                              classloader );
        } catch ( final RuntimeDroolsException e ) {
View Full Code Here

Examples of org.drools.spi.Extractor

        final FieldTemplate[] fields = new FieldTemplate[]{cheeseName, cheesePrice};
        final FactTemplate cheese = new FactTemplateImpl( pkg,
                                                          "Cheese",
                                                          fields );

        final Extractor extractName = new FactTemplateFieldExtractor( cheese,
                                                                      0 );
        final Extractor extractPrice = new FactTemplateFieldExtractor( cheese,
                                                                       1 );

        final Fact stilton = cheese.createFact( 10 );
        stilton.setFieldValue( "name",
                               "stilton" );
        stilton.setFieldValue( "price",
                               new Integer( 200 ) );

        assertEquals( "stilton",
                      extractName.getValue( null, stilton ) );

        assertEquals( new Integer( 200 ),
                      extractPrice.getValue( null, stilton ) );

        assertFalse( extractName.isNullValue( null, stilton ) );
       
        stilton.setFieldValue( "name",
                               null );
       
        assertTrue( extractName.isNullValue( null, stilton ) );
        assertFalse( extractPrice.isNullValue( null, stilton ) );
       
        final Fact brie = cheese.createFact( 12 );
        brie.setFieldValue( "name",
                            "brie" );
        brie.setFieldValue( "price",
                            new Integer( 55 ) );

        assertEquals( "brie",
                      extractName.getValue( null, brie ) );

        assertEquals( new Integer( 55 ),
                      extractPrice.getValue( null, brie ) );
       
        assertFalse( extractName.isNullValue( null, brie ) );
       
        brie.setFieldValue( "name",
                            null );
       
        assertTrue( extractName.isNullValue( null, brie ) );
        assertFalse( extractPrice.isNullValue( null, stilton ) );
    }
View Full Code Here

Examples of org.drools.spi.Extractor

        final FieldTemplate[] fields = new FieldTemplate[]{cheeseName, cheesePrice};
        final FactTemplate cheese = new FactTemplateImpl( pkg,
                                                          "Cheese",
                                                          fields );

        final Extractor extractName = new FactTemplateFieldExtractor( cheese,
                                                                      0 );

        final Pattern pattern = new Pattern( 0,
                                          new FactTemplateObjectType( cheese ) );
View Full Code Here

Examples of org.drools.spi.Extractor

     * @param data The data to try out : Array of {arg1, operator, arg2}
     * @param valueType The Evaluator.**_TYPE to test
     */
    private void runEvaluatorTest(final Object[][] data,
                                  final ValueType valueType) {
        final Extractor extractor = new MockExtractor();
        for ( int i = 0; i < data.length; i++ ) {
            final Object[] row = data[i];
            final Evaluator evaluator = valueType.getEvaluator( Operator.determineOperator( (String) row[1] ) );
            checkEvaluatorMethodWithFieldValue( valueType,
                                                extractor,
View Full Code Here

Examples of org.drools.spi.Extractor

        final ObjectType type = new ClassObjectType( Cheese.class );
        final Pattern col = new Pattern( 0,
                                       type,
                                       "foo" );
        final Declaration dec = col.getDeclaration();
        final Extractor ext = dec.getExtractor();
        assertEquals( Cheese.class,
                      ext.getExtractToClass() );

        final Cheese stilton = new Cheese( "stilton",
                                           42 );

        assertEquals( stilton,
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.