Rule Execution Server API

ilog.rules.bom.serializer
Interface IlrSerializer

All Known Implementing Classes:
IlrAbstractSerializer, IlrJavaSerializer, IlrXMLSerializer

public interface IlrSerializer

This interface has methods to write an object model to an output stream and to read it back.


Method Summary
 ClassLoader getClassLoader()
          Returns the class loader set by a call to setClassLoader.
 String getName()
          Returns the serializer name
 boolean isCompactMode()
          Returns true if compact mode is enabled when writing an object model.
 boolean isJavaClassLookupEnabled()
          Returns true if Java class lookup is enabled when reading an object model definition.
 IlrDynamicObjectModel readObjectModel(Reader reader)
          Reads an object model from a reader.
 void setClassLoader(ClassLoader classLoader)
          Sets the class loader used by the serializer to define native classes.
 void setCompactMode(boolean compactMode)
          Sets compact mode to compactMode.
 void setJavaClassLookupEnabled(boolean flag)
          Enables or disables Java class lookup.
 void writeObjectModel(IlrObjectModel model, Writer writer)
          Writes an object model to a writer.
 void writeObjectModel(IlrObjectModel model, Writer writer, IlrSelector selector)
          Writes parts of an object model to a writer.
 void writeObjectModel(IlrObjectModel model, Writer writer, IlrSelector selector, Iterator initialTypes)
          Writes parts of an object model to a writer.
 

Method Detail

getName

String getName()
Returns the serializer name


getClassLoader

ClassLoader getClassLoader()
Returns the class loader set by a call to setClassLoader.


setClassLoader

void setClassLoader(ClassLoader classLoader)
Sets the class loader used by the serializer to define native classes. If the class loader is null then the Class.forName method is used to load classes.

Initially this property is null.


isJavaClassLookupEnabled

boolean isJavaClassLookupEnabled()
Returns true if Java class lookup is enabled when reading an object model definition. When enabled, classes declared as native are mapped to the corresponding Java class.

Initially this property is false.


setJavaClassLookupEnabled

void setJavaClassLookupEnabled(boolean flag)
Enables or disables Java class lookup.


isCompactMode

boolean isCompactMode()
Returns true if compact mode is enabled when writing an object model. When enabled classes bound to actual Java classes (those for which IlrType.getJavaClass has a non null return value) are not written to the output stream by the writeObjectModel method.

Note that when reading streams that were produced in compact mode, Java class lookup must be enabled (see setJavaClassLookupEnabled.

Initially this property is not enabled.


setCompactMode

void setCompactMode(boolean compactMode)
Sets compact mode to compactMode.


writeObjectModel

void writeObjectModel(IlrObjectModel model,
                      Writer writer)
                      throws IOException
Writes an object model to a writer.

Throws:
IOException - if an I/O error occurs
Parameters:
model - an object model

writeObjectModel

void writeObjectModel(IlrObjectModel model,
                      Writer writer,
                      IlrSelector selector)
                      throws IOException
Writes parts of an object model to a writer. The selector

For a model element to be serialized it must be accepted by the selector along with all other model elements on which it depends.

It follows that if the given selector rejects a class (say C) but accepts an attribute of another class having type C then the attribute will not be serialized since its type has been rejected. The same goes for methods with respect to their parameter types, return type and exception types and also for classes with respect to their superclasses and superinterfaces.

Throws:
IOException - if an I/O error occurs
Parameters:
model - an object model
writer - a writer
selector - a selector which specifies which elements of the object model will be serialized. If null the object model is completely serialized.

writeObjectModel

void writeObjectModel(IlrObjectModel model,
                      Writer writer,
                      IlrSelector selector,
                      Iterator initialTypes)
                      throws IOException
Writes parts of an object model to a writer. The selector

This method writes the classes and enums given by the initialTypes iterator along with their members (attributes, methods and tags). Other types, not present in initialTypes but indirectly required (such as the types of attribute, etc...) are also written but their members are omitted.

Note that for a model element to be serialized it must also be accepted by the given selector along with all other model elements on which it depends.

It is recommended to use IlrSelectors.dynamicTypes(model) as the value of the initialTypes parameter so that classes bound to actual Java classes are not serialized.

Throws:
IOException
Parameters:
model - an object model
writer - a writer
selector - an object model subset selector. If null, then IlrSelectors.AllElements is used.
initialTypes - an iterator which iterates over the classes and enums that must be fully serialized.

readObjectModel

IlrDynamicObjectModel readObjectModel(Reader reader)
                                      throws IOException,
                                             IlrSyntaxError
Reads an object model from a reader.

Throws:
IOException - if an I/O error occurs
IlrSyntaxError - if a syntax error occurs
Parameters:
reader - a reader.

Rule Execution Server API

© Copyright IBM Corp. 1987, 2013