zinger.bsheet
Class StandardMapPersistence

java.lang.Object
  extended by zinger.bsheet.AbstractPersistence
      extended by zinger.bsheet.StandardMapPersistence
All Implemented Interfaces:
Persistence
Direct Known Subclasses:
StreamMapPersistence

public abstract class StandardMapPersistence
extends AbstractPersistence


Field Summary
static java.lang.String APPEARANCE_MAP_KEY
           
static java.lang.String COLUMN_IDENTIFIERS_KEY
           
static java.lang.String COLUMNS_KEY
           
static java.lang.String DATA_VECTOR_KEY
           
static java.lang.String DATA_VECTOR_LENGTH_KEY
           
static java.lang.String FORMATS_KEY
           
static java.lang.String ROW_HEIGHTS_KEY
           
static java.lang.String VERSION_KEY
           
 
Fields inherited from class zinger.bsheet.AbstractPersistence
extensions, fileFilter
 
Constructor Summary
StandardMapPersistence()
           
StandardMapPersistence(javax.swing.filechooser.FileFilter fileFilter, java.lang.String[] extensions)
           
 
Method Summary
protected  void decompressDataVector(java.util.Vector dataVector, int originalLength)
          Decompresses given two-dimensional data vector.
 boolean evalValues(javax.swing.JTable table, java.util.Map map)
           
protected  java.util.List getColumns(javax.swing.table.TableColumnModel columnModel)
          Creates a List of Column objects from a table model's column enumerator.
protected  java.util.Vector getCompressedDataVector(java.util.Vector dataVector)
          Creates a compressed version of the given two-dimensional data vector.
 boolean isLoadCapable()
           
protected abstract  java.util.Map load(java.io.File file)
           
 boolean load(javax.swing.JTable table, java.io.File file)
          Loads a document into the model behind the table.
protected  void load(java.util.Map map, javax.swing.JTable table)
          Loads table model data from the specified object map.
protected  java.util.Map save(javax.swing.JTable table)
           
 boolean save(javax.swing.JTable table, java.io.File file)
          Persists the document from the model behind the table.
protected abstract  void save(java.util.Map map, java.io.File file)
           
protected  void setColumns(java.util.List columns, javax.swing.table.TableColumnModel columnModel)
          Sets the columns in the table model based on the List containing Column objects.
 
Methods inherited from class zinger.bsheet.AbstractPersistence
autocorrectFile, getFileFilter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VERSION_KEY

public static final java.lang.String VERSION_KEY
See Also:
Constant Field Values

COLUMN_IDENTIFIERS_KEY

public static final java.lang.String COLUMN_IDENTIFIERS_KEY
See Also:
Constant Field Values

DATA_VECTOR_KEY

public static final java.lang.String DATA_VECTOR_KEY
See Also:
Constant Field Values

DATA_VECTOR_LENGTH_KEY

public static final java.lang.String DATA_VECTOR_LENGTH_KEY
See Also:
Constant Field Values

COLUMNS_KEY

public static final java.lang.String COLUMNS_KEY
See Also:
Constant Field Values

FORMATS_KEY

public static final java.lang.String FORMATS_KEY
See Also:
Constant Field Values

ROW_HEIGHTS_KEY

public static final java.lang.String ROW_HEIGHTS_KEY
See Also:
Constant Field Values

APPEARANCE_MAP_KEY

public static final java.lang.String APPEARANCE_MAP_KEY
See Also:
Constant Field Values
Constructor Detail

StandardMapPersistence

public StandardMapPersistence(javax.swing.filechooser.FileFilter fileFilter,
                              java.lang.String[] extensions)

StandardMapPersistence

public StandardMapPersistence()
Method Detail

isLoadCapable

public boolean isLoadCapable()
Returns:
true if the implementation can load a document as well as persist it

save

public boolean save(javax.swing.JTable table,
                    java.io.File file)
             throws java.io.IOException
Description copied from interface: Persistence
Persists the document from the model behind the table.

