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