Class Preferences
- java.lang.Object
-
- ghidra.framework.preferences.Preferences
-
public class Preferences extends java.lang.Object
Uses Properties to manage user preferences as name/value pairs. All methods are static.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
APPLICATION_PREFERENCES_FILENAME
TheAPPLICATION_PREFERENCES_FILENAME
is the default name for the user preferences file.static java.lang.String
LAST_EXPORT_DIRECTORY
Preference name for the export directory that was last accessed.static java.lang.String
LAST_IMPORT_DIRECTORY
Preference name for the import directory that was last accessed for domain files.static java.lang.String
LAST_NEW_PROJECT_DIRECTORY
Preference name for directory last selected for creating a new project.static java.lang.String
LAST_OPENED_ARCHIVE_DIRECTORY
Preference name for the last opened archive directory.static java.lang.String
LAST_TOOL_EXPORT_DIRECTORY
Preference name for export directory that was last accessed for tools.static java.lang.String
LAST_TOOL_IMPORT_DIRECTORY
Preference name for import directory that was last accessed for tools.static java.lang.String
PROJECT_DIRECTORY
Preference name for the project directory.static java.lang.String
USER_PLUGIN_JAR_DIRECTORY
Preference name of the user plugin jar directory.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
addPluginPath(java.lang.String path)
Append path to the plugin path.static void
addPluginPaths(java.lang.String[] paths)
Append paths to the plugin path.static void
clear()
Clears all properties in this Preferences object.static java.lang.String
getFilename()
Get the filename that will be used in the store() method.static java.lang.String[]
getPluginPaths()
Return the paths in the UserPluginPath property.static java.lang.String
getProperty(java.lang.String name)
Get the property with the given name.static java.lang.String
getProperty(java.lang.String name, java.lang.String defaultValue)
Get the property with the given name; if there is no property, return the defaultValue.static java.lang.String
getProperty(java.lang.String name, java.lang.String defaultValue, boolean useHistoricalValue)
Get the property with the given name; if there is no property, return the defaultValue.static java.util.List<java.lang.String>
getPropertyNames()
Get an array of known property names.static java.lang.String
removeProperty(java.lang.String name)
Removes the given preference from this preferences object.static void
setFilename(java.lang.String name)
Set the filename so that when the store() method is called, the preferences are written to this file.static void
setPluginPathProperty(java.lang.String pathProperty)
Set the plugin path property.static void
setPluginPaths(java.lang.String[] paths)
Set the paths to be used as the UserPluginPath property.static void
setProperty(java.lang.String name, java.lang.String value)
Set the property value.static boolean
store()
Store the preferences in a file for the current filename.
-
-
-
Field Detail
-
APPLICATION_PREFERENCES_FILENAME
public static final java.lang.String APPLICATION_PREFERENCES_FILENAME
TheAPPLICATION_PREFERENCES_FILENAME
is the default name for the user preferences file.- See Also:
Preferences
, Constant Field Values
-
USER_PLUGIN_JAR_DIRECTORY
public static final java.lang.String USER_PLUGIN_JAR_DIRECTORY
Preference name of the user plugin jar directory.- See Also:
- Constant Field Values
-
LAST_OPENED_ARCHIVE_DIRECTORY
public static final java.lang.String LAST_OPENED_ARCHIVE_DIRECTORY
Preference name for the last opened archive directory.- See Also:
- Constant Field Values
-
PROJECT_DIRECTORY
public static final java.lang.String PROJECT_DIRECTORY
Preference name for the project directory.- See Also:
- Constant Field Values
-
LAST_TOOL_IMPORT_DIRECTORY
public static final java.lang.String LAST_TOOL_IMPORT_DIRECTORY
Preference name for import directory that was last accessed for tools.- See Also:
- Constant Field Values
-
LAST_TOOL_EXPORT_DIRECTORY
public static final java.lang.String LAST_TOOL_EXPORT_DIRECTORY
Preference name for export directory that was last accessed for tools.- See Also:
- Constant Field Values
-
LAST_NEW_PROJECT_DIRECTORY
public static final java.lang.String LAST_NEW_PROJECT_DIRECTORY
Preference name for directory last selected for creating a new project.- See Also:
- Constant Field Values
-
LAST_IMPORT_DIRECTORY
public static final java.lang.String LAST_IMPORT_DIRECTORY
Preference name for the import directory that was last accessed for domain files.- See Also:
- Constant Field Values
-
LAST_EXPORT_DIRECTORY
public static final java.lang.String LAST_EXPORT_DIRECTORY
Preference name for the export directory that was last accessed.- See Also:
- Constant Field Values
-
-
Method Detail
-
clear
public static void clear()
Clears all properties in this Preferences object.Warning: Save any changes pending before calling this method, as this call will erase any changes not written do disk via
store()
-
removeProperty
public static java.lang.String removeProperty(java.lang.String name)
Removes the given preference from this preferences object.- Parameters:
name
- the name of the preference key to remove.- Returns:
- the value that was stored with the given key.
-
getProperty
public static java.lang.String getProperty(java.lang.String name)
Get the property with the given name.Note: all getProperty(...) methods will first check
System.getProperty(String)
for a value first. This allows users to override preferences from the command-line.
-
getProperty
public static java.lang.String getProperty(java.lang.String name, java.lang.String defaultValue)
Get the property with the given name; if there is no property, return the defaultValue.Note: all getProperty(...) methods will first check
System.getProperty(String)
for a value first. This allows users to override preferences from the command-line.- See Also:
getProperty(String, String, boolean)
-
getProperty
public static java.lang.String getProperty(java.lang.String name, java.lang.String defaultValue, boolean useHistoricalValue)
Get the property with the given name; if there is no property, return the defaultValue.This version of getProperty will, when useHistoricalValue is true, look for the given preference value in the last used installation of the application.
Note: all getProperty(...) methods will first check
System.getProperty(String)
for a value first. This allows users to override preferences from the command-line.- Parameters:
name
- The name of the property for which to get a valuedefaultValue
- The value to use if there is no value yet set for the given nameuseHistoricalValue
- True signals to check the last used application installation for a value for the given name if that value has not yet been set.- Returns:
- the property with the given name; if there is no property, return the defaultValue.
- See Also:
getProperty(String)
,getProperty(String, String)
-
setProperty
public static void setProperty(java.lang.String name, java.lang.String value)
Set the property value. If a null value is passed, then the property is removed from this collection of preferences.- Parameters:
name
- property namevalue
- value for property
-
getPropertyNames
public static java.util.List<java.lang.String> getPropertyNames()
Get an array of known property names.- Returns:
- if there are no properties, return a zero-length array
-
getFilename
public static java.lang.String getFilename()
Get the filename that will be used in the store() method.
-
setFilename
public static void setFilename(java.lang.String name)
Set the filename so that when the store() method is called, the preferences are written to this file.- Parameters:
name
-
-
store
public static boolean store()
Store the preferences in a file for the current filename.- Throws:
java.lang.RuntimeException
- if the preferences filename was not set
-
getPluginPaths
public static java.lang.String[] getPluginPaths()
Return the paths in the UserPluginPath property. Return zero length array if this property is not set.
-
setPluginPaths
public static void setPluginPaths(java.lang.String[] paths)
Set the paths to be used as the UserPluginPath property.
-
setPluginPathProperty
public static void setPluginPathProperty(java.lang.String pathProperty)
Set the plugin path property.- Parameters:
pathProperty
- A string of paths separated byFile.pathSeparator
characters
-
addPluginPath
public static void addPluginPath(java.lang.String path)
Append path to the plugin path.- Parameters:
path
- the plugin path to add
-
addPluginPaths
public static void addPluginPaths(java.lang.String[] paths)
Append paths to the plugin path.- Parameters:
paths
- the plugin paths to add
-
-