ca.macewan.ims.enterprise.io
Class IMSEnterpriseBuilder

java.lang.Object
  extended byca.macewan.ims.enterprise.io.IMSEnterpriseProcessor
      extended byca.macewan.ims.enterprise.io.IMSEnterpriseExportProcessor
          extended byca.macewan.ims.enterprise.io.IMSEnterpriseBuilder

public class IMSEnterpriseBuilder
extends ca.macewan.ims.enterprise.io.IMSEnterpriseExportProcessor

IMSEnterpriseBuilder lets you write an IMS enterprise XML file as a series of top level elements. This is as opposed to the IMSEnterpriseWriter class, which writes an entire IMS enterprise XML document in one write action. The advantages of this builder as opposed to the writer class are mainly in terms of resource management and flexibility.

IMSEnterpriseBuilder builder = new IMSEnterpriseBuilder(someOutputStream);
builder.writeComments(comments);
builder.writePerson(person);
...
builder.endDocument();
 
The builder must finish with a call to endDocument, or else the closing </enterprise> tag won't be written and the resulting XML file will be invalid.

Version:
0.1
Author:
Erwin Veugelers

Constructor Summary
IMSEnterpriseBuilder(OutputStream out)
          Creates an IMSEnterpriseBuilder with the given output stream, and using the default system JSR173 XMLOutputFactory class for writing the XML document.
IMSEnterpriseBuilder(String writerClass, OutputStream out)
          Creates an IMSEnterpriseBuilder where the writerClass argument is used to specify the JSR173 XMLOutputFactory class to be used.
IMSEnterpriseBuilder(String writerClass, Writer out)
          Creates an IMSEnterpriseBuilder where the writerClass argument is used to specify the JSR173 XMLOutputFactory class to be used.
IMSEnterpriseBuilder(Writer out)
          Creates an IMSEnterpriseBuilder with the given writer, and using the default system JSR173 XMLOutputFactory class for writing the XML document.
 
Method Summary
 void endDocument()
          Finishes the XML document and closes the underlying writer or output stream.
 boolean isIMSValidating()
          Returns true if IMS enterprise validation is turned on.
 void setIMSValidating(boolean v)
          Turn IMS enterprise validation on or off.
 void writeComments(Comments comments)
          Writes a comments object to the XML file.
 void writeGroup(Group group)
          Writes a group object to the XML file.
 void writeMembership(Membership membership)
          Writes a membership object to the XML file.
 void writePerson(Person person)
          Writes a person object to the XML file.
 void writeProperties(Properties properties)
          Writes a properties object to the XML file.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IMSEnterpriseBuilder

public IMSEnterpriseBuilder(OutputStream out)
                     throws IMSEnterpriseException
Creates an IMSEnterpriseBuilder with the given output stream, and using the default system JSR173 XMLOutputFactory class for writing the XML document.

Parameters:
out - The output stream to write to.

IMSEnterpriseBuilder

public IMSEnterpriseBuilder(Writer out)
                     throws IMSEnterpriseException
Creates an IMSEnterpriseBuilder with the given writer, and using the default system JSR173 XMLOutputFactory class for writing the XML document.

Parameters:
out - The writer to write to.

IMSEnterpriseBuilder

public IMSEnterpriseBuilder(String writerClass,
                            OutputStream out)
                     throws IMSEnterpriseException
Creates an IMSEnterpriseBuilder where the writerClass argument is used to specify the JSR173 XMLOutputFactory class to be used. Check the JSR173 documentation for more information.

Parameters:
writerClass - The XMLOutputFactory class to use.
out - The output stream to write to.
See Also:
JSR173 API

IMSEnterpriseBuilder

public IMSEnterpriseBuilder(String writerClass,
                            Writer out)
                     throws IMSEnterpriseException
Creates an IMSEnterpriseBuilder where the writerClass argument is used to specify the JSR173 XMLOutputFactory class to be used. Check the JSR173 documentation for more information.

Parameters:
writerClass - The XMLOutputFactory class to use.
out - The writer to write to.
See Also:
JSR173 API
Method Detail

setIMSValidating

public void setIMSValidating(boolean v)
Turn IMS enterprise validation on or off. If true, the builder will call the validate method on the IMS enterprise objects being written, and any writeXXXX() method may throw an IMSEnterpriseException if the information in the XML file is not valid according to the IMS enterprise specification.

Parameters:
v - Whether or not to enable IMS enterprise validation.

isIMSValidating

public boolean isIMSValidating()
Returns true if IMS enterprise validation is turned on.

Returns:
Whether or not IMS enterprise validation is turned on.

writeComments

public void writeComments(Comments comments)
                   throws IMSEnterpriseException
Writes a comments object to the XML file.

Parameters:
comments - The IMS Comments object to write.
Throws:
IMSEnterpriseException

writeProperties

public void writeProperties(Properties properties)
                     throws IMSEnterpriseException
Writes a properties object to the XML file.

Parameters:
properties - The IMS Properties object to write.
Throws:
IMSEnterpriseException

writePerson

public void writePerson(Person person)
                 throws IMSEnterpriseException
Writes a person object to the XML file.

Parameters:
person - The IMS Person object to write.
Throws:
IMSEnterpriseException

writeGroup

public void writeGroup(Group group)
                throws IMSEnterpriseException
Writes a group object to the XML file.

Parameters:
group - The IMS Group object to write.
Throws:
IMSEnterpriseException

writeMembership

public void writeMembership(Membership membership)
                     throws IMSEnterpriseException
Writes a membership object to the XML file.

Parameters:
membership - The IMS Membership object to write.
Throws:
IMSEnterpriseException

endDocument

public void endDocument()
                 throws IMSEnterpriseException
Finishes the XML document and closes the underlying writer or output stream. This method must be called, otherwise the closing </enterprise> tag won't be written and the resulting XML file will be invalid.

Throws:
IMSEnterpriseException