java.lang.Object
org.autogui.base.mapping.GuiPreferences
- Direct Known Subclasses:
GuiPreferences.GuiPreferencesWithPaths
the Preferences holder associated to a
GuiMappingContext
.
Each child is also held by GuiMappingContext
.
The class has a GuiPreferences.GuiValueStore
.
It also has a list of history values.
pack/Type/ //root-context, in a case ofGuiReprObjectPane
(pack.Type) //otherwise, "org/autogui/base/mapping/pack_Type" "$default"/ propName = value... //regular preferences entries ... "$value" = ... //current value, which will precede to history values "$history"/ "0"/ //key-index "index" = ... "value" = ... "time" = ... //Instant.toString()
... propertyName/ //the name of a sub-context ... "$launchPrefs" = "..." //value of "$uuid", "" or "empty" "$saved"/ "$0"/ "$name" = ... "$uuid" = "..." //a value from UUID.randomUUID() ... //same structure as "$default" ...
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
a subclass of prefs for custom usage with supplying specific sub-paths.static class
the abstract definition of key-value store.static class
the concrete implementation of the store byPreferences
static class
an on-memory impl.static class
an entry of the value history, consisting of a value, an index and a time-stamp, associated with a key-index.static class
JSON entry for JSON support objectstatic class
an on-memory impl.static interface
the interface for supporting user-defined prefs: a context-object that implements the interface always saves/loads prefs via the interface.static class
the entire lock object for the preferences -
Field Summary
Modifier and TypeFieldDescriptionprotected Map<GuiMappingContext,
GuiPreferences> protected GuiMappingContext
protected int
protected List<GuiPreferences.HistoryValueEntry>
protected GuiPreferences.PreferencesLock
protected GuiPreferences
protected GuiPreferences.GuiValueStore
-
Constructor Summary
ConstructorDescriptionGuiPreferences
(GuiMappingContext context) GuiPreferences
(GuiPreferences.GuiValueStore valueStore, GuiMappingContext context) GuiPreferences
(GuiPreferences parent, GuiMappingContext context) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addHistoryValue
(Object value) add a value to the history.void
addHistoryValue
(Object value, Instant optionalTime) void
clearAll()
after calling the method, the preferences will be invalidatedvoid
void
copyOnMemory
(GuiPreferences parent) static GuiPreferences.GuiValueStore
copyOnMemoryStore
(GuiPreferences src, GuiPreferences prefs, GuiPreferences.GuiValueStore store, boolean putToParent) createHistoryValueEntry
(Object value) void
protected void
fromJsonChildNodes
(GuiPreferences.GuiValueStore store, Map<String, Object> json) getChild
(GuiMappingContext context) loads prefs JSON object forGuiPreferences.PreferencesJsonSupport.setPrefsJson(Map)
getDescendant
(GuiMappingContext descendantContext) getHistoryValue
(Object value) int
getName()
"$default/" ...static int
boolean
void
load or create historyValues: it's size becomes up to historyValueLimit and sorted by index.lock()
replaceMin
(Object v, GuiPreferences.HistoryValueEntry optionalDefault) void
protected void
setChild
(GuiMappingContext context, GuiPreferences child) void
setCurrentValue
(Object value) void
obtainstoJson()
and saves the returned JSON as a prefs entryvoid
setLaunchPrefsAsRoot
(String uuid) toJson()
static String
toStoreKey
(String key)
-
Field Details
-
context
-
parent
-
children
-
valueStore
-
historyValues
-
historyValueLimit
protected int historyValueLimit -
lock
- Since:
- 1.6
-
-
Constructor Details
-
GuiPreferences
-
GuiPreferences
-
GuiPreferences
-
-
Method Details
-
isContextTypeIsJsonSupport
public boolean isContextTypeIsJsonSupport()- Returns:
- the type of the context of the prefs is
GuiPreferences.PreferencesJsonSupport
- Since:
- 1.5
-
getStoreValueMaxLength
public static int getStoreValueMaxLength() -
toStoreKey
-
getChild
- Parameters:
context
- the parent- Returns:
- a child preference for context
-
setChild
-
getName
-
getContext
-
getParent
-
getDescendant
- Parameters:
descendantContext
- a descendant context of the context returned bygetContext()
, can begetContext()
itself- Returns:
- a descendant preference associated with the descendantContext
-
getValueStore
- Returns:
- Preferences based value-store. if it has parent, node for context's name of the parent, otherwise, node for context's object-type (user-node "/pack/ObjType") or node for (pack of this type)+"/"+(context's name).
-
getValueStoreRootFromRepresentation
-
getPreferencesNodeAsRoot
-
resetAsRoot
public void resetAsRoot() -
lock
- Returns:
- lock object with holding the lock
- Since:
- 1.6
-
getSavedStoreListAsRoot
"$default/" ... "$launchPrefs" = "..." "$saved/" "$0/" "$name" = "prefs yyyy/mm/dd hh:mm" "$uuid" = "..." //checked ... "$1/" ...
- Returns:
- saved preferences
-
getLaunchPrefsAsRoot
- Returns:
- "": value of "$uuid", "" (default) or "empty" (empty)
-
setLaunchPrefsAsRoot
-
addNewSavedStoreAsRoot
-
setCurrentValue
-
setCurrentValueAsJsonSupported
obtainstoJson()
and saves the returned JSON as a prefs entry- Parameters:
json
- the saved object- Since:
- 1.5
-
getCurrentValue
-
getCurrentValueAsJsonSupported
loads prefs JSON object forGuiPreferences.PreferencesJsonSupport.setPrefsJson(Map)
- Returns:
- loaded JSON object
- Since:
- 1.5
-
addHistoryValue
add a value to the history.- it first loads the existing history if not yet loaded, by
loadHistoryValues()
. -
it finds an existing entry or a create new entry by
getHistoryValue(Object)
. -
if the entry is a new one (keyIndex==-1), call
replaceMin(Object, HistoryValueEntry)
and obtain the oldest entry with replacing the value. - The entry moves to the end of the history as the latest value, by setting the max index + 1 as it's index, which is a temporarly index. The entire history is sorted by the indices.
-
remove overflowed entries with calling
GuiPreferences.HistoryValueEntry.remove()
. (regularly, this step never happens.) - set index and keyIndex (if keyIndex==-1) for all entries, and flush the store.
- Parameters:
value
- the new entry value
- it first loads the existing history if not yet loaded, by
-
addHistoryValue
-
getHistoryValueUnusedKeyIndex
public int getHistoryValueUnusedKeyIndex() -
getHistoryValues
-
getHistoryValue
- Parameters:
value
- the entry value- Returns:
- a new entry (keyIndex == -1) or an existing entry
-
replaceMin
public GuiPreferences.HistoryValueEntry replaceMin(Object v, GuiPreferences.HistoryValueEntry optionalDefault) -
loadHistoryValues
public void loadHistoryValues()load or create historyValues: it's size becomes up to historyValueLimit and sorted by index. The new entries have -1 indices. -
createHistoryValueEntry
-
clearAll
public void clearAll()after calling the method, the preferences will be invalidated -
clearHistoriesTree
public void clearHistoriesTree() -
clearHistories
public void clearHistories() -
toJson
-
copyOnMemoryAsRoot
-
copyOnMemory
- Parameters:
parent
- the parent which is already an on-memory instance or null- Returns:
- the copied preferences whose value-store is a
GuiPreferences.GuiValueStoreOnMemory
-
copyOnMemoryStore
public static GuiPreferences.GuiValueStore copyOnMemoryStore(GuiPreferences src, GuiPreferences prefs, GuiPreferences.GuiValueStore store, boolean putToParent) -
fromJson
-
fromJsonChildNodes
-