Package org.drools.lang.dsl

Examples of org.drools.lang.dsl.DefaultExpander


    /**
     * Returns an expander for DSLs (only if there is a DSL configured for this
     * package).
     */
    public DefaultExpander getDslExpander() {
        DefaultExpander expander = new DefaultExpander();
        if ( this.dslFiles == null || this.dslFiles.isEmpty() ) {
            return null;
        }
        for ( DSLMappingFile file : this.dslFiles ) {
            expander.addDSLMapping( file.getMapping() );
        }
        return expander;
    }
View Full Code Here


        }
    }

    public void addPackageFromDslr(final Reader source) {
        final DrlParser parser = new DrlParser();
        DefaultExpander expander = getDslExpander();

        try {
            String str = expander.expand( source );
            if ( expander.hasErrors() ) {
                this.results.addAll( expander.getErrors() );
            }

            final PackageDescr pkg = parser.parse( str );
            this.results.addAll( parser.getErrors() );
            if ( !parser.hasErrors() ) {
View Full Code Here

    /**
     * Returns an expander for DSLs (only if there is a DSL configured for this package).
     */
    public DefaultExpander getDslExpander() {
        DefaultExpander expander = new DefaultExpander();
        if ( this.dslFiles == null || this.dslFiles.isEmpty() ) {
            return expander;
        }
        for ( DSLMappingFile file : this.dslFiles ) {
            expander.addDSLMapping( file.getMapping() );
        }
        return expander;
    }
View Full Code Here

    public void addPackageFromDslr(final Resource resource) throws DroolsParserException,
                                                           IOException {
        this.resource = resource;

        final DrlParser parser = new DrlParser();
        DefaultExpander expander = getDslExpander();

        try {
            if ( expander == null ) {
                expander = new DefaultExpander();
            }
            String str = expander.expand( resource.getReader() );
            if ( expander.hasErrors() ) {
                this.results.addAll( expander.getErrors() );
            }

            final PackageDescr pkg = parser.parse( str );
            this.results.addAll( parser.getErrors() );
            if ( !parser.hasErrors() ) {
View Full Code Here

    try {
          BusinessRuleProvider provider = BusinessRuleProviderFactory.getInstance().getProvider();
          Reader knowledge = provider.getKnowledgeReader(resource);

      DrlParser parser = new DrlParser();
          DefaultExpander expander = getDslExpander();

          if (null != expander) {
            knowledge = new StringReader(expander.expand(knowledge));
            if (expander.hasErrors())
              this.results.addAll(expander.getErrors());
          }

          PackageDescr pkg = parser.parse(knowledge);
          if (parser.hasErrors()) {
            this.results.addAll(parser.getErrors());
View Full Code Here

    /**
     * Returns an expander for DSLs (only if there is a DSL configured for this package).
     */
    public DefaultExpander getDslExpander() {
        DefaultExpander expander = new DefaultExpander();
        if ( this.dslFiles == null || this.dslFiles.isEmpty() ) {
            return null;
        }
        for ( DSLMappingFile file : this.dslFiles ) {
            expander.addDSLMapping( file.getMapping() );
        }
        return expander;
    }
View Full Code Here

    }

    public void testExpanderErrorsAfterExpansion() throws Exception {

        final String name = "expander_post_errors.dslr";
        final Expander expander = new DefaultExpander();
        final String expanded = expander.expand( this.getReader( name ) );

        final DRLParser parser = parse( name,
                                        expanded );
        parser.compilation_unit();
        assertTrue( parser.hasErrors() );
View Full Code Here

    public void addPackageFromDslr(final Resource resource) throws DroolsParserException,
                                                             IOException {
        this.resource = resource;

        final DrlParser parser = new DrlParser();
        DefaultExpander expander = getDslExpander();

        try {
            if ( expander == null ) {
                expander = new DefaultExpander();
            }
            String str = expander.expand( resource.getReader() );
            if ( expander.hasErrors() ) {
                this.results.addAll( expander.getErrors() );
            }

            final PackageDescr pkg = parser.parse( str );
            this.results.addAll( parser.getErrors() );
            if ( !parser.hasErrors() ) {
View Full Code Here

            Reader knowledge = provider.getKnowledgeReader( resource );

            DrlParser parser = new DrlParser();

            if ( provider.hasDSLSentences() ) {
                DefaultExpander expander = getDslExpander();

                if ( null != expander ) {
                    knowledge = new StringReader( expander.expand( knowledge ) );
                    if ( expander.hasErrors() ) this.results.addAll( expander.getErrors() );
                }
            }

            PackageDescr pkg = parser.parse( knowledge );
            if ( parser.hasErrors() ) {
View Full Code Here

    /**
     * Returns an expander for DSLs (only if there is a DSL configured for this
     * package).
     */
    public DefaultExpander getDslExpander() {
        DefaultExpander expander = new DefaultExpander();
        if ( this.dslFiles == null || this.dslFiles.isEmpty() ) {
            return null;
        }
        for ( DSLMappingFile file : this.dslFiles ) {
            expander.addDSLMapping( file.getMapping() );
        }
        return expander;
    }
View Full Code Here

TOP

Related Classes of org.drools.lang.dsl.DefaultExpander

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.