|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.ptc.windchill.cadx.common.preference.UserParams
This class provides a user preference system to Java applets or applications. This preference system serves up key-value pairs, directory locations or file locations. It is designed to be flexible enough to solve most user preference issues in that it is up to the implementation team as to which settings are policies and which can be modified by the users or overridden on the command line. It consists of six distinct areas which are searched for the desired objects:
It is intended that the site and default directories would ultimately reside on network disks, protected from user changes, giving the administrators the ability to force certain preferences to be policy rather than the typical arrangement of copying files to all workstations, only to have the users change the control files immediately after the transfers. By specifying those policy values and by providing basic defaults for all options in these two directories, the administrators get the control they need, yet the users can still tailor the application to suit their tastes.
A major difference between this implementation and most property retrieval routines is that the key is main unit being searched for, not the file. Just because an infobrowser.ini file is found in the site dir it does not mean that all preferences stored in infobrowser.ini must be found in that site dir based file. Each key is searched for independently of where any other key has been located.
For example, the infobrowser.ini file might have a geometry section containing top, left, width, and height as keys. The administrator may wish to force the infobrowser to always be top=0 and left=0, yet leave the width and height to the user. To do this, the site dir must contain an infobrowser.ini file with a geometry section and ONLY top=0 and left=0 as the keys in the section. As long as width and height are not specified in the site dir, the user may override them on the command line or in another infobrowser.ini file in the user dir that contains a geometry section and key-value pairs for width and height. To be sure there are first-use values for the width and height (the application will update the settings every time the size or position is changed, but would have no original setting), the administrator could also provide an infobrowser.ini file in the default dir and have default values of top=0, left=0, width=400, height=800.
It has three main access methods for finding objects:
Note that there are older forms of the getEpdParameter method, each using less than four arguments. All these have been deprecated and should be eliminated from code as soon as possible.
IMPORTANT: in order to locate the preference files, the command arguments / parameters "siteDir", "userDir", and "defaultDir" are needed to fix the directory locations needed by the preference system. If none are specified, then all preference data must be supplied in the file.section.key=value format in the command arguments / parameters. These arguments cannot be found anywhere but on the command line since there is no way to locate the files to find these keys unless the keys were set on the command line. It is intended that eventually an LDAP server would supply these keys to the application based on the user, host and the platform type they are currently using.
Implementation note: If only one directory is going to be used, it would be best to use userDir, since without it, no "set" operations can occur. The next level is to add defaultDir with the site default values for the preferences. Finally, add siteDir when it becomes necessary to set site-wide policies.
Nested Class Summary | |
class |
UserParams.DataSourceIni
|
Constructor Summary | |
UserParams()
|
Method Summary | |
private void |
addKeysToCollection(Collection list,
Enumeration enum)
|
private void |
addKeysToList(Vector list,
Enumeration enum)
|
String |
adjustPath(String p,
String dataSource)
|
private String |
checkForDollarValue(String val)
|
private String |
checkPath(String p)
|
private String |
convertDSAndSectName2LowerCase(String key)
|
boolean |
deleteEpdParameter(String key,
String datasource,
String section,
String val)
This method allows applications to delete values of parameters in the $userDir/datasource.ini file, in memory. |
boolean |
doesEpdParameterExist(String key,
String dataSource,
String section)
Read a parameter for a specific datasource from within a specific Section in a specific Ini File. |
private void |
dump()
|
private UserParams.DataSourceIni |
getDataSourceIni(String ds)
|
private String |
getEpdParam(ParamPropReader refIni,
String key)
|
private String |
getEpdParam(ParamPropReader refIni,
String key,
String section)
|
String |
getEpdParameter(String key)
Deprecated. Use the getEpdParameter(key,file,section,default) signature instead. |
String |
getEpdParameter(String key,
String defVal)
Deprecated. Use getEpdParameter (key,file,section,default) instead |
String |
getEpdParameter(String key,
String dataSource,
String defVal)
Deprecated. Use getEpdParameter (key,file,section,default) instead. |
String |
getEpdParameter(String key,
String dataSource,
String section,
String defVal)
Read a parameter for a specific datasource from within a specific Section in a specific Ini File. |
Collection |
getEpdParameterIgnoringCase(String key)
Read a parameter for a specific datasource from within a specific Section in a specific Ini File ignoring case of "key" argument. |
Collection |
getEpdParameterIgnoringCase(String key,
String defVal)
Deprecated. Use getEpdParameterIgnoringCase (key,file,section,default) instead |
Collection |
getEpdParameterIgnoringCase(String key,
String dataSource,
String defVal)
Deprecated. Use getEpdParameterIgnoringCase (key,file,section,default) instead |
Collection |
getEpdParameterIgnoringCase(String key,
String dataSource,
String section,
String defVal)
Read a parameter for a specific datasource from within a specific Section in a specific Ini File ignoring case of "key" argument. |
String |
getEpdPreferenceUrl(String dir)
In this case, the resource path argument will be searched and returned, in the form of a URL encoded string. |
String |
getEpdPreferenceUrl(String dir,
String file)
Overloaded function that also returns the location of the "dir/file" as a preference file location |
Collection |
getKeysForSection(String dataSource,
String section)
Get a Collection of all the keys defined in the ".ini" files for a particular section, in a particular dataSource. |
private String |
getParameter(String k)
|
private String |
getParameterIgnoreCase(String k)
|
private String |
getParameterNoIgnoreCase(String k)
|
private String |
getResourcePath(String loc,
String k)
|
private String |
getResourcePath(URL dir)
|
Collection |
getSectionsForDatasource(String dataSource)
Get a Collection of all the sections defined in the ".ini" files for a particular dataSource. |
String[] |
getSystemEnvironment()
A method to return a listing of all the prop=val Strings from the systemEnv ini file |
private String |
getSystemResourcePath(String loc,
String k)
|
private void |
initialize()
Initialization of UserParams class data |
private String |
internalGetEpdParameter(String key,
String dataSource)
|
private String |
internalGetEpdParamFromSection(String key,
String dataSource,
String section)
|
private Collection |
internalGetEpdParamFromSectionIgnoringCase(String key,
String dataSource,
String section)
|
private Collection |
internalGetEpdParamIgnoringCase(String key,
String dataSource)
|
static void |
main(String[] args)
|
private void |
readEpdParams(String dataSource)
|
private void |
readParamUrls()
|
private ParamPropReader |
readPropertyFile(String loc,
String dataSource)
|
private ParamPropReader |
readPropertyFile(URL url)
|
private ParamPropReader |
readSystemPropertyFile(String loc,
String dataSource)
|
void |
resetEpdParameters()
reset EpdParameters to force them to be reread from a file |
void |
saveAllUserIni()
Saves all userDir based settings. |
boolean |
saveUserIni(String datasource)
This method allows the user to save the $userDir/datasource.ini file to disk, if the file/url permissions permit it. |
boolean |
setEpdParameter(String key,
String datasource,
String section,
String val)
This method allows applications to add/change values of parameters in the $userDir/datasource.ini file, in memory. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private boolean debug
private Vector srcIniList
private ParamPropReader curSiteIni
private ParamPropReader jarSiteIni
private ParamPropReader curUserIni
private ParamPropReader curDefIni
private ParamPropReader jarDefIni
private ParamPropReader envIni
private String[] systemEnv
private String curDataSrc
private String siteUrl
private String userUrl
private String defUrl
private String envUrl
private boolean init
private final String appendPath
private final String extension
private Hashtable sysProps
private Hashtable secHash
private Hashtable keyHash
private Hashtable dsHash
private final String site
private final String def
public final String kvPairPrefix
private final String RESOURCE
private Properties resourceList
public static final String SITE_DIR_KEY_IN_WT_PROP
public static final String USER_DIR_KEY
public static final String DEFAULT_DIR_KEY_IN_WT_PROP
private static final String wtTemp
private static final String wtHome
private static final String defaultCfgDirName
private static final String defaultSiteDirName
private static final String defaultDefaultDirName
private static String siteDirValue
private static String defaultDirValue
Constructor Detail |
public UserParams()
Method Detail |
private void readEpdParams(String dataSource)
private void initialize()
private void readParamUrls()
private String getParameter(String k)
private String getParameterIgnoreCase(String k)
private String getParameterNoIgnoreCase(String k)
private String convertDSAndSectName2LowerCase(String key)
private ParamPropReader readPropertyFile(String loc, String dataSource)
private ParamPropReader readSystemPropertyFile(String loc, String dataSource)
private ParamPropReader readPropertyFile(URL url)
private String checkPath(String p)
public String adjustPath(String p, String dataSource)
private String internalGetEpdParameter(String key, String dataSource)
public String[] getSystemEnvironment()
public String getEpdParameter(String key)
getEpdParameter(String, String, String, String)
public String getEpdParameter(String key, String defVal)
getEpdParameter(String, String)
public String getEpdParameter(String key, String dataSource, String defVal)
getEpdParameter(String, String, String, String)
private String internalGetEpdParamFromSection(String key, String dataSource, String section)
public void resetEpdParameters()
public String getEpdParameter(String key, String dataSource, String section, String defVal)
public boolean doesEpdParameterExist(String key, String dataSource, String section)
public Collection getEpdParameterIgnoringCase(String key)
public Collection getEpdParameterIgnoringCase(String key, String defVal)
getEpdParameter(String, String)
public Collection getEpdParameterIgnoringCase(String key, String dataSource, String defVal)
getEpdParameter(String, String, String, String)
public Collection getEpdParameterIgnoringCase(String key, String dataSource, String section, String defVal)
private Collection internalGetEpdParamFromSectionIgnoringCase(String key, String dataSource, String section)
private Collection internalGetEpdParamIgnoringCase(String key, String dataSource)
public Collection getSectionsForDatasource(String dataSource)
public Collection getKeysForSection(String dataSource, String section)
private void addKeysToCollection(Collection list, Enumeration enum)
private void addKeysToList(Vector list, Enumeration enum)
public String getEpdPreferenceUrl(String dir)
#java.net.URL
,
getEpdParameter(String, String)
public String getEpdPreferenceUrl(String dir, String file)
getEpdPreferenceUrl(String)
private String getSystemResourcePath(String loc, String k)
private String getResourcePath(String loc, String k)
private String getResourcePath(URL dir)
private String getEpdParam(ParamPropReader refIni, String key)
private String getEpdParam(ParamPropReader refIni, String key, String section)
private String checkForDollarValue(String val)
private UserParams.DataSourceIni getDataSourceIni(String ds)
public boolean setEpdParameter(String key, String datasource, String section, String val)
public boolean deleteEpdParameter(String key, String datasource, String section, String val)
public boolean saveUserIni(String datasource)
public void saveAllUserIni()
private void dump()
public static void main(String[] args)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |