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.

SkillInTraining.java 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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. package uk.co.md87.evetool.api.wrappers;
  23. import java.text.DateFormat;
  24. import java.text.ParseException;
  25. import java.text.SimpleDateFormat;
  26. import java.util.Date;
  27. import java.util.logging.Level;
  28. import java.util.logging.Logger;
  29. import uk.co.md87.evetool.api.EveApi;
  30. import uk.co.md87.evetool.api.parser.ApiElement;
  31. import uk.co.md87.evetool.api.wrappers.data.SkillInfo;
  32. /**
  33. *
  34. * TODO: Document SkillInTraining
  35. * @author chris
  36. */
  37. public class SkillInTraining {
  38. private static final Logger LOGGER = Logger.getLogger(SkillInTraining.class.getName());
  39. private SkillInfo skill;
  40. private final boolean inTraining;
  41. private Date startTime, endTime;
  42. private int typeId;
  43. private int startSP, targetSP;
  44. private int targetLevel;
  45. public SkillInTraining(Date startTime, Date endTime, int typeId, int startSP,
  46. int targetSP, int targetLevel) {
  47. this.inTraining = false;
  48. this.startTime = startTime;
  49. this.endTime = endTime;
  50. this.typeId = typeId;
  51. this.startSP = startSP;
  52. this.targetSP = targetSP;
  53. this.targetLevel = targetLevel;
  54. }
  55. public SkillInTraining(final ApiElement resultElement) {
  56. super();
  57. if ("0".equals(resultElement.getChildContent("skillInTraining"))) {
  58. inTraining = false;
  59. } else {
  60. final DateFormat datef = new SimpleDateFormat(EveApi.DATE_FORMAT);
  61. inTraining = true;
  62. try {
  63. startTime = datef.parse(resultElement
  64. .getChildContent("trainingStartTime"));
  65. endTime = datef.parse(resultElement
  66. .getChildContent("trainingEndTime"));
  67. startSP = resultElement.getNumericChildContent("trainingStartSP");
  68. targetSP = resultElement.getNumericChildContent("trainingDestinationSP");
  69. targetLevel = resultElement.getNumericChildContent("trainingToLevel");
  70. typeId = resultElement.getNumericChildContent("trainingTypeID");
  71. } catch (NumberFormatException ex) {
  72. LOGGER.log(Level.SEVERE, "Error parsing skill data", ex);
  73. } catch (ParseException ex) {
  74. LOGGER.log(Level.SEVERE, "Error parsing skill data", ex);
  75. }
  76. }
  77. }
  78. public void setSkill(final SkillInfo skill) {
  79. this.skill = skill;
  80. }
  81. public SkillInfo getSkill() {
  82. return skill;
  83. }
  84. public Date getEndTime() {
  85. return endTime;
  86. }
  87. public boolean isInTraining() {
  88. return inTraining;
  89. }
  90. public int getStartSP() {
  91. return startSP;
  92. }
  93. public Date getStartTime() {
  94. return startTime;
  95. }
  96. public int getTargetLevel() {
  97. return targetLevel;
  98. }
  99. public int getTargetSP() {
  100. return targetSP;
  101. }
  102. public int getTypeId() {
  103. return typeId;
  104. }
  105. @Override
  106. public String toString() {
  107. return "[" + (isInTraining() ? "in training: " + typeId + " to level "
  108. + targetLevel + " (" + startSP + "->" + targetSP + "; "
  109. + startTime + "->" + endTime + ")"
  110. : "not training") + "]";
  111. }
  112. }