ca.macewan.ims.enterprise.io
Class IMSEnterpriseReader

java.lang.Object
  extended byca.macewan.ims.enterprise.io.IMSEnterpriseProcessor
      extended byca.macewan.ims.enterprise.io.IMSEnterpriseImportProcessor
          extended byca.macewan.ims.enterprise.io.IMSEnterpriseReader

public class IMSEnterpriseReader
extends ca.macewan.ims.enterprise.io.IMSEnterpriseImportProcessor

IMSEnterpriseReader lets you read an entire IMS enterprise XML file in one read action. This is as opposed to the IMSEnterpriseParser class, which reads the top-level elements of an IMS enterprise XML document one at a time, much like an iterator. The advantages of this reader as opposed to the iterator-style parser class are mainly in terms of coding simplicity and convenience. After reading the entire document, it is still possible to use the Enterprise.getIterator method to iterate over the document's top-level elements. Note, however, that using this reader to read large IMS enterprise XML files can lead to out-of-memory issues.

IMSEnterpriseReader reader = new IMSEnterpriseReader();
Enterprise enterprise = reader.read(someInputStream);
 

Version:
0.1
Author:
Erwin Veugelers

Constructor Summary
IMSEnterpriseReader()
          Creates a default IMSEnterpriseReader using the system JSR173 XMLInputFactory class for parsing the XML document.
IMSEnterpriseReader(String readerClass)
          Creates an IMSEnterpriseReader where the method argument is used to specify the JSR173 XMLInputFactory class to be used.
 
Method Summary
 boolean isIMSValidating()
          Returns true if IMS enterprise validation is turned on.
 boolean isXMLValidating()
          Returns true if XML validation is turned on.
 Enterprise read(InputStream in)
          Attempts to read the complete XML enterprise information available on the InputStream and builds an Enterprise object representing the information.
 void setIMSValidating(boolean v)
          Turn IMS enterprise validation on or off.
 void setValidating(boolean v)
          Convenience method to set both XML validation and IMS enterprise validation with one method.
 void setXMLValidating(boolean v)
          Turn XML validation on or off.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IMSEnterpriseReader

public IMSEnterpriseReader()
Creates a default IMSEnterpriseReader using the system JSR173 XMLInputFactory class for parsing the XML document.


IMSEnterpriseReader

public IMSEnterpriseReader(String readerClass)
Creates an IMSEnterpriseReader where the method argument is used to specify the JSR173 XMLInputFactory class to be used. Check the JSR173 documentation for more information.

Parameters:
readerClass - The XMLInputFactory class to use.
See Also:
JSR173 API
Method Detail

setValidating

public void setValidating(boolean v)
Convenience method to set both XML validation and IMS enterprise validation with one method. See setXMLValidating and setIMSValidating.

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

setIMSValidating

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

setXMLValidating

public void setXMLValidating(boolean v)
Turn XML validation on or off. The parser will set the underlying JSR173 XML reader validating property to the value of the method argument. This level of validation deals with XML document structure, rather than with IMS enterprise specification validation (see setIMSValidating). The read method may throw an IMSEnterpriseException wrapping any XML exceptions.

Parameters:
v - Whether or not to enable XML validation.

isXMLValidating

public boolean isXMLValidating()
Returns true if XML validation is turned on.

Returns:
Whether or not XML validation is turned on.

read

public Enterprise read(InputStream in)
                throws IMSEnterpriseException
Attempts to read the complete XML enterprise information available on the InputStream and builds an Enterprise object representing the information.

Parameters:
in - The stream to read the XML data from.
Returns:
An IMS Enterprise object.
Throws:
IMSEnterpriseException - Exceptions may be thrown regarding IMS enterprise validation (see setIMSValidating), XML validation (see setXMLValidating) or general XML reading errors.