public class prefs extends Object
omero.prefs
Preferences
node in order to store Java properties-file
like values on a user basis. This simplifies configuration and permits
quicker re-installs, and less wrangling with configuration files.
A single string value is stored as DEFAULT
(which by default is the
value DEFAULT
, and points to the name of some node under
"omero.prefs". This value can be overridden by the "OMERO_CONFIG" environment
variable. Almost all commands work on this default node, referred to here as
a "profile".Modifier and Type | Field and Description |
---|---|
static boolean |
DEBUG
Activated by setting DBEUG=true in the environment.
|
static String |
DEFAULT
Key (and default value) of the property under
ROOT which defines
which "profile" (subnode} is in effect. |
static String |
ENV
Environment variable which can be set to override the current, active
profile.
|
static String |
ROOT
"omero.prefs", the value of the root
Preferences node used for
all configuration work. |
static Properties |
STDIN
Storing the standard in as a
Properties instance as early as
possible to prevent lost data. |
Constructor and Description |
---|
prefs() |
Modifier and Type | Method and Description |
---|---|
static String[] |
all(String[] args)
Calls
Preferences.childrenNames() and returns the array. |
static String[] |
args(String... args)
Converts varargs to a String-array.
|
static String[] |
def(String[] args)
Returns the current default if no argument is given, or sets the default
to the given string (or "" if null) otherwise returing "Default set to:
... ".
|
static String[] |
dispatch(String[] args)
Uses the first string in the argument array to reflectively invoke
another method with the same signature on
prefs . |
static String[] |
drop(String[] args)
Drops the entire profile (
subnode ) via
Preferences.removeNode() . |
static String[] |
exit(String[] args)
Uses the length of the argument array as the exit code.
|
static String[] |
export(String[] args)
Exports all properties in the current profile to
System.out , or
if a single argument is given, that is take to be the name of a target
ouput file. |
static String[] |
get(String[] args)
Returns either the given key=value pairs (or all if no argument is
given).
|
static String[] |
help(String[] args)
Returns a help string array.
|
static String[] |
join(String... args)
Joins all the String arguments given into a single String (joined with "
"), and returns that String as the first element of a new array.
|
static String[] |
keys(String[] args)
Returns
Preferences.keys() |
static String[] |
load_nowarn(String[] args)
Performs the same actions as
load(String[]) but does not throw
CONFLICT if a key already exists. |
static String[] |
load(String[] args)
Loads a profile from
Properties files, or properly formatted
System.in input if no files are given. |
static void |
main(String[] args)
Entry point to the prefs command line too.
|
static String[] |
notNull(String[] args)
Returns an empty array if the argument is null.
|
static String[] |
pop(String[] args)
Creates a new subarray from the argument, effectively popping off the
first element.
|
static String[] |
print(String[] args)
Prints the arg array and returns an empty array (for exit purposes)
|
static String[] |
printDebug(String[] args)
Delegates to
printErr(String[]) iff DEBUG is true. |
static String[] |
printErr(String[] args)
Prints the arg array and returns the input array (for exit purposes)
|
static String[] |
set(String[] args)
Takes an array of length 2, using args[0] as the key and args[1] as the
value to be set.
|
static String[] |
sys(String[] args)
Replaces the user
Preferences instance with the system
Preferences and continues dispatching. |
static String[] |
test(String[] args)
Simple test framework, callable from the command line via "java prefs
test"
|
static String[] |
usage(String[] args)
Returns a usage string array.
|
public static final Properties STDIN
Properties
instance as early as
possible to prevent lost data.public static final boolean DEBUG
System.err
.public static final String ROOT
Preferences
node used for
all configuration work.public static final String DEFAULT
ROOT
which defines
which "profile" (subnode} is in effect.public static final String ENV
public static void main(String[] args)
dispatch(String[])
method to invoke a public static method which
takes a popped
String-argument array.args
- Not null. Can be empty.public static String[] usage(String[] args)
args
- Ignored.public static String[] help(String[] args)
usage(String[])
but
may eventually return a more man page-like statement.args
- Ignored.public static String[] print(String[] args)
public static String[] printErr(String[] args)
public static String[] printDebug(String[] args)
printErr(String[])
iff DEBUG
is true.public static String[] exit(String[] args)
public static String[] dispatch(String[] args) throws Throwable
prefs
. If the array is
null, empty, or begins with an non-extant method, USAGE
will be
thrown. Otherwise, invokes the named method, returning its return value
or returning the cause of any InvocationTargetException
.Throwable
public static String[] sys(String[] args) throws Throwable
Preferences
instance with the system
Preferences
and continues dispatching.Throwable
public static String[] all(String[] args) throws BackingStoreException
Preferences.childrenNames()
and returns the array.args
- Ignored.BackingStoreException
public static String[] def(String[] args)
args
- String array of length 0 or 1. Otherwise USAGE
is
thrown.public static String[] drop(String[] args) throws BackingStoreException
subnode
) via
Preferences.removeNode()
.args
- Ignored.BackingStoreException
public static String[] keys(String[] args) throws BackingStoreException
Preferences.keys()
args
- Ignored.BackingStoreException
public static String[] get(String[] args) throws BackingStoreException
BackingStoreException
public static String[] set(String[] args) throws BackingStoreException
load(String[])
.args
- BackingStoreException
public static String[] export(String[] args) throws BackingStoreException, IOException
System.out
, or
if a single argument is given, that is take to be the name of a target
ouput file. Export will fail if the file already exists. This method may
be removed in favor of using piping with get(String[])
.
Properties are in standard Java Properties
format.BackingStoreException
IOException
public static String[] load(String[] args) throws IOException
Properties
files, or properly formatted
System.in
input if no files are given. If a key to be loaded
already exists in the configuration, CONFLICT
will be thrown.
Use load_nowarn(String[])
instead, or drop(String[])
the profile before loading.IOException
public static String[] load_nowarn(String[] args) throws IOException
load(String[])
but does not throw
CONFLICT
if a key already exists.IOException
public static String[] join(String... args)
public static String[] notNull(String[] args)
public static String[] pop(String[] args)
Version: 5.1.4-ice35-b55
Copyright © 2015 The University of Dundee & Open Microscopy Environment. All Rights Reserved.