Rule Execution Server API

ilog.rules.bom.serializer
Class IlrJavaSerializer

java.lang.Object
  extended by ilog.rules.bom.serializer.IlrAbstractSerializer
      extended by ilog.rules.bom.serializer.IlrJavaSerializer
All Implemented Interfaces:
IlrSerializer

public class IlrJavaSerializer
extends IlrAbstractSerializer

A serializer which uses a Java-like syntax to serialize object model.


Field Summary
static String Name
          The name of the serializer (the string bom_java).
 
Constructor Summary
IlrJavaSerializer()
           
 
Method Summary
 String getName()
          Returns the serializer name
 void readObjectModel(IlrMutableObjectModel model, Reader reader)
          Reads object model elements from a reader and adds them into an existing object model.
 IlrDynamicObjectModel readObjectModel(Reader reader)
          Reads an object model from a reader.
 void writeObjectModel(IlrObjectModel objectModel, Writer writer)
          Writes an object model to a writer.
 void writeObjectModel(IlrObjectModel objectModel, Writer writer, IlrSelector selector)
          Writes parts of an object model to a writer.
 void writeObjectModel(IlrObjectModel objectModel, Writer writer, IlrSelector selector, Iterator initialTypes)
          Writes parts of an object model to a writer.
 void writePartialObjectModel(IlrObjectModel objectModel, Writer writer, IlrSelector selector)
           
 
Methods inherited from class ilog.rules.bom.serializer.IlrAbstractSerializer
getClassLoader, isCompactMode, isJavaClassLookupEnabled, setClassLoader, setCompactMode, setJavaClassLookupEnabled
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

Name

public static final String Name
The name of the serializer (the string bom_java).

See Also:
Constant Field Values
Constructor Detail

IlrJavaSerializer

public IlrJavaSerializer()
Method Detail

getName

public final String getName()
Returns the serializer name


writeObjectModel

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

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

writeObjectModel

public void writeObjectModel(IlrObjectModel objectModel,
                             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:
objectModel - 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

public void writeObjectModel(IlrObjectModel objectModel,
                             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:
objectModel - 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.

writePartialObjectModel

public void writePartialObjectModel(IlrObjectModel objectModel,
                                    Writer writer,
                                    IlrSelector selector)
                             throws IOException
Throws:
IOException

readObjectModel

public 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.

readObjectModel

public void readObjectModel(IlrMutableObjectModel model,
                            Reader reader)
                     throws IOException,
                            IlrSyntaxError
Reads object model elements from a reader and adds them into an existing object model.

Since:
JRules 5.0
Throws:
IOException - If an I/O error occurs.
IlrSyntaxError - If a syntax error occurs.
Parameters:
model - The objet model.
reader - The reader.

Rule Execution Server API

© Copyright IBM Corp. 1987, 2012