edu.northwestern.at.utils.swing
Class SaveTableData

java.lang.Object
  extended by edu.northwestern.at.utils.swing.SaveTableModelData
      extended by edu.northwestern.at.utils.swing.SaveTableData

public class SaveTableData
extends SaveTableModelData

Saves data stored in a JTable to a file is several different formats.


Field Summary
 
Fields inherited from class edu.northwestern.at.utils.swing.SaveTableModelData
csvFilter, htmlFilter, tabFilter
 
Constructor Summary
protected SaveTableData()
          Don't allow instantiation but do allow overrides.
 
Method Summary
static java.lang.String[] getColumnTitles(javax.swing.JTable table)
          Get column titles for a table.
static void saveTableDataToFile(javax.swing.JTable table, java.lang.String title, boolean outputColumnTitles, java.lang.String fileName)
          Saves the table data to a file.
static void saveTableDataToFile(java.awt.Window parentWindow, javax.swing.JTable table, java.lang.String title, boolean outputColumnTitles)
          Saves the table model data to a file.
static void saveTableDataToFileAsCSV(javax.swing.JTable table, java.lang.String title, boolean outputColumnTitles, java.lang.String fileName)
          Saves the table model data to a file in CSV format.
static void saveTableDataToFileAsTAB(javax.swing.JTable table, java.lang.String title, boolean outputColumnTitles, java.lang.String fileName)
          Saves the table model data to a file in TAB format.
static void saveTableDataToFileAsXHTML(javax.swing.JTable table, java.lang.String title, boolean outputColumnTitles, java.lang.String fileName)
          Saves the table model data to a file in XHTML format.
static java.lang.String tableDataToCSV(javax.swing.JTable table, java.lang.String title, boolean outputColumnTitles)
          Convert contents of a JTable to comma separated values.
static java.lang.String tableDataToTAB(javax.swing.JTable table, java.lang.String title, boolean outputColumnTitles)
          Convert contents of a Table to tab separated values.
static java.lang.String tableDataToXHTML(javax.swing.JTable table, java.lang.String title, boolean outputColumnTitles, int border)
          Convert contents of a Table to XHTML.
 
Methods inherited from class edu.northwestern.at.utils.swing.SaveTableModelData
cleanColumnHeader, saveTableModelDataToFile, saveTableModelDataToFile, saveTableModelDataToFileAsCSV, saveTableModelDataToFileAsTAB, saveTableModelDataToFileAsXHTML, tableModelDataToCSV, tableModelDataToTAB, tableModelDataToXHTML
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SaveTableData

protected SaveTableData()
Don't allow instantiation but do allow overrides.

Method Detail

getColumnTitles

public static java.lang.String[] getColumnTitles(javax.swing.JTable table)
Get column titles for a table.

Parameters:
table - The table whose column titles are desired.
Returns:
String array of column titles.

tableDataToCSV

public static java.lang.String tableDataToCSV(javax.swing.JTable table,
                                              java.lang.String title,
                                              boolean outputColumnTitles)
Convert contents of a JTable to comma separated values.

Parameters:
table - The table containing the data to convert to command separated values.
title - Title for table.
outputColumnTitles - true to output column headers.
Returns:
The comma separated table data. Each table row appears on a new line.

tableDataToTAB

public static java.lang.String tableDataToTAB(javax.swing.JTable table,
                                              java.lang.String title,
                                              boolean outputColumnTitles)
Convert contents of a Table to tab separated values.

Parameters:
table - The table containing the data to convert to command separated values.
title - Title for table.
outputColumnTitles - true to output column headers.
Returns:
The tab separated table data. Each table row appears on a new line.

tableDataToXHTML

public static java.lang.String tableDataToXHTML(javax.swing.JTable table,
                                                java.lang.String title,
                                                boolean outputColumnTitles,
                                                int border)
Convert contents of a Table to XHTML.

Parameters:
table - The table containing the data to convert to command separated values.
title - Title for table.
outputColumnTitles - true to output column headers.
border - Border size for table. Set to 0 for no border.
Returns:
The XHTML formatted table data.

saveTableDataToFileAsCSV

public static void saveTableDataToFileAsCSV(javax.swing.JTable table,
                                            java.lang.String title,
                                            boolean outputColumnTitles,
                                            java.lang.String fileName)
Saves the table model data to a file in CSV format.

Parameters:
table - The table containing the data to save.
title - The title for the data.
outputColumnTitles - true to output column titles.
fileName - The file name to which to save the data.

saveTableDataToFileAsTAB

public static void saveTableDataToFileAsTAB(javax.swing.JTable table,
                                            java.lang.String title,
                                            boolean outputColumnTitles,
                                            java.lang.String fileName)
Saves the table model data to a file in TAB format.

Parameters:
table - The table containing the data to save.
title - The title for the data.
outputColumnTitles - true to output column titles.
fileName - The file name to which to save the data.

saveTableDataToFileAsXHTML

public static void saveTableDataToFileAsXHTML(javax.swing.JTable table,
                                              java.lang.String title,
                                              boolean outputColumnTitles,
                                              java.lang.String fileName)
Saves the table model data to a file in XHTML format.

Parameters:
table - The table containing the data to save.
title - The title for the data.
outputColumnTitles - true to output column titles.
fileName - The file name to which to save the data.

saveTableDataToFile

public static void saveTableDataToFile(javax.swing.JTable table,
                                       java.lang.String title,
                                       boolean outputColumnTitles,
                                       java.lang.String fileName)
Saves the table data to a file.

Parameters:
table - Table holding data to save.
title - The title for the data. Null if no title.
outputColumnTitles - true to output column titles.
fileName - The file name to which to save the data.

The filename extension determines the type of output. .csv -> comma separated values, .tab -> tab separate values, and .htm or .html -> xhtml. If the filename does not end in one of these, a comma separated file format is used.


saveTableDataToFile

public static void saveTableDataToFile(java.awt.Window parentWindow,
                                       javax.swing.JTable table,
                                       java.lang.String title,
                                       boolean outputColumnTitles)
Saves the table model data to a file. Prompts for a file name.

Parameters:
parentWindow - Parent window for file dialog.
table - The table whose data is to be saved.
title - The title for the table data.
outputColumnTitles - true to output column titles.