Package org.drools.lang.descr

Examples of org.drools.lang.descr.GlobalDescr


        assertEquals( 1,
                      pack.getImports().size() );
        assertEquals( 2,
                      pack.getGlobals().size() );

        final GlobalDescr foo = (GlobalDescr) pack.getGlobals().get( 0 );
        assertEquals( "java.lang.String",
                      foo.getType() );
        assertEquals( "foo",
                      foo.getIdentifier() );
        final GlobalDescr bar = (GlobalDescr) pack.getGlobals().get( 1 );
        assertEquals( "java.lang.Integer",
                      bar.getType() );
        assertEquals( "bar",
                      bar.getIdentifier() );
    }
View Full Code Here


                            }
                        }
                        // add globals
                        List globals = drlInfo.getPackageDescr().getGlobals();
                        for (Iterator iterator = globals.iterator(); iterator.hasNext();) {
                            GlobalDescr globalDescr = (GlobalDescr) iterator.next();
                            Global global = DroolsModelBuilder.addGlobal(
                                pkg, globalDescr.getIdentifier(), file, globalDescr.getStartCharacter(),
                                globalDescr.getEndCharacter() - globalDescr.getStartCharacter() + 1);
                            // create link between resource and created rule nodes
                            List droolsElements = (List) resourcesMap.get(file);
                            if (droolsElements == null) {
                                droolsElements = new ArrayList();
                                resourcesMap.put(file, droolsElements);
View Full Code Here

        if ( this.globals == null ) {
            this.globals = new ArrayList<GlobalDescr>( globalNames.length );
        }

        for (String globalName: globalNames) {
            this.globals.add(new GlobalDescr(globalName, "java.lang.Object"));
        }
    }
View Full Code Here

   
    private void loadGlobals() {
        String[] globalNames = process.getGlobalNames();
        this.globals = new ArrayList<GlobalDescr>(globalNames.length);
        for (String globalName: globalNames) {
            this.globals.add(new GlobalDescr(globalName, "java.lang.Object"));
        }
    }
View Full Code Here

                    }
                }
            }
            // globals
            for (Iterator iterator = packageDescr.getGlobals().iterator(); iterator.hasNext(); ) {
                GlobalDescr globalDescr = (GlobalDescr) iterator.next();
                if (globalDescr != null) {
                    BaseDescr result = getDescr(globalDescr, offset);
                    if (result != null) {
                        return result;
                    }
View Full Code Here

        assertEquals( 1,
                      pack.getImports().size() );
        assertEquals( 2,
                      pack.getGlobals().size() );

        final GlobalDescr foo = (GlobalDescr) pack.getGlobals().get( 0 );
        assertEquals( "java.lang.String",
                      foo.getType() );
        assertEquals( "foo",
                      foo.getIdentifier() );
        final GlobalDescr bar = (GlobalDescr) pack.getGlobals().get( 1 );
        assertEquals( "java.lang.Integer",
                      bar.getType() );
        assertEquals( "bar",
                      bar.getIdentifier() );
    }
View Full Code Here

                      impdescr.getEndCharacter() );

        assertEquals( 2,
                      pkg.getGlobals().size() );

        GlobalDescr global = pkg.getGlobals().get( 0 );
        assertEquals( "java.util.List<java.util.Map<String,Integer>>",
                      global.getType() );
        assertEquals( "aList",
                      global.getIdentifier() );
        assertEquals( source.indexOf( "global " + global.getType() ),
                      global.getStartCharacter() );
        assertEquals( source.indexOf( "global " + global.getType() + " " + global.getIdentifier() ) +
                              ("global " + global.getType() + " " + global.getIdentifier()).length(),
                      global.getEndCharacter() );

        global = pkg.getGlobals().get( 1 );
        assertEquals( "Integer",
                      global.getType() );
        assertEquals( "aNumber",
                      global.getIdentifier() );
        assertEquals( source.indexOf( "global " + global.getType() ),
                      global.getStartCharacter() );
        assertEquals( source.indexOf( "global " + global.getType() + " " + global.getIdentifier() ) +
                              ("global " + global.getType() + " " + global.getIdentifier()).length(),
                      global.getEndCharacter() );
    }
View Full Code Here

    private void populateGlobalInfo(final List jars) {

        // populating information for the globals
        for ( final Iterator it = pkgDescr.getGlobals().iterator(); it.hasNext(); ) {
            final GlobalDescr global = (GlobalDescr) it.next();
            try {
                final String shortTypeName = getShortNameOfClass( global.getType() );
                final Class< ? > clazz = loadClass( global.getType(),
                                                    jars );
                if ( !this.builder.hasFieldsForType( shortTypeName ) ) {

                    loadClassFields( clazz,
                                     shortTypeName );

                    this.builder.addGlobalType( global.getIdentifier(),
                                                shortTypeName );

                }
                if ( implementsCollection( clazz ) ) {
                    this.builder.addGlobalCollection( global.getIdentifier() );
                }
                this.builder.addGlobalType( global.getIdentifier(),
                                            shortTypeName );
            } catch ( final IOException e ) {
                this.errors.add( "Error while inspecting class for global: " + global.getType() + " error message: " + e.getMessage() );
            }

        }
    }
View Full Code Here

    private String processGlobalsList(final List globals) {
        String globalList = "";

        for ( final Iterator it = globals.iterator(); it.hasNext(); ) {
            final GlobalDescr global = (GlobalDescr) it.next();
            final String identifier = global.getIdentifier();
            final String type = global.getType();
            final String globalTemplate = "global " + type + " " + identifier + ";" + DrlDumper.eol;
            globalList += globalTemplate;
        }

        return globalList + DrlDumper.eol;
View Full Code Here

                      impdescr.getEndCharacter() );

        assertEquals( 2,
                      pkg.getGlobals().size() );

        GlobalDescr global = pkg.getGlobals().get( 0 );
        assertEquals( "java.util.List<java.util.Map<String,Integer>>",
                      global.getType() );
        assertEquals( "aList",
                      global.getIdentifier() );
        assertEquals( source.indexOf( "global " + global.getType() ),
                      global.getStartCharacter() );
        assertEquals( source.indexOf( "global " + global.getType() + " " + global.getIdentifier() ) +
                              ("global " + global.getType() + " " + global.getIdentifier()).length(),
                      global.getEndCharacter() );

        global = pkg.getGlobals().get( 1 );
        assertEquals( "Integer",
                      global.getType() );
        assertEquals( "aNumber",
                      global.getIdentifier() );
        assertEquals( source.indexOf( "global " + global.getType() ),
                      global.getStartCharacter() );
        assertEquals( source.indexOf( "global " + global.getType() + " " + global.getIdentifier() ) +
                              ("global " + global.getType() + " " + global.getIdentifier()).length(),
                      global.getEndCharacter() );
    }
View Full Code Here

TOP

Related Classes of org.drools.lang.descr.GlobalDescr

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.