org.openadaptor.doconverter
Class BasicXML2DOConverter

java.lang.Object
  extended by org.openadaptor.doconverter.XMLReader
      extended by org.openadaptor.doconverter.DOConverter
          extended by org.openadaptor.doconverter.BasicXML2DOConverter
All Implemented Interfaces:
XML2DOConverter

public class BasicXML2DOConverter
extends DOConverter
implements XML2DOConverter

The BasicXML2DOConverter is a subclass of DOConverter used for reading arrays of DataObjects in XML format. Currently it supports two versions of the syntax; 1.0 was the original, and 1.1 extends it to support 'streamed' attributes and a special 'wrapper' DataObject with a variable number of arguments whose DOTypes are encoded in the attribute tags.

Version:
1.1
Author:
Tim Bissell
See Also:
BasicDO2XMLConverter

Field Summary
protected  OASecurityManager _securityManager
          Holds the OASecurityManager or null for no security
protected static int ONE_OH
          symbolic name for 1.0 syntax version (equals index in VERSION_STR_ARRAY)
protected static int ONE_ONE
          symbolic name for 1.1 syntax version (equals index in VERSION_STR_ARRAY)
protected static java.lang.String TYPE_STR
          DO XML syntax name "basicdo".
protected static java.lang.String[] VERSION_STR_ARRAY
          array of supported versions
 
Fields inherited from class org.openadaptor.doconverter.DOConverter
_SECTION_START_TAG, _SECTIONEND, DCD_FALSE_VAL, DCD_NULL_ATTR, DCD_TRUE_VAL, decompressorFactory, DOC_TYPE_ATTR, DOC_VERSION_ATTR, ENDROW, log, MESSAGEID_ATTR, metadataParserFactory, ROW, ROWNUM, ROWNUM_NUMATTR, ROWNUM_TAG, SECTION_END_STR, SECTION_START_STR, START_TAG, XMLDATA_FALSE_VAL, XMLDATA_TRUE_VAL
 
Constructor Summary
BasicXML2DOConverter()
          Designated constructor.
 
Method Summary
 DataObject[] fromFile(java.lang.String filename, DataObject[] prototypes, DOTypeHolder types)
          Reads a serialised DataObject message from file filename.
 DataObject[] fromParser(XParser parser, DataObject[] prototypes, DOTypeHolder types)
          Creates an array of DataObjects from XML on parser input stream.
 DataObject[] fromParser(XParser parser, DOFactoryTypeHolder prototypes)
          Creates an array of DataObjects from XML on parser input stream.
 OASecurityManager getSecurityManager()
          Returns the OASecurityManager used by the receiver.
 java.lang.String getSyntaxName()
          Returns the type string "basicdo"
 java.lang.String getSyntaxVersion()
          Returns the most "highest" version strings.
 java.lang.String[] getSyntaxVersions()
          Returns the version strings.
 void setSecurityManager(OASecurityManager securityManager)
          Sets the OASecurityManager used by the receiver.
 
Methods inherited from class org.openadaptor.doconverter.DOConverter
getNewSectionStartTag, getNumberedRowTag, getSectionEndTag, getSectionStartTag, initialiseTags, main, xmlParsingFailed, xmlParsingFailed
 
Methods inherited from class org.openadaptor.doconverter.XMLReader
matchComment, matchEndTagNamed, matchTag, matchTagExactly, nextTag, nextXMLElement, xmlParsingFailedExpecting, xmlParsingFailedExpecting
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TYPE_STR

protected static java.lang.String TYPE_STR
DO XML syntax name "basicdo".


VERSION_STR_ARRAY

protected static java.lang.String[] VERSION_STR_ARRAY
array of supported versions


ONE_OH

protected static final int ONE_OH
symbolic name for 1.0 syntax version (equals index in VERSION_STR_ARRAY)

See Also:
Constant Field Values

ONE_ONE

protected static final int ONE_ONE
symbolic name for 1.1 syntax version (equals index in VERSION_STR_ARRAY)

See Also:
Constant Field Values

_securityManager

protected OASecurityManager _securityManager
Holds the OASecurityManager or null for no security

Constructor Detail

BasicXML2DOConverter

public BasicXML2DOConverter()
Designated constructor.

Method Detail

setSecurityManager

public void setSecurityManager(OASecurityManager securityManager)
Sets the OASecurityManager used by the receiver. Passes the new SecurityManager on to its relevant dependent objects.

Specified by:
setSecurityManager in interface XML2DOConverter
Parameters:
securityManager - New OASecurityManager.

getSecurityManager

public OASecurityManager getSecurityManager()
Returns the OASecurityManager used by the receiver.

Specified by:
getSecurityManager in interface XML2DOConverter

getSyntaxName

public java.lang.String getSyntaxName()
Returns the type string "basicdo"

Specified by:
getSyntaxName in interface XML2DOConverter
Specified by:
getSyntaxName in class DOConverter

getSyntaxVersion

public java.lang.String getSyntaxVersion()
Returns the most "highest" version strings.

Specified by:
getSyntaxVersion in interface XML2DOConverter
Specified by:
getSyntaxVersion in class DOConverter

getSyntaxVersions

public java.lang.String[] getSyntaxVersions()
Returns the version strings.

Specified by:
getSyntaxVersions in interface XML2DOConverter
Specified by:
getSyntaxVersions in class DOConverter

fromFile

public DataObject[] fromFile(java.lang.String filename,
                             DataObject[] prototypes,
                             DOTypeHolder types)
                      throws java.io.IOException,
                             DataObjectException
Reads a serialised DataObject message from file filename.

Parameters:
filename - name of file to be read.
prototypes - Collection of DataObjects instances to be cloned when creating DataObjects from the message.
types - A collection of DOTypes for use in building the DataObjects, but not defined in the Array of prototypes.
Returns:
Array of DataObjects encoded in file filename.
Throws:
java.io.IOException - throw if there is a problem reading file filename.
DataObjectException - thrown if there is a problem decoding the the DataObject message (contains explanatory text).

fromParser

public DataObject[] fromParser(XParser parser,
                               DataObject[] prototypes,
                               DOTypeHolder types)
                        throws java.io.IOException,
                               DataObjectException
Creates an array of DataObjects from XML on parser input stream. If the prototypes reader is not null, the method will populate copies of the prototype DataObject instances when it reads in DataObjects with the same type name as that prototype.

Specified by:
fromParser in interface XML2DOConverter
Parameters:
parser - XML data stream.
prototypes - Collection of DataObjects instances to be cloned when creating DataObjects from the message.
types - A collection of DOTypes for use in building the DataObjects, but not defined in the Array of prototypes.
Returns:
an array of DataObjects.
Throws:
DataObjectException - raised if the input stream was not valid XML format.
java.io.IOException - raised if there was an input error.

fromParser

public DataObject[] fromParser(XParser parser,
                               DOFactoryTypeHolder prototypes)
                        throws java.io.IOException,
                               DataObjectException
Creates an array of DataObjects from XML on parser input stream. If the prototypes reader is not null, the method will populate copies of the prototype DataObject instances when it reads in DataObjects with the same type name as that prototype.

Specified by:
fromParser in interface XML2DOConverter
Parameters:
parser - XML data stream.
prototypes - Collection of DataObjects instances to be cloned when creating DataObjects from the message.
Returns:
an array of DataObjects.
Throws:
DataObjectException - raised if the input stream was not valid XML format.
java.io.IOException - raised if there was an input error.