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 Summary
Fields inherited from class ghidra.framework.options.GProperties
DATE_FORMAT, map, NAME, TYPE -
Constructor Summary
ConstructorsChangeConstructorDescriptionDefault 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) REMOVEDRemoved -
Method Summary
ChangeModifier and TypeMethodDescriptionNEWprotected org.jdom.ElementcreateElement(String key, Object value) getSaveState(String name) Returns the sub SaveState associated with the given name.NEWprotected voidprocessElement(org.jdom.Element element) voidputSaveState(String name, SaveState value) Associates a sub SaveState value with the given name.MODIFIEDvoidsaveToFile(File file) Write the saveState to a file as XMLREMOVEDSaveStatereadJsonFile(File file) RemovedREMOVEDvoidsaveToJsonFile(File file) RemovedREMOVEDElementRemovedREMOVEDJsonObjectRemovedREMOVEDElementcreateElementFromElement(String internalKey, Element internalElement) RemovedREMOVEDbooleanisEmpty() RemovedREMOVEDvoidremove(String name) RemovedREMOVEDvoidclear() RemovedREMOVEDintsize() RemovedREMOVEDString[]getNames() RemovedREMOVEDvoidputInt(String name, int value) RemovedREMOVEDvoidputByte(String name, byte value) RemovedREMOVEDvoidputShort(String name, short value) RemovedREMOVEDvoidputLong(String name, long value) RemovedREMOVEDvoidputString(String name, String value) RemovedREMOVEDvoidputColor(String name, Color value) RemovedREMOVEDvoidputDate(String name, Date value) RemovedREMOVEDvoidputFile(String name, File value) RemovedREMOVEDvoidputKeyStroke(String name, KeyStroke value) RemovedREMOVEDvoidputFont(String name, Font value) RemovedREMOVEDvoidputBoolean(String name, boolean value) RemovedREMOVEDvoidputFloat(String name, float value) RemovedREMOVEDvoidputDouble(String name, double value) RemovedREMOVEDintgetInt(String name, int defaultValue) RemovedREMOVEDbytegetByte(String name, byte defaultValue) RemovedREMOVEDshortgetShort(String name, short defaultValue) RemovedREMOVEDlonggetLong(String name, long defaultValue) RemovedREMOVEDbooleangetBoolean(String name, boolean defaultValue) RemovedREMOVEDStringgetString(String name, String defaultValue) RemovedREMOVEDColorgetColor(String name, Color defaultValue) RemovedREMOVEDDategetDate(String name, Date defaultValue) RemovedREMOVEDFilegetFile(String name, File defaultValue) RemovedREMOVEDKeyStrokegetKeyStroke(String name, KeyStroke defaultValue) RemovedREMOVEDFontgetFont(String name, Font defaultValue) RemovedREMOVEDfloatgetFloat(String name, float defaultValue) RemovedREMOVEDdoublegetDouble(String name, double defaultValue) RemovedREMOVEDvoidputInts(String name, int[] value) RemovedREMOVEDvoidputBytes(String name, byte[] value) RemovedREMOVEDvoidputShorts(String name, short[] value) RemovedREMOVEDvoidputLongs(String name, long[] value) RemovedREMOVEDvoidputStrings(String name, String[] value) RemovedREMOVEDvoidputBooleans(String name, boolean[] value) RemovedREMOVEDvoidputFloats(String name, float[] value) RemovedREMOVEDvoidputDoubles(String name, double[] value) RemovedREMOVEDint[]getInts(String name, int[] defaultValue) RemovedREMOVEDbyte[]getBytes(String name, byte[] defaultValue) RemovedREMOVEDshort[]getShorts(String name, short[] defaultValue) RemovedREMOVEDlong[]getLongs(String name, long[] defaultValue) RemovedREMOVEDboolean[]getBooleans(String name, boolean[] defaultValue) RemovedREMOVEDString[]getStrings(String name, String[] defaultValue) RemovedREMOVEDTgetEnum(String name, T defaultValue) RemovedREMOVEDfloat[]getFloats(String name, float[] defaultValue) RemovedREMOVEDdouble[]getDoubles(String name, double[] defaultValue) RemovedREMOVEDbooleanhasValue(String name) RemovedREMOVEDvoidputXmlElement(String name, Element element) RemovedREMOVEDElementgetXmlElement(String name) RemovedREMOVEDStringtoString() RemovedMethods inherited from class ghidra.framework.options.GProperties
clear, createElementFromElement, getAsType, getBoolean, getBooleans, getByte, getBytes, getColor, getDate, getDouble, getDoubles, getEnum, getFile, getFloat, getFloats, getFont, getGProperties, getInt, getInts, getKeyStroke, getLong, getLongs, 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
-
SaveState
Creates 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
-
SaveState
public SaveState()Default Constructor for SaveState; uses "SAVE_STATE" as the name of the state.- See Also:
-
SaveState
Construct 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
-
SaveState
public SaveState(org.jdom.Element element)
-
-
Method Details
-
saveToFile MODIFIED
removed throws FileNotFoundException-void saveToFile(java.io.File file) throws FileNotFoundException, IOException+void saveToFile(java.io.File file) throws IOExceptionWrite the saveState to a file as XML- Parameters:
file- the file to write to.- Throws:
IOException- if the file could not be writtenFileNotFoundException(removed)
-
putSaveState
Associates 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.
-
getSaveState
Returns 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.
-
processElement NEW
protected void processElement(org.jdom.Element element) - Overrides:
processElementin classGProperties
-
createElement NEW
- Overrides:
createElementin classGProperties
-