|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object edu.northwestern.at.utils.swing.SaveTableModelData
public class SaveTableModelData
Saves data stored in a TableModel to a file is several different formats.
Field Summary | |
---|---|
protected static FileExtensionFilter |
csvFilter
CSV extension file filter. |
protected static FileExtensionFilter |
htmlFilter
HTML extension file filter. |
protected static FileExtensionFilter |
tabFilter
TAB extension file filter. |
Constructor Summary | |
---|---|
protected |
SaveTableModelData()
Don't allow instantiation but do allow overrides. |
Method Summary | |
---|---|
static java.lang.String |
cleanColumnHeader(java.lang.String columnHeader)
Clean up a column header. |
static void |
saveTableModelDataToFile(javax.swing.table.TableModel tableModel,
java.lang.String title,
java.lang.String[] columnTitles,
java.lang.String fileName)
Saves the table data to a file. |
static void |
saveTableModelDataToFile(java.awt.Window parentWindow,
javax.swing.table.TableModel tableModel,
java.lang.String title,
java.lang.String[] columnTitles)
Saves the table model data to a file. |
static void |
saveTableModelDataToFileAsCSV(javax.swing.table.TableModel tableModel,
java.lang.String title,
java.lang.String[] columnTitles,
java.lang.String fileName)
Saves the table model data to a file in CSV format. |
static void |
saveTableModelDataToFileAsTAB(javax.swing.table.TableModel tableModel,
java.lang.String title,
java.lang.String[] columnTitles,
java.lang.String fileName)
Saves the table model data to a file in TAB format. |
static void |
saveTableModelDataToFileAsXHTML(javax.swing.table.TableModel tableModel,
java.lang.String title,
java.lang.String[] columnTitles,
java.lang.String fileName)
Saves the table model data to a file in XHTML format. |
static java.lang.String |
tableModelDataToCSV(javax.swing.table.TableModel tableModel,
java.lang.String title,
java.lang.String[] columnTitles)
Convert contents of a TableModel to comma separated values. |
static java.lang.String |
tableModelDataToTAB(javax.swing.table.TableModel tableModel,
java.lang.String title,
java.lang.String[] columnTitles)
Convert contents of a TableModel to tab separated values. |
static java.lang.String |
tableModelDataToXHTML(javax.swing.table.TableModel tableModel,
java.lang.String title,
java.lang.String[] columnTitles,
int border)
Convert contents of a TableModel to XHTML. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static FileExtensionFilter csvFilter
protected static FileExtensionFilter tabFilter
protected static FileExtensionFilter htmlFilter
Constructor Detail |
---|
protected SaveTableModelData()
Method Detail |
---|
public static java.lang.String cleanColumnHeader(java.lang.String columnHeader)
columnHeader
- The column header string to clean up.
HTML tags are removed, multiple blanks are squeezed to one blank, and leading and trailing blanks are removed.
public static java.lang.String tableModelDataToCSV(javax.swing.table.TableModel tableModel, java.lang.String title, java.lang.String[] columnTitles)
tableModel
- The TableModel containing the data to
convert to command separated values.title
- Title for table.columnTitles
- The column headers.
May be null to suppress column headers.
public static java.lang.String tableModelDataToTAB(javax.swing.table.TableModel tableModel, java.lang.String title, java.lang.String[] columnTitles)
tableModel
- The TableModel containing the data to
convert to tab separated values.title
- Title for table.columnTitles
- The column headers.
May be null to suppress column headers.
public static java.lang.String tableModelDataToXHTML(javax.swing.table.TableModel tableModel, java.lang.String title, java.lang.String[] columnTitles, int border)
tableModel
- The TableModel containing the data to
convert to XHTML.title
- Title for table.columnTitles
- The column headers.
May be null to suppress column headers.border
- Border size for table. Set to 0 for no
border.
public static void saveTableModelDataToFileAsCSV(javax.swing.table.TableModel tableModel, java.lang.String title, java.lang.String[] columnTitles, java.lang.String fileName)
tableModel
- The table model containing the data to save.title
- The title for the data.columnTitles
- The column titles. Null if no titles.fileName
- The file name to which to save the data. public static void saveTableModelDataToFileAsTAB(javax.swing.table.TableModel tableModel, java.lang.String title, java.lang.String[] columnTitles, java.lang.String fileName)
tableModel
- The table model containing the data to save.title
- The title for the data.columnTitles
- The column titles. Null if no titles.fileName
- The file name to which to save the data. public static void saveTableModelDataToFileAsXHTML(javax.swing.table.TableModel tableModel, java.lang.String title, java.lang.String[] columnTitles, java.lang.String fileName)
tableModel
- The table model containing the data to save.title
- The title for the data.columnTitles
- The column titles. Null if no titles.fileName
- The file name to which to save the data. public static void saveTableModelDataToFile(javax.swing.table.TableModel tableModel, java.lang.String title, java.lang.String[] columnTitles, java.lang.String fileName)
tableModel
- Table model holding data to save.title
- The title for the data. Null if no title.columnTitles
- The column titles. Null if no 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 separated values, and .htm or .html -> xhtml. If the filename does not end in one of these, a comma separated file format is used.
public static void saveTableModelDataToFile(java.awt.Window parentWindow, javax.swing.table.TableModel tableModel, java.lang.String title, java.lang.String[] columnTitles)
parentWindow
- Parent window for file dialog.tableModel
- The table model whose data is to be saved.title
- The title for the data.columnTitles
- The column titles.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |