ILOG JRules

ilog.rules.xml.binding
Class IlrXmlHelper

java.lang.Object
  extended by ilog.rules.xml.binding.IlrXmlHelper

public class IlrXmlHelper
extends Object

This class contains some useful static methods to help parameterize and handle an XML data driver.


Nested Class Summary
static class IlrXmlHelper.Config
          Deprecated.  
 
Field Summary
static String XML_DIRECTORIES
          Deprecated.  
static String XML_DOC_PARSER_CLASS
          Resource name used to define the document parser class, which has to be an implementation of org.xml.sax.XMLReader.
static String XML_DOC_PARSER_OBJECT
          Deprecated.  
static String XML_ERROR_HANDLER_CLASS
          Resource name used to define the error handler class, which has to be an implementation of ilog.rules.xml.util.IlrXmlErrorHandler.
static String XML_ERROR_HANDLER_OBJECT
          Deprecated.  
static String XML_NS_EVALUATION
          Resource name used to define the namespace evaluation mode.
static String XML_SCHEMA_PARSER_CLASS
          Resource name used to define the schema parser class, which has to be an implementation of org.xml.sax.XMLReader.
static String XML_SCHEMA_PARSER_OBJECT
          Deprecated.  
static String XML_SCHEMA_RESOLVER_CLASS
          Resource name used to define the schema file resolver class, which is an implementation of ilog.rules.xml.util.IlrXsdLocationResolver).
static String XML_XOM_MAPPER
          Deprecated.  
static String XML_XOM_MAPPER_CLASS
          Resource name used to define the XML-XOM mapper class, which has to be an implementation of ilog.rules.xml.util.IlrXmlXomMapper.
 
Constructor Summary
IlrXmlHelper()
           
 
Method Summary
static IlrXmlObject assertXmlObject(IlrContext context, String xsdFile, String pckName, String xmlFile)
          Adds the XML object defined by its XML data file and its schema model description in a context.
static IlrXmlDataDriver createDataDriver(IlrContext context)
          Creates a new data driver from a context.
static IlrXmlDataDriver createDataDriver(IlrResources resources)
          Creates a new data driver given a list of parameters.
static IlrXmlDataDriver createDataDriver(IlrRuleset ruleset)
          Creates a new data driver from a ruleset.
static IlrXmlDataDriver createDataDriver(IlrXmlHelper.Config config)
          Deprecated.  
static String getCanonicalName(String name)
          Returns a canonical file name.
static IlrXmlNsResolver getNamespaceResolver(String defaultPackage)
          Returns a namespace resolver based on a unique default package.
static boolean mergeXoms(IlrReflect fromXom, IlrReflect toXom, IlrSelector selector)
          Merges two dynamic XOM properties.
static InputSource openFile(String fileName)
          Open a local file as a well-initialized InputSource instance.
static InputSource openFile(String fileName, IlrResources resource)
          Open a local file as a well-initialized InputSource instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

XML_SCHEMA_PARSER_OBJECT

public static final String XML_SCHEMA_PARSER_OBJECT
Deprecated. 
Resource name used to define a new XML parser.

See Also:
Constant Field Values

XML_DOC_PARSER_OBJECT

public static final String XML_DOC_PARSER_OBJECT
Deprecated. 
Resource name used to define a new XML parser.

See Also:
Constant Field Values

XML_ERROR_HANDLER_OBJECT

public static final String XML_ERROR_HANDLER_OBJECT
Deprecated. 
Resource name used to define a new XML parser.

See Also:
Constant Field Values

XML_DIRECTORIES

public static final String XML_DIRECTORIES
Deprecated. 
Resource name used to define the list of file directories.

See Also:
Constant Field Values

XML_XOM_MAPPER

public static final String XML_XOM_MAPPER
Deprecated. 
Resource name used to define the XML-XOM mapper instance.

See Also:
Constant Field Values

XML_NS_EVALUATION

public static final String XML_NS_EVALUATION
Resource name used to define the namespace evaluation mode.

See Also:
Constant Field Values

XML_SCHEMA_RESOLVER_CLASS

public static final String XML_SCHEMA_RESOLVER_CLASS
Resource name used to define the schema file resolver class, which is an implementation of ilog.rules.xml.util.IlrXsdLocationResolver).

See Also:
IlrXsdLocationResolver, Constant Field Values

