|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object facets.util.Tracer facets.util.app.AppValues
public class AppValues
Can persist/depersist configuration and session state/user preferences.
AppValues
wraps two ValueNode
s which can be used to
read, maintain and store values on behalf of a client application.
Field Summary | |
---|---|
java.lang.String |
appName
Simple name of the class passed to the constructor; expected to be the application name. |
static java.lang.String |
KEY_TIMEOUT
Key for flag specifying instance behaviour. |
static java.lang.String |
KEY_TIMEOUT_SYSTEM
Key for flag specifying instance behaviour. |
static java.lang.String |
NATURE_DEBUG
Key for setting Debug.natureDebug . |
static java.lang.String |
NATURE_NO_SYSTEM_ACCESS
Key for flag specifying instance behaviour. |
static java.lang.String |
NATURE_RECORD_RUNS
Key for flag specifying instance behaviour. |
static java.lang.String |
NATURE_WRITABLE
Key for flag specifying instance behaviour. |
static java.lang.String |
PATH_APP
Type/path of values node. |
static java.lang.String |
PATH_CORE
Type/path of values node. |
static java.lang.String[] |
PATH_CORE_APP
Type/path of values node. |
static java.lang.String[] |
PATH_CORE_DEBUG
Type/path of values node. |
static java.lang.String |
PATH_DEBUG
Type/path of values node. |
static java.lang.String |
PATH_RUNS
Type/path of values node. |
static ValueNode |
stateDebug
Global state node for debug values. |
static java.lang.String |
TYPE_NATURE
Type of root node, used by # storageFile(boolean) . |
static java.lang.String |
TYPE_STATE
Type of root node, used by # storageFile(boolean) . |
Constructor Summary | |
---|---|
AppValues(java.lang.Class appClass)
Unique constructor. |
Method Summary | |
---|---|
protected void |
addNatureDefaults(ValueNode root)
Can set default configuration values. |
protected void |
addStateDefaults(ValueNode root)
Can set default session/preferences values. |
void |
adjustClassValues()
Can refresh class variables etc from state values. |
boolean |
hasSystemAccess()
Can these values (and by implication the application) access the file system, clipboard etc? |
ValueNode |
nature(boolean core)
Defines application configuration or 'nature'. |
void |
readValues(java.lang.String... parameters)
Reads values from (in order) defaults, parameters and storage. |
ValueNode |
state(java.lang.String... typePath)
Stores application session state and user preferences. |
protected void |
traceOutput(java.lang.String msg)
Outputs complete trace messages to console or elsewhere. |
void |
tryWriteValues(java.lang.String msg)
Attempts to persist current values in XML format. |
Methods inherited from class facets.util.Tracer |
---|
trace, trace, trace, trace, trace, traceDebug, traceDebug, traceObjectText, traceOutputWithClass |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String TYPE_STATE
storageFile(boolean)
.
public static final java.lang.String TYPE_NATURE
storageFile(boolean)
.
public static final java.lang.String PATH_CORE
public static final java.lang.String PATH_APP
public static final java.lang.String PATH_DEBUG
public static final java.lang.String[] PATH_CORE_APP
public static final java.lang.String[] PATH_CORE_DEBUG
public static final java.lang.String PATH_RUNS
public static final java.lang.String NATURE_DEBUG
Debug.natureDebug
.
Set to false
for release binaries; to true
in binary by passing
as argument.
public static final java.lang.String NATURE_WRITABLE
public static final java.lang.String NATURE_RECORD_RUNS
public static final java.lang.String NATURE_NO_SYSTEM_ACCESS
public static final java.lang.String KEY_TIMEOUT
public static final java.lang.String KEY_TIMEOUT_SYSTEM
public static final ValueNode stateDebug
Created empty, added as child of core state.
public final java.lang.String appName
Used by storageFile(boolean)
.
Constructor Detail |
---|
public AppValues(java.lang.Class appClass)
Builds data roots ready for readValues(String[])
:
appClass
- should generally be the client application class; its simple name is
used for the appName
fieldMethod Detail |
---|
protected void addNatureDefaults(ValueNode root)
Called from readValues(String[])
;
values added are treated as defaults for nature(boolean)
.
Default implementation is empty.
protected void addStateDefaults(ValueNode root)
Called from readValues(String[])
;
values added are treated as defaults for state(String...)
.
Default implementation is empty.
root
- of the state(String...)
treepublic final void readValues(java.lang.String... parameters)
Returns without effect after the first call; calls to nature(boolean)
and state(String...)
will fail before this method is called.
Node paths are created before reading for
nature
: PATH_CORE
with basic values
state
: PATH_CORE_DEBUG
and PATH_CORE_APP
.
parameters
- passed from main
or constructed from
applet parameters; any member not a key=value pair is
interpreted as parameter=true.public void adjustClassValues()
Called from readValues(String[])
; defined public
to allow calls
when values are changed.
Default implementation sets Debug.natureDebug
.
public final void tryWriteValues(java.lang.String msg)
NATURE_RECORD_RUNS
is true
, adds a child to the
PATH_RUNS
child of PATH_CORE
.
nature(boolean)
if NATURE_WRITABLE
is true
;
protected void traceOutput(java.lang.String msg)
Tracer
Default prepends helpful classname to message.
traceOutput
in class Tracer
msg
- passed from one of the public
methodspublic final ValueNode nature(boolean core)
Initial contents are set by
addNatureDefaults(ValueNode)
title
passed to the
constructor and accessible as a system resource. core
nodes)
as key-value pairs, verbatim if containing '=',
otherwise as 'parameter=true'. Value updates are lost after each session
(which is why parameters are added to these values rather than to the
ostensibly more appropriate state(String...)
).
core
- returns the framework-specific sub-nodepublic final ValueNode state(java.lang.String... typePath)
Initial contents are set by
addStateDefaults(ValueNode)
title
passed to the
constructor and located in the start directory. Value updates can be written to the .state file
with tryWriteValues(String)
.
typePath
- specifies a path within the state tree to a node which is
created if required; no parameter specifies the rootpublic boolean hasSystemAccess()
NATURE_NO_SYSTEM_ACCESS
which can be passed as an
argument
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |