|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.swing.table.AbstractTableModel
com.bbn.openmap.dataAccess.shape.DbfTableModel
public class DbfTableModel
An implementation of TableModel that manages tabular data read from a dbf file and enables the user to stored data store herein to be saved to a file conforming to the DBF III file format specification. To create a three one column model:
DbfTableModel model = new DbfTableModel(1); model.setDecimalCount(0, (byte) 0); model.setLength(0, (byte) 10); model.setColumnName(0, "Column1"); model.setType(0, (byte) DbfTableModel.TYPE_CHARACTER); model.setDecimalCount(1, (byte) 0); model.setLength(1, (byte) 10); model.setColumnName(1, "Column1"); model.setType(1, (byte) DbfTableModel.TYPE_NUMERIC); model.setDecimalCount(2, (byte) 0); model.setLength(2, (byte) 10); model.setColumnName(2, "Column1"); model.setType(2, (byte) DbfTableModel.TYPE_CHARACTER); esriLayer.setModel(model);
Field Summary | |
---|---|
protected int |
_columnCount
Class scope variable for the number of columns that exist in the model |
protected byte[] |
_decimalCounts
An array of bytes that contain the number of decimal places for each column |
protected int[] |
_lengths
An array of bytes that contain the character lengths for each column |
protected java.lang.String[] |
_names
An array of bytes that contain the names for each column |
protected java.util.List<java.util.List<java.lang.Object>> |
_records
Class scope reference to a list of data formatted by row |
protected byte[] |
_types
An array of bytes that contain the column types for each column |
protected boolean |
DEBUG
|
protected boolean |
dirty
|
static int |
DONE_MASK
Button mask to drop the frame quietly, with the modifications to the table complete. |
protected boolean |
exitOnClose
|
protected java.lang.StringBuffer |
filePath
|
protected javax.swing.JFrame |
frame
|
static java.util.logging.Logger |
logger
|
static int |
MODIFY_COLUMN_MASK
Edit button mask, to allow adding/removing columns in the attribute table. |
static int |
MODIFY_ROW_MASK
Edit button mask, to allow adding/removing rows. |
protected DbfTableModel |
parent
|
static int |
SAVE_MASK
Button mask to show a save button to write out any changes. |
protected javax.swing.JTable |
table
|
static byte |
TYPE_AUTOINCREMENT
Same as a Long |
static byte |
TYPE_BINARY
10 digits representing a .DBT block number. |
static byte |
TYPE_CHARACTER
All OEM code page characters - padded with blanks to the width of the field. |
static byte |
TYPE_DATE
8 bytes - date stored as a string in the format YYYYMMDD. |
static byte |
TYPE_DOUBLE
8 bytes - no conversions, stored as a double. |
static byte |
TYPE_FLOAT
Number stored as a string, right justified, and padded with blanks to the width of the field. |
static byte |
TYPE_LOGICAL
1 byte - initialized to 0x20 (space) otherwise T or F. |
static byte |
TYPE_LONG
4 bytes. |
static byte |
TYPE_MEMO
10 digits (bytes) representing a .DBT block number. |
static byte |
TYPE_NUMERIC
Number stored as a string, right justified, and padded with blanks to the width of the field. |
static byte |
TYPE_OLE
10 digits (bytes) representing a .DBT block number. |
static byte |
TYPE_TIMESTAMP
8 bytes - two longs, first for date, second for time. |
protected boolean |
writable
|
static java.lang.Double |
ZERO
Old Object value held for every NUMERIC cell that had a problem importing. |
Fields inherited from class javax.swing.table.AbstractTableModel |
---|
listenerList |
Constructor Summary | |
---|---|
protected |
DbfTableModel()
|
|
DbfTableModel(DbfInputStream is)
Creates a DbfTableModel based on an InputStream |
|
DbfTableModel(int columnCount)
Creates a blank DbfTableModel |
Method Summary | |
---|---|
protected byte[] |
add(byte[] current,
byte nb)
|
protected int[] |
add(int[] current,
byte nb)
|
protected java.lang.String[] |
add(java.lang.String[] current,
java.lang.String string)
|
void |
addBlankRecord()
|
protected void |
addColumn(java.util.List<java.lang.Object> recordColumn)
The types in the ArrayList are set - String, Byte, Integer, Integer - to match the format of the header. |
void |
addRecord(java.util.List<java.lang.Object> columns)
Adds a row of data to the the model |
void |
append(DbfTableModel dbf)
|
static java.lang.String |
appendWhitespaceOrTrim(java.lang.String s,
int length)
A method that looks at the length of String s and returns a copy of it with whitespace appended to the end to allow it to have the provided length. |
void |
cleanupChanges()
|
protected void |
commitEvents(DbfTableModel model)
|
protected void |
deleteColumn(int columnIndex)
Delete a column, iterating through all the records and deleting that part of each record. |
void |
doAction(OMGraphicList list,
OMGraphic graphic,
OMAction action,
DbfTableModelFactory dbfFactory)
|
void |
exitWindowClosed()
|
java.util.List<java.lang.Object> |
getBlankRecord()
|
java.lang.Class<? extends java.lang.Object> |
getColumnClass(int c)
Retrieves the column class for the passed in column index |
int |
getColumnCount()
Retrieves the number of columns that exist in the model |
int |
getColumnIndexForName(java.lang.String columnName)
Find the column index of the column with the given name. |
java.lang.String |
getColumnName(int column)
Retrieves the column name for the passed in column index |
static DbfTableModel |
getDbfTableModel(java.net.URL dbf)
Creates a DbfTableModel for a given .dbf file |
byte |
getDecimalCount(int column)
Retrieves the number of decimal places for the passed in column index |
java.lang.Object |
getEmptyDefaultForType(byte type)
|
java.awt.Component |
getGUI(java.lang.String filename,
int actionMask)
|
int |
getLength(int column)
Retrieves the character length for the passed in column index |
static java.lang.Object |
getObjectForType(java.lang.String cellContents,
int type,
java.text.DecimalFormat df,
int columnLength)
|
java.util.List<java.lang.Object> |
getRecord(int recordnumber)
Retrieves the record array list for the passed record number. |
java.util.Iterator<java.util.List<java.lang.Object>> |
getRecords()
Get an iterator over the records. |
int |
getRowCount()
Retrieves the number of columns that exist in the model |
static java.lang.String |
getStringForType(java.lang.Object obj,
byte type,
java.text.DecimalFormat df,
int columnLength)
Takes the object and converts it to a String for output. |
protected javax.swing.JTable |
getTable()
|
javax.swing.JTable |
getTable(javax.swing.ListSelectionModel lsm)
Needs to be called before displaying the DbfTableModel. |
byte |
getType(int column)
Retrieves the column type for the passed in column index |
java.lang.Object |
getValueAt(int row,
int column)
Retrieves a value for a specific column and row index |
boolean |
getWritable()
|
DbfTableModel |
headerClone()
Create another DbfTableModel with the same structure as this one (number of columns, column names, lengths and decimal counts). |
void |
hideGUI()
|
boolean |
isCellEditable(int rowIndex,
int columnIndex)
|
boolean |
isExitOnClose()
|
static boolean |
isNumericalType(byte type)
|
static boolean |
isValidType(byte type)
|
java.util.Iterator<java.util.List<java.lang.Object>> |
iterator()
Iterable method for the records. |
static void |
main(java.lang.String[] args)
|
boolean |
matches(DbfTableModel dbf)
|
static DbfTableModel |
read(java.net.URL dbf)
|
protected byte[] |
remove(byte[] current,
int index)
|
java.util.List<java.lang.Object> |
remove(int index)
Remove the record at the index. |
protected int[] |
remove(int[] current,
int index)
|
protected java.lang.String[] |
remove(java.lang.String[] current,
int index)
|
void |
setColumnName(int column,
java.lang.String name)
Sets the column name for the passed-in field index |
void |
setDecimalCount(int column,
byte decimalCount)
Sets the decimal count for the passed in field index |
void |
setExitOnClose(boolean exitOnClose)
|
void |
setLength(int column,
int length)
Set the character length for the passed-in field index |
void |
setType(int column,
byte type)
Sets the column type for the passed-in field index |
void |
setValueAt(java.lang.Object object,
int row,
int column)
|
void |
setWritable(boolean set)
|
void |
showGUI(java.lang.String filename,
int actionMask)
|
void |
tableChanged(javax.swing.event.TableModelEvent e)
|
static void |
test()
|
static java.lang.String |
write(DbfTableModel model,
java.lang.String location)
|
Methods inherited from class javax.swing.table.AbstractTableModel |
---|
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, removeTableModelListener |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static java.util.logging.Logger logger
public static final byte TYPE_BINARY
public static final byte TYPE_CHARACTER
public static final byte TYPE_DATE
public static final byte TYPE_NUMERIC
public static final byte TYPE_LOGICAL
public static final byte TYPE_MEMO
public static final byte TYPE_TIMESTAMP
public static final byte TYPE_LONG
public static final byte TYPE_AUTOINCREMENT
public static final byte TYPE_FLOAT
public static final byte TYPE_DOUBLE
public static final byte TYPE_OLE
public static final int MODIFY_ROW_MASK
public static final int MODIFY_COLUMN_MASK
public static final int DONE_MASK
public static final int SAVE_MASK
public static final java.lang.Double ZERO
protected int[] _lengths
protected byte[] _decimalCounts
protected byte[] _types
protected java.lang.String[] _names
protected java.util.List<java.util.List<java.lang.Object>> _records
protected int _columnCount
protected boolean writable
protected javax.swing.JTable table
protected final DbfTableModel parent
protected boolean dirty
protected boolean exitOnClose
protected boolean DEBUG
protected final java.lang.StringBuffer filePath
protected javax.swing.JFrame frame
Constructor Detail |
---|
protected DbfTableModel()
public DbfTableModel(int columnCount)
columnCount
- The number of columns this model will managepublic DbfTableModel(DbfInputStream is)
is
- The dbf fileMethod Detail |
---|
public void addRecord(java.util.List<java.lang.Object> columns)
columns
- A collection of columns that comprise the row of data
An
- exception is thrown if the number of elements in the passed
in collection does not match the number of columns in the
modelpublic java.util.List<java.lang.Object> remove(int index)
public void addBlankRecord()
public java.util.List<java.lang.Object> getBlankRecord()
public java.lang.Object getEmptyDefaultForType(byte type)
public static boolean isNumericalType(byte type)
public static boolean isValidType(byte type)
public java.util.List<java.lang.Object> getRecord(int recordnumber)
recordnumber
- The record number
public java.util.Iterator<java.util.List<java.lang.Object>> getRecords()
public java.util.Iterator<java.util.List<java.lang.Object>> iterator()
iterator
in interface java.lang.Iterable<java.util.List<java.lang.Object>>
public java.lang.Class<? extends java.lang.Object> getColumnClass(int c)
getColumnClass
in interface javax.swing.table.TableModel
getColumnClass
in class javax.swing.table.AbstractTableModel
c
- The column index
public int getColumnCount()
getColumnCount
in interface javax.swing.table.TableModel
public byte getDecimalCount(int column)
column
- The column index
public java.lang.String getColumnName(int column)
getColumnName
in interface javax.swing.table.TableModel
getColumnName
in class javax.swing.table.AbstractTableModel
column
- The column index
public int getColumnIndexForName(java.lang.String columnName)
columnName
-
public int getLength(int column)
column
- The column index
public int getRowCount()
getRowCount
in interface javax.swing.table.TableModel
public byte getType(int column)
column
- The column index
public java.lang.Object getValueAt(int row, int column)
getValueAt
in interface javax.swing.table.TableModel
public void setColumnName(int column, java.lang.String name)
column
- The column indexname
- The name to assign for the passed-in column indexpublic void setDecimalCount(int column, byte decimalCount)
column
- The index to the columndecimalCount
- The number of decimals places to assign to the passed
in columnpublic void setLength(int column, int length)
column
- The column indexlength
- The character length to assign for the passed-in column
indexpublic void setType(int column, byte type)
column
- The column indextype
- The type of column to assign for the passed-in column indexpublic void setValueAt(java.lang.Object object, int row, int column)
setValueAt
in interface javax.swing.table.TableModel
setValueAt
in class javax.swing.table.AbstractTableModel
public boolean isCellEditable(int rowIndex, int columnIndex)
isCellEditable
in interface javax.swing.table.TableModel
isCellEditable
in class javax.swing.table.AbstractTableModel
public void setWritable(boolean set)
public boolean getWritable()
public javax.swing.JTable getTable(javax.swing.ListSelectionModel lsm)
protected javax.swing.JTable getTable()
public java.awt.Component getGUI(java.lang.String filename, int actionMask)
public void hideGUI()
public void showGUI(java.lang.String filename, int actionMask)
public void exitWindowClosed()
public void tableChanged(javax.swing.event.TableModelEvent e)
tableChanged
in interface javax.swing.event.TableModelListener
protected void commitEvents(DbfTableModel model)
protected void deleteColumn(int columnIndex)
protected int[] remove(int[] current, int index)
protected byte[] remove(byte[] current, int index)
protected java.lang.String[] remove(java.lang.String[] current, int index)
protected void addColumn(java.util.List<java.lang.Object> recordColumn)
protected int[] add(int[] current, byte nb)
protected byte[] add(byte[] current, byte nb)
protected java.lang.String[] add(java.lang.String[] current, java.lang.String string)
public void cleanupChanges()
public DbfTableModel headerClone()
public static DbfTableModel getDbfTableModel(java.net.URL dbf)
dbf
- The url of the file to retrieve.
public static DbfTableModel read(java.net.URL dbf) throws java.lang.Exception
java.lang.Exception
public static java.lang.String write(DbfTableModel model, java.lang.String location) throws java.io.FileNotFoundException, java.io.IOException
java.io.FileNotFoundException
java.io.IOException
public static java.lang.String getStringForType(java.lang.Object obj, byte type, java.text.DecimalFormat df, int columnLength)
obj
- type
- df
- columnLength
- the length of the column entries, so whitespace can
be added if needed.
public static java.lang.String appendWhitespaceOrTrim(java.lang.String s, int length)
s
- length
-
public static java.lang.Object getObjectForType(java.lang.String cellContents, int type, java.text.DecimalFormat df, int columnLength) throws java.text.ParseException
java.text.ParseException
public boolean isExitOnClose()
public void setExitOnClose(boolean exitOnClose)
public static void main(java.lang.String[] args)
public static void test()
public boolean matches(DbfTableModel dbf)
public void append(DbfTableModel dbf)
public void doAction(OMGraphicList list, OMGraphic graphic, OMAction action, DbfTableModelFactory dbfFactory)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |