Browse Source

Add skill queue support

master
Chris Smith 15 years ago
parent
commit
09b14887dc

+ 11
- 0
src/uk/co/md87/evetool/api/EveApi.java View File

@@ -40,6 +40,7 @@ import uk.co.md87.evetool.api.wrappers.RaceList;
40 40
 import uk.co.md87.evetool.api.wrappers.ShipList;
41 41
 import uk.co.md87.evetool.api.wrappers.SkillInTraining;
42 42
 import uk.co.md87.evetool.api.wrappers.SkillList;
43
+import uk.co.md87.evetool.api.wrappers.SkillQueue;
43 44
 
44 45
 /**
45 46
  * Allows access to the EVE Api (see http://api.eve-online.com/).
@@ -137,6 +138,16 @@ public class EveApi implements Cloneable {
137 138
         return getResponse("/char/SkillInTraining.xml.aspx", SkillInTraining.class, true, true);
138 139
     }
139 140
 
141
+    /**
142
+     * Retrieves the skill queue for the specified character.
143
+     * Requires a limited API key, user ID and character ID.
144
+     *
145
+     * @return The character's current skill queue
146
+     */
147
+    public ApiResponse<SkillQueue> getSkillQueue() {
148
+        return getResponse("/char/SkillQueue.xml.aspx", SkillQueue.class, true, true);
149
+    }
150
+
140 151
     /**
141 152
      * Retrieves a list of market orders placed by the character.
142 153
      * Requires a limited API key, user ID and character ID.

+ 11
- 0
src/uk/co/md87/evetool/api/wrappers/SkillInTraining.java View File

@@ -49,6 +49,17 @@ public class SkillInTraining {
49 49
     private int startSP, targetSP;
50 50
     private int targetLevel;
51 51
 
52
+    public SkillInTraining(Date startTime, Date endTime, int typeId, int startSP,
53
+            int targetSP, int targetLevel) {
54
+        this.inTraining = false;
55
+        this.startTime = startTime;
56
+        this.endTime = endTime;
57
+        this.typeId = typeId;
58
+        this.startSP = startSP;
59
+        this.targetSP = targetSP;
60
+        this.targetLevel = targetLevel;
61
+    }
62
+
52 63
     public SkillInTraining(final ApiElement resultElement) {
53 64
         super();
54 65
 

+ 74
- 0
src/uk/co/md87/evetool/api/wrappers/SkillQueue.java View File

@@ -0,0 +1,74 @@
1
+/*
2
+ * Copyright (c) 2009 Chris Smith
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package uk.co.md87.evetool.api.wrappers;
24
+
25
+import java.text.DateFormat;
26
+import java.text.ParseException;
27
+import java.text.SimpleDateFormat;
28
+import java.util.ArrayList;
29
+import java.util.Date;
30
+import java.util.logging.Level;
31
+import java.util.logging.Logger;
32
+
33
+import uk.co.md87.evetool.api.EveApi;
34
+import uk.co.md87.evetool.api.parser.ApiElement;
35
+
36
+/**
37
+ *
38
+ * TODO: Document SkillQueue
39
+ * @author chris
40
+ */
41
+public class SkillQueue extends ArrayList<SkillInTraining> {
42
+
43
+    /**
44
+     * A version number for this class. It should be changed whenever the class
45
+     * structure is changed (or anything else that would prevent serialized
46
+     * objects being unserialized with the new class).
47
+     */
48
+    private static final long serialVersionUID = 10;
49
+
50
+    private static final Logger LOGGER = Logger.getLogger(SkillQueue.class.getName());
51
+
52
+    public SkillQueue(final ApiElement resultElement) {
53
+        super();
54
+
55
+        final DateFormat datef = new SimpleDateFormat(EveApi.DATE_FORMAT);
56
+
57
+        for (ApiElement row : resultElement.getRowset("skillqueue")) {
58
+            try {
59
+                final int id = row.getNumericAttribute("typeID");
60
+                final int level = row.getNumericAttribute("level");
61
+                final int startSP = row.getNumericAttribute("startSP");
62
+                final int endSP = row.getNumericAttribute("endSP");
63
+                final Date startTime = datef.parse(row.getStringAttribute("startTime"));
64
+                final Date endTime = datef.parse(row.getStringAttribute("endTime"));
65
+                final int position = row.getNumericAttribute("queuePosition");
66
+
67
+                add(new SkillInTraining(startTime, endTime, id, startSP, endSP, level));
68
+            } catch (ParseException ex) {
69
+                LOGGER.log(Level.WARNING, "Unable to parse date", ex);
70
+            }
71
+        }
72
+    }
73
+
74
+}

Loading…
Cancel
Save