org.jscience.architecture.lift.util
Class Converter

java.lang.Object
  extended by org.jscience.architecture.lift.util.Converter

public class Converter
extends java.lang.Object

Description of the Class


Field Summary
static boolean CompatibilityMode
          Set this to true if you need bug-compatibility with the old version.
 
Constructor Summary
Converter()
           
 
Method Summary
static java.lang.String CSV_pack(java.lang.String[] In, char Delim, char Esc)
          Packs a records (0,1, or more fields) into a CSV line.
static java.lang.String[] CSV_unpack(java.lang.String In, char Delim, char Esc)
          Unpacks a records (0,1, or more fields) from a CSV line.
static java.lang.String[][] CSV_unpack(java.lang.String Filename, char Delim, char Esc, boolean SkipHeader)
          Description of the Method
static java.lang.String HTMLTableLine(java.lang.String Name, java.lang.String[] Line, java.lang.String Link)
          Description of the Method
static void main(java.lang.String[] args)
          The main program for the Converter class
static java.lang.String[] toCSV(java.lang.String[][] Data, java.lang.String[] Header, java.lang.String NullString, char Delimeter, char Escape)
          Converts some strings into a CSV-like array.
static void toCSV(java.lang.String FileName, java.lang.String[][] Data, java.lang.String[] Header, java.lang.String NullString, char Delimeter, char Escape)
          Description of the Method
static java.lang.String[] toHTML(java.lang.String[][] Data, java.lang.String[] Header, java.lang.String NullString, java.lang.String Caption, java.lang.String TableParams)
          Converts some strings into a HTML-like table.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CompatibilityMode

public static final boolean CompatibilityMode
Set this to true if you need bug-compatibility with the old version. There was a bug in the previous release that did handled malformed csv files differently. Whenever a line contained whitespaces after the last escape char or before the first one, the Converter converted it in a wrong way, to a field that contained this escape char. It should have prodocued an error as the escape char was not properly escaped. Now, it trims the line and still beheaves incorrectly, yet effectively.

See Also:
Constant Field Values
Constructor Detail

Converter

public Converter()
Method Detail

CSV_pack

public static java.lang.String CSV_pack(java.lang.String[] In,
                                        char Delim,
                                        char Esc)
Packs a records (0,1, or more fields) into a CSV line. NOTE: Slow and dumb.

Parameters:
In - The fields of the record.
Delim - The delimeter character, '\t', ';' and ',' are the most frequent ones.
Esc - The escape character, '"' and '\'' are the most frequent ones.
Returns:
The CSV-packed record.

CSV_unpack

public static java.lang.String[][] CSV_unpack(java.lang.String Filename,
                                              char Delim,
                                              char Esc,
                                              boolean SkipHeader)
Description of the Method

Parameters:
Filename - Description of the Parameter
Delim - Description of the Parameter
Esc - Description of the Parameter
SkipHeader - Description of the Parameter
Returns:
Description of the Return Value

CSV_unpack

public static java.lang.String[] CSV_unpack(java.lang.String In,
                                            char Delim,
                                            char Esc)
Unpacks a records (0,1, or more fields) from a CSV line. NOTE: Slow and dumb.

Parameters:
In - The CSV-packed line.
Delim - The delimeter character, '\t', ';' and ',' are the most frequent ones.
Esc - The escape character, '"' and '\'' are the most frequent ones.
Returns:
The fields of the record.

HTMLTableLine

public static java.lang.String HTMLTableLine(java.lang.String Name,
                                             java.lang.String[] Line,
                                             java.lang.String Link)
Description of the Method

Parameters:
Name - Description of the Parameter
Line - Description of the Parameter
Link - Description of the Parameter
Returns:
Description of the Return Value

main

public static void main(java.lang.String[] args)
The main program for the Converter class

Parameters:
args - The command line arguments

toCSV

public static void toCSV(java.lang.String FileName,
                         java.lang.String[][] Data,
                         java.lang.String[] Header,
                         java.lang.String NullString,
                         char Delimeter,
                         char Escape)
                  throws java.io.IOException
Description of the Method

Parameters:
FileName - Description of the Parameter
Data - Description of the Parameter
Header - Description of the Parameter
NullString - Description of the Parameter
Delimeter - Description of the Parameter
Escape - Description of the Parameter
Throws:
java.io.IOException - Description of the Exception

toCSV

public static java.lang.String[] toCSV(java.lang.String[][] Data,
                                       java.lang.String[] Header,
                                       java.lang.String NullString,
                                       char Delimeter,
                                       char Escape)
Converts some strings into a CSV-like array.

Parameters:
Data - The input data, first index is row index, second is column index
Header - The header strings for the data
NullString - All nulls are replaced by this in the Data. "N/A", " " and "" are very common.
Delimeter - Description of the Parameter
Escape - Description of the Parameter
Returns:
The HTML-like encoded lines of the table.

toHTML

public static java.lang.String[] toHTML(java.lang.String[][] Data,
                                        java.lang.String[] Header,
                                        java.lang.String NullString,
                                        java.lang.String Caption,
                                        java.lang.String TableParams)
Converts some strings into a HTML-like table.

Parameters:
Data - The input data, first index is row index, second is column index
Header - The header strings for the data
NullString - All nulls are replaced by this in the Data. "N/A", " " and "" are very common.
Caption - The caption of the table
TableParams - The params of the table tag.
Returns:
The HTML-like encoded lines of the table.