Package ghidra.framework.options
Class SaveState
java.lang.Object
ghidra.framework.options.GProperties
ghidra.framework.options.XmlProperties
ghidra.framework.options.SaveState
- Direct Known Subclasses:
- PreferenceState
Class for saving name/value pairs as XML or Json.  Classes that want to be
 able to save their state can do so using the SaveState object.
 The idea is that each state variable in the class
 is first saved into a SaveState object via a String key.  Then the SaveState
 object is written out as XML or Json.  When the save state object is
 restored, the SaveState object is constructed with an XML Element or JsonObject
 that contains all of the name/value pairs. Since the "get" methods require
 a default value, the object that is recovering its state variables
 will be successfully initialized even if
 the given key,value pair is not found in the SaveState object.
 
Note: Names for options are assumed to be unique. When a putXXX() method is called, if a value already exists for a name, it will be overwritten.
The SaveState supports the following types:
      java primitives
      arrays of java primitives
      String
      Color
      Font
      KeyStroke
      File
      Date
      Enum
      SaveState (values can be nested SaveStates)
  - 
Field SummaryFields inherited from class ghidra.framework.options.GPropertiesDATE_FORMAT, map, NAME, TYPE
- 
Constructor SummaryConstructorsConstructorDescriptionDefault Constructor for SaveState; uses "SAVE_STATE" as the name of the state.Construct a SaveState from a file containing XML from a previously saved SaveState.Creates a new SaveState object with a non-default name.SaveState(org.jdom.Element element) 
- 
Method SummaryModifier and TypeMethodDescriptionprotected org.jdom.ElementcreateElement(String key, Object value) getSaveState(String name) Returns the sub SaveState associated with the given name.protected voidprocessElement(org.jdom.Element element) voidputSaveState(String name, SaveState value) Associates a sub SaveState value with the given name.voidsaveToFile(File file) Write the saveState to a file as XMLMethods inherited from class ghidra.framework.options.GPropertiesclear, createElementFromElement, getAsType, getBoolean, getBooleans, getByte, getBytes, getColor, getDate, getDouble, getDoubles, getEnum, getFile, getFloat, getFloats, getFont, getGProperties, getInt, getInts, getKeyStroke, getLong, getLongs, getName, getNames, getShort, getShorts, getString, getStrings, getXmlElement, hasValue, isEmpty, putBoolean, putBooleans, putByte, putBytes, putColor, putDate, putDouble, putDoubles, putEnum, putFile, putFloat, putFloats, putFont, putGProperties, putInt, putInts, putKeyStroke, putLong, putLongs, putShort, putShorts, putString, putStrings, putXmlElement, remove, saveToJson, saveToJsonFile, saveToXml, saveToXmlFile, size, toString
- 
Constructor Details- 
SaveStateCreates a new SaveState object with a non-default name. The name serves no real purpose other than as a hint as to what the SaveState represents- Parameters:
- name- of the state
 
- 
SaveStatepublic SaveState()Default Constructor for SaveState; uses "SAVE_STATE" as the name of the state.- See Also:
 
- 
SaveStateConstruct a SaveState from a file containing XML from a previously saved SaveState.- Parameters:
- file- the file containing the XML to read.
- Throws:
- IOException- if the file can't be read or is not formatted properly for a SaveState
 
- 
SaveStatepublic SaveState(org.jdom.Element element) 
 
- 
- 
Method Details- 
saveToFileWrite the saveState to a file as XML- Parameters:
- file- the file to write to.
- Throws:
- IOException- if the file could not be written
 
- 
putSaveStateAssociates a sub SaveState value with the given name.- Parameters:
- name- The name in the name,value pair.
- value- The value in the name,value pair.
 
- 
getSaveStateReturns the sub SaveState associated with the given name.- Parameters:
- name- The name associated with the desired Element.
- Returns:
- The SaveState object associated with the given name.
 
- 
processElementprotected void processElement(org.jdom.Element element) - Overrides:
- processElementin class- GProperties
 
- 
createElement- Overrides:
- createElementin class- GProperties
 
 
-