Examples of parseAndLoad()


Examples of org.drools.compiler.lang.dsl.DSLMappingFile.parseAndLoad()

    @Test
    public void testExpandParts() throws Exception {
        DSLMappingFile file = new DSLTokenizedMappingFile();
        String dsl = "[when]foo=Foo()\n[then]bar {num}=baz({num});";
        file.parseAndLoad(new StringReader(dsl));
        assertEquals(0,
                file.getErrors().size());
        DefaultExpander ex = new DefaultExpander();
        ex.addDSLMapping(file.getMapping());
View Full Code Here

Examples of org.drools.compiler.lang.dsl.DSLTokenizedMappingFile.parseAndLoad()

        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>();
            }
View Full Code Here

Examples of org.drools.compiler.lang.dsl.DSLTokenizedMappingFile.parseAndLoad()

        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>();
            }
View Full Code Here

Examples of org.drools.compiler.lang.dsl.DSLTokenizedMappingFile.parseAndLoad()

        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>();
            }
View Full Code Here

Examples of org.drools.compiler.lang.dsl.DSLTokenizedMappingFile.parseAndLoad()

                stream = input.getStorage().getContents();
            }

            model = new NLGrammarModel();
            DSLMappingFile file = new DSLTokenizedMappingFile();
            file.parseAndLoad( new InputStreamReader( stream ) );
            model.addEntries( file.getMapping().getEntries() );
            stream.close();

        } catch ( CoreException e ) {
            throw new IllegalStateException( "Unable to load DSL configuration file. (CoreException: " + e.getMessage() + ")" );
View Full Code Here

Examples of org.drools.compiler.lang.dsl.DSLTokenizedMappingFile.parseAndLoad()

                Reader reader = DSLAdapter.getDSLContent(content, dslRuleEditor.getResource());
                if (reader == null) {
                    throw new IllegalArgumentException("Could not find dsl definition.");
                }
                DSLMappingFile mapping = new DSLTokenizedMappingFile();
                mapping.parseAndLoad(reader);
                reader.close();
                expander.addDSLMapping(mapping.getMapping());
                expander.expand(content);
                // if translation succeeds, change to drl viewer
                drlRuleViewer.setInput(getEditorInput());
View Full Code Here

Examples of org.drools.compiler.lang.dsl.DSLTokenizedMappingFile.parseAndLoad()

   
    /** This will load in the DSL config file, using the DSLMapping from drools-compiler */
    void readConfig(InputStream stream) throws IOException, CoreException {
        DSLTokenizedMappingFile file = new DSLTokenizedMappingFile();
        file.parseAndLoad(new InputStreamReader(stream));

        DSLMapping grammar = file.getMapping();
        List<DSLMappingEntry> conditions = grammar.getEntries( DSLMappingEntry.CONDITION );
        List<DSLMappingEntry> consequences = grammar.getEntries( DSLMappingEntry.CONSEQUENCE );
       
View Full Code Here

Examples of org.drools.compiler.lang.dsl.DSLTokenizedMappingFile.parseAndLoad()

    private List<ValidationMessage> doValidation( final String content ) {
        final List<ValidationMessage> validationMessages = new ArrayList<ValidationMessage>();
        final DSLTokenizedMappingFile dslLoader = new DSLTokenizedMappingFile();
        try {
            if ( !dslLoader.parseAndLoad( new StringReader( content ) ) ) {
                validationMessages.addAll( makeValidationMessages( dslLoader ) );
            }
            return validationMessages;

        } catch ( IOException e ) {
View Full Code Here

Examples of org.drools.compiler.lang.dsl.DSLTokenizedMappingFile.parseAndLoad()

            final List<String> rhs = new ArrayList<String>();
            final String dsl = ioService.readAllString( path );

            //Construct a dummy DRL file to parse index elements
            final DSLTokenizedMappingFile dslLoader = new DSLTokenizedMappingFile();
            if ( dslLoader.parseAndLoad( new StringReader( dsl ) ) ) {
                for ( DSLMappingEntry e : dslLoader.getMapping().getEntries() ) {
                    switch ( e.getSection() ) {
                        case CONDITION:
                            lhs.add( e.getValuePattern() );
                            break;
View Full Code Here

Examples of org.drools.compiler.lang.dsl.DSLTokenizedMappingFile.parseAndLoad()

       
        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 RuntimeException( "Error parsing and loading DSL file." + file.getErrors() );
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.