1 package com.nexuiz.demorecorder.application;
\r
3 import java.util.Properties;
\r
6 * Class that stores the application and global plug-in preferences of the Nexuiz
\r
7 * Demo Recorder application. Set and Get property methods have been modified to
\r
8 * now supply a category.
\r
10 public class NDRPreferences extends Properties {
\r
12 private static final long serialVersionUID = 4363913054294979418L;
\r
13 private static final String CONCATENATOR = ".";
\r
15 * Category that defines a setting to be a setting of the NDR application itself
\r
16 * (and not of one of the plugins).
\r
18 public static final String MAIN_APPLICATION = "NDR";
\r
21 * Searches for the property with the specified key in this property list.
\r
22 * If the key is not found in this property list, the default property list,
\r
23 * and its defaults, recursively, are then checked. The method returns
\r
24 * <code>null</code> if the property is not found.
\r
26 * @param category the category of the setting
\r
27 * @param key the property key.
\r
28 * @return the value in this property list with the specified category+key value.
\r
30 public String getProperty(String category, String key) {
\r
31 return getProperty(getConcatenatedKey(category, key));
\r
35 * Calls the <tt>Hashtable</tt> method <code>put</code>. Provided for
\r
36 * parallelism with the <tt>getProperty</tt> method. Enforces use of
\r
37 * strings for property keys and values. The value returned is the
\r
38 * result of the <tt>Hashtable</tt> call to <code>put</code>.
\r
40 * @param category the category of the setting
\r
41 * @param key the key to be placed into this property list.
\r
42 * @param value the value corresponding to <tt>key</tt>.
\r
43 * @return the previous value of the specified key in this property
\r
44 * list, or <code>null</code> if it did not have one.
\r
46 public void setProperty(String category, String key, String value) {
\r
47 setProperty(getConcatenatedKey(category, key), value);
\r
51 * Returns only the category of a key that is a concatenated string of category and key.
\r
52 * @param concatenatedString
\r
55 public static String getCategory(String concatenatedString) {
\r
56 return concatenatedString.substring(0, concatenatedString.indexOf(CONCATENATOR));
\r
59 public static String getKey(String concatenatedString) {
\r
60 return concatenatedString.substring(concatenatedString.indexOf(CONCATENATOR) + 1, concatenatedString.length());
\r
63 public static String getConcatenatedKey(String category, String key) {
\r
64 return category + CONCATENATOR + key;
\r