Desktop tool for browsing account info from EVE-Online
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ApiDownloader.java 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. * To change this template, choose Tools | Templates
  3. * and open the template in the editor.
  4. */
  5. package uk.co.md87.evetool.api.io;
  6. import java.io.IOException;
  7. import java.util.HashMap;
  8. import java.util.List;
  9. import java.util.Map;
  10. /**
  11. *
  12. * @author chris
  13. */
  14. public class ApiDownloader {
  15. private String userID = null;
  16. private String charID = null;
  17. private String apiKey = null;
  18. public ApiDownloader() {
  19. }
  20. public ApiDownloader(final String userID, final String apiKey) {
  21. this.userID = userID;
  22. this.apiKey = apiKey;
  23. }
  24. public ApiDownloader(final String userID, final String apiKey, final String charID) {
  25. this.userID = userID;
  26. this.apiKey = apiKey;
  27. this.charID = charID;
  28. }
  29. public String getPage(final String method, final Map<String, String> args)
  30. throws IOException {
  31. final Map<String, String> ourArgs = new HashMap<String, String>(args);
  32. // TODO: Caching
  33. if (userID != null) {
  34. ourArgs.put("userID", userID);
  35. }
  36. if (apiKey != null) {
  37. ourArgs.put("apiKey", apiKey);
  38. }
  39. if (charID != null) {
  40. ourArgs.put("characterID", charID);
  41. }
  42. final StringBuilder builder = new StringBuilder();
  43. for (String line : Downloader.getPage(method, ourArgs)) {
  44. builder.append(line);
  45. }
  46. return builder.toString();
  47. }
  48. }