org.drools.ide.common.server.rules
Class SuggestionCompletionLoader

java.lang.Object
  extended by org.drools.ide.common.server.rules.SuggestionCompletionLoader
All Implemented Interfaces:
ClassToGenericClassConverter

public class SuggestionCompletionLoader
extends Object
implements ClassToGenericClassConverter

This utility class loads suggestion completion stuff for the package configuration, introspecting from models, templates etc.

This also includes DSL stuff, basically, everything you need to get started with a package. It also validates the package configuration, and can provide errors.

This does NOT validate assets in the package, other then to load up DSLs, models etc as needed.

FYI: the tests for this are in the BRMS module, in context of a full BRMS.


Nested Class Summary
static interface SuggestionCompletionLoader.ExternalImportDescrProvider
          Interface used for add external ImportDescr added to SuggestionCompletionEngine Use this to add Fact Types that are not imported by the package.
 
Constructor Summary
SuggestionCompletionLoader()
          This uses the current classes classloader as a base, and jars can be added.
SuggestionCompletionLoader(ClassLoader classLoader)
          This allows a pre existing classloader to be used (and preferred) for resolving types.
 
Method Summary
 void addExternalImportDescrProvider(SuggestionCompletionLoader.ExternalImportDescrProvider provider)
           
 List<String> getErrors()
          Returns a list of String errors.
 Set<org.drools.lang.descr.ImportDescr> getExternalImportDescrs()
           
 String getShortNameOfClass(String clazz)
           
 SuggestionCompletionEngine getSuggestionEngine(String header, List<JarInputStream> jars, List<org.drools.lang.dsl.DSLTokenizedMappingFile> dsls)
          This will validate, and generate a new engine, ready to go.
 SuggestionCompletionEngine getSuggestionEngine(String header, List<JarInputStream> jars, List<org.drools.lang.dsl.DSLTokenizedMappingFile> dsls, List<String> dataEnums)
          This will validate, and generate a new engine, ready to go.
 boolean hasErrors()
           
 List<String> removeIrrelevantFields(Collection<String> fields)
          This will remove the unneeded "fields" that come from java.lang.Object these are really not needed for the modeller.
 String translateClassToGenericType(Class<?> type)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SuggestionCompletionLoader

public SuggestionCompletionLoader()
This uses the current classes classloader as a base, and jars can be added.


SuggestionCompletionLoader

public SuggestionCompletionLoader(ClassLoader classLoader)
This allows a pre existing classloader to be used (and preferred) for resolving types.

Method Detail

getSuggestionEngine

public SuggestionCompletionEngine getSuggestionEngine(String header,
                                                      List<JarInputStream> jars,
                                                      List<org.drools.lang.dsl.DSLTokenizedMappingFile> dsls)
This will validate, and generate a new engine, ready to go. If there are errors, you can get them by doing getMissingClasses();

Parameters:
header - The package configuration file content.
jars - a list of jars to look inside (pass in empty array if not needed) this is a list of JarInputStream
dsls - any dsl files. This is a list of DSLMappingFile.
Returns:
A SuggestionCompletionEngine ready to be used in anger.

getSuggestionEngine

public SuggestionCompletionEngine getSuggestionEngine(String header,
                                                      List<JarInputStream> jars,
                                                      List<org.drools.lang.dsl.DSLTokenizedMappingFile> dsls,
                                                      List<String> dataEnums)
This will validate, and generate a new engine, ready to go. If there are errors, you can get them by doing getMissingClasses();

Parameters:
header - The package configuration file content.
jars - a list of jars to look inside (pass in empty array if not needed) this is a list of JarInputStream
dsls - any dsl files. This is a list of DSLMappingFile.
dataEnums - this is a list of String's which hold data enum definitions. (normally will be just one, but for completeness can load multiple).
Returns:
A SuggestionCompletionEngine ready to be used in anger.

getShortNameOfClass

public String getShortNameOfClass(String clazz)

removeIrrelevantFields

public List<String> removeIrrelevantFields(Collection<String> fields)
This will remove the unneeded "fields" that come from java.lang.Object these are really not needed for the modeller.


translateClassToGenericType

public String translateClassToGenericType(Class<?> type)
Specified by:
translateClassToGenericType in interface ClassToGenericClassConverter
Returns:

addExternalImportDescrProvider

public void addExternalImportDescrProvider(SuggestionCompletionLoader.ExternalImportDescrProvider provider)

getExternalImportDescrs

public Set<org.drools.lang.descr.ImportDescr> getExternalImportDescrs()

hasErrors

public boolean hasErrors()
Returns:
true if there were errors when processing the package.

getErrors

public List<String> getErrors()
Returns a list of String errors.



Copyright © 2001-2012 JBoss by Red Hat. All Rights Reserved.