org.kie.internal.builder

## Class KnowledgeBuilderFactory

- java.lang.Object
- - org.kie.internal.builder.KnowledgeBuilderFactory

-     public class KnowledgeBuilderFactory
      extends Object

  This factory is used to build the knowledge base resources that are held collectively in KnowledgePackages. The KnowledgePackage also provides the role of 'namespacing'. An optional KnowlegeBuilderConfiguration can be supplied. The KnowledgeBuilderConfiguration is itself created from this factory. The KnowledgeBuilderConfiguration allows you to set the ClassLoader to be used along with other setting like the default dialect and compiler, as well as many other options.

       KnowledgeBuilder kbuilder = KnowlegeBuilderFactory.newKnowledgeBuilder();

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `KnowledgeBuilderFactory()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static DecisionTableConfiguration` | `newDecisionTableConfiguration()` DecisionTable resources require a ResourceConfiguration, that configuration instance is created here.
    `static JaxbConfiguration` | `newJaxbConfiguration(com.sun.tools.xjc.Options xjcOpts, String systemId)`
    `static KnowledgeBuilder` | `newKnowledgeBuilder()` Create and return a new KnowledgeBuilder, using the default KnowledgeBuilderConfigurations
    `static KnowledgeBuilder` | `newKnowledgeBuilder(org.kie.api.KieBase kbase)`
    `static KnowledgeBuilder` | `newKnowledgeBuilder(org.kie.api.KieBase kbase, KnowledgeBuilderConfiguration conf)`
    `static KnowledgeBuilder` | `newKnowledgeBuilder(KnowledgeBuilderConfiguration conf)` Create and return a new KnowledgeBuilder, using he given KnowledgeBuilderConfigurations
    `static KnowledgeBuilderConfiguration` | `newKnowledgeBuilderConfiguration()` Create a KnowledgeBuilderConfiguration on which properties can be set.
    `static KnowledgeBuilderConfiguration` | `newKnowledgeBuilderConfiguration(Properties properties, ClassLoader... classLoaders)` Create a KnowledgeBuilderConfiguration on which properties can be set.
    `static ScoreCardConfiguration` | `newScoreCardConfiguration()` ResourceConfiguration for score cards.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### KnowledgeBuilderFactory

          public KnowledgeBuilderFactory()

  - ### Method Detail

    - #### newKnowledgeBuilder

          public static KnowledgeBuilder newKnowledgeBuilder()

      Create and return a new KnowledgeBuilder, using the default KnowledgeBuilderConfigurations
      Returns:
        The KnowledgeBuilder

    - #### newKnowledgeBuilder

          public static KnowledgeBuilder newKnowledgeBuilder(KnowledgeBuilderConfiguration conf)

      Create and return a new KnowledgeBuilder, using he given KnowledgeBuilderConfigurations
      Returns:
        The KnowledgeBuilder

    - #### newKnowledgeBuilder

          public static KnowledgeBuilder newKnowledgeBuilder(org.kie.api.KieBase kbase)

    - #### newKnowledgeBuilder

          public static KnowledgeBuilder newKnowledgeBuilder(org.kie.api.KieBase kbase,
                                                             KnowledgeBuilderConfiguration conf)

    - #### newKnowledgeBuilderConfiguration

          public static KnowledgeBuilderConfiguration newKnowledgeBuilderConfiguration()

      Create a KnowledgeBuilderConfiguration on which properties can be set.
      Returns:
        The KnowledgeBuilderConfiguration.

    - #### newKnowledgeBuilderConfiguration

          public static KnowledgeBuilderConfiguration newKnowledgeBuilderConfiguration(Properties properties,
                                                                                       ClassLoader... classLoaders)

      Create a KnowledgeBuilderConfiguration on which properties can be set. Use the given properties file and ClassLoader - either of which can be null.
      Returns:
        The KnowledgeBuilderConfiguration.

    - #### newDecisionTableConfiguration

          public static DecisionTableConfiguration newDecisionTableConfiguration()

      DecisionTable resources require a ResourceConfiguration, that configuration instance is created here. Note that if you are passing a Reader, you must use an InputStreamReader so the encoding can be determined.

           KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
           DecisionTableConfiguration dtconf = KnowledgeBuilderFactory.newDecisionTableConfiguration();
           dtconf.setInputType( DecisionTableInputType.XLS );
           dtconf.setWorksheetName( "Tables_2" );
           kbuilder.add( new URL( "file://IntegrationExampleTest.xls" ),
                                 ResourceType.DTABLE,
                                 dtconf );
           assertFalse( kbuilder.hasErrors() );
           KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();

      Returns:

    - #### newScoreCardConfiguration

          public static ScoreCardConfiguration newScoreCardConfiguration()

      ResourceConfiguration for score cards. It allows for the worksheet name to be specified.

      Simple example showing how to build a KnowledgeBase from an XLS resource.

           KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
           ScoreCardConfiguration scconf = KnowledgeBuilderFactory.newScoreCardConfiguration();
           scconf.setWorksheetName( "Tables_2" );
           kbuilder.add( ResourceFactory.newUrlResource( "file://IntegrationExampleTest.xls" ),
                         ResourceType.SCARD,
                         scconf );
           assertFalse( kbuilder.hasErrors() );
           KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();

    - #### newJaxbConfiguration

          public static JaxbConfiguration newJaxbConfiguration(com.sun.tools.xjc.Options xjcOpts,
                                                               String systemId)

Copyright © 2001–2020 JBoss by Red Hat. All rights reserved.