public class Preferences extends Object
Constructor and Description |
---|
Preferences()
Load the preferences from the default location (~/.jsky/jsky.properties)
|
Preferences(String filename)
Load the preferences from the given filename.
|
Modifier and Type | Method and Description |
---|---|
Object |
deserialize(String name)
Attempt to read a serialized object from a file with the given base name.
|
static String |
get(String key)
Return the preference value for the given key, or null if not found.
|
static boolean |
get(String key,
boolean defaultValue)
Return the preference value for the given key, or the default value if not found.
|
static String |
get(String key,
String defaultValue)
Return the preference value for the given key, or the default value if not found.
|
File |
getCacheDir()
Return the name of the directory to use to save downloaded files.
|
File |
getDir()
Return the name of the directory to use to store the preferences.
|
File |
getFile()
Return the full path name of the file to use to store the preferences
|
String |
getPreference(String key)
Return the preference value for the given key, or null if not found.
|
String |
getPreference(String key,
String defaultValue)
Return the preference value for the given key, or the default value if not found.
|
static Preferences |
getPreferences()
Return the global instance of this class, creating one first if needed
|
Properties |
getProperties()
Return the Properties object used to store the key/value pairs.
|
String |
getSep()
Return the system path separator.
|
static void |
manageLocation(Component component)
Track changes in the location of the given component (normally
a JFrame or JInternalFrame).
|
static void |
manageLocation(Component component,
int x,
int y)
Track changes in the location of the given component (normally
a JFrame or JInternalFrame).
|
static void |
manageLocation(Component component,
int x,
int y,
String name)
Track changes in the location of the given component (normally
a JFrame or JInternalFrame).
|
static void |
manageSize(JComponent component,
Dimension defaultSize)
Track changes in the size of the given component.
|
static void |
manageSize(JComponent component,
Dimension defaultSize,
String name)
Track changes in the size of the given component.
|
void |
serialize(String name,
Object object)
Attempt to serialize an object to a file with the given base name.
|
static void |
set(String key,
boolean value)
Add a key,value pair to the set of preferences.
|
static void |
set(String key,
String value)
Add a key,value pair to the set of preferences.
|
void |
setPreference(String key,
String value)
Add a key,value pair to the set of preferences.
|
static void |
setPreferences(Preferences p)
Set the one global instance of this class.
|
static void |
unset(String key)
Remove a key from the set of preferences.
|
void |
unsetPreference(String key)
Remove a key from the set of preferences.
|
public Preferences()
public Preferences(String filename)
public File getDir()
public File getCacheDir()
public String getSep()
public File getFile()
public Properties getProperties()
public static Preferences getPreferences()
public static void setPreferences(Preferences p)
public void setPreference(String key, String value)
public void unsetPreference(String key)
public String getPreference(String key)
public String getPreference(String key, String defaultValue)
public static void set(String key, String value)
public static void set(String key, boolean value)
public static void unset(String key)
public static String get(String key)
public static String get(String key, String defaultValue)
public static boolean get(String key, boolean defaultValue)
public void serialize(String name, Object object) throws FileNotFoundException, OptionalDataException, IOException
getDir()
plus the name plus the suffix ".ser".public Object deserialize(String name) throws FileNotFoundException, ClassNotFoundException, IOException
getDir()
plus the name plus the suffix ".ser". An exception is thrown if the file
does not exist or is corrupt.public static void manageLocation(Component component)
component
- a component whose location should be restored when the
application restartspublic static void manageLocation(Component component, int x, int y)
component
- a component whose location should be restored when the
application restartsx
- the default x location of the componenty
- the default y location of the componentpublic static void manageLocation(Component component, int x, int y, String name)
component
- a component whose location should be restored when the
application restartsx
- the default x location of the componenty
- the default y location of the componentname
- the name to store this information underpublic static void manageSize(JComponent component, Dimension defaultSize)
component
- a component whose size should be restored when the
application restartspreferredSize
- the default size of the component, or null for the defaultpublic static void manageSize(JComponent component, Dimension defaultSize, String name)
component
- a component whose size should be restored when the
application restartspreferredSize
- the default size of the componentname
- the name to store this information underCopyright © 2023 Central Laboratory of the Research Councils. All Rights Reserved.