ca.macewan.ims.enterprise.io
Class IMSEnterpriseWriter

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

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

IMSEnterpriseWriter lets you write an entire IMS enterprise XML file in one write action. This is as opposed to the IMSEnterpriseBuilder class, which writes the top-level elements of an IMS enterprise XML document one at a time. The advantages of this writer as opposed to the builder class are mainly in terms of coding simplicity and convenience. Note, however, that building large IMS enterprise structures in memory prior to writing them can lead to out-of-memory issues.

IMSEnterpriseWriter writer = new IMSEnterpriseWriter();
writer.write(enterprise, someOutputStream);
 

Version:
0.1
Author:
Erwin Veugelers

Constructor Summary
IMSEnterpriseWriter()
          Creates a default IMSEnterpriseWriter using the system JSR173 XMLOutputFactory class for writing the XML document.
IMSEnterpriseWriter(String writerClass)
          Creates an IMSEnterpriseWriter where the method argument is used to specify the JSR173 XMLOutputFactory class to be used.
 
Method Summary
 boolean isIMSValidating()
          Returns true if IMS enterprise validation is turned on.
 void setIMSValidating(boolean v)
          Turn IMS enterprise validation on or off.
 void write(Enterprise enterprise, OutputStream out)
          Attempts to write the complete XML enterprise information in the Enterprise object to the OutputStream.
 void write(Enterprise enterprise, Writer out)
          Attempts to write the complete XML enterprise information in the Enterprise object to the Writer.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IMSEnterpriseWriter

public IMSEnterpriseWriter()
Creates a default IMSEnterpriseWriter using the system JSR173 XMLOutputFactory class for writing the XML document.


IMSEnterpriseWriter

public IMSEnterpriseWriter(String writerClass)
Creates an IMSEnterpriseWriter where the method 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.
See Also:
JSR173 API
Method Detail

setIMSValidating

public void setIMSValidating(boolean v)
Turn IMS enterprise validation on or off. If true, the writer will call the validate method on the IMS enterprise objects being written, and the write 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.

write

public void write(Enterprise enterprise,
                  OutputStream out)
           throws IMSEnterpriseException
Attempts to write the complete XML enterprise information in the Enterprise object to the OutputStream.

Parameters:
enterprise - The IMS Enterprise object to write.
out - The stream to write to.
Throws:
IMSEnterpriseException - Exceptions may be thrown regarding IMS enterprise validation (see setIMSValidating) or general XML writing errors.

write

public void write(Enterprise enterprise,
                  Writer out)
           throws IMSEnterpriseException
Attempts to write the complete XML enterprise information in the Enterprise object to the Writer.

Parameters:
enterprise - The IMS Enterprise object to write.
out - The writer to write to.
Throws:
IMSEnterpriseException - Exceptions may be thrown regarding IMS enterprise validation (see setIMSValidating) or general XML writing errors.