Browse Source

Misc tidying and lots of javadoc

master
Chris Smith 15 years ago
parent
commit
7d9f0bf53b

+ 4
- 0
src/uk/co/md87/evetool/Main.java View File

@@ -33,6 +33,8 @@ import uk.co.md87.evetool.api.util.TableCreator;
33 33
 import uk.co.md87.evetool.ui.MainWindow;
34 34
 
35 35
 /**
36
+ * Main class for the program. Handles initialisation of the core assets
37
+ * and UI.
36 38
  *
37 39
  * @author chris
38 40
  */
@@ -45,6 +47,8 @@ public class Main {
45 47
     private static final String[] TABLES = new String[]{"Accounts"};
46 48
 
47 49
     /**
50
+     * Main program entry point.
51
+     * 
48 52
      * @param args the command line arguments
49 53
      */
50 54
     public static void main(final String[] args) {

+ 11
- 2
src/uk/co/md87/evetool/api/io/QueueSizeListener.java View File

@@ -23,12 +23,21 @@
23 23
 package uk.co.md87.evetool.api.io;
24 24
 
25 25
 /**
26
- *
27
- * TODO: Document QueueSizeListener
26
+ * An interface to be implemented by objects that wish to be notified when
27
+ * the size of the queue of API requests changes. The queue and notification
28
+ * of listeners is handled by the {@link ApiDownloader}.
29
+ * 
28 30
  * @author chris
29 31
  */
30 32
 public interface QueueSizeListener {
31 33
 
34
+    /**
35
+     * Called whenever the queue size changes (in either direction), and
36
+     * immediately after the listener is registered with the
37
+     * {@link ApiDownloader}.
38
+     *
39
+     * @param size The new size of the request queue
40
+     */
32 41
     void queueSizeUpdate(final int size);
33 42
 
34 43
 }

+ 26
- 4
src/uk/co/md87/evetool/api/parser/ApiParser.java View File

@@ -33,19 +33,34 @@ import org.jdom.JDOMException;
33 33
 import org.jdom.input.SAXBuilder;
34 34
 
35 35
 /**
36
- *
37
- * TODO: Document ApiParser
36
+ * Parses the result of an API request.
37
+ * 
38 38
  * @author chris
39 39
  */
40 40
 public class ApiParser {
41 41
 
42
+    /**
43
+     * Parses the specified data into a tree of {@link ApiResult}s.
44
+     *
45
+     * @param data The data to be parsed
46
+     * @return A representation of the data as a tree of ApiResults
47
+     * @throws IOException If the data cannot be read correctly
48
+     * @throws JDOMException If the XML data cannot be parsed correctly
49
+     * @throws ParserException If the API data cannot be processed correctly
50
+     */
42 51
     public ApiResult parseResult(final String data) throws IOException, JDOMException,
43 52
             ParserException {
44 53
         return parseResult(new SAXBuilder().build(new StringReader(data)));
45 54
     }
46 55
 
47
-    public ApiResult parseResult(final Document doc) throws IOException, JDOMException,
48
-            ParserException {
56
+    /**
57
+     * Parses the specified document into a tree of {@link ApiResult}s.
58
+     *
59
+     * @param doc The document to be parsed
60
+     * @return A representation of the document as a tree of ApiResults
61
+     * @throws ParserException If the API data cannot be processed correctly
62
+     */
63
+    public ApiResult parseResult(final Document doc) throws ParserException {
49 64
         final Element root = doc.getRootElement();
50 65
 
51 66
         if (!"eveapi".equals(root.getName())) {
@@ -58,6 +73,13 @@ public class ApiParser {
58 73
         return result;
59 74
     }
60 75
 
76
+    /**
77
+     * Adds the specified XML {@link Element} and its children to the specified
78
+     * {@link ApiElement}.
79
+     *
80
+     * @param result The ApiElement to append the results to
81
+     * @param element The XML Element to be parsed and added
82
+     */
61 83
     @SuppressWarnings("unchecked")
62 84
     protected void addElements(final ApiElement result, final Element element) {
63 85
         for (Attribute attr : (List<Attribute>) element.getAttributes()) {

+ 15
- 3
src/uk/co/md87/evetool/api/parser/NamedApiElement.java View File

@@ -23,18 +23,30 @@
23 23
 package uk.co.md87.evetool.api.parser;
24 24
 
25 25
 /**
26
- *
27
- * TODO: Document NamedApiElement
26
+ * An extension of a standard {@link ApiElement} that has a name associated with
27
+ * it.
28
+ * 
28 29
  * @author chris
29 30
  */
30 31
 public class NamedApiElement extends ApiElement {
31 32
 
33
+    /** The name of this ApiElement. */
32 34
     private final String name;
33 35
 
34
-    public NamedApiElement(String name) {
36
+    /**
37
+     * Creates a new NamedApiElement with the specified name.
38
+     *
39
+     * @param name The name of the ApiElement
40
+     */
41
+    public NamedApiElement(final String name) {
35 42
         this.name = name;
36 43
     }
37 44
 
45
+    /**
46
+     * Retrieves the name of this NamedApiElement.
47
+     *
48
+     * @return This element's name
49
+     */
38 50
     public String getName() {
39 51
         return name;
40 52
     }

+ 17
- 4
src/uk/co/md87/evetool/api/parser/ParserException.java View File

@@ -23,8 +23,9 @@
23 23
 package uk.co.md87.evetool.api.parser;
24 24
 
25 25
 /**
26
- *
27
- * TODO: Document ParserException
26
+ * Indicates that a problem was encountered when parsing the XML API result
27
+ * in line with the published EVE API specifications.
28
+ * 
28 29
  * @author chris
29 30
  */
30 31
 public class ParserException extends Exception {
@@ -36,11 +37,23 @@ public class ParserException extends Exception {
36 37
      */
37 38
     private static final long serialVersionUID = 10;
38 39
 
39
-    public ParserException(String message, Throwable cause) {
40
+    /**
41
+     * Creates a new ParserException caused by the specified {@link Throwable},
42
+     * with the specified error message.
43
+     *
44
+     * @param message A textual description of the exception
45
+     * @param cause The exception or error that caused the parser failure
46
+     */
47
+    public ParserException(final String message, final Throwable cause) {
40 48
         super(message, cause);
41 49
     }
42 50
 
43
-    public ParserException(String message) {
51
+    /**
52
+     * Creates a new ParserException with the specified error message.
53
+     *
54
+     * @param message A textual description of the exception
55
+     */
56
+    public ParserException(final String message) {
44 57
         super(message);
45 58
     }
46 59
 

+ 15
- 4
src/uk/co/md87/evetool/api/wrappers/CharacterList.java View File

@@ -23,15 +23,14 @@
23 23
 package uk.co.md87.evetool.api.wrappers;
24 24
 
25 25
 import java.util.ArrayList;
26
-import java.util.Map;
27 26
 
28 27
 import uk.co.md87.evetool.api.parser.ApiElement;
29 28
 import uk.co.md87.evetool.api.wrappers.data.BasicCharInfo;
30 29
 import uk.co.md87.evetool.api.wrappers.data.BasicCorpInfo;
31 30
 
32 31
 /**
33
- *
34
- * TODO: Document CharacterList
32
+ * A list of characters associated with a particular account.
33
+ * 
35 34
  * @author chris
36 35
  */
37 36
 public class CharacterList extends ArrayList<BasicCharInfo> {
@@ -43,14 +42,26 @@ public class CharacterList extends ArrayList<BasicCharInfo> {
43 42
      */
44 43
     private static final long serialVersionUID = 10;
45 44
 
45
+    /**
46
+     * Creates a new character list from the specified result set.
47
+     *
48
+     * @param resultElement The result element of a character list query.
49
+     */
46 50
     public CharacterList(final ApiElement resultElement) {
47 51
         super();
48 52
 
49
-        for (ApiElement child : resultElement.getChild("rowset").getChildren()) {
53
+        for (ApiElement child : resultElement.getRowset("characters")) {
50 54
             add(getCharInfo(child));
51 55
         }
52 56
     }
53 57
 
58
+    /**
59
+     * Constructs a {@link BasicCharInfo} object corresponding to the data in
60
+     * the specified row.
61
+     *
62
+     * @param row The row of data to be parsed
63
+     * @return A corresponding BasicCharInfo object
64
+     */
54 65
     protected BasicCharInfo getCharInfo(final ApiElement row) {
55 66
         final BasicCorpInfo corpInfo = new BasicCorpInfo(
56 67
                 row.getStringAttribute("corporationName"),

+ 6
- 0
src/uk/co/md87/evetool/api/wrappers/data/BasicCharInfo.java View File

@@ -22,6 +22,8 @@
22 22
 
23 23
 package uk.co.md87.evetool.api.wrappers.data;
24 24
 
25
+import uk.co.md87.evetool.ui.listable.Retrievable;
26
+
25 27
 /**
26 28
  *
27 29
  * TODO: Document BasicCharInfo
@@ -39,18 +41,22 @@ public class BasicCharInfo {
39 41
         this.corp = corp;
40 42
     }
41 43
 
44
+    @Retrievable(deferred=true, name="Corporation")
42 45
     public BasicCorpInfo getCorp() {
43 46
         return corp;
44 47
     }
45 48
 
49
+    @Retrievable
46 50
     public int getId() {
47 51
         return id;
48 52
     }
49 53
 
54
+    @Retrievable
50 55
     public String getName() {
51 56
         return name;
52 57
     }
53 58
 
59
+    /** {@inheritDoc} */
54 60
     @Override
55 61
     public String toString() {
56 62
         return "[" + name + " (" + id + ") in " + corp + "]";

+ 4
- 0
src/uk/co/md87/evetool/api/wrappers/data/BasicCloneInfo.java View File

@@ -22,6 +22,8 @@
22 22
 
23 23
 package uk.co.md87.evetool.api.wrappers.data;
24 24
 
25
+import uk.co.md87.evetool.ui.listable.Retrievable;
26
+
25 27
 /**
26 28
  *
27 29
  * TODO: Document BasicCloneInfo
@@ -37,10 +39,12 @@ public class BasicCloneInfo {
37 39
         this.spLimit = spLimit;
38 40
     }
39 41
 
42
+    @Retrievable
40 43
     public String getName() {
41 44
         return name;
42 45
     }
43 46
 
47
+    @Retrievable(name="Skillpoint limit")
44 48
     public long getSpLimit() {
45 49
         return spLimit;
46 50
     }

+ 5
- 0
src/uk/co/md87/evetool/api/wrappers/data/BasicCorpInfo.java View File

@@ -22,6 +22,8 @@
22 22
 
23 23
 package uk.co.md87.evetool.api.wrappers.data;
24 24
 
25
+import uk.co.md87.evetool.ui.listable.Retrievable;
26
+
25 27
 /**
26 28
  *
27 29
  * TODO: Document BasicCorpInfo
@@ -37,14 +39,17 @@ public class BasicCorpInfo {
37 39
         this.id = id;
38 40
     }
39 41
 
42
+    @Retrievable
40 43
     public int getId() {
41 44
         return id;
42 45
     }
43 46
 
47
+    @Retrievable
44 48
     public String getName() {
45 49
         return name;
46 50
     }
47 51
 
52
+    /** {@inheritDoc} */
48 53
     @Override
49 54
     public String toString() {
50 55
         return "[" + name + " (" + id + ")]";

+ 3
- 0
src/uk/co/md87/evetool/api/wrappers/data/CertClass.java View File

@@ -23,6 +23,7 @@
23 23
 package uk.co.md87.evetool.api.wrappers.data;
24 24
 
25 25
 import java.util.List;
26
+import uk.co.md87.evetool.ui.listable.Retrievable;
26 27
 
27 28
 /**
28 29
  *
@@ -46,10 +47,12 @@ public class CertClass {
46 47
         return certificates;
47 48
     }
48 49
 
50
+    @Retrievable
49 51
     public int getId() {
50 52
         return id;
51 53
     }
52 54
 
55
+    @Retrievable
53 56
     public String getName() {
54 57
         return name;
55 58
     }

+ 6
- 0
src/uk/co/md87/evetool/api/wrappers/data/CertInfo.java View File

@@ -23,6 +23,7 @@
23 23
 package uk.co.md87.evetool.api.wrappers.data;
24 24
 
25 25
 import java.util.List;
26
+import uk.co.md87.evetool.ui.listable.Retrievable;
26 27
 
27 28
 /**
28 29
  *
@@ -53,18 +54,22 @@ public class CertInfo {
53 54
         return certReqs;
54 55
     }
55 56
 
57
+    @Retrievable(name="Issuing corporation ID")
56 58
     public int getCorp() {
57 59
         return corp;
58 60
     }
59 61
 
62
+    @Retrievable(name="Description")
60 63
     public String getDesc() {
61 64
         return desc;
62 65
     }
63 66
 
67
+    @Retrievable
64 68
     public int getGrade() {
65 69
         return grade;
66 70
     }
67 71
 
72
+    @Retrievable
68 73
     public int getId() {
69 74
         return id;
70 75
     }
@@ -73,6 +78,7 @@ public class CertInfo {
73 78
         return skillReqs;
74 79
     }
75 80
 
81
+    /** {@inheritDoc} */
76 82
     @Override
77 83
     public String toString() {
78 84
         return "[" + id + ": grade " + grade + "]";

+ 5
- 0
src/uk/co/md87/evetool/api/wrappers/data/Implant.java View File

@@ -22,6 +22,8 @@
22 22
 
23 23
 package uk.co.md87.evetool.api.wrappers.data;
24 24
 
25
+import uk.co.md87.evetool.ui.listable.Retrievable;
26
+
25 27
 /**
26 28
  *
27 29
  * TODO: Document Implant
@@ -39,14 +41,17 @@ public class Implant {
39 41
         this.bonus = bonus;
40 42
     }
41 43
 
44
+    @Retrievable
42 45
     public Attribute getAttribute() {
43 46
         return attribute;
44 47
     }
45 48
 
49
+    @Retrievable
46 50
     public int getBonus() {
47 51
         return bonus;
48 52
     }
49 53
 
54
+    @Retrievable
50 55
     public String getName() {
51 56
         return name;
52 57
     }

+ 1
- 0
src/uk/co/md87/evetool/ui/ContentPanel.java View File

@@ -34,6 +34,7 @@ import uk.co.md87.evetool.ui.data.AccountChar;
34 34
 
35 35
 /**
36 36
  *
37
+ * TODO: Document ContentPanel
37 38
  * @author chris
38 39
  */
39 40
 public class ContentPanel extends JPanel {

+ 14
- 3
src/uk/co/md87/evetool/ui/StatusPanel.java View File

@@ -23,17 +23,20 @@
23 23
 package uk.co.md87.evetool.ui;
24 24
 
25 25
 import java.awt.Color;
26
+
26 27
 import javax.swing.BorderFactory;
27 28
 import javax.swing.JLabel;
28 29
 import javax.swing.JPanel;
30
+
29 31
 import net.miginfocom.swing.MigLayout;
32
+
30 33
 import uk.co.md87.evetool.Main;
31 34
 import uk.co.md87.evetool.api.io.ApiDownloader;
32 35
 import uk.co.md87.evetool.api.io.QueueSizeListener;
33 36
 
34 37
 /**
35
- *
36
- * TODO: Document StatusPanel
38
+ * Panel which shows status information at the bottom of the main window.
39
+ * 
37 40
  * @author chris
38 41
  */
39 42
 public class StatusPanel extends JPanel implements QueueSizeListener {
@@ -45,8 +48,14 @@ public class StatusPanel extends JPanel implements QueueSizeListener {
45 48
      */
46 49
     private static final long serialVersionUID = 10;
47 50
 
51
+    /** Labels used to display various pieces of information. */
48 52
     private final JLabel leftLabel, centreLabel, rightLabel;
49 53
 
54
+    /**
55
+     * Creates a new status panel for the specified window.
56
+     *
57
+     * @param window The {@link MainWindow} that this status panel is for
58
+     */
50 59
     public StatusPanel(final MainWindow window) {
51 60
         super(new MigLayout());
52 61
 
@@ -63,9 +72,11 @@ public class StatusPanel extends JPanel implements QueueSizeListener {
63 72
         ApiDownloader.addQueueSizeListener(this);
64 73
     }
65 74
 
75
+    /** {@inheritDoc} */
76
+    @Override
66 77
     public void queueSizeUpdate(final int size) {
67 78
         centreLabel.setText(size == 0 ? "" : 
68
-            (size + " queued request" + (size == 1 ? "" : "s")));
79
+            (size + " API quer" + (size == 1 ? "y" : "ies") + " pending"));
69 80
     }
70 81
 
71 82
 }

+ 1
- 0
src/uk/co/md87/evetool/ui/components/AddButton.java View File

@@ -32,6 +32,7 @@ import javax.swing.JButton;
32 32
 
33 33
 /**
34 34
  *
35
+ * TODO: Document AddButton
35 36
  * @author chris
36 37
  */
37 38
 public class AddButton extends JButton {

+ 20
- 3
src/uk/co/md87/evetool/ui/listable/Retrievable.java View File

@@ -28,16 +28,33 @@ import java.lang.annotation.RetentionPolicy;
28 28
 import java.lang.annotation.Target;
29 29
 
30 30
 /**
31
- *
32
- * TODO: Document Retrievable
31
+ * Designates that the return type of the method is retrievable for use in a
32
+ * {@link Listable}.
33
+ * 
33 34
  * @author chris
34 35
  */
35 36
 @Retention(RetentionPolicy.RUNTIME)
36 37
 @Target(ElementType.METHOD)
37 38
 public @interface Retrievable {
38 39
 
40
+    /**
41
+     * Indicates that the return type of the method should be scanned for
42
+     * other retrievable methods, instead of just using the result directly.
43
+     * If the {@link #name()} property is specified as well, the name is used
44
+     * as a prefix for the methods found in the returned retrievable.
45
+     * 
46
+     * @return True if the return type should be scanned for 'deferred'
47
+     * retrievables, false if the result should be used verbatim
48
+     */
39 49
     boolean deferred() default false;
40
-    
50
+
51
+    /**
52
+     * A custom name for the retrievable method. If no name is specified, it is
53
+     * inferred from the method name by stripping prefixes such as 'get' and
54
+     * inserting spaces before CamelCase words.
55
+     * 
56
+     * @return The custom name for the method
57
+     */
41 58
     String name() default "";
42 59
     
43 60
 }

+ 8
- 2
src/uk/co/md87/evetool/ui/listable/UpdateListener.java View File

@@ -23,11 +23,17 @@
23 23
 package uk.co.md87.evetool.ui.listable;
24 24
 
25 25
 /**
26
- *
27
- * TODO: Document UpdateListener
26
+ * Interface to be implemented by objects that wish to be notified when a
27
+ * {@link Listable} has been updated in some way.
28
+ * 
28 29
  * @author chris
29 30
  */
30 31
 public interface UpdateListener {
31 32
 
33
+    /**
34
+     * Called when a {@link Listable} has been updated.
35
+     *
36
+     * @param listable The object that was updated
37
+     */
32 38
     void listableUpdated(final Listable listable);
33 39
 }

+ 0
- 2
src/uk/co/md87/evetool/ui/pages/SkillPage.java View File

@@ -65,8 +65,6 @@ public class SkillPage extends Page {
65 65
         this.factory = factory;
66 66
 
67 67
         setLayout(new MigLayout("fillx, wrap 1"));
68
-
69
-        add(new JLabel("Skills! Moo!"));
70 68
     }
71 69
 
72 70
     /** {@inheritDoc} */

Loading…
Cancel
Save