XML_XOM_MAPPER_CLASS

public static final String XML_XOM_MAPPER_CLASS
Resource name used to define the XML-XOM mapper class, which has to be an implementation of ilog.rules.xml.util.IlrXmlXomMapper.

See Also:
IlrXmlXomMapper, Constant Field Values

XML_ERROR_HANDLER_CLASS

public static final String XML_ERROR_HANDLER_CLASS
Resource name used to define the error handler class, which has to be an implementation of ilog.rules.xml.util.IlrXmlErrorHandler.

See Also:
IlrXmlErrorHandler, Constant Field Values

XML_SCHEMA_PARSER_CLASS

public static final String XML_SCHEMA_PARSER_CLASS
Resource name used to define the schema parser class, which has to be an implementation of org.xml.sax.XMLReader.

See Also:
Constant Field Values

XML_DOC_PARSER_CLASS

public static final String XML_DOC_PARSER_CLASS
Resource name used to define the document parser class, which has to be an implementation of org.xml.sax.XMLReader.

See Also:
Constant Field Values
Constructor Detail

IlrXmlHelper

public IlrXmlHelper()
Method Detail

openFile

public static InputSource openFile(String fileName)
                            throws FileNotFoundException
Open a local file as a well-initialized InputSource instance.

Throws:
FileNotFoundException

openFile

public static InputSource openFile(String fileName,
                                   IlrResources resource)
                            throws FileNotFoundException
Open a local file as a well-initialized InputSource instance.

Throws:
FileNotFoundException

getCanonicalName

public static String getCanonicalName(String name)
Returns a canonical file name.

Parameters:
name - The URL of the file.
Returns:
the canonical file name.

getNamespaceResolver

public static IlrXmlNsResolver getNamespaceResolver(String defaultPackage)
Returns a namespace resolver based on a unique default package. Schema structures are translated into Java components included in this package.

Parameters:
defaultPackage - The default package of the translated Java class.
Returns:
the namespace resolver.

createDataDriver

public static IlrXmlDataDriver createDataDriver(IlrRuleset ruleset)
                                         throws IlrXmlErrorException
Creates a new data driver from a ruleset. The XOM is shared between the data driver and the ruleset.

Throws:
IlrXmlErrorException
Parameters:
ruleset - The ruleset from which to take a data driver.
Returns:
a new data driver.

createDataDriver

public static IlrXmlDataDriver createDataDriver(IlrContext context)
                                         throws IlrXmlErrorException
Creates a new data driver from a context. The XOM is shared between the data driver and the context.

Throws:
IlrXmlErrorException
Parameters:
context - The IlrContext from which to take a data driver.
Returns:
a new data driver.

assertXmlObject

public static IlrXmlObject assertXmlObject(IlrContext context,
                                           String xsdFile,
                                           String pckName,
                                           String xmlFile)
                                    throws IlrXmlErrorException,
                                           FileNotFoundException
Adds the XML object defined by its XML data file and its schema model description in a context.

Throws:
IlrXmlErrorException - when there are errors during the schema or the document file parsing.
FileNotFoundException - when the schema or the document file are not found.
Parameters:
context - The context where the object is recursively added.
xsdFile - The XSD file name defining the model of the object.
pckName - The package where the object's class is defined.
xmlFile - The XML data file that stores the XML objects.
Returns:
the added XML object.

mergeXoms

public static boolean mergeXoms(IlrReflect fromXom,
                                IlrReflect toXom,
                                IlrSelector selector)
Merges two dynamic XOM properties.

Parameters:
fromXom - The source XOM.
toXom - The final XOM.
selector - The selector to be applied. Can be null.
Returns:
the result of the merge.

createDataDriver

public static IlrXmlDataDriver createDataDriver(IlrResources resources)
                                         throws IlrXmlErrorException
Creates a new data driver given a list of parameters. When a parameter is null, the default is used to initialize the driver.

Throws:
IlrXmlErrorException
Returns:
the created driver.

createDataDriver

public static IlrXmlDataDriver createDataDriver(IlrXmlHelper.Config config)
                                         throws IlrXmlErrorException
Deprecated. 

Creates a new data driver given a list of parameters. When a parameter is null, the default is used to initialize the driver.

Throws:
IlrXmlErrorException
Returns:
the created driver.

ILOG JRules