|
@@ -22,18 +22,16 @@
|
22
|
22
|
|
23
|
23
|
package uk.co.md87.evetool.api;
|
24
|
24
|
|
25
|
|
-import java.sql.Connection;
|
26
|
25
|
import java.util.HashMap;
|
27
|
26
|
import java.util.Map;
|
28
|
27
|
import java.util.logging.Level;
|
29
|
28
|
import java.util.logging.Logger;
|
30
|
29
|
|
|
30
|
+import uk.co.md87.evetool.api.io.ApiCache;
|
31
|
31
|
import uk.co.md87.evetool.api.io.ApiDownloader;
|
32
|
|
-import uk.co.md87.evetool.api.io.DBCache;
|
33
|
32
|
import uk.co.md87.evetool.api.parser.ApiElement;
|
34
|
33
|
import uk.co.md87.evetool.api.parser.ApiParser;
|
35
|
34
|
import uk.co.md87.evetool.api.parser.ApiResult;
|
36
|
|
-import uk.co.md87.evetool.api.util.TableCreator;
|
37
|
35
|
import uk.co.md87.evetool.api.wrappers.CertificateTree;
|
38
|
36
|
import uk.co.md87.evetool.api.wrappers.CharacterList;
|
39
|
37
|
import uk.co.md87.evetool.api.wrappers.CharacterSheet;
|
|
@@ -50,23 +48,17 @@ import uk.co.md87.evetool.api.wrappers.SkillList;
|
50
|
48
|
*/
|
51
|
49
|
public class EveApi implements Cloneable {
|
52
|
50
|
|
53
|
|
- /** SQL tables required by the API. */
|
54
|
|
- private static final String[] TABLES = {"PageCache"};
|
55
|
|
-
|
56
|
|
- /** Whether or not tables have been checked. */
|
57
|
|
- private static boolean checkedTables = false;
|
58
|
|
-
|
59
|
51
|
/** Logger to use for this class. */
|
60
|
52
|
private static final Logger LOGGER = Logger.getLogger(EveApi.class.getName());
|
61
|
53
|
|
62
|
54
|
/** Date format for dates returned by the API. */
|
63
|
55
|
public static final String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";
|
64
|
56
|
|
65
|
|
- /** The database connection to use. */
|
66
|
|
- private final Connection conn;
|
67
|
|
-
|
68
|
57
|
/** The downloader to use. */
|
69
|
58
|
private final ApiDownloader downloader;
|
|
59
|
+
|
|
60
|
+ /** The cache to use. */
|
|
61
|
+ private final ApiCache cache;
|
70
|
62
|
|
71
|
63
|
/** The client's user ID, if specified. */
|
72
|
64
|
private int userID;
|
|
@@ -81,17 +73,11 @@ public class EveApi implements Cloneable {
|
81
|
73
|
* Creates a new instance of the EVE API client using the specified database
|
82
|
74
|
* connection.
|
83
|
75
|
*
|
84
|
|
- * @param sqlConnection A connection to a database to use
|
|
76
|
+ * @param cache The Cache implementation to use.
|
85
|
77
|
*/
|
86
|
|
- public EveApi(final Connection sqlConnection) {
|
87
|
|
- this.conn = sqlConnection;
|
88
|
|
-
|
89
|
|
- if (!checkedTables) {
|
90
|
|
- new TableCreator(conn, "/uk/co/md87/evetool/api/db/", TABLES).checkTables();
|
91
|
|
- checkedTables = true;
|
92
|
|
- }
|
93
|
|
-
|
94
|
|
- this.downloader = new ApiDownloader(new DBCache(conn), new ApiParser());
|
|
78
|
+ public EveApi(final ApiCache cache) {
|
|
79
|
+ this.cache = cache;
|
|
80
|
+ this.downloader = new ApiDownloader(cache, new ApiParser());
|
95
|
81
|
}
|
96
|
82
|
|
97
|
83
|
/**
|
|
@@ -247,7 +233,7 @@ public class EveApi implements Cloneable {
|
247
|
233
|
/** {@inheritDoc} */
|
248
|
234
|
@Override
|
249
|
235
|
public EveApi clone() {
|
250
|
|
- final EveApi copy = new EveApi(conn);
|
|
236
|
+ final EveApi copy = new EveApi(cache);
|
251
|
237
|
copy.setApiKey(apiKey);
|
252
|
238
|
copy.setUserID(userID);
|
253
|
239
|
copy.setCharID(charID);
|