Package org.drools.lang.dsl

Examples of org.drools.lang.dsl.DefaultExpander


        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

        }

        for (int index = 0; index < children.length; index++) {
            if (file.parseAndLoad(new StringReader(
                    loadResource(children[index])))) {
                final Expander expander = new DefaultExpander();
                expander.addDSLMapping(file.getMapping());
                resolver.addExpander("*", expander);
            } else {
                throw new RuntimeDroolsException(
                        "Error parsing and loading DSL file."
                                + file.getErrors());
View Full Code Here

    public void compile(BRMSPackageBuilder builder,
                        AssetItem asset,
                        AssemblyErrorLogger logger) throws DroolsParserException,
            IOException {
        DefaultExpander expander = getExpander(builder,
                asset,
                logger);

        String source = getRawDRL(asset);

        //expand and check for errors
        String drl = expander.expand(source);

        if (expander.hasErrors()) {
            List<ExpanderException> exErrs = expander.getErrors();
            for (ExpanderException ex : exErrs) {
                logger.logError(new ContentAssemblyError(
                        ex.getMessage(), asset.getFormat(), asset.getName(), asset.getUUID(), false, true));
            }
            return;
View Full Code Here

        source = getDRL(source,
                asset.getName(),
                null);

        DefaultExpander expander = builder.getDSLExpander();
        stringBuilder.append(expander.expand(source));
    }
View Full Code Here

                            AssetItem asset,
                            StringBuilder stringBuilder) {
        //add the rule keyword if its 'stand alone'
        String source = getRawDRL(asset);

        DefaultExpander expander = builder.getDSLExpander();
        stringBuilder.append(expander.expand(source));

    }
View Full Code Here

        DefaultExpanderResolver resolver = new DefaultExpanderResolver(new StringReader(dsl));
       
       
        final DSLMappingFile file = new DSLTokenizedMappingFile();
        if ( file.parseAndLoad( new StringReader(dsl) ) ) {
            final Expander expander = new DefaultExpander();
            expander.addDSLMapping( file.getMapping() );
            resolver.addExpander("*", expander);
        } else {
            throw new RuntimeDroolsException( "Error parsing and loading DSL file." + file.getErrors() );
        }       

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 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

        DefaultExpanderResolver resolver = new DefaultExpanderResolver(new StringReader(dsl));
       
       
        final DSLMappingFile file = new DSLMappingFile();
        if ( file.parseAndLoad( new StringReader(dsl) ) ) {
            final Expander expander = new DefaultExpander();
            expander.addDSLMapping( file.getMapping() );
            resolver.addExpander("*", expander);
        } else {
            throw new RuntimeDroolsException( "Error parsing and loading DSL file." + file.getErrors() );
        }       

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.