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() {
        if (this.expander == null) {
            expander = new DefaultExpander();
            for (DSLMappingFile file : this.dslFiles) {
                expander.addDSLMapping(file.getMapping());
            }
        }
        return expander;
View Full Code Here


    PackageDescr dslrToPackageDescr(Resource resource) throws DroolsParserException {
        boolean hasErrors;
        PackageDescr pkg;

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

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

            pkg = parser.parse( str );
            this.results.addAll( parser.getErrors() );
            hasErrors = 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() {
        if (this.expander == null) {
            expander = new DefaultExpander();
            for ( DSLMappingFile file : this.dslFiles ) {
                expander.addDSLMapping( file.getMapping() );
            }
        }
        return expander;
View Full Code Here

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

        //add the rule keyword if its 'stand alone'
        String source = asset.getContent();
        if ( DRLFileContentHandler.isStandAloneRule( source ) ) {
            String parentName = this.parentNameFromCategory( asset,
                                                             "" );
            source = wrapRule( asset,
                               parentName,
                               source );
        }

        //expand and check for errors
        String drl = expander.expand( source );
        if ( expander.hasErrors() ) {
            List exErrs = expander.getErrors();
            for ( Iterator iter = exErrs.iterator(); iter.hasNext(); ) {
                ExpanderException ex = (ExpanderException) iter.next();
                logger.logError( new ContentAssemblyError( asset,
                                                           ex.getMessage() ) );
            }
View Full Code Here

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

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

    }
View Full Code Here

    PackageDescr dslrToPackageDescr(Resource resource) throws DroolsParserException {
        boolean hasErrors;
        PackageDescr pkg;

        DrlParser parser = new DrlParser(configuration.getLanguageLevel());
        DefaultExpander expander = getDslExpander();

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

            pkg = parser.parse( str );
            this.results.addAll( parser.getErrors() );
            hasErrors = parser.hasErrors();
View Full Code Here

        Reader knowledge = provider.getKnowledgeReader( resource );

        DrlParser parser = new DrlParser(configuration.getLanguageLevel());

        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

    /**
     * Returns an expander for DSLs (only if there is a DSL configured for this package).
     */
    public DefaultExpander getDSLExpander() {
        if (this.expander == null) {
            expander = new DefaultExpander();
            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.