voji.utils
Class DataFormat

java.lang.Object
  |
  +--voji.utils.DataFormat

public class DataFormat
extends java.lang.Object

This class defines an way to format the result of an SQL query to a string. This is especially useful for printing.


Constructor Summary
DataFormat()
          Creates a new DataFormat instance
DataFormat(java.text.Format format)
          Creates a new DataFormat instance.
 
Method Summary
 java.lang.String format(java.util.Iterator objects)
          Formats an Iterator.
 java.lang.String format(java.util.Iterator objects, int index)
          Formats an Iterator.
static java.util.Vector format(java.util.Iterator objects, java.util.List formats)
          Formats an Iterator using more formats.
 java.lang.String format(java.util.List objects, int index)
          Formats a List
static java.util.Vector format(java.util.List objects, java.util.List formats)
          Formats a List using more formats.
 java.lang.String format(java.lang.Object[] objects, int index)
          Formats an Array
static java.util.Vector format(java.lang.Object[] objects, java.util.List formats)
          Formats an Array using more formats.
 java.lang.String format(java.sql.ResultSet resultSet, int index)
          Formats a ResultSet
static java.util.Vector format(java.sql.ResultSet resultSet, java.util.List formats)
          Formats a ResultSet using more formats.
static java.util.Vector formatAll(java.util.List objects, java.util.List formats)
          Formats a List of List using more formats.
static java.util.Vector formatAll(java.sql.ResultSet resultSet, java.util.List formats)
          Formats a ResultSet using more formats.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataFormat

public DataFormat(java.text.Format format)
Creates a new DataFormat instance. It formats using the given format.

Parameters:
format - the Format to use

DataFormat

public DataFormat()
Creates a new DataFormat instance

Method Detail

format

public java.lang.String format(java.sql.ResultSet resultSet,
                               int index)
                        throws java.sql.SQLException
Formats a ResultSet

Parameters:
resultSet - the ResultSet that needs to be formatted
index - the column index (starting with 1) where to start from
Returns:
the String representation of resultSet
java.sql.SQLException

format

public java.lang.String format(java.lang.Object[] objects,
                               int index)
Formats an Array

Parameters:
objects - the Array of Objects that needs to be formatted
index - the index where to start from
Returns:
the String representation of objects

format

public java.lang.String format(java.util.List objects,
                               int index)
Formats a List

Parameters:
objects - the List of Objects that needs to be formatted
index - the index where to start from
Returns:
the String representation of objects

format

public java.lang.String format(java.util.Iterator objects,
                               int index)
Formats an Iterator.

Parameters:
objects - the Iterator of Objects that needs to be formatted
index - the index where to start from
Returns:
the String representation of objects

format

public java.lang.String format(java.util.Iterator objects)
Formats an Iterator. This just returns the string representation of the first element of that Iterator, so it must be overwritten by child classes.

Parameters:
objects - the Iterator of Objects that needs to be formatted
Returns:
the String representation of objects

format

public static java.util.Vector format(java.sql.ResultSet resultSet,
                                      java.util.List formats)
                               throws java.sql.SQLException
Formats a ResultSet using more formats. The formats are use one after another.

Parameters:
resultSet - the ResultSet that needs to be formatted
formats - a List of DataFormats containing the formats to use
Returns:
a Vector containing the String representations of objects
java.sql.SQLException

format

public static java.util.Vector format(java.lang.Object[] objects,
                                      java.util.List formats)
Formats an Array using more formats. The formats are use one after another.

Parameters:
objects - the Array of Objects that needs to be formatted
formats - a List of DataFormats containing the formats to use
Returns:
a Vector containing the String representations of objects

format

public static java.util.Vector format(java.util.List objects,
                                      java.util.List formats)
Formats a List using more formats. The formats are use one after another.

Parameters:
objects - the List of Objects that needs to be formatted
formats - a List of DataFormats containing the formats to use
Returns:
a Vector containing the String representations of objects

format

public static java.util.Vector format(java.util.Iterator objects,
                                      java.util.List formats)
Formats an Iterator using more formats. The formats are use one after another.
Note: While a format DataFormat(null) means "convert to string", the format null means "don't convert".

Parameters:
objects - the Iterator of Objects that needs to be formatted
formats - a List of DataFormats containing the formats to use
Returns:
a Vector containing the String representations of objects and some Objects unaltered (where the format was null).

formatAll

public static java.util.Vector formatAll(java.sql.ResultSet resultSet,
                                         java.util.List formats)
                                  throws java.sql.SQLException
Formats a ResultSet using more formats. The formats are use one after another for each line.

Parameters:
formats - a List of DataFormats containing the formats to use
Returns:
a Vector of Vector containing the String representations of objects
java.sql.SQLException

formatAll

public static java.util.Vector formatAll(java.util.List objects,
                                         java.util.List formats)
Formats a List of List using more formats. The formats are use one after another for each line.

Parameters:
objects - the List of Objects that needs to be formatted
formats - a List of DataFormats containing the formats to use
Returns:
a Vector of Vector containing the String representations of objects