Package org.drools.compiler.lang.descr

Examples of org.drools.compiler.lang.descr.AttributeDescr


                if ( ctxBuilder == null ) {
                    function = DescrFactory.newPackage().newFunction();
                } else {
                    PackageDescrBuilder pkg = (PackageDescrBuilder) ctxBuilder;
                    function = pkg.newFunction().namespace( pkg.getDescr().getName() );
                    AttributeDescr attribute = pkg.getDescr().getAttribute( "dialect" );
                    if ( attribute != null ) {
                        function.dialect( attribute.getValue() );
                    }
                }
                pushParaphrases( DroolsParaphraseTypes.FUNCTION );
                beginSentence( DroolsSentenceType.FUNCTION );
                setStart( function );
View Full Code Here


        return descr;
    }

    public PackageDescrBuilder attribute( String name,
                                          String value ) {
        descr.addAttribute( new AttributeDescr( name,
                                                value ) );
        return this;
    }
View Full Code Here

    }

    public PackageDescrBuilder attribute( String name,
                                          String value,
                                          AttributeDescr.Type type ) {
        descr.addAttribute( new AttributeDescr( name,
                                                value,
                                                type ) );
        return this;
    }
View Full Code Here

     * which will actually gobble the tokens.
     *
     * @return
     */
    public AttributeDescr attribute( AttributeSupportBuilder< ? > as ) {
        AttributeDescr attribute = null;
        try {
            if ( state.backtracking == 0 && input.LA( 1 ) != DRL5Lexer.EOF ) {
                helper.emit( Location.LOCATION_RULE_HEADER_KEYWORD );
            }
            if ( helper.validateIdentifierKey( DroolsSoftKeywords.SALIENCE ) ) {
                attribute = salience( as );
            } else if ( helper.validateIdentifierKey( DroolsSoftKeywords.ENABLED ) ) {
                attribute = enabled( as );
            } else if ( helper.validateIdentifierKey( DroolsSoftKeywords.NO ) &&
                        helper.validateLT( 2,
                                           "-" ) &&
                        helper.validateLT( 3,
                                           DroolsSoftKeywords.LOOP ) ) {
                attribute = booleanAttribute( as,
                                              new String[]{DroolsSoftKeywords.NO, "-", DroolsSoftKeywords.LOOP} );
            } else if ( helper.validateIdentifierKey( DroolsSoftKeywords.AUTO ) &&
                        helper.validateLT( 2,
                                           "-" ) &&
                        helper.validateLT( 3,
                                           DroolsSoftKeywords.FOCUS ) ) {
                attribute = booleanAttribute( as,
                                              new String[]{DroolsSoftKeywords.AUTO, "-", DroolsSoftKeywords.FOCUS} );
            } else if ( helper.validateIdentifierKey( DroolsSoftKeywords.LOCK ) &&
                        helper.validateLT( 2,
                                           "-" ) &&
                        helper.validateLT( 3,
                                           DroolsSoftKeywords.ON ) &&
                        helper.validateLT( 4,
                                           "-" ) &&
                        helper.validateLT( 5,
                                           DroolsSoftKeywords.ACTIVE ) ) {
                attribute = booleanAttribute( as,
                                              new String[]{DroolsSoftKeywords.LOCK, "-", DroolsSoftKeywords.ON, "-", DroolsSoftKeywords.ACTIVE} );
            } else if ( helper.validateIdentifierKey( DroolsSoftKeywords.REFRACT ) ) {
                attribute = booleanAttribute( as,
                                              new String[]{ DroolsSoftKeywords.REFRACT } );
            } else if ( helper.validateIdentifierKey( DroolsSoftKeywords.AGENDA ) &&
                        helper.validateLT( 2,
                                           "-" ) &&
                        helper.validateLT( 3,
                                           DroolsSoftKeywords.GROUP ) ) {
                attribute = stringAttribute( as,
                                             new String[]{DroolsSoftKeywords.AGENDA, "-", DroolsSoftKeywords.GROUP} );
            } else if ( helper.validateIdentifierKey( DroolsSoftKeywords.ACTIVATION ) &&
                        helper.validateLT( 2,
                                           "-" ) &&
                        helper.validateLT( 3,
                                           DroolsSoftKeywords.GROUP ) ) {
                attribute = stringAttribute( as,
                                             new String[]{DroolsSoftKeywords.ACTIVATION, "-", DroolsSoftKeywords.GROUP} );
            } else if ( helper.validateIdentifierKey( DroolsSoftKeywords.RULEFLOW ) &&
                        helper.validateLT( 2,
                                           "-" ) &&
                        helper.validateLT( 3,
                                           DroolsSoftKeywords.GROUP ) ) {
                attribute = stringAttribute( as,
                                             new String[]{DroolsSoftKeywords.RULEFLOW, "-", DroolsSoftKeywords.GROUP} );
            } else if ( helper.validateIdentifierKey( DroolsSoftKeywords.DATE ) &&
                        helper.validateLT( 2,
                                           "-" ) &&
                        helper.validateLT( 3,
                                           DroolsSoftKeywords.EFFECTIVE ) ) {
                attribute = stringAttribute( as,
                                             new String[]{DroolsSoftKeywords.DATE, "-", DroolsSoftKeywords.EFFECTIVE} );
                attribute.setType( AttributeDescr.Type.DATE );
            } else if ( helper.validateIdentifierKey( DroolsSoftKeywords.DATE ) &&
                        helper.validateLT( 2,
                                           "-" ) &&
                        helper.validateLT( 3,
                                           DroolsSoftKeywords.EXPIRES ) ) {
                attribute = stringAttribute( as,
                                             new String[]{DroolsSoftKeywords.DATE, "-", DroolsSoftKeywords.EXPIRES} );
                attribute.setType( AttributeDescr.Type.DATE );
            } else if ( helper.validateIdentifierKey( DroolsSoftKeywords.DIALECT ) ) {
                attribute = stringAttribute( as,
                                             new String[]{DroolsSoftKeywords.DIALECT} );
            } else if ( helper.validateIdentifierKey( DroolsSoftKeywords.CALENDARS ) ) {
                attribute = stringListAttribute( as,
View Full Code Here

     * which will actually gobble the tokens.
     *
     * @return
     */
    public AttributeDescr attribute(AttributeSupportBuilder<?> as) {
        AttributeDescr attribute = null;
        try {
            if (state.backtracking == 0 && input.LA(1) != DRL6Lexer.EOF) {
                helper.emit(Location.LOCATION_RULE_HEADER_KEYWORD);
            }
            if (helper.validateIdentifierKey(DroolsSoftKeywords.SALIENCE)) {
                attribute = salience(as);
            } else if (helper.validateIdentifierKey(DroolsSoftKeywords.ENABLED)) {
                attribute = enabled(as);
            } else if (helper.validateIdentifierKey(DroolsSoftKeywords.NO) &&
                    helper.validateLT(2,
                            "-") &&
                    helper.validateLT(3,
                            DroolsSoftKeywords.LOOP)) {
                attribute = booleanAttribute(as,
                        new String[]{DroolsSoftKeywords.NO, "-", DroolsSoftKeywords.LOOP});
            } else if (helper.validateIdentifierKey(DroolsSoftKeywords.AUTO) &&
                    helper.validateLT(2,
                            "-") &&
                    helper.validateLT(3,
                            DroolsSoftKeywords.FOCUS)) {
                attribute = booleanAttribute(as,
                        new String[]{DroolsSoftKeywords.AUTO, "-", DroolsSoftKeywords.FOCUS});
            } else if (helper.validateIdentifierKey(DroolsSoftKeywords.LOCK) &&
                    helper.validateLT(2,
                            "-") &&
                    helper.validateLT(3,
                            DroolsSoftKeywords.ON) &&
                    helper.validateLT(4,
                            "-") &&
                    helper.validateLT(5,
                            DroolsSoftKeywords.ACTIVE)) {
                attribute = booleanAttribute(as,
                        new String[]{DroolsSoftKeywords.LOCK, "-", DroolsSoftKeywords.ON, "-", DroolsSoftKeywords.ACTIVE});
            } else if (helper.validateIdentifierKey(DroolsSoftKeywords.REFRACT)) {
                attribute = booleanAttribute(as,
                        new String[]{DroolsSoftKeywords.REFRACT});
            } else if (helper.validateIdentifierKey(DroolsSoftKeywords.DIRECT)) {
                attribute = booleanAttribute(as,
                        new String[]{DroolsSoftKeywords.DIRECT});
            } else if (helper.validateIdentifierKey(DroolsSoftKeywords.AGENDA) &&
                    helper.validateLT(2,
                            "-") &&
                    helper.validateLT(3,
                            DroolsSoftKeywords.GROUP)) {
                attribute = stringAttribute(as,
                        new String[]{DroolsSoftKeywords.AGENDA, "-", DroolsSoftKeywords.GROUP});
            } else if (helper.validateIdentifierKey(DroolsSoftKeywords.ACTIVATION) &&
                    helper.validateLT(2,
                            "-") &&
                    helper.validateLT(3,
                            DroolsSoftKeywords.GROUP)) {
                attribute = stringAttribute(as,
                        new String[]{DroolsSoftKeywords.ACTIVATION, "-", DroolsSoftKeywords.GROUP});
            } else if (helper.validateIdentifierKey(DroolsSoftKeywords.RULEFLOW) &&
                    helper.validateLT(2,
                            "-") &&
                    helper.validateLT(3,
                            DroolsSoftKeywords.GROUP)) {
                attribute = stringAttribute(as,
                        new String[]{DroolsSoftKeywords.RULEFLOW, "-", DroolsSoftKeywords.GROUP});
            } else if (helper.validateIdentifierKey(DroolsSoftKeywords.DATE) &&
                    helper.validateLT(2,
                            "-") &&
                    helper.validateLT(3,
                            DroolsSoftKeywords.EFFECTIVE)) {
                attribute = stringAttribute(as,
                        new String[]{DroolsSoftKeywords.DATE, "-", DroolsSoftKeywords.EFFECTIVE});
                attribute.setType(AttributeDescr.Type.DATE);
            } else if (helper.validateIdentifierKey(DroolsSoftKeywords.DATE) &&
                    helper.validateLT(2,
                            "-") &&
                    helper.validateLT(3,
                            DroolsSoftKeywords.EXPIRES)) {
                attribute = stringAttribute(as,
                        new String[]{DroolsSoftKeywords.DATE, "-", DroolsSoftKeywords.EXPIRES});
                attribute.setType(AttributeDescr.Type.DATE);
            } else if (helper.validateIdentifierKey(DroolsSoftKeywords.DIALECT)) {
                attribute = stringAttribute(as,
                        new String[]{DroolsSoftKeywords.DIALECT});
            } else if (helper.validateIdentifierKey(DroolsSoftKeywords.CALENDARS)) {
                attribute = stringListAttribute(as,
View Full Code Here

    @Before
    public void setUp() throws Exception {
        final Package pkg = new Package( "pkg1" );
        final RuleDescr ruleDescr = new RuleDescr( "rule 1" );
        ruleDescr.addAttribute( new AttributeDescr( "salience",
                                                    "(p.age + 20)/2" ) );
        ruleDescr.setConsequence( "" );

        PackageBuilder pkgBuilder = new PackageBuilder( pkg );
        DialectCompiletimeRegistry dialectRegistry = pkgBuilder.getPackageRegistry( pkg.getName() ).getDialectCompiletimeRegistry();
View Full Code Here

        PackageBuilder pkgBuilder = new PackageBuilder( pkg,
                                                        conf );

        ruleDescr = new RuleDescr( "test consequence builder" );
        ruleDescr.setConsequence( consequence );
        ruleDescr.addAttribute( new AttributeDescr("dialect", "mvel") );
       
        for ( Entry<String, Object> entry : namedConsequences.entrySet() ) {
            ruleDescr.addNamedConsequences( entry.getKey(), entry.getValue() );
        }
View Full Code Here

        assertSame( pkg,
                    mockDialect2.getPkg() );
        assertNull( mockDialect2.getRuleDescr() );

        RuleDescr ruleDescr = new RuleDescr( "test rule" );
        ruleDescr.addAttribute( new AttributeDescr( "dialect",
                                                    "mock" ) );
        ruleDescr.setLhs( new AndDescr() );
        EvalDescr evalDescr = new EvalDescr();
        ruleDescr.getLhs().addDescr( evalDescr );
View Full Code Here

            Map<String, AttributeDescr> pkgAttributes = packageAttributes.get(packageDescr.getNamespace());
            inheritPackageAttributes(pkgAttributes,
                                     ruleDescr);

            if (isEmpty(ruleDescr.getDialect())) {
                ruleDescr.addAttribute(new AttributeDescr("dialect",
                                                          pkgRegistry.getDialect()));
            }
        }

        // Build up map of contexts  and process all rules
View Full Code Here

            // process pattern
            InternalKnowledgePackage pkg = pkgRegistry.getPackage();
            DialectCompiletimeRegistry ctr = pkgRegistry.getDialectCompiletimeRegistry();
            RuleDescr dummy = new RuleDescr(wd.getName() + " Window Declaration");
            dummy.addAttribute(new AttributeDescr("dialect", "java"));
            RuleBuildContext context = new RuleBuildContext(this,
                                                            dummy,
                                                            ctr,
                                                            pkg,
                                                            ctr.getDialect(pkgRegistry.getDialect()));
View Full Code Here

TOP

Related Classes of org.drools.compiler.lang.descr.AttributeDescr

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.