org.sourceforge.espro.utils
Class Table

java.lang.Object
  extended by org.sourceforge.espro.utils.Table

public class Table
extends java.lang.Object

This is a data table, used for exporting data from the questionnaire. The Table is extensible.

Version:
2.0
Author:
(c) 2007 Martin Kaffanke

Constructor Summary
Table()
          Creates a new instance of Table
 
Method Summary
 java.lang.String getString()
          Returns the table as string.
 java.lang.String getString(boolean header, java.lang.String separator, java.lang.String endOfLine)
          Returns the table as string.
static java.lang.String join(java.lang.String[] parts, java.lang.String separator, java.lang.String endOfLine)
          Creates a string from an array of strings.
 void newRow()
          Adds a new row.
 void setValue(java.lang.String column, java.lang.Object value)
          Sets a value into the table on the current row.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Table

public Table()
Creates a new instance of Table

Method Detail

setValue

public void setValue(java.lang.String column,
                     java.lang.Object value)
Sets a value into the table on the current row. This is the main method of the class. We can set any value into the table there will be created the rest of fields with not available data.

Parameters:
column - The name of the column.
value - The value.

newRow

public void newRow()
Adds a new row.


getString

public java.lang.String getString()
Returns the table as string. This is equal to getString(true, "; ", "\n");

Returns:
The String.

getString

public java.lang.String getString(boolean header,
                                  java.lang.String separator,
                                  java.lang.String endOfLine)
Returns the table as string.

Parameters:
header - True if you want a header printed out.
separator - The seperator, i.e. "; ".
endOfLine - The end of line statement, i.e. "\n"
Returns:
The string.

join

public static java.lang.String join(java.lang.String[] parts,
                                    java.lang.String separator,
                                    java.lang.String endOfLine)
Creates a string from an array of strings.

Parameters:
parts - The array of strings.
separator - The separator between the string.
endOfLine - An character for an end of line, this will be put after the last item of the parts array. Set this to "" if you don't need any.
Returns:
The new string.