info.informatica.data
Class DataFormatter

java.lang.Object
  extended by info.informatica.text.FormatPrinter
      extended by info.informatica.data.DataFormatter

public final class DataFormatter
extends info.informatica.text.FormatPrinter

Text formatting parser and printer.

This formatter emulates (not at 100%) the behavior of popular printf C function, adding a few extensions.
Instead of a varargs-style argument as in C, it uses a dataset.

Synopsis:
DataFormatter fmt = new DataFormatter("Cost of item number ${code,7.1d} ("${item,-40.50s}) is ${price,8.2f}.");
Dataset dset = new ResultsetDataset();
dset.set(myResultSet); String formatted_output = fmt.format(dset);

Version:
1.01
Author:
amengual at informatica dot info

Constructor Summary
DataFormatter(String format)
           
DataFormatter(String format, String nullStrText)
           
 
Method Summary
 String format(Dataset data)
          Prints the values in data according to format specifications.
 
Methods inherited from class info.informatica.text.FormatPrinter
format, format, getFormats, hasArguments, sample, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DataFormatter

public DataFormatter(String format)
              throws info.informatica.text.ParsingException
Throws:
info.informatica.text.ParsingException

DataFormatter

public DataFormatter(String format,
                     String nullStrText)
              throws info.informatica.text.ParsingException
Parameters:
format - the format
nullStrText - The String that will substitute null values
Throws:
info.informatica.text.ParsingException
Method Detail

format

public String format(Dataset data)
              throws DatasetException
Prints the values in data according to format specifications.

Parameters:
data - The dataset used to retrieve the values
Returns:
a formatted String with the proper values printed on it
Throws:
DatasetException