Bladeren bron

Fix line endings and trailing spaces

Change-Id: I36ccd739efef6b633cb8f927d820f7bfba49875f
Reviewed-on: http://gerrit.dmdirc.com/1922
Reviewed-by: Greg Holmes <greg@dmdirc.com>
Automatic-Compile: DMDirc Local Commits <dmdirc@googlemail.com>
tags/0.7rc1
Chris Smith 13 jaren geleden
bovenliggende
commit
855c095404

+ 40
- 40
src/com/dmdirc/util/ConfigFile.java Bestand weergeven

49
     /** The key/value sets associated with each key domain. */
49
     /** The key/value sets associated with each key domain. */
50
     private final Map<String, Map<String, String>> keydomains
50
     private final Map<String, Map<String, String>> keydomains
51
             = new HashMap<String, Map<String, String>>();
51
             = new HashMap<String, Map<String, String>>();
52
-    
52
+
53
     /** Whether or not we should automatically create domains. */
53
     /** Whether or not we should automatically create domains. */
54
     private boolean automake;
54
     private boolean automake;
55
 
55
 
56
     /**
56
     /**
57
      * Creates a new read-only Config File from the specified input stream.
57
      * Creates a new read-only Config File from the specified input stream.
58
-     * 
58
+     *
59
      * @param is The input stream to read
59
      * @param is The input stream to read
60
      */
60
      */