Returns:
true if the document was persisted successfully
Throws:
java.io.IOException - if an IO problem occurred during persisting the document

load

public boolean load(javax.swing.JTable table,
                    java.io.File file)
             throws java.io.IOException,
                    java.lang.UnsupportedOperationException
Description copied from interface: Persistence
Loads a document into the model behind the table.

Returns:
true if the document was loaded successfully
Throws:
java.io.IOException - if an IO problem occurred during loading the document
java.lang.UnsupportedOperationException - if the implementation is not capable of loading documents as per isLoadCapable() method
See Also:
Persistence.isLoadCapable()

save

protected java.util.Map save(javax.swing.JTable table)

load

protected void load(java.util.Map map,
                    javax.swing.JTable table)
Loads table model data from the specified object map. Data model is loaded from the map using the following keys:
Constant VariableConstant Value (* = required)Description
COLUMN_IDENTIFIERS_KEY column_ids * A Vector containing column identifiers.
DATA_VECTOR_KEY data_vector * A compressed two-dimensional data vector. A data vector is compressed by removing all trailing empty row elements and trailing null from each ramaining row vector.
DATA_VECTOR_LENGTH_KEY data_vector_length An Integer containing the row count (the length of the data vector).
COLUMNS_KEY columns A List of Column objects.
FORMATS_KEY formats A formats Map used in BSHTableModel for column and cell formatting.
ROW_HEIGHTS_KEY row_heights A Map mapping row indices to row heights for non-default row height values.
APPEARANCE_MAP_KEY appearance_map A cell appearance Map used for column and cell presentation setting.

See Also:
COLUMN_IDENTIFIERS_KEY, DATA_VECTOR_KEY, DATA_VECTOR_LENGTH_KEY, COLUMNS_KEY, FORMATS_KEY, ROW_HEIGHTS_KEY, APPEARANCE_MAP_KEY, DefaultTableModel.setDataVector(java.util.Vector, java.util.Vector), setColumns(java.util.List, javax.swing.table.TableColumnModel), BSHTableModel.setFormats(java.util.Map), BSHTableModel.setAppearanceMap(java.util.Map), decompressDataVector(java.util.Vector, int)

decompressDataVector

protected void decompressDataVector(java.util.Vector dataVector,
                                    int originalLength)
Decompresses given two-dimensional data vector. A data vector is decompressed by setting size of the vector to specified row count (originalLength). Note: This method is not a true inverse function of getCompressedDataVector(Vector) because trailing empty rows are represented by null elements rather than empty Vector objects and trailing null elements of the rows are not restored. Also note that this method operates directly on the passed in vector and mutates it.

See Also:
load(java.util.Map, javax.swing.JTable), getCompressedDataVector(java.util.Vector)

getCompressedDataVector

protected java.util.Vector getCompressedDataVector(java.util.Vector dataVector)
Creates a compressed version of the given two-dimensional data vector. A data vector is compressed by removing all trailing empty row elements and trailing null elements in remaining rows. This method does not mutate passed in Vector.

See Also:
save(javax.swing.JTable), decompressDataVector(java.util.Vector, int)

getColumns

protected java.util.List getColumns(javax.swing.table.TableColumnModel columnModel)
Creates a List of Column objects from a table model's column enumerator.

See Also:
save(javax.swing.JTable), setColumns(java.util.List, javax.swing.table.TableColumnModel)

setColumns

protected void setColumns(java.util.List columns,
                          javax.swing.table.TableColumnModel columnModel)
Sets the columns in the table model based on the List containing Column objects.

See Also:
load(java.util.Map, javax.swing.JTable), getColumns(javax.swing.table.TableColumnModel)

load

protected abstract java.util.Map load(java.io.File file)
                               throws java.io.IOException
Throws:
java.io.IOException

save

protected abstract void save(java.util.Map map,
                             java.io.File file)
                      throws java.io.IOException
Throws:
java.io.IOException

evalValues

public boolean evalValues(javax.swing.JTable table,
                          java.util.Map map)