Class RMXMLWriter

java.lang.Object
com.inductiveautomation.rm.base.RMXMLWriter

public class RMXMLWriter extends 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").

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new xml writer.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected RMSchemaMaker
    Creates a new schema maker.
    boolean
    Returns whether to include fields.
    int
    Returns the next unique id for given property.
    Returns the schema.
    Returns the schema maker.
    boolean
    Returns whether to only use getX/isX accessor methods (as opposed to any method returning a value).
    getXML(Object anObj, Schema aSchema, int aDegreeOfSeparation)
    Returns an element tree for given collections map and schema.
    getXML(Object anObj, Object userInfo, int degreeOfSeparation)
    Returns an xml RXElement tree for given Java dataset and optional userInfo, out to given degree of separation.
    void
    Tells writer to ignore any member of the given class from the serialized object graph.
    void
    ignoreClass(String aClassName)
    Tells writer to ignore any member of the given class name from the serialized object graph.
    void
    ignoreMember(Class aClass, String aName)
    Tells writer to ignore any member with the given class - member combination.
    void
    ignoreMember(String aFieldName)
    Tells writer to ignore any member with the given method/field name from the serialized object graph.
    void
    ignoreMember(String aClassName, String aName)
    Tells writer to ignore any member with the given classname - member combination.
    void
    setIncludeFields(boolean aFlag)
    Sets whether to include fields.
    void
    Sets whether to only use getX/isX accessor methods (as opposed to any method returning a value).
    void
    writeObject(Object anObj, Object userInfo, String aPath, int degreeOfSeparation)
    Writes given Java dataset and optional userInfo to given path as XML, out to given degree of separation.
    void
    writeObject(Object anObj, String aPath)
    Writes given Java dataset to given path as XML, out to three levels deep, which is default degree of separation.
    void
    writeObject(Object anObj, String aPath, int dos)
    Writes given Java dataset to given path as XML, out to given degree of separation.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • RMXMLWriter

      public RMXMLWriter()
      Creates a new xml writer.
  • Method Details

    • getSchemaMaker

      public RMSchemaMaker getSchemaMaker()
      Returns the schema maker.
    • createSchemaMaker

      protected RMSchemaMaker createSchemaMaker()
      Creates a new schema maker.
    • getUseGetAndIsMethodsOnly

      public boolean getUseGetAndIsMethodsOnly()
      Returns whether to only use getX/isX accessor methods (as opposed to any method returning a value).
    • setUseGetAndIsMethodsOnly

      public void setUseGetAndIsMethodsOnly(boolean aFlag)
      Sets whether to only use getX/isX accessor methods (as opposed to any method returning a value).
    • getIncludeFields

      public boolean getIncludeFields()
      Returns whether to include fields.
    • setIncludeFields

      public void setIncludeFields(boolean aFlag)
      Sets whether to include fields.
    • ignoreClass

      public void ignoreClass(Class aClass)
      Tells writer to ignore any member of the given class from the serialized object graph.
    • ignoreClass

      public void ignoreClass(String aClassName)
      Tells writer to ignore any member of the given class name from the serialized object graph.
    • ignoreMember

      public void ignoreMember(String aFieldName)
      Tells writer to ignore any member with the given method/field name from the serialized object graph.
    • ignoreMember

      public void ignoreMember(Class aClass, String aName)
      Tells writer to ignore any member with the given class - member combination.
    • ignoreMember

      public void ignoreMember(String aClassName, String aName)
      Tells writer to ignore any member with the given classname - member combination.
    • writeObject

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

      public void writeObject(Object anObj, String aPath, int dos)
      Writes given Java dataset to given path as XML, out to given degree of separation.
    • writeObject

      public void writeObject(Object anObj, Object userInfo, String aPath, int degreeOfSeparation)
      Writes given Java dataset and optional userInfo to given path as XML, out to given degree of separation.
    • getXML

      public RXElement getXML(Object anObj, Object userInfo, int degreeOfSeparation)
      Returns an xml RXElement tree for given Java dataset and optional userInfo, out to given degree of separation.
    • getXML

      public RXElement getXML(Object anObj, Schema aSchema, int aDegreeOfSeparation)
      Returns an element tree for given collections map and schema.
    • getSchema

      public Schema getSchema()
      Returns the schema.
    • getPropertyNextUniqueID

      public int getPropertyNextUniqueID(Property aProperty)
      Returns the next unique id for given property.