public class StoreConfiguration extends AbstractTableModel
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.
Element
,
StoreControlFrame
,
StoreSource
,
Serialized FormModifier and Type | Field and Description |
---|---|
protected String |
applicationName
Name of the application (used for name of config directory).
|
protected Document |
document
The Document.
|
protected Element |
rootElement
Document root Element.
|
protected String |
storeName
Name of the file used for storage.
|
listenerList
Constructor and Description |
---|
StoreConfiguration(InputStream inputStream)
Create an instance.
|
StoreConfiguration(String applicationName,
String storeName)
Create an instance.
|
Modifier and Type | Method and Description |
---|---|
protected void |
createEmptyDoc()
Create an empty document
|
static List<Element> |
getChildElements(Element element)
Return all the Elements that are children of another Element.
|
int |
getColumnCount()
Get the number of columns.
|
String |
getColumnName(int column)
Get the name of a column.
|
int |
getCount()
Get the number of states that are stored.
|
String |
getDateStamp(int index)
Get the date stamp of a state by index.
|
String |
getDescription(int index)
Get the description of a state by index.
|
int |
getRowCount()
Return the numbers of states that we're currently storing.
|
Element |
getState(int index)
Get a state from the store.
|
Object |
getValueAt(int row,
int column)
Return either the description or date stamp of a state.
|
void |
initFromBackingStore()
Initialise the local DOM from the backing store file.
|
void |
initFromBackingStore(InputStream inputStream)
Initialise the local DOM from an InputStream.
|
boolean |
isCellEditable(int row,
int column)
Let the JTable know that the descriptions are edittable.
|
Element |
newState(String elementName,
String description)
Create a new Element ready for attaching a configuration state
to (i.e.
|
Element |
reGetState(int index)
Re-get a state from the store.
|
void |
removeState(int index)
Permanently remove a state from store.
|
void |
setDateStamp(int index)
Set the date stamp of a state by index.
|
void |
setDescription(int index,
String value)
Set the description of a state by index.
|
void |
setValueAt(Object value,
int row,
int column)
Change a description in response to a user edit.
|
void |
stateCompleted(Element newState)
Add a new state root in a given Element.
|
void |
writeToBackingStore()
Save the Document to backing store.
|
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getColumnClass, getListeners, getTableModelListeners, removeTableModelListener
protected Document document
protected Element rootElement
protected String applicationName
protected String storeName
public StoreConfiguration(String applicationName, String storeName)
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
configurationpublic StoreConfiguration(InputStream inputStream)
inputStream
- InputStream that contains an XML description of a
series of configurations (i.e. a wrapped backing
store file).public void initFromBackingStore(InputStream inputStream)
public void initFromBackingStore()
protected void createEmptyDoc()
public static List<Element> getChildElements(Element element)
public int getCount()
public Element getState(int index)
public Element reGetState(int index)
public String getDescription(int index)
public void setDescription(int index, String value)
public String getDateStamp(int index)
public void setDateStamp(int index)
public void stateCompleted(Element newState)
public Element newState(String elementName, String description)
public void removeState(int index)
public void writeToBackingStore()
public int getRowCount()
public int getColumnCount()
public Object getValueAt(int row, int column)
public String getColumnName(int column)
getColumnName
in interface TableModel
getColumnName
in class AbstractTableModel
public void setValueAt(Object value, int row, int column)
setValueAt
in interface TableModel
setValueAt
in class AbstractTableModel
public boolean isCellEditable(int row, int column)
isCellEditable
in interface TableModel
isCellEditable
in class AbstractTableModel
Copyright © 2024 Central Laboratory of the Research Councils. All Rights Reserved.