ReportMill 7.0 API

com.reportmill.foundation
Class RMXMLWriter

java.lang.Object
  extended bycom.reportmill.foundation.RMXMLWriter

public class RMXMLWriter
extends java.lang.Object

This class turns any Java dataset into XML. The most common use of this class is simply the writeObject() method, which takes a Java dataset and results in a very clean XML description (at the given path):

   new RMXMLWriter().writeObject(myObjects, "MyDataset.xml");
 

The Java dataset can take almost any form: a list, map or hierarchy of EJBs, custom Java classes, Java collections classes or even JDBC ResultSets. The resulting XML file is a very clean description of all the public fields, methods and keys/values in the dataset (out to three levels deep, which is the default "degree of separation").

RMXMLWriter performs its conversion in two steps, first abstracting the object into Java Collections and core types using RMMapMaker, then writing the abstraction to XML.

This code currently supports entity subclasses (eg, Vehicle->Car, Vehicle->Truck) by folding them into their base class (eg, Vehicle). A future version might consider buiding an RMSchema that includes an entity "parent" attribute, so that a hierarchy of entities could be mapped instead of just a list. Subtype's would then refer to the base class for a given relation, and each member of the relation would have to specify it's "Class" if different from base.

Copyright (c) 2004 ReportMill Software, Inc. All Rights Reserved. Contact ReportMill .


Field Summary
static java.lang.String TAG_ID
           
static java.lang.String TAG_SCHEMA
           
 
Constructor Summary
RMXMLWriter()
          Creates a basic instance of RMXMLWriter.
 
Method Summary
 boolean forceIds()
          ForceIds is used to determine if every written entity should automatically have "id" tag
 boolean ignore(java.lang.String aName)
          Ignore Class, Field, Method - these methods provide a way to trim unwanted parts from an object graph
 void ignoreClass(java.lang.Class aClass)
          Ignore Class, Field, Method - these methods provide a way to trim unwanted parts from an object graph
 void ignoreClass(java.lang.String aClassName)
          Ignore Class, Field, Method - these methods provide a way to trim unwanted parts from an object graph
 void ignoreMember(java.lang.String aFieldName)
          Ignore Class, Field, Method - these methods provide a way to trim unwanted parts from an object graph
 boolean includeSublassNames()
          IncludeSubclassNames makes XML include "Class" attribute when class differs from schema (subclasses only)
 void setForceIds(boolean aFlag)
          ForceIds is used to determine if every written entity should automatically have "id" tag
 void setIncludeSubclassNames(boolean aFlag)
          IncludeSubclassNames makes XML include "Class" attribute when class differs from schema (subclasses only)
 void setUseShortClassNames(boolean aFlag)
          UseShortClassNames can make XML prettier - don't use if full classpath is needed (or if duplicate class names)
 boolean useShortClassNames()
          UseShortClassNames can make XML prettier - don't use if full classpath is needed (or if duplicate class names)
 void writeObject(java.lang.Object anObj, java.lang.Object userInfo, java.lang.String aPath, int degreeOfSeparation)
          Writes the given Java dataset to the given path as XML, out to the number of levels deep provided (the "degree of separation").
 void writeObject(java.lang.Object anObj, java.lang.String aPath)
          Writes the given Java dataset to the given path as XML, out to the three levels deep, which is the default "degree of separation".
 void writeObject(java.lang.Object anObj, java.lang.String aPath, int dos)
          Writes the given Java dataset to the given path as XML, out to the number of levels deep provided (the "degree of separation").
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TAG_SCHEMA

public static final java.lang.String TAG_SCHEMA
See Also:
Constant Field Values

TAG_ID

public static final java.lang.String TAG_ID
See Also:
Constant Field Values
Constructor Detail

RMXMLWriter

public RMXMLWriter()
Creates a basic instance of RMXMLWriter.

Method Detail

forceIds

public boolean forceIds()
ForceIds is used to determine if every written entity should automatically have "id" tag


setForceIds

public void setForceIds(boolean aFlag)
ForceIds is used to determine if every written entity should automatically have "id" tag


includeSublassNames

public boolean includeSublassNames()
IncludeSubclassNames makes XML include "Class" attribute when class differs from schema (subclasses only)


setIncludeSubclassNames

public void setIncludeSubclassNames(boolean aFlag)
IncludeSubclassNames makes XML include "Class" attribute when class differs from schema (subclasses only)


useShortClassNames

public boolean useShortClassNames()
UseShortClassNames can make XML prettier - don't use if full classpath is needed (or if duplicate class names)


setUseShortClassNames

public void setUseShortClassNames(boolean aFlag)
UseShortClassNames can make XML prettier - don't use if full classpath is needed (or if duplicate class names)


ignoreClass

public void ignoreClass(java.lang.Class aClass)
Ignore Class, Field, Method - these methods provide a way to trim unwanted parts from an object graph


ignoreClass

public void ignoreClass(java.lang.String aClassName)
Ignore Class, Field, Method - these methods provide a way to trim unwanted parts from an object graph


ignoreMember

public void ignoreMember(java.lang.String aFieldName)
Ignore Class, Field, Method - these methods provide a way to trim unwanted parts from an object graph


ignore

public boolean ignore(java.lang.String aName)
Ignore Class, Field, Method - these methods provide a way to trim unwanted parts from an object graph


writeObject

public void writeObject(java.lang.Object anObj,
                        java.lang.String aPath)
Writes the given Java dataset to the given path as XML, out to the three levels deep, which is the default "degree of separation".


writeObject

public void writeObject(java.lang.Object anObj,
                        java.lang.String aPath,
                        int dos)
Writes the given Java dataset to the given path as XML, out to the number of levels deep provided (the "degree of separation").


writeObject

public void writeObject(java.lang.Object anObj,
                        java.lang.Object userInfo,
                        java.lang.String aPath,
                        int degreeOfSeparation)
Writes the given Java dataset to the given path as XML, out to the number of levels deep provided (the "degree of separation").


ReportMill 7.0 API