net.sourceforge.jdbcimporter.parser
Class XMLDelimiterParser

java.lang.Object
  extended bynet.sourceforge.jdbcimporter.parser.XMLDelimiterParser
All Implemented Interfaces:
DelimiterParser

public class XMLDelimiterParser
extends java.lang.Object
implements DelimiterParser

The XMLDelimiterParser class implements the DelimiterParser interface to parse column values from an XML document that was transformed with the given XSL.

Version:
0.6
Author:
Chris Nagy

Field Summary
protected  javax.xml.parsers.DocumentBuilder documentBuilder
          The XML Parser.
protected  boolean forkThread
          Flag to indicate that a thread should be forked to transform the XML.
protected static org.apache.commons.logging.Log LOG
          The log for debug information.
protected  javax.xml.transform.stream.StreamSource xmlSource
          The input reader.
protected  java.lang.String xslResultFile
          The filename to store the XML after it has been transformed with the XSL.
protected  java.io.Reader xslResultReader
          The input reader after the XML has been transformed with the XSL.
protected  java.lang.String xslString
          The XSL used to transform the XML.
 
Constructor Summary
XMLDelimiterParser()
          Constructor for XMLDeliimiterParser.
 
Method Summary
 java.lang.String getNextRow()
          Returns the next row to be imported as a String.
 ColumnValue[] getValues(java.lang.String nextRow)
          Returns the column values for the row specified.
protected  java.io.Reader initFileReader()
          Initializes a file reader that will be used to parse the resulting XML.
protected  java.io.Reader initPipedReader()
          Initializes a piped reader that will be used to parse the resulting XML.
protected  java.io.Reader initStringReader()
          Initializes a string reader that will be used to parse the resulting XML.
 void setForkThread(boolean flag)
          Sets a flag to indicate whether the XMLDelimiterParser will fork a thread to process the XSL.
 void setReader(java.io.Reader input)
          Sets the input source for the parser.
 void setResultFile(java.lang.String file)
          Sets the file to store the resulting XML after it has been transformed by the XSL.
 void setXSL(java.lang.String str)
          Sets the XSL.
 void setXSLFile(java.lang.String filename)
          Sets the XSL file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

protected static org.apache.commons.logging.Log LOG
The log for debug information.


documentBuilder

protected javax.xml.parsers.DocumentBuilder documentBuilder
The XML Parser.


xslString

protected java.lang.String xslString
The XSL used to transform the XML.


xmlSource

protected javax.xml.transform.stream.StreamSource xmlSource
The input reader.


xslResultReader

protected java.io.Reader xslResultReader
The input reader after the XML has been transformed with the XSL.


xslResultFile

protected java.lang.String xslResultFile
The filename to store the XML after it has been transformed with the XSL.


forkThread

protected boolean forkThread
Flag to indicate that a thread should be forked to transform the XML.

Constructor Detail

XMLDelimiterParser

public XMLDelimiterParser()
Constructor for XMLDeliimiterParser.

Method Detail

setXSLFile

public void setXSLFile(java.lang.String filename)
Sets the XSL file.

Parameters:
filename - the XSL filename

setXSL

public void setXSL(java.lang.String str)
Sets the XSL.

Parameters:
str - the XSL

setResultFile

public void setResultFile(java.lang.String file)
Sets the file to store the resulting XML after it has been transformed by the XSL.

Parameters:
file - the filename

setForkThread

public void setForkThread(boolean flag)
Sets a flag to indicate whether the XMLDelimiterParser will fork a thread to process the XSL.

Parameters:
flag - fork thread flag

setReader

public void setReader(java.io.Reader input)
Description copied from interface: DelimiterParser
Sets the input source for the parser.

Specified by:
setReader in interface DelimiterParser
Parameters:
input - the source of the data to import.
See Also:
DelimiterParser.setReader(Reader)

getNextRow

public java.lang.String getNextRow()
                            throws java.io.IOException
Description copied from interface: DelimiterParser
Returns the next row to be imported as a String.

Specified by:
getNextRow in interface DelimiterParser
Returns:
the next row to import
Throws:
java.io.IOException - if an error occurs while retrieving the next row
See Also:
DelimiterParser.getNextRow()

getValues

public ColumnValue[] getValues(java.lang.String nextRow)
                        throws MalformedDataException
Description copied from interface: DelimiterParser
Returns the column values for the row specified.

Specified by:
getValues in interface DelimiterParser
Parameters:
nextRow - the row to be parsed into column values
Returns:
the column values
Throws:
MalformedDataException - if the row is not formatted properly
See Also:
DelimiterParser.getValues(String)

initFileReader

protected java.io.Reader initFileReader()
                                 throws java.io.IOException
Initializes a file reader that will be used to parse the resulting XML.

Returns:
the reader
Throws:
java.io.IOException

initPipedReader

protected java.io.Reader initPipedReader()
                                  throws java.io.IOException
Initializes a piped reader that will be used to parse the resulting XML.

Returns:
the reader
Throws:
java.io.IOException

initStringReader

protected java.io.Reader initStringReader()
                                   throws java.io.IOException
Initializes a string reader that will be used to parse the resulting XML.

Returns:
the reader
Throws:
java.io.IOException