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

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


    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( KEYWORD ) ) {
                        line = line.substring( KEYWORD.length() ).trim();
                        if ( line.endsWith( ";" ) ) {
                            line = line.substring( 0, line.length() - 1 );
                        }
                        imports.addImport( new Import( line ) );
                    }
                }
            }

            return imports;
View Full Code Here


*/
public class ImportsWriter {

    public static void write( final StringBuilder sb,
                              final HasImports model ) {
        final Imports imports = model.getImports();
        if ( imports == null ) {
            return;
        }
        sb.append( imports.toString() );
        if ( imports.getImports().size() > 0 ) {
            sb.append( "\n" );
        }
    }
View Full Code Here

        //De-serialize Package name
        final String packageName = PackageNameParser.parsePackageName( expandedDRLInfo.plainDrl );
        model.setPackageName( packageName );

        //De-serialize imports
        final Imports imports = ImportsParser.parseImports( expandedDRLInfo.plainDrl );
        for ( Import item : imports.getImports() ) {
            model.getImports().addImport( item );
        }

        boolean isJavaDialect = parseAttributes( model,
                                                 ruleDescr.getAttributes() );
View Full Code Here

    @Test
    public void testEmptyModel() {
        final HasImports model = new HasImports() {

            private Imports imports = new Imports();

            @Override
            public Imports getImports() {
                return imports;
            }
View Full Code Here

    public void testSingleImportModel() {
        final String expectedDrl = "import java.lang.String;\n\n";

        final HasImports model = new HasImports() {

            private Imports imports = new Imports();

            {
                imports.addImport( new Import( "java.lang.String" ) );
            }

            @Override
            public Imports getImports() {
                return imports;
View Full Code Here

                + "import java.lang.String;\n"
                + "import java.lang.Double;\n\n";

        final HasImports model = new HasImports() {

            private Imports imports = new Imports();

            {
                imports.addImport( new Import( "java.lang.String" ) );
                imports.addImport( new Import( "java.lang.Double" ) );
            }

            @Override
            public Imports getImports() {
                return imports;
View Full Code Here

    @Test
    public void testNullContent() {
        final String content = null;

        final Imports imports = ImportsParser.parseImports( content );
        assertNotNull( imports );
        assertTrue( imports.getImports().isEmpty() );
    }
View Full Code Here

    @Test
    public void testEmptyContent() {
        final String content = "";

        final Imports imports = ImportsParser.parseImports( content );
        assertNotNull( imports );
        assertTrue( imports.getImports().isEmpty() );
    }
View Full Code Here

    @Test
    public void testCommentedContent() {
        final String content = "#This is a comment";

        final Imports imports = ImportsParser.parseImports( content );
        assertNotNull( imports );
        assertTrue( imports.getImports().isEmpty() );
    }
View Full Code Here

    @Test
    public void testSingleImportContent() {
        final String content = "import java.lang.String;";

        final Imports imports = ImportsParser.parseImports( content );
        assertNotNull( imports );
        assertEquals( 1,
                      imports.getImports().size() );
        assertEquals( "java.lang.String",
                      imports.getImports().get( 0 ).getType() );
    }
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.