Module org.autogui

Class GuiPreferences.HistoryValueEntry

java.lang.Object
org.autogui.base.mapping.GuiPreferences.HistoryValueEntry
Direct Known Subclasses:
GuiPreferences.HistoryValueEntryJsonSupported, GuiPreferences.HistoryValueEntryOnMemory
Enclosing class:
GuiPreferences

public static class GuiPreferences.HistoryValueEntry extends Object
an entry of the value history, consisting of a value, an index and a time-stamp, associated with a key-index.
     preferences/
        "$history"/
           keyIndex/    : valueStore
                "index" : int
                "value" : String
                "time"  : String //Instant
           ...
 

The value has the following stages. Some types have same form in the multiple stages.

  1. rawObject : actual object. the constructor takes it.
  2. value : the instance-field holds on the memory, toValueInit(Object) with rawObject. if non-null isJsonValue() rawObject, it will be converted as JSON by repr, otherwise, rawObject. setValue(Object) takes it.
  3. storedJsonValue : a JSON object internally created by getStoredJsonValue(). if isJsonValue(), value itself, otherwise, converted JSON by repr.
  4. source : JSON source by getStoredJsonValue()
  • Field Details

  • Constructor Details

  • Method Details

    • toValueInit

      protected Object toValueInit(Object rawObject)
      called from the constructor
      Parameters:
      rawObject - the constructor argument
      Returns:
      stored value as a prefs entry
      Since:
      1.5
    • match

      public boolean match(Object v)
    • getValue

      public Object getValue()
    • setValue

      public void setValue(Object value)
    • storeValue

      protected void storeValue()
    • getKeyIndex

      public int getKeyIndex()
    • getIndex

      public int getIndex()
    • getTime

      public Instant getTime()
    • remove

      public void remove()
    • setKeyIndexWithLoadOrStore

      public void setKeyIndexWithLoadOrStore(int keyIndex)
      if the keyIndex is not -1, it causes store() (if value has been set) or load() (not set).
      Parameters:
      keyIndex - the key index
    • load

      public void load()
      load the "$history/index" value, and if the value is not -1, then also load "$history/value" and decode it as JSON and GuiRepresentation.fromJson(GuiMappingContext, Object, Object). Also, when the value is not -1, load "$history/time" and decode it as a Instant string. getValue() will be null if it failed.
    • fromJsonSource

      public Object fromJsonSource(String s)
    • isJsonValue

      public boolean isJsonValue()
      Returns:
      if false, the value holds a raw-object which might be a non-JSON object, and then the associated representation can create a new value from a JSON source without any raw-object.
    • store

      public void store()
    • getStoredJsonValue

      public String getStoredJsonValue()
    • getValueStore

      public GuiPreferences.GuiValueStore getValueStore()
    • getParent

      protected GuiPreferences.GuiValueStore getParent()
    • setIndex

      public void setIndex(int index)
    • setTime

      public void setTime(Instant time)
    • storeAsCurrentValue

      public void storeAsCurrentValue()
    • loadAsCurrentValue

      public Object loadAsCurrentValue()