61
     public ConfigFile(final InputStream is) {
61
     public ConfigFile(final InputStream is) {
64
 
64
 
65
     /**
65
     /**
66
      * Creates a new Config File from the specified file.
66
      * Creates a new Config File from the specified file.
67
-     * 
67
+     *
68
      * @param file The file to read/write
68
      * @param file The file to read/write
69
      */
69
      */
70
     public ConfigFile(final File file) {
70
     public ConfigFile(final File file) {
73
 
73
 
74
     /**
74
     /**
75
      * Creates a new Config File from the specified file.
75
      * Creates a new Config File from the specified file.
76
-     * 
76
+     *
77
      * @param filename The name of the file to read/write
77
      * @param filename The name of the file to read/write
78
      */
78
      */
79
     public ConfigFile(final String filename) {
79
     public ConfigFile(final String filename) {
84
      * Sets the "automake" value of this config file. If automake is set to
84
      * Sets the "automake" value of this config file. If automake is set to
85
      * true, any calls to getKeyDomain will automatically create the domain
85
      * true, any calls to getKeyDomain will automatically create the domain
86
      * if it did not previously exist.
86
      * if it did not previously exist.
87
-     * 
87
+     *
88
      * @param automake The new value of the automake setting of this file
88
      * @param automake The new value of the automake setting of this file
89
      */
89
      */
90
     public void setAutomake(final boolean automake) {
90
     public void setAutomake(final boolean automake) {
93
 
93
 
94
     /**
94
     /**
95
      * Reads the data from the file.
95
      * Reads the data from the file.
96
-     * 
96
+     *
97
      * @throws IOException if an i/o exception occurred when reading
97
      * @throws IOException if an i/o exception occurred when reading
98
      * @throws InvalidConfigFileException if the config file isn't valid
98
      * @throws InvalidConfigFileException if the config file isn't valid
99
      */
99
      */
101
         String domain = null;
101
         String domain = null;
102
         boolean keydomain = false;
102
         boolean keydomain = false;
103
         int offset;
103
         int offset;
104
-        
104
+
105
         keydomains.clear();
105
         keydomains.clear();
106
         flatdomains.clear();
106
         flatdomains.clear();
107
         domains.clear();
107
         domains.clear();
108
-        
108
+
109
         readLines();
109
         readLines();
110
 
110
 
111
         for (String line : getLines()) {
111
         for (String line : getLines()) {
112
             String tline = line;
112
             String tline = line;
113
-            
114
-            while (!tline.isEmpty() && (tline.charAt(0) == '\t' || 
113
+
114
+            while (!tline.isEmpty() && (tline.charAt(0) == '\t' ||
115
                     tline.charAt(0) == ' ')) {
115
                     tline.charAt(0) == ' ')) {
116
                 tline = tline.substring(1);
116
                 tline = tline.substring(1);
117
             }
117
             }
127
 
127
 
128
                 keydomain = keydomains.containsKey(domain)
128
                 keydomain = keydomains.containsKey(domain)
129
                         || flatdomains.containsValue("keysections", domain);
129
                         || flatdomains.containsValue("keysections", domain);
130
-                
130
+
131
                 if (keydomain && !keydomains.containsKey(domain)) {
131
                 if (keydomain && !keydomains.containsKey(domain)) {
132
                     keydomains.put(domain, new HashMap<String, String>());
132
                     keydomains.put(domain, new HashMap<String, String>());
133
                 } else if (!keydomain && !flatdomains.containsKey(domain)) {
133
                 } else if (!keydomain && !flatdomains.containsKey(domain)) {
150
 
150
 
151
     /**
151
     /**
152
      * Writes the contents of this ConfigFile to disk.
152
      * Writes the contents of this ConfigFile to disk.
153
-     * 
153
+     *
154
      * @throws IOException if the write operation fails
154
      * @throws IOException if the write operation fails
155
      */
155
      */
156
     public void write() throws IOException {
156
     public void write() throws IOException {
158
             throw new UnsupportedOperationException("Cannot write to a file "
158
             throw new UnsupportedOperationException("Cannot write to a file "
159
                     + "that isn't writable");
159
                     + "that isn't writable");
160
         }
160
         }
161
-        
161
+
162
         final List<String> lines = new ArrayList<String>();
162
         final List<String> lines = new ArrayList<String>();
163
 
163
 
164
         lines.add("# This is a DMDirc configuration file.");
164
         lines.add("# This is a DMDirc configuration file.");
191
 
191
 
192
         writeLines(lines);
192
         writeLines(lines);
193
     }
193
     }
194
-    
194
+
195
     /**
195
     /**
196
      * Appends the meta-data (keysections) to the specified list of lines.
196
      * Appends the meta-data (keysections) to the specified list of lines.
197
-     * 
197
+     *
198
      * @param lines The set of lines to be appended to
198
      * @param lines The set of lines to be appended to
199
      */
199
      */
200
     private void writeMeta(final List<String> lines) {
200
     private void writeMeta(final List<String> lines) {
214
             }
214
             }
215
         }
215
         }
216
     }
216
     }
217
-    
217
+
218
     /**
218
     /**
219
      * Retrieves all the key domains for this config file.
219
      * Retrieves all the key domains for this config file.
220
-     * 
220
+     *
221
      * @return This config file's key domains
221
      * @return This config file's key domains
222
      */
222
      */
223
     public Map<String, Map<String, String>> getKeyDomains() {
223
     public Map<String, Map<String, String>> getKeyDomains() {
224
         return keydomains;
224
         return keydomains;
225
     }
225
     }
226
-    
226
+
227
     /**
227
     /**
228
      * Retrieves the key/values of the specified key domain.
228
      * Retrieves the key/values of the specified key domain.
229
-     * 
229
+     *
230
      * @param domain The domain to be retrieved
230
      * @param domain The domain to be retrieved
231
      * @return A map of keys to values in the specified domain
231
      * @return A map of keys to values in the specified domain
232
      */
232
      */
235
             domains.add(domain);
235
             domains.add(domain);
236
             keydomains.put(domain, new HashMap<String, String>());
236
             keydomains.put(domain, new HashMap<String, String>());
237
         }
237
         }
238
-        
238
+
239
         return keydomains.get(domain);
239
         return keydomains.get(domain);
240
     }
240
     }
241
-    
241
+
242
     /**
242
     /**
243
      * Retrieves the content of the specified flat domain.
243
      * Retrieves the content of the specified flat domain.
244
-     * 
244
+     *
245
      * @param domain The domain to be retrieved
245
      * @param domain The domain to be retrieved
246
      * @return A list of lines in the specified domain
246
      * @return A list of lines in the specified domain
247
      */
247
      */
248
     public List<String> getFlatDomain(final String domain) {
248
     public List<String> getFlatDomain(final String domain) {
249
         return flatdomains.get(domain);
249
         return flatdomains.get(domain);
250
     }
250
     }
251
-    
251
+
252
     /**
252
     /**
253
      * Determines if this config file has the specified domain.
253
      * Determines if this config file has the specified domain.
254
-     * 
254
+     *
255
      * @param domain The domain to check for
255
      * @param domain The domain to check for
256
      * @return True if the domain is known, false otherwise
256
      * @return True if the domain is known, false otherwise
257
      */
257
      */
263
     /**
263
     /**
264
      * Determines if this config file has the specified domain, and the domain
264
      * Determines if this config file has the specified domain, and the domain
265
      * is a key domain.
265
      * is a key domain.
266
-     * 
266
+     *
267
      * @param domain The domain to check for
267
      * @param domain The domain to check for
268
      * @return True if the domain is known and keyed, false otherwise
268
      * @return True if the domain is known and keyed, false otherwise
269
      */
269
      */
274
     /**
274
     /**
275
      * Determines if this config file has the specified domain, and the domain
275
      * Determines if this config file has the specified domain, and the domain
276
      * is a flat domain.
276
      * is a flat domain.
277
-     * 
277
+     *
278
      * @param domain The domain to check for
278
      * @param domain The domain to check for
279
      * @return True if the domain is known and flat, false otherwise
279
      * @return True if the domain is known and flat, false otherwise
280
      */
280
      */
281
     public boolean isFlatDomain(final String domain) {
281
     public boolean isFlatDomain(final String domain) {
282
         return flatdomains.containsKey(domain);
282
         return flatdomains.containsKey(domain);
283
     }
283
     }
284
-    
284
+
285
     /**
285
     /**
286
      * Adds a new flat domain to this config file.
286
      * Adds a new flat domain to this config file.
287
-     * 
287
+     *
288
      * @param name The name of the domain to be added
288
      * @param name The name of the domain to be added
289
      * @param data The content of the domain
289
      * @param data The content of the domain
290
      */
290
      */
295
 
295
 
296
     /**
296
     /**
297
      * Adds a new key domain to this config file.
297
      * Adds a new key domain to this config file.
298
-     * 
298
+     *
299
      * @param name The name of the domain to be added
299
      * @param name The name of the domain to be added
300
      * @param data The content of the domain
300
      * @param data The content of the domain
301
-     */    
301
+     */
302
     public void addDomain(final String name, final Map<String, String> data) {
302
     public void addDomain(final String name, final Map<String, String> data) {
303
         domains.add(name);
303
         domains.add(name);
304
         keydomains.put(name, data);
304
         keydomains.put(name, data);
305
     }
305
     }
306
-    
306
+
307
     /**
307
     /**
308
      * Unescapes any escaped characters in the specified input string.
308
      * Unescapes any escaped characters in the specified input string.
309
-     * 
309
+     *
310
      * @param input The string to unescape
310
      * @param input The string to unescape
311
      * @return The string with all escape chars (\) resolved
311
      * @return The string with all escape chars (\) resolved
312
      */
312
      */
325
                 } else {
325
                 } else {
326
                     temp.append(ch);
326
                     temp.append(ch);
327
                 }
327
                 }
328
-                
328
+
329
                 escaped = false;
329
                 escaped = false;
330
             } else if (ch == '\\') {
330
             } else if (ch == '\\') {
331
                 escaped = true;
331
                 escaped = true;
333
                 temp.append(ch);
333
                 temp.append(ch);
334
             }
334
             }
335
         }
335
         }
336
-        
336
+
337
         return temp.toString();
337
         return temp.toString();
338
     }
338
     }
339
-    
339
+
340
     /**
340
     /**
341
      * Escapes the specified input string by prefixing all occurances of
341
      * Escapes the specified input string by prefixing all occurances of
342
      * \, \n, \r, =, # and : with backslashes.
342
      * \, \n, \r, =, # and : with backslashes.
343
-     * 
343
+     *
344
      * @param input The string to be escaped
344
      * @param input The string to be escaped
345
      * @return A backslash-armoured version of the string
345
      * @return A backslash-armoured version of the string
346
      */
346
      */
349
                 .replace("\r", "\\r").replace("=", "\\=")
349
                 .replace("\r", "\\r").replace("=", "\\=")
350
                 .replace(":", "\\:").replace("#", "\\#");
350
                 .replace(":", "\\:").replace("#", "\\#");
351
     }
351
     }
352
-    
352
+
353
     /**
353
     /**
354
      * Finds the first non-escaped instance of '=' in the specified string.
354
      * Finds the first non-escaped instance of '=' in the specified string.
355
-     * 
355
+     *
356
      * @param input The string to be searched
356
      * @param input The string to be searched
357
      * @return The offset of the first non-escaped instance of '=', or -1.
357
      * @return The offset of the first non-escaped instance of '=', or -1.
358
      */
358
      */
359
     protected static int findEquals(final String input) {
359
     protected static int findEquals(final String input) {
360
         boolean escaped = false;
360
         boolean escaped = false;
361
-        
361
+
362
         for (int i = 0; i < input.length(); i++) {
362
         for (int i = 0; i < input.length(); i++) {
363
             if (escaped) {
363
             if (escaped) {
364
                 escaped = false;
364
                 escaped = false;
368
                 return i;
368
                 return i;
369
             }
369
             }
370
         }
370
         }
371
-        
371
+
372
         return -1;
372
         return -1;
373
     }
373
     }
374
 }
374
 }

+ 5
- 5
src/com/dmdirc/util/DownloadListener.java Bestand weergeven

25
 /**
25
 /**
26
  * Defines the method that objects interested in receiving download progress
26
  * Defines the method that objects interested in receiving download progress
27
  * updates should implement.
27
  * updates should implement.
28
- * 
28
+ *
29
  * @author chris
29
  * @author chris
30
  */
30
  */
