appli.sqlplayer.util
Class Table2tsv

java.lang.Object
  extended byappli.sqlplayer.util.Table2tsv

public class Table2tsv
extends java.lang.Object

This conversion class receives the data from a database table row by row and column by column and writes a file to a temporary directory. The file is TSV format. The first row should contain the column name.
Most of the variable refer to xml stuff: this is because previously this class outputted an xml file Use this class as follows:

  1. Build instance
  2. Set Directory where the file should be outputted
  3. Create new document with parameters: Filename of XML output, Tablename
  4. Open Row
  5. Add Column(s)
  6. After last column of this dataset(row) close row
  7. Open Next row
  8. ...
  9. Close Row
  10. Save document

Version:
V2.0 adaptation to CDS stuff
Author:
Alexander Schatten (T.U. Wien), Marc Wenger/CDS

Field Summary
private  java.lang.StringBuffer descrLine
           
private  java.lang.String directory
           
private  java.lang.String filename
           
private  java.lang.StringBuffer line
           
private  int rowCount
           
private  boolean rowOpen
           
private  java.lang.String tablename
           
private  java.io.BufferedWriter wrt
           
 
Constructor Summary
Table2tsv()
           
 
Method Summary
 void addColumn(java.lang.String name, java.lang.String content)
          Add data for new column of current open row
 void closeRow()
          Finish row
 java.lang.String getDirectory()
           
 java.lang.String getFilename()
           
 java.lang.String getTablename()
           
 void newDocument()
          Start new XML document
 void newDocument(java.lang.String filename, java.lang.String tablename)
          Start new XML document
 void openRow()
          Start data entry for new row
 void saveDocument()
          Save current XML tree to XML file
 void setDirectory(java.lang.String newDirectory)
          Set directory path including ending file separator of xml output
 void setFilename(java.lang.String newFilename)
          Set filename of XML file
 void setTablename(java.lang.String newTablename)
          Set tablename of source table
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

filename

private java.lang.String filename

directory

private java.lang.String directory

tablename

private java.lang.String tablename

rowOpen

private boolean rowOpen

wrt

private java.io.BufferedWriter wrt

descrLine

private java.lang.StringBuffer descrLine

line

private java.lang.StringBuffer line

rowCount

private int rowCount
Constructor Detail

Table2tsv

public Table2tsv()
Method Detail

setFilename

public void setFilename(java.lang.String newFilename)
Set filename of XML file

Parameters:
newFilename - filename of XML file in "out" folder

getFilename

public java.lang.String getFilename()
Returns:
filename of XML file

setDirectory

public void setDirectory(java.lang.String newDirectory)
Set directory path including ending file separator of xml output

Parameters:
newDirectory - directory overriding the default output directory

getDirectory

public java.lang.String getDirectory()
Returns:
directory path of xml output

setTablename

public void setTablename(java.lang.String newTablename)
Set tablename of source table

Parameters:
newTablename - name of source table

getTablename

public java.lang.String getTablename()
Returns:
name of sourcetable

newDocument

public void newDocument()
Start new XML document


newDocument

public void newDocument(java.lang.String filename,
                        java.lang.String tablename)
Start new XML document

Parameters:
filename - Filename of XML document
tablename - Tablename of current table

saveDocument

public void saveDocument()
                  throws java.io.IOException
Save current XML tree to XML file

Throws:
java.io.IOException

openRow

public void openRow()
Start data entry for new row


closeRow

public void closeRow()
Finish row


addColumn

public void addColumn(java.lang.String name,
                      java.lang.String content)
Add data for new column of current open row

Parameters:
name - Column name
content - content of this column