wt.prefs
Class WTPreferences

java.lang.Object
  extended by wt.prefs.Preferences
      extended by wt.prefs.WTPreferences
All Implemented Interfaces:
Serializable

Deprecated.

public class WTPreferences
extends Preferences
implements Serializable

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

See Also:
Serialized Form

Field Summary
static String CONTAINER_CONTEXT
          Deprecated.  
static String CONTAINER_POLICY_CONTEXT
          Deprecated.  
static String DEFAULT_CONTEXT
          Deprecated.  
static String DIVISION_CONTEXT
          Deprecated.  
static String DIVISION_POLICY_CONTEXT
          Deprecated.  
static String USER_CONTEXT
          Deprecated.  
 
Method Summary
protected  Preferences child(String name)
          Deprecated.  
 Preferences[] children()
          Deprecated.  
 void flush()
          Deprecated.  
 String get(String key, String def)
          Deprecated.  
 String getContext(String key)
          Deprecated.  
 String[] getContextMask()
          Deprecated.  
 String getEditContext()
          Deprecated.  
 boolean isContext(String key, String context)
          Deprecated.  
 String[] keys()
          Deprecated.  
 void preload()
          Deprecated.  
 void preload(String[] keys)
          Deprecated.  
 String put(String key, String value)
          Deprecated.  
 void putAll(HashMap map)
          Deprecated.  
 void putAll(String context, HashMap map)
          Deprecated.  
 void refresh()
          Deprecated.  
 void refresh(String key)
          Deprecated.  
 void refresh(String[] keys)
          Deprecated.  
 String remove(String key)
          Deprecated.  
protected  boolean removeChild(String name)
          Deprecated.  
 boolean removeNode(String pathName)
          Deprecated.  
 void setContextMask(String[] a_ContextMask)
          Deprecated.  
 void setEditContext(String a_EditContext)
          Deprecated.  
 
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

DIVISION_CONTEXT

public static final String DIVISION_CONTEXT
Deprecated. 
Constant for Division Context Preference Heirarchies

Supported API: true

See Also:
Constant Field Values

DIVISION_POLICY_CONTEXT

public static final String DIVISION_POLICY_CONTEXT
Deprecated. 
Constant for Policy driven preferences

Supported API: true

See Also:
Constant Field Values

USER_CONTEXT

public static final String USER_CONTEXT
Deprecated. 


Supported API: true

See Also:
Constant Field Values

DEFAULT_CONTEXT

public static final String DEFAULT_CONTEXT
Deprecated. 


Supported API: true

See Also:
Constant Field Values

CONTAINER_CONTEXT

public static final String CONTAINER_CONTEXT
Deprecated. 
Constant for Container Context Preference Heirarchies

Supported API: true

See Also:
Constant Field Values

CONTAINER_POLICY_CONTEXT

public static final String CONTAINER_POLICY_CONTEXT
Deprecated. 
Constant for Policy driven preferences

Supported API: true

See Also:
Constant Field Values
Method Detail

getContextMask

public String[] getContextMask()
Deprecated. 

Gets the value of the attribute: contextMask; The list of contexts used in retrieving values from persistance storage. In retrieving values from storage, the context will be searched in order and return the first value found. The default context is {WTPreferences.USER, WTPreferences.DEFAULT}. This allows users to specify a preference value that "hide" values stored in the DEFAULT context. In the absence of a value in the USER context, the DEFAULT context will be returned. In the case that no contexts contain value, the programmatic default passed in the get calls will be returned.

Supported API: true

Returns:
String[]
See Also:
get(String,String)

setContextMask

public void setContextMask(String[] a_ContextMask)
Deprecated. 

Sets the value of the attribute: contextMask; The list of contexts used in retrieving values from persistance storage. In retrieving values from storage, the context will be searched in order and return the first value found. The default context is {WTPreferences.USER, WTPreferences.DEFAULT}. This allows users to specify a preference value that "hide" values stored in the DEFAULT context. In the absence of a value in the USER context, the DEFAULT context will be returned. In the case that no contexts contain value, the programmatic default passed in the get calls will be returned.

Supported API: true

Parameters:
a_ContextMask -
See Also:
get(String,String)

getEditContext

public String getEditContext()
Deprecated. 

Gets the value of the attribute: editContext; Context which edit calls (ie put, remove) will be persisted against. Do not create context's beginning with '$', these are reserved for use by the system.

Supported API: true

Returns:
String
See Also:
put(String,String), remove(String)

setEditContext

public void setEditContext(String a_EditContext)
Deprecated. 

Sets the value of the attribute: editContext; Context which edit calls (ie put, remove) will be persisted against. Do not create context's beginning with '$', these are reserved for use by the system.

Supported API: true

Parameters:
a_EditContext -
See Also:
put(String,String), remove(String)

preload

public void preload()
Deprecated. 

Preloads all preference entries into the preference object. If preload is not set then preference entries will be retrieved from the server as necessary. Preload should probably be used if the application knows that it will be retrieving multiple entries.

Supported API: true


preload

public void preload(String[] keys)
Deprecated. 

Preloads preference entries into the preference object for all keys specified in the keys argument. If preload is not set then preference entries will be retrieved from the server as necessary. Preload should probably be used if the application knows that it will be retrieving multiple entries.

Supported API: true

Parameters:
keys -

getContext

public String getContext(String key)
Deprecated. 

Returns the context which a call to a get operation would retrieve a value from. The context returned from this call may contain additional information beyond that of the editContext which created the element. Use the isContext method to check which context a value is retrieved from.

Supported API: true

Parameters:
key - key whose associated value's context is returned.
Returns:
String
See Also:
isContext(String,String)

isContext

public boolean isContext(String key,
                         String context)
Deprecated. 

Returns true if the context used in retrieving the key's value is the same as the context passed in. This should be used in place of comparing a context with the value returned by getContext. getContext may have additional information appended to the context which is stripped by the comparison within this method.

To check if the returned value is from the user's context:

boolean fromUser = pref.isContext("foo", WTPreferences.USER_CONTEXT);

Supported API: true

Parameters:
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.
Returns:
boolean
See Also:
getContext(String), USER_CONTEXT, DEFAULT_CONTEXT

putAll

public void putAll(String context,
                   HashMap map)
            throws WTException
Deprecated. 

Will put all the entries in the HashMap into the Preferences System.

Supported API: true

Parameters:
context - The edit context
map - The map of key/value pairs
Throws:
WTException

putAll

public void putAll(HashMap map)
            throws WTException
Deprecated. 

Will put all the entries in the HashMap into the Preferences System. The edit context will be set to the user Edit Context

Supported API: true

Parameters:
map - The map of key/value pairs
Throws:
WTException

refresh

public void refresh(String key)
Deprecated. 

Ensures that future reads from this preference node for the key reflect any changes that have been committed to the persistent store.

Supported API: true

Parameters:
key -
See Also:
flush()

refresh

public void refresh(String[] keys)
Deprecated. 

Ensures that future reads for the given keys of this preference node reflect any changes that have been committed to the persistent store.

Supported API: true

Parameters:
keys -
See Also:
flush()

child

protected Preferences child(String name)
Deprecated. 

Returns the named child of this preference node, creating it if it does not already exist. The name must be a string consisting of one or more characters. Names must not contain the slash character ('/').

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

Specified by:
child in class Preferences
Parameters:
name - the name of the child node to return, relative to this preference node
Returns:
the named child node.
Throws:
IllegalArgumentException - if child's name is invalid.

children

public Preferences[] children()
Deprecated. 

Returns the children of this preference node. (The returned array will be of size zero if this node has no children.)

Supported API: true

Specified by:
children in class Preferences
Returns:
the children of this preference node.

flush

public void flush()
           throws WTException
Deprecated. 

Forces any changes in the contents of this preference node and its descendants to the persistent store. If this preference node has been created since the last call to 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.

Specified by:
flush in class Preferences
Throws:
WTException

get

public String get(String key,
                  String def)
Deprecated. 

Returns the value associated with the specified key in this preference node. Returns the specified default if there is no value associated with the key, or the backing store is inaccessible.

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

Specified by:
get in class Preferences
Parameters:
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.
Returns:
the value associated with key, or def if no value is associated with key.

keys

public String[] keys()
Deprecated. 

Returns all of the keys that have an associated value in this preference node.

Supported API: true

Specified by:
keys in class Preferences
Returns:
an array of the keys that have an associated value in this preference node.

put

public String put(String key,
                  String value)
           throws WTException
Deprecated. 

Associated the specified value with the specified key in this preference node.

Supported API: true

Specified by:
put in class Preferences
Parameters:
key - key with which the specified value is to be associated.
value - value to be associated with the specified key.
Returns:
previous value associated with specified key, or null if there was no mapping for the key.
Throws:
WTException

refresh

public void refresh()
Deprecated. 

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).

Specified by:
refresh in class Preferences
See Also:
flush()

remove

public String remove(String key)
              throws WTException
Deprecated. 

Removes the value associated with the specified key in this preference node, if any. returns the value previously associated with the key, or null if there was no value associated with the key.

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

Specified by:
remove in class Preferences
Parameters:
key - key whose mapping is to be removed from the preference node.
Throws:
WTException
See Also:
get(String, String)

removeChild

protected boolean removeChild(String name)
                       throws WTException
Deprecated. 

Removes the named child of this preference node and all of its descendants, invalidating any preferences contained in the removed nodes. Once a node has been removed, attempting any operation on the corresponding Preferences object may fail with an IllegalStateException.

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

Specified by:
removeChild in class Preferences
Parameters:
name - the name of the child node to remove, relative to this preference node.
Throws:
WTException

removeNode

public boolean removeNode(String pathName)
                   throws WTException
Deprecated. 

Removes the named preference node and all of its descendants, invalidating any preferences contained in the removed nodes. Accepts a relative or absolute pathname. Absolute pathnames (which begin with '/') are interpreted relative to the root of this preference node. Relative pathnames (which begin with any character other than slash) are interpreted relative to this Preferences itself. The pathname "" is valid, and refers to this preference node itself. Once a node has been removed, attempting any operation on the corresponding Preferences object may fail with an IllegalStateOperation. The removal of the specified node is not guaranteed to be persistent until the flushmethod 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.

Supported API: true

Specified by:
removeNode in class Preferences
Parameters:
pathName - the path name of the preference node to remove.
Returns:
true if the specified preference node existed prior to the call
Throws:
WTException
See Also:
flush()