com.xigole.util.sql.outputformatter
Class XMLFormatter

java.lang.Object
  extended by com.xigole.util.sql.outputformatter.XMLFormatter
All Implemented Interfaces:
JisqlFormatter

public class XMLFormatter
extends java.lang.Object
implements JisqlFormatter

This is the default XML formatter for Jisql. It outputs data in an XML format.


Constructor Summary
XMLFormatter()
           
 
Method Summary
 void consumeOptions(joptsimple.OptionSet options)
          Consumes any options that were specified on the command line.
 void formatData(java.io.PrintStream out, java.sql.ResultSet resultSet, java.sql.ResultSetMetaData metaData)
          Called to output the data.
 void formatFooter(java.io.PrintStream out, java.sql.ResultSetMetaData metaData)
          Outputs a footer for a query.
 void formatHeader(java.io.PrintStream out, java.sql.ResultSetMetaData metaData)
          Outputs a header for a query.
 void setSupportedOptions(joptsimple.OptionParser parser)
          Sets a the option list for this formatter.
 void usage(java.io.PrintStream out)
          Called to output a usage message to the command line window.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLFormatter

public XMLFormatter()
Method Detail

setSupportedOptions

public void setSupportedOptions(joptsimple.OptionParser parser)
Sets a the option list for this formatter. This is a no-op in the XMLFormatter.

Specified by:
setSupportedOptions in interface JisqlFormatter
Parameters:
parser - the OptionParser to use.

consumeOptions

public void consumeOptions(joptsimple.OptionSet options)
                    throws java.lang.Exception
Consumes any options that were specified on the command line. There are no options to set for the XMLFormatter so this method is a no-op.

Specified by:
consumeOptions in interface JisqlFormatter
Parameters:
options - the OptionSet that the main driver is using.
Throws:
java.lang.Exception - if there is a problem parsing the command line arguments.

usage

public void usage(java.io.PrintStream out)
Called to output a usage message to the command line window. This message should contain information on how to call the formatter. There are no options to set for the XMLFormatter so this method is a no-op.

Specified by:
usage in interface JisqlFormatter
Parameters:
out - where to put the usage message.

formatHeader

public void formatHeader(java.io.PrintStream out,
                         java.sql.ResultSetMetaData metaData)
                  throws java.lang.Exception
Outputs a header for a query. For the XMLFormater this outputs the XML pre-amble. The character encoding defaults to the current character encoding in use.

Specified by:
formatHeader in interface JisqlFormatter
Parameters:
out - a PrintStream to send any output to.
metaData - the ResultSetMetaData for the output.
Throws:
java.lang.Exception

formatData

public void formatData(java.io.PrintStream out,
                       java.sql.ResultSet resultSet,
                       java.sql.ResultSetMetaData metaData)
                throws java.lang.Exception
Called to output the data. Note that for the XMLFormatter null fields are just output as an empty field.

Specified by:
formatData in interface JisqlFormatter
Parameters:
out - the PrintStream to output data to.
resultSet - the ResultSet for the row.
metaData - the ResultSetMetaData for the row.
Throws:
java.lang.Exception

formatFooter

public void formatFooter(java.io.PrintStream out,
                         java.sql.ResultSetMetaData metaData)
                  throws java.lang.Exception
Outputs a footer for a query. This method isn't used in the XMLFormatter.

Specified by:
formatFooter in interface JisqlFormatter
Parameters:
out - the PrintStream to output data to.
metaData - the ResultSetMetaData for the output.
Throws:
java.lang.Exception