|
Holger's Java API |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjavax.swing.table.AbstractTableModel
javax.swing.table.DefaultTableModel
com.antelmann.util.table.FileTableModel
public class FileTableModel
a table model that enables importing/exporting from/to a CSV file easily. When read from a file, the model is completely placed in-memory
Strings.getFields(String, String, boolean),
Serialized Form| Field Summary |
|---|
| Fields inherited from class javax.swing.table.DefaultTableModel |
|---|
columnIdentifiers, dataVector |
| Fields inherited from class javax.swing.table.AbstractTableModel |
|---|
listenerList |
| Fields inherited from interface com.antelmann.util.PatternExtractor |
|---|
SELF_EXTRACTOR, STRING_EXTRACTOR |
| Constructor Summary | |
|---|---|
FileTableModel(File file,
boolean firstLineContainsHeader,
String fieldSeparator,
boolean usesQuotes)
creates an in-memory TableModel based on an import file where the first line contains headers |
|
FileTableModel(File file,
boolean firstLineContainsHeader,
String fieldSeparator,
boolean usesQuotes,
String charSet)
|
|
FileTableModel(File file,
String fieldSeparator,
boolean usesQuotes)
assumes that the first line contains header |
|
FileTableModel(Reader input,
boolean firstLineContainsHeader,
String fieldSeparator,
boolean usesQuotes)
|
|
FileTableModel(TableModel model)
enables to create a FileTableModel from any model, so that it can be saved as a file |
|
| Method Summary | |
|---|---|
Object |
extractPattern(Object cellValue)
responsible by default for converting a cell value into the value that is used when saving the value to a file. |
protected String |
quote(Object cellValue)
this implementation uses quoteValue(Object) |
static String |
quoteValue(Object value)
if the given value is a String, it is placed in quotes (while containing quotes are double-quoted); null values are converted to an empty String and other values are returned as their toString() results. |
void |
saveToFile(File file,
String fieldSeparator,
boolean usesQuotes)
|
void |
saveToFile(File file,
String fieldSeparator,
boolean usesQuotes,
PatternExtractor<Object,Object> extractor)
|
void |
saveToWriter(Writer writer,
String fieldSeparator,
boolean usesQuotes,
PatternExtractor<Object,Object> extractor)
will always write a header line. |
| Methods inherited from class javax.swing.table.DefaultTableModel |
|---|
addColumn, addColumn, addColumn, addRow, addRow, convertToVector, convertToVector, getColumnCount, getColumnName, getDataVector, getRowCount, getValueAt, insertRow, insertRow, isCellEditable, moveRow, newDataAvailable, newRowsAdded, removeRow, rowsRemoved, setColumnCount, setColumnIdentifiers, setColumnIdentifiers, setDataVector, setDataVector, setNumRows, setRowCount, setValueAt |
| Methods inherited from class javax.swing.table.AbstractTableModel |
|---|
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getColumnClass, getListeners, getTableModelListeners, removeTableModelListener |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public FileTableModel(TableModel model)
public FileTableModel(File file,
String fieldSeparator,
boolean usesQuotes)
throws IOException
IOException
public FileTableModel(File file,
boolean firstLineContainsHeader,
String fieldSeparator,
boolean usesQuotes)
throws IOException
IOException
public FileTableModel(File file,
boolean firstLineContainsHeader,
String fieldSeparator,
boolean usesQuotes,
String charSet)
throws IOException
IOException
@Todo(value="doesn\'t yet support csv files that contain quoted line breaks")
public FileTableModel(Reader input,
boolean firstLineContainsHeader,
String fieldSeparator,
boolean usesQuotes)
throws IOException
IOException| Method Detail |
|---|
public Object extractPattern(Object cellValue)
extractPattern in interface PatternExtractor<Object,Object>quote(Object),
saveToFile(File, String, boolean)protected String quote(Object cellValue)
quoteValue(Object)
public static String quoteValue(Object value)
public void saveToFile(File file,
String fieldSeparator,
boolean usesQuotes)
throws IOException
IOException
public void saveToFile(File file,
String fieldSeparator,
boolean usesQuotes,
PatternExtractor<Object,Object> extractor)
throws IOException
IOException
public void saveToWriter(Writer writer,
String fieldSeparator,
boolean usesQuotes,
PatternExtractor<Object,Object> extractor)
throws IOException
IOException
|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||