Browse Source

Remove some deprecated Formatter methods

git-svn-id: http://svn.dmdirc.com/trunk@2613 00569f92-eb28-0410-84fd-f71c24880f
tags/0.5.5
Chris Smith 16 years ago
parent
commit
4546fa6bd9

+ 1
- 50
src/com/dmdirc/ui/messages/Formatter.java View File

@@ -30,7 +30,6 @@ import com.dmdirc.config.IdentityManager;
30 30
 import java.io.InputStream;
31 31
 import java.util.HashMap;
32 32
 import java.util.IllegalFormatConversionException;
33
-import java.util.List;
34 33
 import java.util.Map;
35 34
 import java.util.MissingFormatArgumentException;
36 35
 import java.util.UnknownFormatConversionException;
@@ -55,7 +54,7 @@ public final class Formatter {
55 54
         config.addChangeListener("formatter", new ConfigChangeListener() {
56 55
             @Override
57 56
             public void configChanged(final String domain, final String key) {
58
-                Formatter.typeCache.clear();
57
+                Formatter.typeCache.remove(key);
59 58
             }
60 59
         });
61 60
     }
@@ -179,16 +178,6 @@ public final class Formatter {
179 178
         typeCache.put(format, types);
180 179
     }
181 180
     
182
-    /**
183
-     * Returns a list of the available formatters.
184
-     *
185
-     * @return Set of formatters
186
-     * @deprecated This should be done via a config manager directly
187
-     */
188
-    @Deprecated
189
-    public static List<String> getFormats() {
190
-        return config.getOptions("formatter");
191
-    }
192 181
     /**
193 182
      * Determines whether the formatter knows of a specific message type.
194 183
      * 
@@ -199,32 +188,6 @@ public final class Formatter {
199 188
         return config.hasOption("formatter", messageType);
200 189
     }
201 190
     
202
-    /**
203
-     * Allows plugins (etc) to register new default formats.
204
-     * 
205
-     * @param name The name of the format
206
-     * @param format The actual format itself
207
-     * @deprecated This should now be done via the identities system
208
-     */
209
-    @Deprecated
210
-    public static void registerDefault(final String name, final String format) {        
211
-        typeCache.remove(name);
212
-        
213
-        IdentityManager.getConfigIdentity().setOption("formatter", name, format);
214
-    }
215
-    
216
-    /**
217
-     * Loads the specified file into the formatter.
218
-     *
219
-     * @param file File to be loaded
220
-     * @return True iff the operation succeeeded, false otherwise
221
-     * @deprecated No longer has any effect
222
-     */
223
-    @Deprecated
224
-    public static boolean loadFile(final String file) {
225
-        return false;
226
-    }
227
-    
228 191
     /**
229 192
      * Reads the specified input stream as a properties file and loads the
230 193
      * contained formatter settings into the formatter.
@@ -238,18 +201,6 @@ public final class Formatter {
238 201
         return false;
239 202
     }
240 203
     
241
-    /**
242
-     * Saves the current formatter into the specified file.
243
-     * 
244
-     * @param target The target file
245
-     * @return True iff the operation succeeded, false otherwise
246
-     * @deprecated No longer has any effect
247
-     */
248
-    @Deprecated
249
-    public static boolean saveAs(final String target) {
250
-        return false;        
251
-    }
252
-    
253 204
     /**
254 205
      * Reloads the formatter.
255 206
      * 

+ 0
- 121
test/com/dmdirc/ui/messages/FormatterTest.java View File

@@ -1,121 +0,0 @@
1
-/*
2
- * Copyright (c) 2006-2007 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5
- * of this software and associated documentation files (the "Software"), to deal
6
- * in the Software without restriction, including without limitation the rights
7
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- * copies of the Software, and to permit persons to whom the Software is
9
- * furnished to do so, subject to the following conditions:
10
- *
11
- * The above copyright notice and this permission notice shall be included in
12
- * all copies or substantial portions of the Software.
13
- *
14
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- * SOFTWARE.
21
- */
22
-
23
-package com.dmdirc.ui.messages;
24
-
25
-import com.dmdirc.Main;
26
-import com.dmdirc.config.IdentityManager;
27
-
28
-import java.io.File;
29
-import java.util.Set;
30
-
31
-import org.junit.Before;
32
-import org.junit.Test;
33
-import static org.junit.Assert.*;
34
-
35
-public class FormatterTest {
36
-    
37
-    @Before
38
-    public void setUp() throws Exception {
39
-        IdentityManager.load();
40
-    }
41
-
42
-    @Test
43
-    public void testFormatMessage() {
44
-        Formatter.registerDefault("unitTest", "abc %2$s %1$s def");
45
-        
46
-        // Standard format test
47
-        assertEquals(Formatter.formatMessage("unitTest", "123", "456"), "abc 456 123 def");
48
-        
49
-        // Check unknown formats
50
-        assertTrue(Formatter.formatMessage("unitTest123", "m").indexOf("No format string") > -1);
51
-        
52
-        Formatter.registerDefault("unitTest2", "abc %2$$$ZAS %1$s def");
53
-        
54
-        // And invalid formats
55
-        assertTrue(Formatter.formatMessage("unitTest2", "m").indexOf("Invalid format string") > -1);
56
-    }
57
-
58
-    @Test
59
-    public void testGetFormats() {
60
-        final Set<String> s1 = Formatter.getFormats();
61
-        Formatter.registerDefault("unitTest3", "abc");
62
-        final Set<String> s2 = Formatter.getFormats();
63
-        final Set<String> s3 = Formatter.getFormats();
64
-        
65
-        assertEquals(s2, s3);
66
-        assertTrue(s1.size() + 1 == s2.size());
67
-    }
68
-
69
-    @Test
70
-    public void testHasFormat() {
71
-        final String[] targets = new String[]{"unknown", "abc", "def", "unittestfail"};
72
-        
73
-        for (String target : targets) {
74
-            assertFalse(Formatter.hasFormat(target));
75
-        }
76
-        
77
-        for (String target : Formatter.getFormats()) {
78
-            assertTrue(Formatter.hasFormat(target));
79
-        }
80
-    }
81
-
82
-    @Test
83
-    public void testSaveAndLoad() {
84
-        Formatter.registerDefault("unitTest_saveLoad", "");
85
-        
86
-        final String fileName = "unittest_formatter";
87
-        final File file = new File(Main.getConfigDir() + fileName);
88
-        
89
-        if (file.exists()) {
90
-            file.delete();
91
-        }
92
-        
93
-        Formatter.saveAs(fileName);
94
-        
95
-        assertTrue(file.exists());
96
-        
97
-        Formatter.reload();
98
-        
99
-        Formatter.loadFile(fileName);
100
-        
101
-        assertTrue(Formatter.hasFormat("unitTest_saveLoad"));
102
-        
103
-        file.delete();
104
-    }
105
-
106
-    @Test
107
-    public void testReload() {
108
-        Formatter.reload();
109
-        
110
-        final Set<String> s1 = Formatter.getFormats();
111
-        
112
-        Formatter.registerDefault("UnitTestABCDEF", "");
113
-        
114
-        Formatter.reload();
115
-        
116
-        final Set<String> s2 = Formatter.getFormats();
117
-        
118
-        assertEquals(s1.size(), s2.size());
119
-    }
120
-    
121
-}

Loading…
Cancel
Save