浏览代码

Core javadoc. Fixes issue 633.

Removed some now-unused popup type stuff

git-svn-id: http://svn.dmdirc.com/trunk@3137 00569f92-eb28-0410-84fd-f71c24880f
tags/0.6
Chris Smith 16 年前
父节点
当前提交
8cdeab2ef4

+ 17
- 0
src/com/dmdirc/CustomWindow.java 查看文件

@@ -28,6 +28,7 @@ import com.dmdirc.ui.WindowManager;
28 28
 import com.dmdirc.ui.interfaces.Window;
29 29
 
30 30
 /**
31
+ * A generic custom window implementation.
31 32
  * 
32 33
  * @author chris
33 34
  */
@@ -39,10 +40,19 @@ public class CustomWindow extends FrameContainer {
39 40
     /** This custom window's title. */
40 41
     private final String title;
41 42
 
43
+    /** The window used by this container. */
42 44
     private Window window;
43 45
 
46
+    /** This window's parent window. */
44 47
     private Window parent = null;
45 48
 
49
+    /**
50
+     * Creates a new custom window as a child of the specified window.
51
+     * 
52
+     * @param name The name of this custom window
53
+     * @param title The title of this custom window
54
+     * @param parent The parent of this custom window
55
+     */
46 56
     public CustomWindow(final String name, final String title,
47 57
             final Window parent) {
48 58
         super();
@@ -62,6 +72,12 @@ public class CustomWindow extends FrameContainer {
62 72
         window.setVisible(true);
63 73
     }
64 74
 
75
+    /**
76
+     * Creates a new custom window as a top-level window.
77
+     * 
78
+     * @param name The name of this custom window
79
+     * @param title The parent of this custom window
80
+     */
65 81
     public CustomWindow(final String name, final String title) {
66 82
         super();
67 83
 
@@ -134,6 +150,7 @@ public class CustomWindow extends FrameContainer {
134 150
         return title;
135 151
     }
136 152
 
153
+    /** {@inheritDoc} */
137 154
     @Override
138 155
     public ConfigManager getConfigManager() {
139 156
         return parent == null ? IdentityManager.getGlobalConfig() : parent

+ 8
- 1
src/com/dmdirc/commandline/RemoteInterface.java 查看文件

@@ -29,11 +29,18 @@ import java.rmi.RemoteException;
29 29
 import java.util.List;
30 30
 
31 31
 /**
32
- *
32
+ * Defines the interface that is available using RMI.
33
+ * 
33 34
  * @author chris
34 35
  */
35 36
 public interface RemoteInterface extends Remote {
36 37
     
38
+    /**
39
+     * Connects to the specified list of addresses.
40
+     * 
41
+     * @param addresses The addresses to connect to.
42
+     * @throws java.rmi.RemoteException on problems communicating
43
+     */
37 44
     void connect(List<IrcAddress> addresses) throws RemoteException;
38 45
 
39 46
 }

+ 6
- 1
src/com/dmdirc/commandline/RemoteServer.java 查看文件

@@ -32,15 +32,20 @@ import java.rmi.server.UnicastRemoteObject;
32 32
 import java.util.List;
33 33
 
34 34
 /**
35
- *
35
+ * An RMI server that allows other clients to interact with DMDirc.
36
+ * 
36 37
  * @author chris
37 38
  */
38 39
 public class RemoteServer implements RemoteInterface {
39 40
     
41
+    /**
42
+     * Creates a new instance of RemoteServer.
43
+     */
40 44
     public RemoteServer() {
41 45
         super();
42 46
     }
43 47
     
48
+    /** {@inheritDoc} */
44 49
     @Override
45 50
     public void connect(List<IrcAddress> addresses) throws RemoteException {
46 51
         for (IrcAddress address : addresses) {

+ 27
- 1
src/com/dmdirc/commandparser/CommandManager.java 查看文件

@@ -43,7 +43,6 @@ import com.dmdirc.logger.ErrorLevel;
43 43
 import com.dmdirc.logger.Logger;
44 44
 import com.dmdirc.ui.input.TabCompleter;
45 45
 import com.dmdirc.util.MapList;
46
-import com.dmdirc.util.WeakList;
47 46
 
48 47
 import java.util.ArrayList;
49 48
 import java.util.HashMap;
@@ -376,6 +375,13 @@ public final class CommandManager {
376 375
         return getCommand(null, name);
377 376
     }
378 377
     
378
+    /**
379
+     * Retrieves a command of the specified type with the specified name.
380
+     * 
381
+     * @param type The type of the command to look for
382
+     * @param name The name to look for
383
+     * @return A command with a matching signature, or null if none were found
384
+     */
379 385
     public static Command getCommand(final CommandType type, final String name) {
380 386
         final List<Command> res = getCommands(type, name);
381 387
         
@@ -393,6 +399,12 @@ public final class CommandManager {
393 399
                 || getCommand(CommandType.TYPE_CHAT, command) != null;
394 400
     }
395 401
        
402
+    /**
403
+     * Retrieves a list of the names of all commands of the specified type.
404
+     * 
405
+     * @param type The type of command to list
406
+     * @return A list of command names
407
+     */
396 408
     public static List<String> getCommandNames(final CommandType type) {
397 409
         final List<String> res = new ArrayList<String>();
398 410
         
@@ -403,10 +415,24 @@ public final class CommandManager {
403 415
         return res;
404 416
     }
405 417
     
418
+    /**
419
+     * Retrieves a list of all commands of the specified type.
420
+     * 
421
+     * @param type The type of command to list
422
+     * @return A list of commands
423
+     */    
406 424
     public static List<Command> getCommands(final CommandType type) {    
407 425
         return getCommands(type, null);
408 426
     }
409 427
     
428
+    /**
429
+     * Retrieves a list of all commands of the specified type, with the
430
+     * specified name.
431
+     * 
432
+     * @param type The type of command to list, or null for all types
433
+     * @param name The name of the command to look for, or null for any name
434
+     * @return A list of matching commands
435
+     */    
410 436
     private static List<Command> getCommands(final CommandType type,
411 437
             final String name) {
412 438
         final List<Command> res = new ArrayList<Command>();

+ 15
- 2
src/com/dmdirc/commandparser/CommandType.java 查看文件

@@ -30,17 +30,30 @@ import com.dmdirc.commandparser.commands.QueryCommand;
30 30
 import com.dmdirc.commandparser.commands.ServerCommand;
31 31
 
32 32
 /**
33
- *
33
+ * Defines the possible targets for commands.
34
+ * 
34 35
  * @author chris
35 36
  */
36 37
 public enum CommandType {
37 38
     
39
+    /** A global command, which may be executed anywhere. */
38 40
     TYPE_GLOBAL,
41
+    /** A server command, which only makes sense in the context of a connection. */
39 42
     TYPE_SERVER,
43
+    /** A chat command, which needs a MessageTarget to make sense. */
40 44
     TYPE_CHAT,
45
+    /** A channel command. */
41 46
     TYPE_CHANNEL,
47
+    /** A query command. */
42 48
     TYPE_QUERY;
43
-    
49
+   
50
+    /**
51
+     * Looks up the command type for the specified command, by inspecting its
52
+     * class.
53
+     * 
54
+     * @param command The command to look up
55
+     * @return The type of the specified command
56
+     */
44 57
     public static CommandType fromCommand(final Command command) {
45 58
         if (command instanceof GlobalCommand) {
46 59
             return TYPE_GLOBAL;

+ 15
- 7
src/com/dmdirc/commandparser/PopupManager.java 查看文件

@@ -22,14 +22,8 @@
22 22
 
23 23
 package com.dmdirc.commandparser;
24 24
 
25
-import com.dmdirc.Precondition;
26 25
 import com.dmdirc.config.ConfigManager;
27
-import com.dmdirc.logger.ErrorLevel;
28
-import com.dmdirc.logger.Logger;
29 26
 
30
-import java.util.LinkedHashMap;
31
-import java.util.List;
32
-import java.util.Map;
33 27
 
34 28
 /**
35 29
  * The popup manager manages which commands should be present in popup menus.
@@ -50,13 +44,20 @@ public class PopupManager {
50 44
      * Configuration data is read from the specified config manager.
51 45
      * 
52 46
      * @param menuType The type of the menu that is needed
53
-     * @param configManager The config manager to be used for the mnenu
47
+     * @param configManager The config manager to be used for the menu
54 48
      * @return The PopupMenu that should be displayed
55 49
      */
56 50
     public static PopupMenu getMenu(final PopupType menuType, final ConfigManager configManager) {
57 51
         return getMenu(menuType.toString(), configManager);
58 52
     }
59 53
     
54
+    /**
55
+     * Retrieves the menu with the specified name.
56
+     * 
57
+     * @param menuName The name of the menu to read
58
+     * @param configManager The config manager to be used for the menu
59
+     * @return The PopupMenu with the specified name
60
+     */
60 61
     private static PopupMenu getMenu(final String menuName, final ConfigManager configManager) {
61 62
         final PopupMenu res = new PopupMenu();
62 63
         
@@ -71,6 +72,13 @@ public class PopupManager {
71 72
         return res;
72 73
     }
73 74
     
75
+    /**
76
+     * Creates a PopupMenuItem for the specified item.
77
+     * 
78
+     * @param item The item to be turned into a PopupMenuItem
79
+     * @param configManager The config manager to beused for the menu
80
+     * @return The corresponding PopupMenuItem
81
+     */
74 82
     private static PopupMenuItem getItem(final String item, final ConfigManager configManager) {
75 83
         PopupMenuItem res;
76 84
         

+ 22
- 5
src/com/dmdirc/commandparser/PopupMenu.java 查看文件

@@ -27,23 +27,40 @@ import java.util.Collection;
27 27
 import java.util.List;
28 28
 
29 29
 /**
30
- *
30
+ * Represents an abstract, UI-independent popup menu.
31
+ * 
31 32
  * @author chris
32 33
  */
33 34
 public class PopupMenu {
34 35
     
36
+    /** The items contained within this popup menu. */
35 37
     private final List<PopupMenuItem> items = new ArrayList<PopupMenuItem>();
36 38
     
39
+    /**
40
+     * Retrieves a list of items contained within this popup menu.
41
+     * 
42
+     * @return A list of this popup menu's items.
43
+     */
37 44
     public List<PopupMenuItem> getItems() {
38 45
         return items;
39 46
     }
40 47
 
41
-    public boolean add(final PopupMenuItem e) {
42
-        return items.add(e);
48
+    /**
49
+     * Adds the specified item to this popup menu.
50
+     * 
51
+     * @param e The item to be added to the popup menu.
52
+     */
53
+    public void add(final PopupMenuItem e) {
54
+        items.add(e);
43 55
     }
44 56
 
45
-    public boolean addAll(final Collection<? extends PopupMenuItem> c) {
46
-        return items.addAll(c);
57
+    /**
58
+     * Adds all of the items in the specified collection to this popup menu.
59
+     * 
60
+     * @param c The collection whose items should be added.
61
+     */
62
+    public void addAll(final Collection<? extends PopupMenuItem> c) {
63
+        items.addAll(c);
47 64
     }    
48 65
 
49 66
 }

+ 50
- 3
src/com/dmdirc/commandparser/PopupMenuItem.java 查看文件

@@ -23,46 +23,93 @@
23 23
 package com.dmdirc.commandparser;
24 24
 
25 25
 /**
26
- *
26
+ * Represents an abstract, UI-independent popup menu item.
27
+ * 
27 28
  * @author chris
28 29
  */
29 30
 public class PopupMenuItem {
30
-    
31
+   
32
+    /** Whether this item is a divider. */
31 33
     private boolean divider = false;
34
+    /** The submenu for this item, if any. */
32 35
     private PopupMenu submenu = null;
36
+    /** The name of this item, if any. */
33 37
     private String name;
38
+    /** The command for this item, if any. */
34 39
     private String command;
35 40
     
41
+    /**
42
+     * Creates a new PopupMenuItem that is used as a divider.
43
+     */
36 44
     public PopupMenuItem() {
37 45
         divider = true;
38 46
     }
39 47
     
48
+    /**
49
+     * Creates a new PopupMenuItem that is used as a submenu.
50
+     * 
51
+     * @param name The name of the menu item
52
+     * @param submenu The submenu of this item
53
+     */
40 54
     public PopupMenuItem(final String name, final PopupMenu submenu) {
41 55
         this.name = name;
42 56
         this.submenu = submenu;
43 57
     }
44 58
     
59
+    /**
60
+     * Creates a new PopupMenuItem that executes a command.
61
+     * 
62
+     * @param name The name of the menu item
63
+     * @param command The command to be executed
64
+     */
45 65
     public PopupMenuItem(final String name, final String command) {
46 66
         this.name = name;
47 67
         this.command = command;
48 68
     }
49 69
     
70
+    /**
71
+     * Determines if this menu item is a divider or not.
72
+     * 
73
+     * @return True if this item is a divider, false otherwise.
74
+     */
50 75
     public boolean isDivider() {
51 76
         return divider;
52 77
     }
53
-    
78
+
79
+    /**
80
+     * Determines if this menu item contains a submenu or not.
81
+     * 
82
+     * @return True if this item contains a submenu, false otherwise.
83
+     */    
54 84
     public boolean isSubMenu() {
55 85
         return submenu != null;
56 86
     }
57 87
     
88
+    /**
89
+     * Retrieves the submenu associated with this item.
90
+     * 
91
+     * @return This menu item's submenu.
92
+     */
58 93
     public PopupMenu getSubMenu() {
59 94
         return submenu;
60 95
     }
61 96
     
97
+    /**
98
+     * Retrieves the name of this menu item.
99
+     * 
100
+     * @return This menu item's name.
101
+     */
62 102
     public String getName() {
63 103
         return name;
64 104
     }
65 105
     
106
+    /**
107
+     * Retrieves the command for this menu item, with the specified argumenwits
108
+     * substituted in.
109
+     * 
110
+     * @param arguments The arguments needed for this command
111
+     * @return The command to be passed to a command parser
112
+     */
66 113
     public String getCommand(final Object... arguments) {
67 114
         return CommandManager.getCommandChar() + String.format(command, arguments);
68 115
     }

+ 4
- 24
src/com/dmdirc/commandparser/PopupType.java 查看文件

@@ -35,40 +35,20 @@ public enum PopupType {
35 35
      * 
36 36
      * Expected arguments: the nickname of the user who was clicked on.
37 37
      */
38
-    CHAN_NICKLIST("nick", "chan-nick", "chan-nick-list"),
38
+    CHAN_NICKLIST,
39 39
         
40 40
     /**
41 41
      * The menu that appears when right clicking in a channel window.
42 42
      * 
43 43
      * Expected arguments: none.
44 44
      */
45
-    CHAN_CHAN("chan"),
45
+    CHAN_CHAN,
46 46
     
47 47
     /**
48 48
      * The menu that appears when right clicking in a query window.
49 49
      * 
50 50
      * Expected arguments: the nickname of the user who the query is with.
51 51
      */
52
-    QUERY_QUERY("nick", "query");
53
-    
54
-    private final String[] domains;
55
-    
56
-    /**
57
-     * Instansiates one of the PopupTypes.
58
-     * 
59
-     * @param domains The configuration domains used for the type
60
-     */
61
-    PopupType(final String ... domains) {
62
-        this.domains = domains;
63
-    }
64
-    
65
-    /**
66
-     * Retrieve a list of the domains that should be used by this type.
67
-     * 
68
-     * @return This type's domains
69
-     */
70
-    public String[] getDomains() {
71
-        return domains.clone();
72
-    }
73
-    
52
+    QUERY_QUERY;
53
+       
74 54
 }

+ 24
- 1
src/com/dmdirc/commandparser/commands/PreviousCommand.java 查看文件

@@ -24,20 +24,43 @@ package com.dmdirc.commandparser.commands;
24 24
 
25 25
 import java.util.Date;
26 26
 
27
+/**
28
+ * Stores information about a previously executed command.
29
+ * 
30
+ * @author chris
31
+ */
27 32
 public final class PreviousCommand {
28
-    
33
+   
34
+    /** The full command that was executed. */
29 35
     private final String line;
36
+    
37
+    /** The timestamp of its execution. */
30 38
     private final long time;
31 39
     
40
+    /**
41
+     * Creates a new record of the specified command.
42
+     * 
43
+     * @param line The full command that was executed
44
+     */
32 45
     public PreviousCommand(final String line) {
33 46
         this.line = line;
34 47
         this.time = new Date().getTime();
35 48
     }
36 49
     
50
+    /**
51
+     * Retrieves the time that the command was executed at.
52
+     * 
53
+     * @return The timestamp that the command was executed at
54
+     */
37 55
     public long getTime() {
38 56
         return time;
39 57
     }
40 58
     
59
+    /**
60
+     * Retrieves the command that was executed.
61
+     * 
62
+     * @return The command that was executed.
63
+     */
41 64
     public String getLine() {
42 65
         return line;
43 66
     }

+ 0
- 1
src/com/dmdirc/commandparser/commands/global/LoadPlugin.java 查看文件

@@ -25,7 +25,6 @@ package com.dmdirc.commandparser.commands.global;
25 25
 import com.dmdirc.commandparser.CommandManager;
26 26
 import com.dmdirc.commandparser.commands.GlobalCommand;
27 27
 import com.dmdirc.commandparser.commands.IntelligentCommand;
28
-import com.dmdirc.plugins.Plugin;
29 28
 import com.dmdirc.plugins.PluginInfo;
30 29
 import com.dmdirc.plugins.PluginManager;
31 30
 import com.dmdirc.ui.input.AdditionalTabTargets;

+ 1
- 0
src/com/dmdirc/commandparser/commands/server/RawServerCommand.java 查看文件

@@ -35,6 +35,7 @@ import com.dmdirc.ui.interfaces.InputWindow;
35 35
  */
36 36
 public final class RawServerCommand extends ServerCommand {
37 37
     
38
+    /** The name of this raw command. */
38 39
     private final String myName;
39 40
     
40 41
     /**

+ 17
- 1
src/com/dmdirc/config/ConfigTarget.java 查看文件

@@ -35,7 +35,22 @@ public final class ConfigTarget implements Comparable, Serializable {
35 35
     
36 36
     /** The possible target types. */
37 37
     public static enum TYPE {
38
-        GLOBALDEFAULT, GLOBAL, THEME, PROFILE, IRCD, NETWORK, SERVER, CHANNEL,
38
+        /** Client-wide default settings. */
39
+        GLOBALDEFAULT,
40
+        /** Client-wide settings. */
41
+        GLOBAL,
42
+        /** Settings for a theme. */
43
+        THEME,
44
+        /** Settings for a profile. */
45
+        PROFILE,
46
+        /** Settings for an IRCd. */
47
+        IRCD,
48
+        /** Settings for a network. */
49
+        NETWORK,
50
+        /** Settings for a server. */
51
+        SERVER,
52
+        /** Settings for a channel. */
53
+        CHANNEL,
39 54
     }
40 55
     
41 56
     /**
@@ -224,6 +239,7 @@ public final class ConfigTarget implements Comparable, Serializable {
224 239
      *
225 240
      * @return A string representation of this object
226 241
      */
242
+    @Override
227 243
     public String toString() {
228 244
         switch (type) {
229 245
         case GLOBALDEFAULT:

+ 7
- 0
src/com/dmdirc/config/Identity.java 查看文件

@@ -74,6 +74,7 @@ public class Identity extends ConfigSource implements Serializable,
74 74
     /** The configuration details for this identity. */
75 75
     protected final Properties properties;
76 76
     
77
+    /** The global config manager. */
77 78
     protected ConfigManager globalConfig;
78 79
     
79 80
     /** The config change listeners for this source. */
@@ -220,6 +221,12 @@ public class Identity extends ConfigSource implements Serializable,
220 221
         }
221 222
     }
222 223
     
224
+    /**
225
+     * Fires the config changed listener for the specified option after this
226
+     * identity is reloaded.
227
+     * 
228
+     * @param object A string describing the changed option (domain.key)
229
+     */
223 230
     private void fireReloadChange(final Object object) {
224 231
         final String string = (String) object;
225 232
         final String domain = string.substring(0, string.indexOf('.'));

+ 6
- 0
src/com/dmdirc/config/IdentityManager.java 查看文件

@@ -157,6 +157,12 @@ public final class IdentityManager {
157 157
         }
158 158
     }
159 159
     
160
+    /**
161
+     * Loads an identity from the specified file. If the identity already
162
+     * exists, it is told to reload instead.
163
+     * 
164
+     * @param file The file to load the identity from.
165
+     */
160 166
     private static void loadIdentity(final File file) {
161 167
         for (Identity identity : identities) {
162 168
             if (file.equals(identity.getFile())) {

+ 2
- 2
src/com/dmdirc/logger/DMDircExceptionHandler.java 查看文件

@@ -33,7 +33,7 @@ public final class DMDircExceptionHandler implements Thread.UncaughtExceptionHan
33 33
     }
34 34
     
35 35
     /** {@inheritDoc} */
36
-    public void uncaughtException(final Thread thread, final Throwable throwable) {
37
-        Logger.appError(ErrorLevel.HIGH, throwable.toString(), throwable);
36
+    public void uncaughtException(final Thread t, final Throwable e) {
37
+        Logger.appError(ErrorLevel.HIGH, e.toString(), e);
38 38
     }
39 39
 }

+ 1
- 1
src/com/dmdirc/themes/Theme.java 查看文件

@@ -27,7 +27,6 @@ import com.dmdirc.config.InvalidIdentityFileException;
27 27
 import com.dmdirc.logger.ErrorLevel;
28 28
 import com.dmdirc.logger.Logger;
29 29
 import com.dmdirc.util.resourcemanager.ZipResourceManager;
30
-import com.dmdirc.ui.messages.Formatter;
31 30
 
32 31
 import java.io.File;
33 32
 import java.io.IOException;
@@ -43,6 +42,7 @@ public class Theme {
43 42
     /** The file to load the theme from. */
44 43
     private final File file;
45 44
     
45
+    /** The resource manager we're using for this theme. */
46 46
     private ZipResourceManager rm;
47 47
     
48 48
     /**

+ 6
- 0
src/com/dmdirc/updater/Update.java 查看文件

@@ -43,11 +43,17 @@ public final class Update {
43 43
      * An enumeration of possible statuses.
44 44
      */
45 45
     public static enum STATUS {
46
+        /** The update is waiting to be started. */
46 47
         PENDING,
48
+        /** The update is currently downloading. */
47 49
         DOWNLOADING,
50
+        /** The update is currently installing. */
48 51
         INSTALLING,
52
+        /** The update has been installed correctly. */
49 53
         INSTALLED,
54
+        /** An error was encountered during update. */
50 55
         ERROR,
56
+        /** A restart is needed to complete the update. */
51 57
         RESTART_NEEDED
52 58
     }
53 59
 

+ 1
- 0
src/com/dmdirc/updater/components/ActionGroupComponent.java 查看文件

@@ -34,6 +34,7 @@ import com.dmdirc.updater.UpdateComponent;
34 34
  */
35 35
 public class ActionGroupComponent implements UpdateComponent {
36 36
     
37
+    /** The group that this component represents. */
37 38
     private ActionGroup group;
38 39
     
39 40
     /**

+ 9
- 0
src/com/dmdirc/util/Downloader.java 查看文件

@@ -161,6 +161,15 @@ public class Downloader {
161 161
         output.close();
162 162
     }    
163 163
     
164
+    /**
165
+     * Creates an URL connection for the specified URL and data.
166
+     * 
167
+     * @param url The URL to connect to
168
+     * @param postData The POST data to pass to the URL
169
+     * @return An URLConnection for the specified URL/data
170
+     * @throws java.net.MalformedURLException If the specified URL is malformed
171
+     * @throws java.io.IOException If an I/O exception occurs while connecting
172
+     */
164 173
     private static URLConnection getConnection(final String url, final String postData)
165 174
             throws MalformedURLException, IOException {
166 175
         final URL myUrl = new URL(url);

+ 6
- 0
src/com/dmdirc/util/EquatableWeakReference.java 查看文件

@@ -29,10 +29,16 @@ import java.lang.ref.WeakReference;
29 29
  * An extension of WeakReference that implements a sane equals and hashcode
30 30
  * method.
31 31
  * 
32
+ * @param <T> The type of object that this reference contains
32 33
  * @author chris
33 34
  */
34 35
 public class EquatableWeakReference<T> extends WeakReference<T> {
35 36
     
37
+    /**
38
+     * Creates a new instance of EquatableWeakReference.
39
+     * 
40
+     * @param referent The object that this weak reference should reference.
41
+     */
36 42
     public EquatableWeakReference(T referent) {
37 43
         super(referent);
38 44
     }

+ 11
- 1
src/com/dmdirc/util/InvalidConfigFileException.java 查看文件

@@ -23,13 +23,23 @@
23 23
 package com.dmdirc.util;
24 24
 
25 25
 /**
26
- *
26
+ * Thrown to indicate that a config file is invalid.
27 27
  * @author chris
28 28
  */
29 29
 public class InvalidConfigFileException extends Exception {
30 30
     
31
+    /**
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
34
+     * objects being unserialized with the new class).
35
+     */    
31 36
     private static final long serialVersionUID = 1;
32 37
 
38
+    /**
39
+     * Creates a new InvalidConfigFileException.
40
+     * 
41
+     * @param string A description of the exception that occured.
42
+     */
33 43
     public InvalidConfigFileException(String string) {
34 44
         super(string);
35 45
     }

+ 5
- 0
src/com/dmdirc/util/IrcAddress.java 查看文件

@@ -39,6 +39,11 @@ import java.util.List;
39 39
  */
40 40
 public class IrcAddress implements Serializable {
41 41
     
42
+    /**
43
+     * A version number for this class. It should be changed whenever the class
44
+     * structure is changed (or anything else that would prevent serialized
45
+     * objects being unserialized with the new class).
46
+     */    
42 47
     private final static long serialVersionUID = 1;
43 48
 
44 49
     /** Whether or not this address uses SSL. */

+ 101
- 7
src/com/dmdirc/util/RollingList.java 查看文件

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

+ 1
- 0
src/com/dmdirc/util/StringTranscoder.java 查看文件

@@ -31,6 +31,7 @@ import java.nio.charset.Charset;
31 31
  */
32 32
 public class StringTranscoder {
33 33
    
34
+    /** The charset that is used by this transcoder. */
34 35
     private final Charset charset;
35 36
     
36 37
     /**

+ 25
- 2
src/com/dmdirc/util/WeakList.java 查看文件

@@ -30,18 +30,27 @@ import java.util.List;
30 30
 import java.util.ListIterator;
31 31
 
32 32
 /**
33
- *
34
- * @param <T>
33
+ * Implements a list of weak references. The weak references (and subsequent
34
+ * garbage collection) are handled transparently.
35
+ * 
36
+ * @param <T> The type of object that this list will contain.
35 37
  * @author chris
36 38
  */
37 39
 public class WeakList<T> implements List<T> {
38 40
 
41
+    /** The items in this list. */
39 42
     private final List<WeakReference<T>> list = new ArrayList<WeakReference<T>>();
40 43
 
44
+    /**
45
+     * Creates a new instance of WeakList.
46
+     */
41 47
     public WeakList() {
42 48
         super();
43 49
     }
44 50
 
51
+    /**
52
+     * Removes any entries from the list that have been GC'd.
53
+     */
45 54
     private void cleanUp() {
46 55
         for (int i = 0; i < list.size(); i++) {
47 56
             if (list.get(i).get() == null) {
@@ -50,6 +59,12 @@ public class WeakList<T> implements List<T> {
50 59
         }
51 60
     }
52 61
 
62
+    /**
63
+     * Dereferences the specified list of WeakReferences to get a plain List.
64
+     * 
65
+     * @param list The list to be dereferenced
66
+     * @return A list containing the items referenced by the specified list
67
+     */
53 68
     private List<T> dereferenceList(final List<WeakReference<T>> list) {
54 69
         final List<T> res = new ArrayList<T>();
55 70
 
@@ -62,6 +77,14 @@ public class WeakList<T> implements List<T> {
62 77
         return res;
63 78
     }
64 79
 
80
+    /**
81
+     * Creates a new collection of weak references to elements in the specified
82
+     * collection.
83
+     * 
84
+     * @param c The collection whose elements should be referenced
85
+     * @return A copy of the specified collection, with each item wrapped in
86
+     * a weak reference.
87
+     */
65 88
     @SuppressWarnings(value = "unchecked")
66 89
     private Collection<WeakReference<T>> referenceCollection(final Collection<?> c) {
67 90
         final Collection<WeakReference<T>> res = new ArrayList<WeakReference<T>>();

正在加载...
取消
保存