Package org.drools.guvnor.models.commons.shared.imports

Examples of org.drools.guvnor.models.commons.shared.imports.Imports


    public void testMultipleImportsContent() {
        final String content = ""
                + "import java.lang.String;\n"
                + "import java.lang.Double;\n";

        final Imports imports = ImportsParser.parseImports( content );
        assertNotNull( imports );
        assertEquals( 2,
                      imports.getImports().size() );
        assertEquals( "java.lang.String",
                      imports.getImports().get( 0 ).getType() );
        assertEquals( "java.lang.Double",
                      imports.getImports().get( 1 ).getType() );
    }
View Full Code Here


                + "#This is a comment\n"
                + "import java.lang.Double;\n"
                + "\n"
                + "import java.lang.Byte;\n";

        final Imports imports = ImportsParser.parseImports( content );
        assertNotNull( imports );
        assertEquals( 3,
                      imports.getImports().size() );
        assertEquals( "java.lang.String",
                      imports.getImports().get( 0 ).getType() );
        assertEquals( "java.lang.Double",
                      imports.getImports().get( 1 ).getType() );
        assertEquals( "java.lang.Byte",
                      imports.getImports().get( 2 ).getType() );
    }
View Full Code Here

    private ImportsParser() {

    }

    public static Imports parseImports(final String content) {
        Imports imports = new Imports();

        if (content == null || content.trim().equals("")) {
            return imports;
        } else {
            final String[] lines = content.split("\\n");

            for (int i = 0; i < lines.length; i++) {
                String line = lines[i].trim();
                if (!line.equals("") && !line.startsWith("#")) {
                    if (line.startsWith("import")) {
                        line = line.substring(6).trim();
                        if (line.endsWith(";")) {
                            line = line.substring(0, line.length() - 1);
                        }
                        imports.addImport(new Import(line));
                    }
                }
            }

            return imports;
View Full Code Here

        return m;
    }

    private void addImports( final RuleModel model,
                             final String drl ) {
        final Imports imports = ImportsParser.parseImports( drl );
        for ( Import item : imports.getImports() ) {
            model.getImports().addImport( item );
        }
    }
View Full Code Here

TOP

Related Classes of org.drools.guvnor.models.commons.shared.imports.Imports

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.