uk.org.ogsadai.converters.resultset.csv
Class CSVResultSetHandler
java.lang.Object
|
+--uk.org.ogsadai.converters.resultset.StrategicResultSetHandler
|
+--uk.org.ogsadai.converters.resultset.csv.CSVResultSetHandler
- All Implemented Interfaces:
- ResultSetHandler
- public class CSVResultSetHandler
- extends StrategicResultSetHandler
- implements ResultSetHandler
A ResultSetHandler
that uses the strategy design pattern and builds an CSV representation of a java.sql.ResultSet
.
The format of a CSV file is defined by CSVConfigurator
object passed in the constructor.
- Author:
- The OGSA-DAI Project Team.
- See Also:
CSVConfigurator
Method Summary |
void |
columnEnd(java.lang.StringBuffer output)
Write any data corresponding to the end of a new column. |
void |
columnStart(java.lang.StringBuffer output)
Write any data corresponding to the start of a new column. |
void |
footer(java.lang.StringBuffer output)
Write any footer data. |
void |
header(java.lang.StringBuffer output, java.sql.ResultSet rs)
Write any header data to the output stream. |
private java.lang.String |
metadata(java.sql.ResultSetMetaData metaData)
Writes the CVS header (first line) with column names. |
void |
rowEnd(java.lang.StringBuffer output)
Write any data corresponding to the end of a row. |
void |
rowStart(java.lang.StringBuffer output)
Write any data corresponding to the start of a new row. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
COPYRIGHT_NOTICE
private static final java.lang.String COPYRIGHT_NOTICE
-
- See Also:
- Constant Field Values
mConfigurator
private CSVConfigurator mConfigurator
-
rowJustStarted
private boolean rowJustStarted
-
CSVResultSetHandler
public CSVResultSetHandler(java.sql.ResultSet rs,
CSVConfigurator configurator)
throws ResultSetHandlerException
-
Constructs a new handler.
- Parameters:
rs
- Result set to convert
configurator
- Configuration object
- Throws:
ResultSetHandlerException
- If a problem occurs when accessing the ResultSet.
header
public void header(java.lang.StringBuffer output,
java.sql.ResultSet rs)
throws ResultSetHandlerException
- Description copied from interface:
ResultSetHandler
-
Write any header data to the output stream. This will be invoked once by the
ResultSetConverter
before any other events.
-
- Specified by:
header
in interface ResultSetHandler
-
- Parameters:
output
- Output string buffer to append data to
rs
- ResultSet from which to extract header information.
- Throws:
ResultSetHandlerException
- If a problem occurs when accessing the ResultSet.
rowStart
public void rowStart(java.lang.StringBuffer output)
- Description copied from interface:
ResultSetHandler
-
Write any data corresponding to the start of a new row.
-
- Specified by:
rowStart
in interface ResultSetHandler
-
- Parameters:
output
- Output string buffer to append data to.
columnStart
public void columnStart(java.lang.StringBuffer output)
- Description copied from interface:
ResultSetHandler
-
Write any data corresponding to the start of a new column.
-
- Specified by:
columnStart
in interface ResultSetHandler
-
- Parameters:
output
- Output string buffer to append data to.
columnEnd
public void columnEnd(java.lang.StringBuffer output)
- Description copied from interface:
ResultSetHandler
-
Write any data corresponding to the end of a new column.
-
- Specified by:
columnEnd
in interface ResultSetHandler
-
- Parameters:
output
- Output string buffer to append data to.
rowEnd
public void rowEnd(java.lang.StringBuffer output)
- Description copied from interface:
ResultSetHandler
-
Write any data corresponding to the end of a row.
-
- Specified by:
rowEnd
in interface ResultSetHandler
-
- Parameters:
output
- Output string buffer to append data to.
footer
public void footer(java.lang.StringBuffer output)
- Description copied from interface:
ResultSetHandler
-
Write any footer data.
-
- Specified by:
footer
in interface ResultSetHandler
-
- Parameters:
output
- Output string buffer to append data to.
metadata
private java.lang.String metadata(java.sql.ResultSetMetaData metaData)
throws ResultSetHandlerException
-
Writes the CVS header (first line) with column names.
-
-
- Parameters:
metaData
- ResultSet meta data.
- Returns:
- element as a string.
- Throws:
ResultSetHandlerException
- If a problem occurs when accessing the ResultSet.