Rule Execution Server API

ilog.rules.xml.binding
Class IlrXmlDefaultDataDriver

java.lang.Object
  extended by ilog.rules.xml.binding.IlrXmlDefaultSchemaDriver
      extended by ilog.rules.xml.binding.IlrXmlDefaultDataDriver
All Implemented Interfaces:
IlrXmlDataDriver, IlrXmlDocumentDriver, IlrXmlSchemaDriver

public class IlrXmlDefaultDataDriver
extends IlrXmlDefaultSchemaDriver
implements IlrXmlDataDriver

This class is the default implementation of the IlrXmlDataDriver interface. It translates an XML Schema to an eXecution Object Model (XOM). It then loads an XML data file and represents it as an IlrXmlObject. It also saves an IlrXmlObject as an XML data file.

The XML driver creation may be parametrized by a configuration resource file. The resource file can set the XML parser, the list of XML directories scanned by the parser, and the inner class policy.

See Also:
IlrXmlObject, IlrXmlModel, IlrXmlErrorException, IlrReflect

Constructor Summary
IlrXmlDefaultDataDriver()
          Builds an instance with an empty default object model.
IlrXmlDefaultDataDriver(IlrReflect model)
          Builds an instance based on an external object model.
IlrXmlDefaultDataDriver(IlrReflect model, IlrResources resources)
          Builds an instance with an object model and a resource file.
IlrXmlDefaultDataDriver(IlrResources resources)
          Builds an instance with an empty default object model.
 
Method Summary
static void assertObjects(IlrXmlObject object, IlrContext context, String[] classNames)
          Asserts XML Objects of a tree in a context.
 void end()
          Disposes properly the allocated memory.
 IlrXmlModel getXmlModel()
          Gets the reflection model over dynamic class and instances.
 IlrXmlObject readObject(InputStream objectIs)
          Reads an XML document to create an IlrXmlObject Java instance given the mapping contained in the driver model.
 IlrXmlObject readObject(Reader objectReader)
          Reads an XML document to create an IlrXmlObject Java instance given the mapping contained in the driver model.
 void setModel(IlrReflect model, boolean resetErrors)
          Sets a new object model for the driver.
 void writeObject(IlrXmlObject object, Writer objectWriter)
          Writes an IlrXmlObject instance as an XML document given the Java/XML mapping defined in the driver object model.
 
Methods inherited from class ilog.rules.xml.binding.IlrXmlDefaultSchemaDriver
createDocumentDriver, getErrors, getModel, getWarnings, loadModel, loadModel, loadModels, setModel
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface ilog.rules.xml.IlrXmlSchemaDriver
createDocumentDriver, getErrors, getModel, getWarnings, loadModel, loadModel, loadModels, setModel
 
Methods inherited from interface ilog.rules.xml.IlrXmlDocumentDriver
getErrors, getModel, getWarnings, readObject
 

Constructor Detail

IlrXmlDefaultDataDriver

public IlrXmlDefaultDataDriver()
                        throws IlrXmlErrorException
Builds an instance with an empty default object model.

Throws:
IlrXmlErrorException - when the building is impossible.

IlrXmlDefaultDataDriver

public IlrXmlDefaultDataDriver(IlrResources resources)
                        throws IlrXmlErrorException
Builds an instance with an empty default object model.

Throws:
IlrXmlErrorException - if the building fails.
Parameters:
resources - Used to initialize the driver.

IlrXmlDefaultDataDriver

public IlrXmlDefaultDataDriver(IlrReflect model)
                        throws IlrXmlErrorException
Builds an instance based on an external object model. The model resources, if they exist, are processed to set up the driver.

Throws:
IlrXmlErrorException - if the building fails.
Parameters:
model - The object model to be used by the driver.

IlrXmlDefaultDataDriver

public IlrXmlDefaultDataDriver(IlrReflect model,
                               IlrResources resources)
                        throws IlrXmlErrorException
Builds an instance with an object model and a resource file.

Throws:
IlrXmlErrorException - if the building fails.
Parameters:
model - The XOM.
resources - Used to initialize the driver.
Method Detail

setModel

public void setModel(IlrReflect model,
                     boolean resetErrors)
              throws IlrXmlErrorException
Sets a new object model for the driver.

Throws:
IlrXmlErrorException - thrown when the model is invalid
Parameters:
model - the new driver object model.

readObject

public IlrXmlObject readObject(Reader objectReader)
                        throws IlrXmlErrorException
Reads an XML document to create an IlrXmlObject Java instance given the mapping contained in the driver model.

Specified by:
readObject in interface IlrXmlDocumentDriver
Throws:
IlrXmlErrorException - thrown when the reading fails.
Parameters:
objectReader - The reader containing the XML document.
Returns:
the Java instance related to the XML information.

readObject

public IlrXmlObject readObject(InputStream objectIs)
                        throws IlrXmlErrorException
Reads an XML document to create an IlrXmlObject Java instance given the mapping contained in the driver model.

Specified by:
readObject in interface IlrXmlDocumentDriver
Throws:
IlrXmlErrorException - thrown when the reading fails.
Parameters:
objectIs - The input stream containing the XML document.
Returns:
the Java instance related to the XML information.

writeObject

public void writeObject(IlrXmlObject object,
                        Writer objectWriter)
                 throws IlrXmlErrorException
Writes an IlrXmlObject instance as an XML document given the Java/XML mapping defined in the driver object model.

Specified by:
writeObject in interface IlrXmlDocumentDriver
Throws:
IlrXmlErrorException - thrown when the writing fails.
Parameters:
object - The default object to be written.
objectWriter - The XML document writer.

assertObjects

public static void assertObjects(IlrXmlObject object,
                                 IlrContext context,
                                 String[] classNames)
                          throws IlrXmlErrorException
Asserts XML Objects of a tree in a context.

Throws:
IlrXmlErrorException - when a class does not belong to the context model.
Parameters:
object - The object root.
context - The context where the objects are asserted.
classNames - The class name to be explored or asserted. If null, the default class is explored and asserted.
See Also:
IlrXmlObjectAsserter

end

public void end()
Disposes properly the allocated memory.

Specified by:
end in interface IlrXmlDocumentDriver
Specified by:
end in interface IlrXmlSchemaDriver
Overrides:
end in class IlrXmlDefaultSchemaDriver

getXmlModel

public IlrXmlModel getXmlModel()
Gets the reflection model over dynamic class and instances.

Specified by:
getXmlModel in interface IlrXmlDocumentDriver
Specified by:
getXmlModel in interface IlrXmlSchemaDriver
Overrides:
getXmlModel in class IlrXmlDefaultSchemaDriver

Rule Execution Server API

© Copyright IBM Corp. 1987, 2013