Package org.drools.lang.dsl

Examples of org.drools.lang.dsl.DSLTokenizedMappingFile


    private DefaultExpanderResolver resolveDSLFiles() throws IOException {

        DefaultExpanderResolver resolver = new DefaultExpanderResolver();
        final File dir = new File(this.srcdir.getAbsolutePath());
        DSLMappingFile file = new DSLTokenizedMappingFile();

        FilenameFilter filter = new FilenameFilter() {
            public boolean accept(File dir, String name) {
                return name.endsWith(".dsl");
            }
        };

        String[] children = dir.list(filter);
        if (children.length == 0) {
            throw new BuildException(
                    "There are no DSL files for this directory:"
                            + this.srcdir.getAbsolutePath());
        }

        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());
            }
        }

        return resolver;
    }
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() );
        }       

        DrlParser parser = new DrlParser();
        String result = parser.getExpandedDRL( drl, resolver);
        assertEqualsIgnoreWhitespace( "rule 'foo' \n when \n Something() \n then \n another(); \nend", result );
View Full Code Here

        return pkg;
    }

    public void addDsl( Resource resource ) throws IOException {
        this.resource = resource;
        DSLTokenizedMappingFile file = new DSLTokenizedMappingFile();

        Reader reader = null;
        try {
            reader = resource.getReader();
            if (!file.parseAndLoad( reader )) {
                this.results.addAll( file.getErrors() );
            }
            if (this.dslFiles == null) {
                this.dslFiles = new ArrayList<DSLTokenizedMappingFile>();
            }
            this.dslFiles.add( file );
View Full Code Here

        return pkg;
    }

    public void addDsl( Resource resource ) throws IOException {
        this.resource = resource;
        DSLTokenizedMappingFile file = new DSLTokenizedMappingFile();

        Reader reader = null;
        try {
            reader = resource.getReader();
            if (!file.parseAndLoad( reader )) {
                this.results.addAll( file.getErrors() );
            }
            if (this.dslFiles == null) {
                this.dslFiles = new ArrayList<DSLTokenizedMappingFile>();
            }
            this.dslFiles.add( file );
View Full Code Here

    }

    public void addDsl( Resource resource ) throws IOException {
        this.resource = resource;

        DSLTokenizedMappingFile file = new DSLTokenizedMappingFile();
        if ( !file.parseAndLoad( resource.getReader() ) ) {
            this.results.addAll( file.getErrors() );
        }
        if ( this.dslFiles == null ) {
            this.dslFiles = new ArrayList<DSLTokenizedMappingFile>();
        }
        this.dslFiles.add( file );
View Full Code Here

    }
   
    public void addDsl(Resource resource) throws IOException {
        this.resource = resource;

        DSLTokenizedMappingFile file = new DSLTokenizedMappingFile();
        file.parseAndLoad( resource.getReader() );
        if ( this.dslFiles == null ) {
            this.dslFiles = new ArrayList<DSLTokenizedMappingFile>();
        }
        this.dslFiles.add( file );
View Full Code Here

        // e.getMessage() );
        // }
        // }

        for (final Iterator it = dsls.iterator(); it.hasNext();) {
            final DSLTokenizedMappingFile file = (DSLTokenizedMappingFile) it.next();
            final DSLMapping mapping = file.getMapping();
            for (final Iterator entries = mapping.getEntries().iterator(); entries.hasNext();) {
                final AbstractDSLMappingEntry entry = (AbstractDSLMappingEntry) entries.next();
                if (entry.getSection() == DSLMappingEntry.CONDITION) {
                    this.builder.addDSLConditionSentence(entry.getMappingKey());
                } else if (entry.getSection() == DSLMappingEntry.CONSEQUENCE) {
View Full Code Here

    }

    public void addDsl( Resource resource ) throws IOException {
        this.resource = resource;

        DSLTokenizedMappingFile file = new DSLTokenizedMappingFile();
        if (!file.parseAndLoad( resource.getReader() )) {
            this.results.addAll( file.getErrors() );
        }
        if (this.dslFiles == null) {
            this.dslFiles = new ArrayList<DSLTokenizedMappingFile>();
        }
        this.dslFiles.add( file );
View Full Code Here

    }

    public void addDsl(Resource resource) throws IOException {
        this.resource = resource;

        DSLTokenizedMappingFile file = new DSLTokenizedMappingFile();
        if ( !file.parseAndLoad( resource.getReader() ) ) {
            this.results.addAll( file.getErrors() );
        }
        if ( this.dslFiles == null ) {
            this.dslFiles = new ArrayList<DSLTokenizedMappingFile>();
        }
        this.dslFiles.add( file );
View Full Code Here

    }

    public void addDsl(Resource resource) throws IOException {
        this.resource = resource;

        DSLTokenizedMappingFile file = new DSLTokenizedMappingFile();
        file.parseAndLoad( resource.getReader() );
        if ( this.dslFiles == null ) {
            this.dslFiles = new ArrayList<DSLTokenizedMappingFile>();
        }
        this.dslFiles.add( file );
View Full Code Here

TOP

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

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.