public class CASA extends Object
Modifier and Type | Class and Description |
---|---|
(package private) static class |
CASA.SilentPreferences |
Modifier and Type | Field and Description |
---|---|
static int |
ENVIRONMENT |
static int |
SYSTEM |
private static CASA.SilentPreferences |
systemPreferences |
private static boolean |
systemPrefsFailureLogged
Set this to false if you want to attempt to write appropriate data to the System preferences,
otherwise (if true) this will not bother to attempt to write to System preferences.
|
static int |
USER |
private static CASA.SilentPreferences |
userPreferences |
Constructor and Description |
---|
CASA() |
Modifier and Type | Method and Description |
---|---|
protected void |
finalize() |
static void |
flush(int operation)
Flushes user and/or system preferences to make them persistent.
|
static String |
getBuildInfo() |
static int |
getLACdefaultport() |
private static boolean |
getPref(String name,
boolean default_) |
private static int |
getPref(String name,
int default_) |
private static String |
getPref(String name,
String default_) |
static boolean |
getPreference(String prefName,
boolean defaultValue,
int function)
Specialized boolean version of
getPreference(String, String, int) . |
static int |
getPreference(String prefName,
int defaultValue,
int function)
Specialized int version of
getPreference(String, String, int) . |
static long |
getPreference(String prefName,
long defaultValue,
int function)
Specialized long version of
getPreference(String, String, int) . |
static Map<String,String> |
getPreference(String prefName,
Map<String,String> defaultValue,
int operation) |
static String |
getPreference(String prefName,
String defaultValue,
int operation)
Reads preferences from one of:
System environment variables
System user preferences
System system preferences
in that order.
|
static String |
getPutPreferenceIfAbsent() |
static String |
getRoot() |
static String |
getRouter() |
static boolean |
isDieOnLACExitDefault() |
private static boolean |
isPrefPresent(CASA.SilentPreferences p,
String name) |
static boolean |
isSystemPrefsWorking(boolean verbose) |
static void |
putPreference(String prefName,
boolean defaultValue,
int operation) |
static void |
putPreference(String prefName,
int defaultValue,
int operation) |
static void |
putPreference(String prefName,
Map<String,?> defaultValue,
int operation) |
static void |
putPreference(String prefName,
String defaultValue,
int operation) |
static void |
putPreferenceIfAbsent(String prefName,
int defaultValue,
int operation) |
static void |
putPreferenceIfAbsent(String prefName,
String defaultValue,
int operation) |
static void |
removePreference(String prefName,
int operation) |
static void |
setDieOnLACExitDefault(boolean dieOnLACExitDefault) |
static void |
setLACdefaultport(int lACdefaultport) |
private static void |
setPref(String name,
boolean default_) |
private static void |
setPref(String name,
int default_) |
private static void |
setPref(String name,
String default_) |
static void |
setPutPreferenceIfAbsent(String putPreferenceIfAbsent) |
static void |
setRoot(String root) |
static void |
setRouter(String router) |
void |
setUp() |
void |
tearDown() |
void |
testPrefs() |
static void |
writeDefaultPrefs()
Write out the default preferences to both the user and system preferences.
|
private static final CASA.SilentPreferences userPreferences
private static final CASA.SilentPreferences systemPreferences
public static int ENVIRONMENT
public static int USER
public static int SYSTEM
private static boolean systemPrefsFailureLogged
public static void writeDefaultPrefs()
public static boolean isSystemPrefsWorking(boolean verbose)
public static String getPreference(String prefName, String defaultValue, int operation)
ENVIRONMENT
, USER
, SYSTEM
, #SAVE
, and #REMOVE
. The first
three flags mean we should attempt to read from that source (in that order). The #SAVE
flag indicates that, if we don't find the value in that source (or some error occurs), we
should save the given defaultValue to that source (but only the first one, in order). However,
this method will never overwrite a non-default value in the preferences store (although it can be
used to remove an preference).
Note that you cannot save a value to an environment variable, only to preferences. #REMOVE
behaves similarly, but removes the value from that source.
There are some special flag words:
#SAVE
and #REMOVE
are used together, #SAVE
will override.
Note that to remove or save specifically either a user or system preference you should use only
USER|REMOVE or only SYSTEM|REMOVE (or SAVE, as appropriate) -- this method works on only the
first priority element found.
In some systems, the system preferences may not work, in which case, this method
silently falls back to using the user preferences instead (although, this fact was probably
logged already by writeDefaultPrefs()
.
prefName
- The name of the preference variabledefaultValue
- The default valueoperation
- The flag word, which should be and disjuction (|) of one or more of
ENVIRONMENT
, USER
, SYSTEM
, #SAVE
#REMOVE
.public static Map<String,String> getPreference(String prefName, Map<String,String> defaultValue, int operation)
public static void putPreference(String prefName, int defaultValue, int operation)
public static void putPreference(String prefName, boolean defaultValue, int operation)
public static void putPreference(String prefName, Map<String,?> defaultValue, int operation)
public static void putPreferenceIfAbsent(String prefName, int defaultValue, int operation)
public static void putPreferenceIfAbsent(String prefName, String defaultValue, int operation)
private static boolean isPrefPresent(CASA.SilentPreferences p, String name)
public static void removePreference(String prefName, int operation)
public static int getPreference(String prefName, int defaultValue, int function)
getPreference(String, String, int)
.prefName
- The name of the preference variabledefaultValue
- The default valuefunction
- The flag word, which should be and disjuction (|) of one or more of
ENVIRONMENT
, USER
, SYSTEM
, #SAVE
#REMOVE
.getPreference(String, String, int)
public static boolean getPreference(String prefName, boolean defaultValue, int function)
getPreference(String, String, int)
.prefName
- The name of the preference variabledefaultValue
- The default valuefunction
- The flag word, which should be and disjuction (|) of one or more of
ENVIRONMENT
, USER
, SYSTEM
, #SAVE
#REMOVE
.getPreference(String, String, int)
public static long getPreference(String prefName, long defaultValue, int function)
getPreference(String, String, int)
.prefName
- The name of the preference variabledefaultValue
- The default valuefunction
- The flag word, which should be and disjuction (|) of one or more of
ENVIRONMENT
, USER
, SYSTEM
, #SAVE
#REMOVE
.getPreference(String, String, int)
protected void finalize() throws Throwable
public static void flush(int operation) throws IllegalAccessError
operation
- if the USER bit is set flushes user preferences, if the SYSTEM
bit is set flushes system preferences, if neither or both are set then both are flushed.IllegalAccessError
public final void testPrefs()
private static int getPref(String name, int default_)
private static boolean getPref(String name, boolean default_)
private static void setPref(String name, int default_)
private static void setPref(String name, boolean default_)
public static int getLACdefaultport()
public static void setLACdefaultport(int lACdefaultport)
lACdefaultport
- the lACdefaultport to setpublic static String getPutPreferenceIfAbsent()
public static void setPutPreferenceIfAbsent(String putPreferenceIfAbsent)
putPreferenceIfAbsent
- the putPreferenceIfAbsent to setpublic static String getRouter()
public static void setRouter(String router)
synonymURLs
- the synonymURLs to setpublic static String getRoot()
public static void setRoot(String root)
root
- the root to setpublic static boolean isDieOnLACExitDefault()
public static void setDieOnLACExitDefault(boolean dieOnLACExitDefault)
dieOnLACExitDefault
- the dieOnLACExitDefault to setpublic static String getBuildInfo()