Class StoreConfiguration
- All Implemented Interfaces:
Serializable, TableModel
An instance of this class presents itself as two services. One is as a JTable model, this provides a model of two columns, the first being the state description the second the date stamp. The second set of services are provided to get at states and to store new ones. These latter options are provided by passing back references to suitable Elements of a Document, which then act as roots for the state.
The format of the XML file is just determined by the practices
adopted in this file and by the StoreSource
implementation, rather than by a DTD or Schema. The root element is
<configs> each child of this element is called whatever
StoreSource.getTagName() returns, with the attributes "description"
and "date-stamp", what goes after this is determined by the writer
of the configurations, but the general idea is for each object in
the configuration to write its state to a new Element.
- Author:
- Peter W. Draper
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected StringName of the application (used for name of config directory).protected DocumentThe Document.protected ElementDocument root Element.protected StringName of the file used for storage.Fields inherited from class AbstractTableModel
listenerList -
Constructor Summary
ConstructorsConstructorDescriptionStoreConfiguration(InputStream inputStream) Create an instance.StoreConfiguration(String applicationName, String storeName) Create an instance. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidCreate an empty documentgetChildElements(Element element) Return all the Elements that are children of another Element.intGet the number of columns.getColumnName(int column) Get the name of a column.intgetCount()Get the number of states that are stored.getDateStamp(int index) Get the date stamp of a state by index.getDescription(int index) Get the description of a state by index.intReturn the numbers of states that we're currently storing.getState(int index) Get a state from the store.getValueAt(int row, int column) Return either the description or date stamp of a state.voidInitialise the local DOM from the backing store file.voidinitFromBackingStore(InputStream inputStream) Initialise the local DOM from an InputStream.booleanisCellEditable(int row, int column) Let the JTable know that the descriptions are edittable.Create a new Element ready for attaching a configuration state to (i.e.reGetState(int index) Re-get a state from the store.voidremoveState(int index) Permanently remove a state from store.voidsetDateStamp(int index) Set the date stamp of a state by index.voidsetDescription(int index, String value) Set the description of a state by index.voidsetValueAt(Object value, int row, int column) Change a description in response to a user edit.voidstateCompleted(Element newState) Add a new state root in a given Element.voidSave the Document to backing store.Methods inherited from class AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getColumnClass, getListeners, getTableModelListeners, removeTableModelListener
-
Field Details
-
document
The Document. -
rootElement
Document root Element. -
applicationName
Name of the application (used for name of config directory). -
storeName
Name of the file used for storage.
-
-
Constructor Details
-
StoreConfiguration
Create an instance. This synchronises the current total state with that of the backing store.- Parameters:
applicationName- name of the application controlling this store. Used to create a top-element, also defines the configuration directory. XXX use Properties for this?storeName- name of the file that contains the configuration
-
StoreConfiguration
Create an instance. This synchronises the current total state with that read from a given InputStream (useful when want to get a default configuration using a getResource()). If you use this method it is not possible to save to backing store.- Parameters:
inputStream- InputStream that contains an XML description of a series of configurations (i.e. a wrapped backing store file).
-
-
Method Details
-
initFromBackingStore
Initialise the local DOM from an InputStream. -
initFromBackingStore
public void initFromBackingStore()Initialise the local DOM from the backing store file. If this doesn't exist then just create an empty Document with a basic root Element. -
createEmptyDoc
protected void createEmptyDoc()Create an empty document -
getChildElements
-
getCount
public int getCount()Get the number of states that are stored. -
getState
Get a state from the store. These are indexed simply by the order in the current document. -
reGetState
Re-get a state from the store. Re-getting implies that this will be overwritten so all children are removed. -
getDescription
Get the description of a state by index. -
setDescription
Set the description of a state by index. -
getDateStamp
Get the date stamp of a state by index. -
setDateStamp
public void setDateStamp(int index) Set the date stamp of a state by index. Updates to representation of the current time. -
stateCompleted
Add a new state root in a given Element. The Element should be created by the newState method. -
newState
Create a new Element ready for attaching a configuration state to (i.e. get this Element then write the configuration data attached to it). When the new configuration is completed invoke the stateCompleted method, the configuration will not be part of the structure until then. -
removeState
public void removeState(int index) Permanently remove a state from store. -
writeToBackingStore
public void writeToBackingStore()Save the Document to backing store. -
getRowCount
public int getRowCount()Return the numbers of states that we're currently storing. -
getColumnCount
public int getColumnCount()Get the number of columns. Always 2. -
getValueAt
Return either the description or date stamp of a state. -
getColumnName
Get the name of a column.- Specified by:
getColumnNamein interfaceTableModel- Overrides:
getColumnNamein classAbstractTableModel
-
setValueAt
Change a description in response to a user edit.- Specified by:
setValueAtin interfaceTableModel- Overrides:
setValueAtin classAbstractTableModel
-
isCellEditable
public boolean isCellEditable(int row, int column) Let the JTable know that the descriptions are edittable.- Specified by:
isCellEditablein interfaceTableModel- Overrides:
isCellEditablein classAbstractTableModel
-