31
 public interface DownloadListener {
31
 public interface DownloadListener {
32
 
32
 
33
     /**
33
     /**
34
      * Called when the progress of the download has changed.
34
      * Called when the progress of the download has changed.
35
-     * 
35
+     *
36
      * @param percent The percentage of the file that has been downloaded
36
      * @param percent The percentage of the file that has been downloaded
37
      */
37
      */
38
     void downloadProgress(float percent);
38
     void downloadProgress(float percent);
39
-    
39
+
40
     /**
40
     /**
41
      * Called to notify the listener if this download has an indeterminate
41
      * Called to notify the listener if this download has an indeterminate
42
      * length.
42
      * length.
43
-     * 
43
+     *
44
      * @param indeterminate true or false
44
      * @param indeterminate true or false
45
-     * 
45
+     *
46
      * @since 0.6
46
      * @since 0.6
47
      */
47
      */
48
     void setIndeterminate(final boolean indeterminate);
48
     void setIndeterminate(final boolean indeterminate);

+ 4
- 4
src/com/dmdirc/util/EquatableWeakReference.java Bestand weergeven

28
 /**
28
 /**
29
  * An extension of WeakReference that implements a sane equals and hashcode
29
  * An extension of WeakReference that implements a sane equals and hashcode
30
  * method.
30
  * method.
31
- * 
31
+ *
32
  * @param <T> The type of object that this reference contains
32
  * @param <T> The type of object that this reference contains
33
  * @author chris
33
  * @author chris
34
  */
34
  */
35
 public class EquatableWeakReference<T> extends WeakReference<T> {
35
 public class EquatableWeakReference<T> extends WeakReference<T> {
36
-    
36
+
37
     /**
37
     /**
38
      * Creates a new instance of EquatableWeakReference.
38
      * Creates a new instance of EquatableWeakReference.
39
-     * 
39
+     *
40
      * @param referent The object that this weak reference should reference.
40
      * @param referent The object that this weak reference should reference.
41
      */
41
      */
42
     public EquatableWeakReference(final T referent) {
42
     public EquatableWeakReference(final T referent) {
58
     public int hashCode() {
58
     public int hashCode() {
59
         return get().hashCode();
59
         return get().hashCode();
60
     }
60
     }
61
-    
61
+
62
 }
62
 }

+ 3
- 3
src/com/dmdirc/util/InvalidConfigFileException.java Bestand weergeven

27
  * @author chris
27
  * @author chris
28
  */
28
  */
29
 public class InvalidConfigFileException extends Exception {
29
 public class InvalidConfigFileException extends Exception {
30
-    
30
+
31
     /**
31
     /**
32
      * A version number for this class. It should be changed whenever the class
32
      * A version number for this class. It should be changed whenever the class
33
      * structure is changed (or anything else that would prevent serialized
33
      * structure is changed (or anything else that would prevent serialized
34
      * objects being unserialized with the new class).
34
      * objects being unserialized with the new class).
35
-     */    
35
+     */
36
     private static final long serialVersionUID = 1;
36
     private static final long serialVersionUID = 1;
37
 
37
 
38
     /**
38
     /**
39
      * Creates a new InvalidConfigFileException.
39
      * Creates a new InvalidConfigFileException.
40
-     * 
40
+     *
41
      * @param string A description of the exception that occured.
41
      * @param string A description of the exception that occured.
42
      */
42
      */
43
     public InvalidConfigFileException(final String string) {
43
     public InvalidConfigFileException(final String string) {

+ 12
- 12
src/com/dmdirc/util/ListenerList.java Bestand weergeven

30
 /**
30
 /**
31
  * Represents a list of event listeners, similar to EventListenerList, but
31
  * Represents a list of event listeners, similar to EventListenerList, but
32
  * not swing specific.
32
  * not swing specific.
33
- * 
33
+ *
34
  * @author chris
34
  * @author chris
35
  */
35
  */
36
 public class ListenerList {
36
 public class ListenerList {
37
-    
37
+
38
     /** The map of class->listener or string->listener that we're using. */
38
     /** The map of class->listener or string->listener that we're using. */
39
     private final Map<Object, Collection<Object>> listeners
39
     private final Map<Object, Collection<Object>> listeners
40
             = new HashMap<Object, Collection<Object>>();
40
             = new HashMap<Object, Collection<Object>>();
41
-       
41
+
42
     /**
42
     /**
43
      * Adds a new listener of the specified type to this listener list.
43
      * Adds a new listener of the specified type to this listener list.
44
-     * 
44
+     *
45
      * @param <T> The type of listener to be added
45
      * @param <T> The type of listener to be added
46
      * @param listenerType The type of listener to be added
46
      * @param listenerType The type of listener to be added
47
      * @param listener The listener to be added
47
      * @param listener The listener to be added
53
 
53
 
54
         listeners.get(listenerType).add(listener);
54
         listeners.get(listenerType).add(listener);
55
     }
55
     }
56
-    
56
+
57
     /**
57
     /**
58
      * Adds a new listener of the specified type to this listener list.
58
      * Adds a new listener of the specified type to this listener list.
59
-     * 
59
+     *
60
      * @param listenerType The name of the type of listener that's being added
60
      * @param listenerType The name of the type of listener that's being added
61
      * @param listener The listener to be added
61
      * @param listener The listener to be added
62
      */
62
      */
67
 
67
 
68
         listeners.get(listenerType).add(listener);
68
         listeners.get(listenerType).add(listener);
69
     }
69
     }
70
-    
70
+
71
     /**
71
     /**
72
      * Removes the specified listener from the list of listeners for the
72
      * Removes the specified listener from the list of listeners for the
73
      * specified type.
73
      * specified type.
79
     public <T> void remove(final Class<T> listenerType, final T listener) {
79
     public <T> void remove(final Class<T> listenerType, final T listener) {
80
         get(listenerType).remove(listener);
80
         get(listenerType).remove(listener);
81
     }
81
     }
82
-    
82
+
83
     /**
83
     /**
84
      * Removes the specified listener from the list of listeners for the
84
      * Removes the specified listener from the list of listeners for the
85
      * specified type.
85
      * specified type.
86
-     * 
86
+     *
87
      * @param listenerType The name of the type that the listener should be
87
      * @param listenerType The name of the type that the listener should be
88
      * removed from
88
      * removed from
89
      * @param listener The listener to be removed
89
      * @param listener The listener to be removed
91
     public void remove(final String listenerType, final Object listener) {
91
     public void remove(final String listenerType, final Object listener) {
92
         get(listenerType).remove(listener);
92
         get(listenerType).remove(listener);
93
     }
93
     }
94
-    
94
+
95
     /**
95
     /**
96
      * Retrieves the list of listeners for the specified type.
96
      * Retrieves the list of listeners for the specified type.
97
      *
97
      *
107
             return new CopyOnWriteArrayList<T>();
107
             return new CopyOnWriteArrayList<T>();
108
         }
108
         }
109
     }
109
     }
110
-    
110
+
111
     /**
111
     /**
112
      * Retrieves the list of listeners for the specified type.
112
      * Retrieves the list of listeners for the specified type.
113
-     * 
113
+     *
114
      * @param listenerType The type of listener to be retrieved
114
      * @param listenerType The type of listener to be retrieved
115
      * @return A list of listeners for the specified type
115
      * @return A list of listeners for the specified type
116
      */
116
      */

+ 3
- 3
src/com/dmdirc/util/ReturnableThread.java Bestand weergeven

24
 
24
 
25
 /**
25
 /**
26
  * Normal thread with the potential to return a value.
26
  * Normal thread with the potential to return a value.
27
- * 
27
+ *
28
  * @param T Type to be returned
28
  * @param T Type to be returned
29
  */
29
  */
30
 public abstract class ReturnableThread<T> extends Thread {
30
 public abstract class ReturnableThread<T> extends Thread {
38
 
38
 
39
     /**
39
     /**
40
      * Sets the returnable object.
40
      * Sets the returnable object.
41
-     * 
41
+     *
42
      * @param value new returnable object
42
      * @param value new returnable object
43
      */
43
      */
44
     public void setObject(final T value) {
44
     public void setObject(final T value) {
47
 
47
 
48
     /**
48
     /**
49
      * Returns the object set by this thread.
49
      * Returns the object set by this thread.
50
-     * 
50
+     *
51
      * @return Returnable object
51
      * @return Returnable object
52
      */
52
      */
53
     public T getObject() {
53
     public T getObject() {

+ 34
- 34
src/com/dmdirc/util/RollingList.java Bestand weergeven

28
 /**
28
 /**
29
  * Implements a "rolling list". A rolling list has a maximum capacity, and
29
  * Implements a "rolling list". A rolling list has a maximum capacity, and
30
  * removes the oldest elements from the list to maintain this capacity.
30
  * removes the oldest elements from the list to maintain this capacity.
31
- * 
32
- * @param <T> The type if items that this list contains 
31
+ *
32
+ * @param <T> The type if items that this list contains
33
  * @author chris
33
  * @author chris
34
  */
34
  */
35
 public class RollingList<T> {
35
 public class RollingList<T> {
36
-   
36
+
37
     /** The items in this rolling list. */
37
     /** The items in this rolling list. */
38
     private final List<T> items = new ArrayList<T>();
38
     private final List<T> items = new ArrayList<T>();
39
     /** The maximum capacity of this list. */
39
     /** The maximum capacity of this list. */
44
     private int position = 0;
44
     private int position = 0;
45
     /** The "empty" item to be added. */
45
     /** The "empty" item to be added. */
46
     private T empty;
46
     private T empty;
47
-    
47
+
48
     /**
48
     /**
49
      * Creates a new RollingList of the specified capacity.
49
      * Creates a new RollingList of the specified capacity.
50
-     * 
50
+     *
51
      * @param capacity The capacity of this list.
51
      * @param capacity The capacity of this list.
52
      */
52
      */
53
     public RollingList(final int capacity) {
53
     public RollingList(final int capacity) {
58
     /**
58
     /**
59
      * Creates a new RollingList of the specified capacity, with the specified
59
      * Creates a new RollingList of the specified capacity, with the specified
60
      * "empty" element appended to the end.
60
      * "empty" element appended to the end.
61
-     * 
61
+     *
62
      * @param capacity The capacity of this list.
62
      * @param capacity The capacity of this list.
63
      * @param empty The "empty" element to be added
63
      * @param empty The "empty" element to be added
64
-     */    
64
+     */
65
     public RollingList(final int capacity, final T empty) {
65
     public RollingList(final int capacity, final T empty) {
66
         this.capacity = capacity;
66
         this.capacity = capacity;
67
         this.addEmpty = true;
67
         this.addEmpty = true;
70
 
70
 
71
     /**
71
     /**
72
      * Removes the specified element from this list.
72
      * Removes the specified element from this list.
73
-     * 
73
+     *
74
      * @param o The object to be removed from the list.
74
      * @param o The object to be removed from the list.
75
      * @return True if the list contained the specified element,
75
      * @return True if the list contained the specified element,
76
      * false otherwise.
76
      * false otherwise.
81
 
81
 
82
     /**
82
     /**
83
      * Determines if this list is currently empty.
83
      * Determines if this list is currently empty.
84
-     * 
84
+     *
85
      * @return True if the list is empty, false otherwise.
85
      * @return True if the list is empty, false otherwise.
86
      */
86
      */
87
     public boolean isEmpty() {
87
     public boolean isEmpty() {
90
 
90
 
91
     /**
91
     /**
92
      * Retrieves the item at the specified index in this list.
92
      * Retrieves the item at the specified index in this list.
93
-     * 
93
+     *
94
      * @param index The index to look up
94
      * @param index The index to look up
95
      * @return The item at the specified index
95
      * @return The item at the specified index
96
      */
96
      */
100
 
100
 
101
     /**
101
     /**
102
      * Determines if this list contains the specified object.
102
      * Determines if this list contains the specified object.
103
-     * 
103
+     *
104
      * @param o The object to be checked
104
      * @param o The object to be checked
105
      * @return True if this list contains the item, false otherwise.
105
      * @return True if this list contains the item, false otherwise.
106
      */
106
      */
113
      */
113
      */
114
     public void clear() {
114
     public void clear() {
115
         items.clear();
115
         items.clear();
116
-    }  
117
-    
116
+    }
117
+
118
     /**
118
     /**
119
      * Adds the specified item to this list. If the list has reached its
119
      * Adds the specified item to this list. If the list has reached its
120
      * maximum capacity, this method will remove elements from the start of the
120
      * maximum capacity, this method will remove elements from the start of the
121
      * list until there is sufficient room for the new element.
121
      * list until there is sufficient room for the new element.
122
-     * 
122
+     *
123
      * @param e The element to be added to the list.
123
      * @param e The element to be added to the list.
124
      * @return True
124
      * @return True
125
      */
125
      */
128
             items.remove(0);
128
             items.remove(0);
129
             position--;
129
             position--;
130
         }
130
         }
131
-        
131
+
132
         return items.add(e);
132
         return items.add(e);
133
     }
133
     }
134
-    
134
+
135
     /**
135
     /**
136
      * Retrieves the current position within the list.
136
      * Retrieves the current position within the list.
137
-     * 
137
+     *
138
      * @return This list's positional pointer
138
      * @return This list's positional pointer
139
      */
139
      */
140
     public int getPosition() {
140
     public int getPosition() {
143
 
143
 
144
     /**
144
     /**
145
      * Sets the positional pointer of this list.
145
      * Sets the positional pointer of this list.
146
-     * 
146
+     *
147
      * @param position The new position
147
      * @param position The new position
148
      */
148
      */
149
     public void setPosition(final int position) {
149
     public void setPosition(final int position) {
150
         this.position = position;
150
         this.position = position;
151
-    }    
152
-    
151
+    }
152
+
153
     /**
153
     /**
154
      * Determines if there is an element after the positional pointer of
154
      * Determines if there is an element after the positional pointer of
155
      * the list.
155
      * the list.
156
-     * 
156
+     *
157
      * @return True if there is an element, false otherwise.
157
      * @return True if there is an element, false otherwise.
158
      */
158
      */
159
     public boolean hasNext() {
159
     public boolean hasNext() {
160
         return (items.size() > position + 1) || ((items.size() > position)
160
         return (items.size() > position + 1) || ((items.size() > position)
161
                 && addEmpty);
161
                 && addEmpty);
162
     }
162
     }
163
-    
163
+
164
     /**
164
     /**
165
      * Retrieves the element after the positional pointer of the list.
165
      * Retrieves the element after the positional pointer of the list.
166
-     * 
166
+     *
167
      * @return The next element in the list
167
      * @return The next element in the list
168
      */
168
      */
169
     public T getNext() {
169
     public T getNext() {
174
             return empty;
174
             return empty;
175
         }
175
         }
176
     }
176
     }
177
-    
177
+
178
     /**
178
     /**
179
      * Determines if there is an element befpre the positional pointer of
179
      * Determines if there is an element befpre the positional pointer of
180
      * the list.
180
      * the list.
181
-     * 
181
+     *
182
      * @return True if there is an element, false otherwise.
182
      * @return True if there is an element, false otherwise.
183
-     */    
183
+     */
184
     public boolean hasPrevious() {
184
     public boolean hasPrevious() {
185
         return 0 < position;
185
         return 0 < position;
186
     }
186
     }
187
-    
187
+
188
     /**
188
     /**
189
      * Retrieves the element before the positional pointer of the list.
189
      * Retrieves the element before the positional pointer of the list.
190
-     * 
190
+     *
191
      * @return The previous element in the list
191
      * @return The previous element in the list
192
-     */    
192
+     */
193
     public T getPrevious() {
193
     public T getPrevious() {
194
         return get(--position);
194
         return get(--position);
195
-    }    
196
-    
195
+    }
196
+
197
     /**
197
     /**
198
      * Sets the positional pointer of this list to the end.
198
      * Sets the positional pointer of this list to the end.
199
      */
199
      */
200
     public void seekToEnd() {
200
     public void seekToEnd() {
201
         position = items.size();
201
         position = items.size();
202
     }
202
     }
203
-    
203
+
204
     /**
204
     /**
205
      * Sets the positional pointer of this list to the start.
205
      * Sets the positional pointer of this list to the start.
206
      */
206
      */
207
     public void seekToStart() {
207
     public void seekToStart() {
208
         position = 0;
208
         position = 0;
209
     }
209
     }
210
-    
210
+
211
     /**
211
     /**
212
      * Retrieves a list of items that this rolling list contains.
212
      * Retrieves a list of items that this rolling list contains.
213
-     * 
213
+     *
214
      * @return A list of items in this rolling list.
214
      * @return A list of items in this rolling list.
215
      */
215
      */
216
     public List<T> getList() {
216
     public List<T> getList() {

+ 1
- 1
src/com/dmdirc/util/StreamUtil.java Bestand weergeven

32
  * @author chris
32
  * @author chris
33
  */
33
  */
34
 public final class StreamUtil {
34
 public final class StreamUtil {
35
-    
35
+
36
     /** Shouldn't be called. */
36
     /** Shouldn't be called. */
37
     private StreamUtil() {
37
     private StreamUtil() {
38
         super();
38
         super();

+ 23
- 23
src/com/dmdirc/util/TextFile.java Bestand weergeven

36
 
36
 
37
 /**
37
 /**
38
  * Allows reading and writing to a plain text file via a list of lines.
38
  * Allows reading and writing to a plain text file via a list of lines.
39
- * 
39
+ *
40
  * @author chris
40
  * @author chris
41
  */
41
  */
42
 public class TextFile {
42
 public class TextFile {
43
-    
43
+
44
     /** The file we're dealing with. */
44
     /** The file we're dealing with. */
45
     private File file;
45
     private File file;
46
-    
46
+
47
     /** The input stream we're dealing with. */
47
     /** The input stream we're dealing with. */
48
     private InputStream is;
48
     private InputStream is;
49
-    
49
+
50
     /** The lines we've read from the file. */
50
     /** The lines we've read from the file. */
51
     private List<String> lines;
51
     private List<String> lines;
52
 
52
 
53
     /** The charset to use to read the file. */
53
     /** The charset to use to read the file. */
54
     private final Charset charset;
54
     private final Charset charset;
55
-    
55
+
56
     /**
56
     /**
57
      * Creates a new instance of TextFile for the specified file, and uses the
57
      * Creates a new instance of TextFile for the specified file, and uses the
58
      * default charset.
58
      * default charset.
59
-     * 
59
+     *
60
      * @param filename The file to be read/written
60
      * @param filename The file to be read/written
61
      */
61
      */
62
     public TextFile(final String filename) {
62
     public TextFile(final String filename) {
66
     /**
66
     /**
67
      * Creates a new instance of TextFile for the specified File, and uses the
67
      * Creates a new instance of TextFile for the specified File, and uses the
68
      * default charset.
68
      * default charset.
69
-     * 
69
+     *
70
      * @param file The file to read
70
      * @param file The file to read
71
      */
71
      */
72
     public TextFile(final File file) {
72
     public TextFile(final File file) {
73
         this(file, Charset.defaultCharset());
73
         this(file, Charset.defaultCharset());
74
     }
74
     }
75
-    
75
+
76
     /**
76
     /**
77
      * Creates a new instance of TextFile for an input stream, and uses the
77
      * Creates a new instance of TextFile for an input stream, and uses the
78
      * default charset.
78
      * default charset.
79
-     * 
79
+     *
80
      * @param is The input stream to read from
80
      * @param is The input stream to read from
81
      */
81
      */
82
     public TextFile(final InputStream is) {
82
     public TextFile(final InputStream is) {
108
         this.is = is;
108
         this.is = is;
109
         this.charset = charset;
109
         this.charset = charset;
110
     }
110
     }
111
-    
111
+
112
     /**
112
     /**
113
      * Retrieves the contents of the file as a list of lines. If getLines() or
113
      * Retrieves the contents of the file as a list of lines. If getLines() or
114
      * readLines() has previously been called, a cached version is returned.
114
      * readLines() has previously been called, a cached version is returned.
115
-     * 
115
+     *
116
      * @return A list of lines in the file
116
      * @return A list of lines in the file
117
      * @throws IOException if an I/O exception occurs
117
      * @throws IOException if an I/O exception occurs
118
      */
118
      */
120
         if (lines == null) {
120
         if (lines == null) {
121
             readLines();
121
             readLines();
122
         }
122
         }
123
-        
123
+
124
         return lines;
124
         return lines;
125
     }
125
     }
126
-    
126
+
127
     /**
127
     /**
128
      * Reads the contents of the file into this TextFile's line cache.
128
      * Reads the contents of the file into this TextFile's line cache.
129
-     * 
129
+     *
130
      * @throws IOException If an I/O exception occurs
130
      * @throws IOException If an I/O exception occurs
131
      */
131
      */
132
     public void readLines() throws IOException {
132
     public void readLines() throws IOException {
151
             StreamUtil.close(inputStream);
151
             StreamUtil.close(inputStream);
152
         }
152
         }
153
     }
153
     }
154
-    
154
+
155
     /**
155
     /**
156
      * Determines if this file is writable or not.
156
      * Determines if this file is writable or not.
157
-     * 
157
+     *
158
      * @return True if the file is writable, false otherwise
158
      * @return True if the file is writable, false otherwise
159
      */
159
      */
160
     public boolean isWritable() {
160
     public boolean isWritable() {
161
         return file != null;
161
         return file != null;
162
     }
162
     }
163
-    
163
+
164
     /**
164
     /**
165
      * Writes the specified list of lines to the file.
165
      * Writes the specified list of lines to the file.
166
-     * 
166
+     *
167
      * @param lines The lines to be written
167
      * @param lines The lines to be written
168
      * @throws IOException if an I/O exception occurs
168
      * @throws IOException if an I/O exception occurs
169
      */
169
      */
172
             throw new UnsupportedOperationException("Cannot write to TextFile "
172
             throw new UnsupportedOperationException("Cannot write to TextFile "
173
                     + "opened with an InputStream");
173
                     + "opened with an InputStream");
174
         }
174
         }
175
-        
175
+
176
         BufferedWriter writer = null;
176
         BufferedWriter writer = null;
177
 
177
 
178
         try {
178
         try {
179
             writer = new BufferedWriter(new FileWriter(file));
179
             writer = new BufferedWriter(new FileWriter(file));
180
-        
180
+
181
             for (String line : lines) {
181
             for (String line : lines) {
182
                 writer.write(line);
182
                 writer.write(line);
183
                 writer.newLine();
183
                 writer.newLine();
189
 
189
 
190
     /**
190
     /**
191
      * Retrieves the File for this TextFile, if there is one.
191
      * Retrieves the File for this TextFile, if there is one.
192
-     * 
192
+     *
193
      * @return This TextFile's file, or null
193
      * @return This TextFile's file, or null
194
      */
194
      */
195
     public File getFile() {
195
     public File getFile() {
196
         return file;
196
         return file;
197
     }
197
     }
198
-    
198
+
199
     /**
199
     /**
200
      * Deletes the file associated with this textfile, if there is one.
200
      * Deletes the file associated with this textfile, if there is one.
201
      */
201
      */
204
             throw new UnsupportedOperationException("Cannot delete TextFile "
204
             throw new UnsupportedOperationException("Cannot delete TextFile "
205
                     + "opened with an InputStream");
205
                     + "opened with an InputStream");
206
         }
206
         }
207
-        
207
+
208
         file.delete();
208
         file.delete();
209
     }
209
     }
210
 
210
 

+ 3
- 3
src/com/dmdirc/util/WeakList.java Bestand weergeven

32
 /**
32
 /**
33
  * Implements a list of weak references. The weak references (and subsequent
33
  * Implements a list of weak references. The weak references (and subsequent
34
  * garbage collection) are handled transparently.
34
  * garbage collection) are handled transparently.
35
- * 
35
+ *
36
  * @param <T> The type of object that this list will contain.
36
  * @param <T> The type of object that this list will contain.
37
  * @author chris
37
  * @author chris
38
  */
38
  */
55
 
55
 
56
     /**
56
     /**
57
      * Dereferences the specified list of WeakReferences to get a plain List.
57
      * Dereferences the specified list of WeakReferences to get a plain List.
58
-     * 
58
+     *
59
      * @param list The list to be dereferenced
59
      * @param list The list to be dereferenced
60
      * @return A list containing the items referenced by the specified list
60
      * @return A list containing the items referenced by the specified list
61
      */
61
      */
74
     /**
74
     /**
75
      * Creates a new collection of weak references to elements in the specified
75
      * Creates a new collection of weak references to elements in the specified
76
      * collection.
76
      * collection.
77
-     * 
77
+     *
78
      * @param c The collection whose elements should be referenced
78
      * @param c The collection whose elements should be referenced
79
      * @return A copy of the specified collection, with each item wrapped in
79
      * @return A copy of the specified collection, with each item wrapped in
80
      * a weak reference.
80
      * a weak reference.

+ 4
- 4
src/com/dmdirc/util/WeakMapList.java Bestand weergeven

29
  * accessing the data. Implements a Map-like interface for easier transition.
29
  * accessing the data. Implements a Map-like interface for easier transition.
30
  * This implementation uses WeakLists (i.e., lists of weak references) - all
30
  * This implementation uses WeakLists (i.e., lists of weak references) - all
31
  * references to values are wrapped in WeakReferences.
31
  * references to values are wrapped in WeakReferences.
32
- * 
32
+ *
33
  * @param <S> the type of keys maintained by this map
33
  * @param <S> the type of keys maintained by this map
34
  * @param <T> the type of mapped values
34
  * @param <T> the type of mapped values
35
  * @author chris
35
  * @author chris
36
  */
36
  */
37
 public class WeakMapList<S,T> extends MapList<S,T> {
37
 public class WeakMapList<S,T> extends MapList<S,T> {
38
-    
38
+
39
     /**
39
     /**
40
      * Retrieves the list of values associated with the specified key, creating
40
      * Retrieves the list of values associated with the specified key, creating
41
      * the key if neccessary.
41
      * the key if neccessary.
42
-     * 
42
+     *
43
      * @param key The key to retrieve
43
      * @param key The key to retrieve
44
      * @return A list of the specified key's values
44
      * @return A list of the specified key's values
45
      */
45
      */
48
         if (!map.containsKey(key)) {
48
         if (!map.containsKey(key)) {
49
             map.put(key, new WeakList<T>());
49
             map.put(key, new WeakList<T>());
50
         }
50
         }
51
-        
51
+
52
         return map.get(key);
52
         return map.get(key);
53
     }
53
     }
54
 }
54
 }

+ 1
- 1
src/com/dmdirc/util/validators/PermissiveValidator.java Bestand weergeven

28
  * @author chris
28
  * @author chris
29
  */
29
  */
30
 public class PermissiveValidator<V> implements Validator<V> {
30
 public class PermissiveValidator<V> implements Validator<V> {
31
-    
31
+
32
     /**
32
     /**
33
      * Creates a new instance of PermissiveValidator.
33
      * Creates a new instance of PermissiveValidator.
34
      */
34
      */

+ 3
- 3
src/com/dmdirc/util/validators/RegexStringValidator.java Bestand weergeven

1
 /*
1
 /*
2
  * Copyright (c) 2006-2011 Chris Smith, Shane Mc Cormack, Gregory Holmes
2
  * Copyright (c) 2006-2011 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
- * 
3
+ *
4
  * Permission is hereby granted, free of charge, to any person obtaining a copy
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
5
  * of this software and associated documentation files (the "Software"), to deal
6
  * in the Software without restriction, including without limitation the rights
6
  * in the Software without restriction, including without limitation the rights
7
  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
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
8
  * copies of the Software, and to permit persons to whom the Software is
9
  * furnished to do so, subject to the following conditions:
9
  * furnished to do so, subject to the following conditions:
10
- * 
10
+ *
11
  * The above copyright notice and this permission notice shall be included in
11
  * The above copyright notice and this permission notice shall be included in
12
  * all copies or substantial portions of the Software.
12
  * all copies or substantial portions of the Software.
13
- * 
13
+ *
14
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
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,
15
  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE

+ 3
- 3
src/com/dmdirc/util/validators/StringLengthValidator.java Bestand weergeven

23
 
23
 
24
 /**
24
 /**
25
  * Validates that the length of a string is within certain bounds.
25
  * Validates that the length of a string is within certain bounds.
26
- * 
26
+ *
27
  * @author chris
27
  * @author chris
28
  */
28
  */
29
 public class StringLengthValidator implements Validator<String> {
29
 public class StringLengthValidator implements Validator<String> {
30
-    
30
+
31
     /** The minimum string length. */
31
     /** The minimum string length. */
32
     protected final int min;
32
     protected final int min;
33
-    
33
+
34
     /** The maximum string length. */
34
     /** The maximum string length. */
35
     protected final int max;
35
     protected final int max;
36
 
36
 

Laden…
Annuleren
Opslaan