]> git.xonotic.org Git - xonotic/xonotic.git/blob - misc/tools/NexuizDemoRecorder/main/src/main/java/com/nexuiz/demorecorder/application/NDRPreferences.java
initial checkin from nexuiz svn r8756
[xonotic/xonotic.git] / misc / tools / NexuizDemoRecorder / main / src / main / java / com / nexuiz / demorecorder / application / NDRPreferences.java
1 package com.nexuiz.demorecorder.application;\r
2 \r
3 import java.util.Properties;\r
4 \r
5 /**\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
9  */\r
10 public class NDRPreferences extends Properties {\r
11         \r
12         private static final long serialVersionUID = 4363913054294979418L;\r
13         private static final String CONCATENATOR = ".";\r
14         /**\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
17          */\r
18         public static final String MAIN_APPLICATION = "NDR";\r
19 \r
20         /**\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
25      *\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
29      */\r
30         public String getProperty(String category, String key) {\r
31                 return getProperty(getConcatenatedKey(category, key));\r
32         }\r
33         \r
34         /**\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
39      *\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
45      */\r
46         public void setProperty(String category, String key, String value) {\r
47                 setProperty(getConcatenatedKey(category, key), value);\r
48         }\r
49         \r
50         /**\r
51          * Returns only the category of a key that is a concatenated string of category and key.\r
52          * @param concatenatedString\r
53          * @return\r
54          */\r
55         public static String getCategory(String concatenatedString) {\r
56                 return concatenatedString.substring(0, concatenatedString.indexOf(CONCATENATOR));\r
57         }\r
58         \r
59         public static String getKey(String concatenatedString) {\r
60                 return concatenatedString.substring(concatenatedString.indexOf(CONCATENATOR) + 1, concatenatedString.length());\r
61         }\r
62         \r
63         public static String getConcatenatedKey(String category, String key) {\r
64                 return category + CONCATENATOR + key;\r
65         }\r
66 }\r