public abstract class AbstractConfigStorage extends java.lang.Object implements ConfigStorage, ConfigConstants
Modifier and Type | Field and Description |
---|---|
protected int |
blockSize |
protected long |
interval |
protected java.util.TimerTask |
loadJob |
protected ConfigRegistry |
registry |
protected java.util.TimerTask |
saveJob |
protected java.util.concurrent.atomic.AtomicBoolean |
saveScheduled |
protected int |
strategy |
protected java.util.concurrent.atomic.AtomicInteger |
unsavedChangesCounter |
BLOCKWISE_SAVING, DESCRIPTION_KEY, DISPLAY_MODE, ENTRY_HIDDEN, ENTRY_LOCKED, ENTRY_MODIFIABLE, EXCLUSIVE, FILE_TYPE, FOLDER_TYPE, GROUP_VIRTUAL, HANDLER, IMMEDIATE_SAVING, INDENT, INLINE, ITEM_TYPE, MANUAL_SAVING, MAX_ITEM_COUNT, MAX_LENGTH, MAX_VALUE, MIN_ITEM_COUNT, MIN_VALUE, MODE_GRID, MODE_LIST, MODE_TABBED, MODE_TREE, MULTILINE, NAME_KEY, NOTE_KEY, OPTIONS, OPTIONS_KEYS, ORIENTATION, PATTERN, PATTERN_DESCRIPTION_KEY, PERIODIC_SAVING, PRECISION, RENDERER, SEPARATED
Constructor and Description |
---|
AbstractConfigStorage() |
Modifier and Type | Method and Description |
---|---|
void |
commit()
Tells the storage to asynchronously save its
data to the underlying resource location.
|
void |
commitNow() |
int |
getBlockSize() |
long |
getInterval() |
boolean |
hasUnsavedChanges() |
protected abstract void |
read() |
void |
setBlockSize(int blockSize) |
void |
setInterval(long interval) |
void |
setRegistry(ConfigRegistry registry)
Sets the
ConfigRegistry for this
storage. |
void |
setStrategy(int strategy) |
void |
setValue(java.lang.String path,
java.lang.Object value)
Stores the new value for the given path.
|
protected abstract boolean |
setValue0(java.lang.String path,
java.lang.Object value) |
void |
update()
Tells the storage to asynchronously reload its
data from whatever source it is linked with.
|
void |
updateNow()
Loads data synchronously from the underlying data storage.
|
protected abstract void |
write() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getValue
protected java.util.concurrent.atomic.AtomicInteger unsavedChangesCounter
protected java.util.concurrent.atomic.AtomicBoolean saveScheduled
protected int strategy
protected int blockSize
protected long interval
protected ConfigRegistry registry
protected java.util.TimerTask saveJob
protected java.util.TimerTask loadJob
protected abstract void read() throws java.lang.Exception
java.lang.Exception
protected abstract void write() throws java.lang.Exception
java.lang.Exception
public void setRegistry(ConfigRegistry registry)
ConfigStorage
ConfigRegistry
for this
storage.The registry should only be used for callback reasons when data in the storage has been updated and entries in the registry have to be synchronized.
setRegistry
in interface ConfigStorage
public boolean hasUnsavedChanges()
hasUnsavedChanges
in interface ConfigStorage
public void setStrategy(int strategy)
public void commit()
ConfigStorage
commit
in interface ConfigStorage
public void update()
ConfigStorage
update
in interface ConfigStorage
public void commitNow()
commitNow
in interface ConfigStorage
public void updateNow()
ConfigStorage
updateNow
in interface ConfigStorage
public void setValue(java.lang.String path, java.lang.Object value)
ConfigStorage
The actual further reaction to this call is implementation dependent. Some storages will mirror every change instantly to the underlying storage back-end, others will delay such saving or even omit it totally and rely on user side decisions.
setValue
in interface ConfigStorage
protected abstract boolean setValue0(java.lang.String path, java.lang.Object value)
public int getBlockSize()
public void setBlockSize(int blockSize)
blockSize
- the blockSize to setpublic long getInterval()
public void setInterval(long interval)
interval
- the interval to set