|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectwt.prefs.Preferences
wt.prefs.WTPreferences
Concrete implementation of javax.prefs.Preferences using Windchill for the backing store.
Features beyond the javax.prefs specification are available using this implementation, but typical preference operations should be invoked from the abstract Preferences class to insure compatibility with other Preferences implementation which may become available in the future.
The main additional feature of WTPreferences is the inclusion of contexts.
A context defines a grouping of preference entries. An instance of
WTPreference has a contextMask and an editContext attribute which define
the contexts used in reading and writing preference entries. contextMask
is actually an array of contexts which are searched in order for each
get request. The default contextMask is {USER_CONTEXT, DEFAULT_CONTEXT}
and the default editContext is the first element of the contextMask.
These default settings allow a user to "hide" a system-wide default.
If no entries are found within the contextMask's contexts, then the
programmatic default will be returned.
Supported API: true
Extendable: false
Field Summary | |
private boolean |
CACHE_COMPLETE
|
private static boolean |
CACHE_VERBOSE
|
private static String |
CLASSNAME
|
static String |
CONTAINER_CONTEXT
Constant for Container Context Preference Heirarchies Supported API: true |
static String |
CONTAINER_POLICY_CONTEXT
Constant for Policy driven preferences Supported API: true |
private String[] |
contextMask
|
static String |
DEFAULT_CONTEXT
Supported API: true |
static String |
DIVISION_CONTEXT
Constant for Division Context Preference Heirarchies Supported API: true |
static String |
DIVISION_POLICY_CONTEXT
Constant for Policy driven preferences Supported API: true |
private String |
editContext
|
private Hashtable |
entries
|
private PreferenceServiceFwd |
prefFwd
|
private static String |
RESOURCE
|
private String |
user
|
static String |
USER_CONTEXT
Supported API: true |
private static boolean |
VERBOSE
|
Fields inherited from class wt.prefs.Preferences |
|
Constructor Summary | |
protected |
WTPreferences()
Creates a new uninitialized WTPreferences object. |
protected |
WTPreferences(Preferences parent,
String name)
Creates a new WTPreferences node with the specified parent and the specified name relative to its parent. |
protected |
WTPreferences(Preferences parent,
String name,
boolean createCache)
|
Method Summary | |
protected Preferences |
child(String name)
Returns the named child of this preference node, creating it if it does not already exist. |
Preferences[] |
children()
Returns the children of this preference node. |
void |
clear()
Removes all of the preferences (key-value associations) in this preference node. |
boolean |
containsKey(String aKey,
String[] mask)
will return true if the Preferences contains the desired key. |
private static String |
createCacheKey(String key,
String context)
|
void |
flush()
Forces any changes in the contents of this preference node and its descendants to the persistent store. |
String |
get(String key,
String def)
Returns the value associated with the specified key in this preference node. |
String[] |
getAsList(String key,
String token)
This method will get a Preference from the system for the desired key and along with a token String will return an array of items that represent the items in the Preference Separated by the Token. |
String |
getContext(String key)
Returns the context which a call to a get operation would retrieve a value from. |
String[] |
getContextMask()
Gets the value of the attribute: contextMask; The list of contexts used in retrieving values from persistance storage. |
String |
getEditContext()
Gets the value of the attribute: editContext; Context which edit calls (ie put, remove) will be persisted against. |
private PrefEntry |
getEntry(String key)
|
PrefEntry |
getEntry(String key,
boolean checkCache)
|
private static String |
getKeyFromcreateCacheKey(String key)
|
private String |
getUser()
|
boolean |
isContext(String key,
String context)
Returns true if the context used in retrieving the key's value is the same as the context passed in. |
boolean |
isUserContext(String key)
This method will determine whether a given key's preference for the current context is the User Context. |
String[] |
keys()
Returns all of the keys that have an associated value in this preference node. |
static void |
main(String[] args)
|
void |
preload()
Preloads all preference entries into the preference object. |
void |
preload(String[] keys)
Preloads preference entries into the preference object for all keys specified in the keys argument. |
String |
put(String key,
String value)
Associated the specified value with the specified key in this preference node. |
void |
putAll(HashMap map)
Will put all the entries in the HashMap into the Preferences System. |
void |
putAll(String context,
HashMap map)
Will put all the entries in the HashMap into the Preferences System. |
String |
putAsList(String key,
String[] value,
String token)
This method will put a Preference into the system for the desired key and along with a token String will store an array of items that. |
void |
refresh()
Ensures that future reads from this preference node and its descendants reflect any changes that have been committed to the persistent store (from any VM). |
void |
refresh(String key)
Ensures that future reads from this preference node for the key reflect any changes that have been committed to the persistent store. |
void |
refresh(String[] keys)
Ensures that future reads for the given keys of this preference node reflect any changes that have been committed to the persistent store. |
String |
remove(String key)
Removes the value associated with the specified key in this preference node, if any. |
protected boolean |
removeChild(String name)
Removes the named child of this preference node and all of its descendants, invalidating any preferences contained in the removed nodes. |
boolean |
removeNode(String pathName)
Removes the named preference node and all of its descendants, invalidating any preferences contained in the removed nodes. |
static Preferences |
root()
Returns the root preference node for the calling user. |
static Preferences |
root(boolean createCache)
|
void |
setContextMask(String[] a_ContextMask)
Sets the value of the attribute: contextMask; The list of contexts used in retrieving values from persistance storage. |
void |
setEditContext(String a_EditContext)
Sets the value of the attribute: editContext; Context which edit calls (ie put, remove) will be persisted against. |
String |
toString()
|
private static String |
uncreateCacheKey(String key)
|
void |
updateContext(String key,
String value,
String context)
|
private void |
updateEntry(PrefEntry entry)
|
Methods inherited from class wt.prefs.Preferences |
forClass, forPackage, fullName, getBoolean, getInt, init, name, node, nodeExists, parent, putBoolean, putInt |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
private static final String RESOURCE
private static final String CLASSNAME
private Hashtable entries
private String[] contextMask
private String editContext
public static final String DIVISION_CONTEXT
public static final String DIVISION_POLICY_CONTEXT
public static final String USER_CONTEXT
public static final String DEFAULT_CONTEXT
public static final String CONTAINER_CONTEXT
public static final String CONTAINER_POLICY_CONTEXT
private String user
private PreferenceServiceFwd prefFwd
private static boolean VERBOSE
private static boolean CACHE_VERBOSE
private boolean CACHE_COMPLETE
Constructor Detail |
protected WTPreferences()
protected WTPreferences(Preferences parent, String name)
parent
- name
-
java.lang.IllegalArumentException
- if name
contains
a slahs ('/'), or parent
is null and name isn't "".protected WTPreferences(Preferences parent, String name, boolean createCache)
Method Detail |
public String[] getContextMask()
get(String,String)
public void setContextMask(String[] a_ContextMask)
a_ContextMask
- get(String,String)
public String getEditContext()
put(String,String)
,
remove(String)
public void setEditContext(String a_EditContext)
a_EditContext
- put(String,String)
,
remove(String)
public void preload()
public void preload(String[] keys)
keys
- public String getContext(String key)
key
- key whose associated value's context is returned.
isContext(String,String)
public boolean isContext(String key, String context)
To check if the returned value is from the user's context:
boolean fromUser = pref.isContext("foo", WTPreferences.USER_CONTEXT);
Supported API: true
key
- key whose associated value's context is being compared.context
- context which is being compared with key's context. This may be any context, predefined context's are USER_CONTEXT and DEFAULT_CONTEXT.
getContext(String)
,
USER_CONTEXT
,
DEFAULT_CONTEXT
public boolean isUserContext(String key)
key
- The key to determine the context for.
public void putAll(String context, HashMap map) throws WTException
context
- The edit contextmap
- The map of key/value pairs
WTException
public void putAll(HashMap map) throws WTException
map
- The map of key/value pairs
WTException
public void refresh(String key)
key
- flush()
public void refresh(String[] keys)
keys
- flush()
protected Preferences child(String name)
If this call causes a node to be created, this node is not guaranteed
to be persistent until the flush
method is called on
this node or one of its ancestors (or descendants).
Supported API: true
child
in class Preferences
name
- the name of the child node to return, relative to this preference node
IllegalArgumentException
- if child's name is invalid.public Preferences[] children()
children
in class Preferences
public void flush() throws WTException
flush
, it and all
its ancestors and descendants are made permanent by this operation.
Note that this call is not guaranteed to flush any preference
values in ancestor nodes; merely the nodes' existence.
Once this method returns successfully, it is safe to assume that all changes made prior to the call have become permanent.
flush
in class Preferences
WTException
public String get(String key, String def)
Some implementations may store default values in their backing
stores. If there is no value associated with the specified key, but
there is such a persistent default, it is returned in preference
to the specified default.
Supported API: true
get
in class Preferences
key
- key whose associated value is to be returned.def
- the value to be returned in the event that this preference node has no value associated with key
.
key
, or def
if no value is associated with key
.public String[] keys()
keys
in class Preferences
public String put(String key, String value) throws WTException
put
in class Preferences
key
- key with which the specified value is to be associated.value
- value to be associated with the specified key.
null
if there was no mapping for the key.
WTException
public void refresh()
refresh
in class Preferences
flush()
public String remove(String key) throws WTException
If this implementation supports stored defaults, and there
is such a default for the specified property, the stored default will
be "exposed" by this call, in the sense that it will be returned by
a succeeding call to get
.
Supported API: true
remove
in class Preferences
key
- key whose mapping is to be removed from the preference node.
WTException
get(String, String)
protected boolean removeChild(String name) throws WTException
The removal of the specified node is not guaranteed to be persistent
until the flush
method is called on an ancestor of the
specified node.
Supported API: true
removeChild
in class Preferences
name
- the name of the child node to remove, relative to this preference node.
WTException
public boolean removeNode(String pathName) throws WTException
flush
method is called on an ancestor of the
specified node. (It is illegal to remove the root node.)
The context of the node which is being removed will be the same edit
and search context defined for the current node. Thus a context can
delete a node and all of their subnodes, but not another context's
nodes.
removeNode
in class Preferences
pathName
- the path name of the preference node to remove.
WTException
flush()
public static Preferences root()
Preferences
public static Preferences root(boolean createCache)
public String[] getAsList(String key, String token)
getAsList(keyX, "|")
would return a String
array which matches the array order passed to the putAsList( )
method, say in this case { Order, Size }
key
- The key to obtain the Preference fortoken
- The token to use to split the Preferences. If token is
null then the String will be tokenized using \uFFFF.
public String putAsList(String key, String[] value, String token) throws WTException
value
parameter using the token.
key
- The key to store the Preference forvalue
- The array of items to insert into Preferences in the order
They are to be inserted.token
- The token to use to split the Preferences. If token is
null then \uFFFF is used
WTException
public void updateContext(String key, String value, String context) throws WTException
WTException
private void updateEntry(PrefEntry entry) throws WTException
WTException
public void clear() throws WTException
Preferences
clear
in class Preferences
WTException
public boolean containsKey(String aKey, String[] mask)
aKey
- The key to search for.mask
- The context mask to use for checking values.
private final PrefEntry getEntry(String key)
public final PrefEntry getEntry(String key, boolean checkCache)
public String toString()
private static final String uncreateCacheKey(String key)
private static final String getKeyFromcreateCacheKey(String key)
private String getUser() throws WTException
WTException
private static final String createCacheKey(String key, String context)
public static void main(String[] args)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |