wt.prefs.registry
Class PrefsRegistry

java.lang.Object
  extended bywt.prefs.registry.PrefsRegistry
All Implemented Interfaces:
RemoteAccess

public class PrefsRegistry
extends Object
implements RemoteAccess

This class is responsible for managing the Preferences Registry. The Preference Registry consists of two parts. The first is the Registry of Localized Preference data such as Perference Names, Descriptions and so forth. The second part is the Preference Meta-Data such as information on the type of Preference, The UI Renderer etc. Most methods will require a Fully Qualified keyname as an argument. A Fully Qualified Preference keyname is of the form:


. Each node in the key is separated by '/' characters. Depending on the method, the keyname or null will be returned if a valid value could not be found in the registry. (Please see the method signature and documentation below for details.) The registry will be comprised of two localized files:

The prefRegisty[_XX_YY].class files (where optionally the XX is the language and YY is the country, such as prefRegistry_en_US.class) will exist for each of the supported locales in Windchill, and contain the Preference Localized Data for all Preferences shipped with the Windchill product. The custRegistry is the customized registry. Windchill provides an empty custRegistry.rbInfo file which may be customized by the customizers to meet the locale requirements of a customer. Any key may exist in both the customized registry and the preference registry, however the customized value will be retrieved first if it exists and will supercede the Windchill registry entry. This is useful if a customer wishes to expand/decrease the information provided for a preference, or rename a preference from the client side. See the registry rbInfo files for details on the correct format to use for the key/names if creating entries in the rbInfo files. Instructions on the compiling rbInfo files should be located in the Windchill Customizers Guide.

Along with Preference Registry rbInfo files, there are a pair of properties files which are used to store non-localized data which may be required for the use of certain preferences. This may include information such as a class name to invoke for the given preference, a Preference Type etc. These files are located in the wt/prefs/registry under the codebase folder and are called:

Like the registry files, these files will load the Preference properties first followed by the customization properties second overriding any properties that are in common. Thus the customized file has the 'final say' on the given property. The format of the property values are described in the properties files themselves. Values may be retrieved using the getValue(String,[String]) methods below. Alternatively, a grouping of properties may be obtained via the getValues(String,String) method.

The properties files can be reloaded dynamically at runtime without having to shutdown the MethodServer and restarting by invoking the method reloadProperties() or by invoking this class from the command prompt (if in a development environment) using java wt.prefs.registry.PrefsRegistry

Supported API: true

Extendable: false


Field Summary
static String BOOLEAN_LABEL
          The constant for Boolean type labels
private static String coreResource
          The constant for Windchill preference Registry
private static String custInfoFilename
          Static filename for the customized Infos
static String CUSTOM_RENDERER
          Properties File OnlyThe constant for Custom Renderer Tags which determine the renderer to use.
private static String custResource
          The constant for customized preference Registry
static String DEFAULT
          The constant for the local default value
static String DESCRIPTION
          The constant for the local description
static String DIRECTORY_ONLY
          Properties File Only The constant for Directory Only Preferences.
static String DISPLAY_NAME
          The constant for the local display name
private static boolean isLoaded
          static constant for loading of preferences
private static String prefInfoFilename
          Static filename for the preference Infos
private static Properties prefProperties
          Static property file for customizations
private static String RESOURCE
          static constant for the preference resource bundles
static String SHORT_DESCRIPTION
          The constant for the local short description
static String SUFFIX_TOKEN
          delimiter for separation of keyname from suffix in properties files
static String TEXT_LABEL
          The constant for the local list of valid values
static String TYPE
          Properties File Only The constant for Preference Type
static String USER_VISIBLE
          Properties File Only The constant for The User Visible Property flag.
static String VALID_VALUES
          The constant for Valid Values
 
Fields inherited from interface wt.method.RemoteAccess
versionID
 
Constructor Summary
PrefsRegistry()
           
 
Method Summary
private static void addToVector(Vector vec, String key)
           
private static String getLocalizedDefault(String keyname, Locale aLocale)
          Deprecated.  
static String getLocalizedDescription(String keyname, Locale aLocale)
          This method will return the localized description for the given key name.
static String getLocalizedName(String keyname, Locale aLocale)
          This method will return the localized name of the preference given a fully qualified key name.
static String getLocalizedShortDescription(String keyname, Locale aLocale)
          This method will return the localized short description for the given key name.
protected static String getLocalizedValue(String keyname, Locale locale)
          This method will get a localized value from the Registry whose name is a valid keyname.
static String getLocalizedValue(String keyname, String constant, Locale locale)
          This method will get a localized value from the Registry using the keyname and a constant.
static HashMap getLocalizedValues(String keyname, String constant, Locale locale)
          This method will return a map of Localized Values from the registry.
static Vector getRegistryKeys()
          This method will return a list of all the Registry Keys that are in the the registry that may be used to query the registry.
protected static String getValue(String keyname)
          This method will return an entry from the Preference property Information file for the given formated keyname.
static String getValue(String keyname, String suffix)
          This method will return an entry from the Preference property Information files for the given keyname and optional suffix.
static HashMap getValues(String keyname, String suffix)
          This method will return a map of all the values which are referenced by the designated keyname and optional suffix from the properties file.
static void initializeProperties()
          This method will initialize the properties object by re-reading the properties files, and creating the properties object if required.
static void main(String[] args)
          This method serves as a way to flush the properties registry files at runtime, which is useful if a developer wants to change the properties file without shutting down and restarting the method servers.
static void reloadProperties()
          This method will cause the properties files to be reinitialized within the Preference Registry within the MethodServer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SUFFIX_TOKEN

public static final String SUFFIX_TOKEN
delimiter for separation of keyname from suffix in properties files

See Also:
Constant Field Values

DISPLAY_NAME

public static final String DISPLAY_NAME
The constant for the local display name

See Also:
Constant Field Values

DESCRIPTION

public static final String DESCRIPTION
The constant for the local description

See Also:
Constant Field Values

DEFAULT

public static final String DEFAULT
The constant for the local default value

See Also:
Constant Field Values

TEXT_LABEL

public static final String TEXT_LABEL
The constant for the local list of valid values

See Also:
Constant Field Values

SHORT_DESCRIPTION

public static final String SHORT_DESCRIPTION
The constant for the local short description

See Also:
Constant Field Values

VALID_VALUES

public static final String VALID_VALUES
The constant for Valid Values

See Also:
Constant Field Values

BOOLEAN_LABEL

public static final String BOOLEAN_LABEL
The constant for Boolean type labels

See Also:
Constant Field Values

CUSTOM_RENDERER

public static final String CUSTOM_RENDERER
Properties File OnlyThe constant for Custom Renderer Tags which determine the renderer to use.

See Also:
Constant Field Values

DIRECTORY_ONLY

public static final String DIRECTORY_ONLY
Properties File Only The constant for Directory Only Preferences.

See Also:
Constant Field Values

TYPE

public static final String TYPE
Properties File Only The constant for Preference Type

See Also:
Constant Field Values

USER_VISIBLE

public static final String USER_VISIBLE
Properties File Only The constant for The User Visible Property flag. This flag determines whether the preference is to be displayed in the client Preference Interface.

See Also:
Constant Field Values

coreResource

private static final String coreResource
The constant for Windchill preference Registry

See Also:
Constant Field Values

custResource

private static final String custResource
The constant for customized preference Registry

See Also:
Constant Field Values

prefProperties

private static Properties prefProperties
Static property file for customizations


custInfoFilename

private static final String custInfoFilename
Static filename for the customized Infos

See Also:
Constant Field Values

prefInfoFilename

private static final String prefInfoFilename
Static filename for the preference Infos

See Also:
Constant Field Values

isLoaded

private static boolean isLoaded
static constant for loading of preferences


RESOURCE

private static final String RESOURCE
static constant for the preference resource bundles

See Also:
Constant Field Values
Constructor Detail

PrefsRegistry

public PrefsRegistry()
Method Detail

getLocalizedName

public static final String getLocalizedName(String keyname,
                                            Locale aLocale)
This method will return the localized name of the preference given a fully qualified key name. The key name should have it's path separated by the '/' character. If the locale is not a valid Windchill locale, the default locale's value will be returned. If there is no entry for the localized name in either the customized or core Preference Registry, the keyname will be returned.

Parameters:
keyname - The preference key.
aLocale - The locale of the key

Supported API: true
Returns:
The localized name of the preference or the keyname if there is not entry.

getLocalizedDescription

public static final String getLocalizedDescription(String keyname,
                                                   Locale aLocale)
This method will return the localized description for the given key name.

Parameters:
keyname - The preference key.
aLocale - The locale of the key

Supported API: true
Returns:
The localized description or null if not found.

getLocalizedShortDescription

public static final String getLocalizedShortDescription(String keyname,
                                                        Locale aLocale)
This method will return the localized short description for the given key name.

Parameters:
keyname - The preference key.
aLocale - The locale of the key

Supported API: true
Returns:
The localized short description or null if not found.

getLocalizedDefault

private static String getLocalizedDefault(String keyname,
                                          Locale aLocale)
Deprecated.  

This method will return the localized default value for the preference.

Parameters:
keyname - The preference key.
aLocale - The locale of the key.
Returns:
The localized default value of the key, or null if not specified.

getRegistryKeys

public static Vector getRegistryKeys()
This method will return a list of all the Registry Keys that are in the the registry that may be used to query the registry. The keys are the fully qualified preference Keys and anything after the SUFFIX_TOKEN will be parsed off. Essentially, it returns a vector of all the keys for which there is some registry entry for.

Supported API: true

Returns:
Vector The list of keys.

addToVector

private static void addToVector(Vector vec,
                                String key)

getLocalizedValue

protected static String getLocalizedValue(String keyname,
                                          Locale locale)
This method will get a localized value from the Registry whose name is a valid keyname. A valid keyname will consist of the Fully Qualified Preference key and a constant such as DISPLAY_NAME. The customized resource bundle will be searched first, followed by the preference resource bundle provided by Windchill. If none of these are found the properties files will be searched for an entry in an alternate resource bundle.

Parameters:
keyname - The keyname to search for (well-formed)
locale - The locale to search for the key in.
Returns:
The Value for the specified locale, default locale or null if not found.

getLocalizedValue

public static String getLocalizedValue(String keyname,
                                       String constant,
                                       Locale locale)
This method will get a localized value from the Registry using the keyname and a constant. A valid keyname will consist of the Fully Qualified Preference Key. The constant is optional, and if null will be ignored. The Customized resource bundle will be searched first, followed by the Windchill resource bundle for the value. If none of these are found the properties files will be searched for an entry in an alternate resource bundle.

Parameters:
keyname - The fully Qualified Preference Key name.
constant - The constant (either defined above or not)
locale - The locale for the value

Supported API: true
Returns:
The localized value for the locale, the default locale or null if not found.

getLocalizedValues

public static HashMap getLocalizedValues(String keyname,
                                         String constant,
                                         Locale locale)
This method will return a map of Localized Values from the registry. This method will first attempt to read the Fully Qualified Preference Keyname with the appended optional constant from the properties files, and if found will utilize this value to determine the desired localized values. If not found in the properties file, the registry will be checked, however placing non-localized information in the registry is NOT recommended.

An example entry in the properties file might be:


Using this example, the getLocalizedValues() method would expect a keyname of /wt/test/Sample and a constant of %VALID_VALUES. This would then be queried in the properties files. The values ACCEPT_BUTTON and DENY_BUTTON would then be requested from the registry under the registry key of /wt/test/Sample%VALID_VALUES.ACCEPT_BUTTON for example, and this value would be placed in the HashMap.

Parameters:
keyname - The name of the preference key
constant - The optional constant to append to the key
locale - The locale of the Preference values.

Supported API: true
Returns:
HashMap The map of localized values which correspond to the desired keyname and constant, or an empty map if none are found.

getValue

protected static String getValue(String keyname)
This method will return an entry from the Preference property Information file for the given formated keyname. If not property is found null will be returned. The formated keyname is a fully qualified key name with an option SUFFIX_TOKEN and a suffix. Ideally, if a suffix is required use the method getValue(String,String) below to retrieve the property as this will insure a properly formated keyname is generated.

Parameters:
keyname - The fully qualified formated keyname.
Returns:
The Preference Property or null if not found.

getValue

public static final String getValue(String keyname,
                                    String suffix)
This method will return an entry from the Preference property Information files for the given keyname and optional suffix. If no property is found null will be returned.

Parameters:
keyname - The key name for the preference.
suffix - The optional suffix (without the SUFFIX_TOKEN)

Supported API: true
Returns:
The property for the keyname/suffix or null

getValues

public static HashMap getValues(String keyname,
                                String suffix)
This method will return a map of all the values which are referenced by the designated keyname and optional suffix from the properties file. This data should be non-localized preference Meta-data. The method will first retrieve the property defined as the Fully Qualified Key Name and suffix, such as the example below:


For each value that is contained in the property (in this case there is two ACCEPT_FLAG and DENY_FLAG) these properties are looked up in the Prefernce Property files. Any values found will be returned in the map. If the value can not be found, the map will contain the value obtained from the reference (for example ACCEPT_FLAG) for both the map key and value.

Note:In the above example, the suffix %VALID_VALUES was used, however any suffix is valid.

Parameters:
keyname - The keyname to retrieve
suffix - The suffix to retrive the information under.

Supported API: true
Returns:
HashMap a map of values from the registry.

initializeProperties

public static void initializeProperties()
                                 throws IOException
This method will initialize the properties object by re-reading the properties files, and creating the properties object if required.

Supported API: true

Throws:
IOException - Thrown if there is an error reading the files.

reloadProperties

public static void reloadProperties()
                             throws IOException,
                                    WTException
This method will cause the properties files to be reinitialized within the Preference Registry within the MethodServer.

Supported API: true

Throws:
IOException - Thown if there is an error reading the files.
WTException

main

public static void main(String[] args)
This method serves as a way to flush the properties registry files at runtime, which is useful if a developer wants to change the properties file without shutting down and restarting the method servers.

Supported API: true

Parameters:
args - (ignored)