diff options
Diffstat (limited to 'src/eu/equalparts/cardbase/query')
-rw-r--r-- | src/eu/equalparts/cardbase/query/IO.java | 8 | ||||
-rw-r--r-- | src/eu/equalparts/cardbase/query/Test.java | 70 |
2 files changed, 4 insertions, 74 deletions
diff --git a/src/eu/equalparts/cardbase/query/IO.java b/src/eu/equalparts/cardbase/query/IO.java index 9b81b20..e913966 100644 --- a/src/eu/equalparts/cardbase/query/IO.java +++ b/src/eu/equalparts/cardbase/query/IO.java @@ -13,7 +13,7 @@ import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; -import eu.equalparts.cardbase.data.CardBase; +import eu.equalparts.cardbase.data.Cardbase; import eu.equalparts.cardbase.data.CardSet; import eu.equalparts.cardbase.data.MetaCardSet; @@ -59,8 +59,8 @@ public class IO { * @throws JsonMappingException * @throws IOException */ - public static CardBase readCardBase(File file) throws JsonParseException, JsonMappingException, IOException { - return mapper.readValue(file, CardBase.class); + public static Cardbase readCardBase(File file) throws JsonParseException, JsonMappingException, IOException { + return mapper.readValue(file, Cardbase.class); } /** @@ -72,7 +72,7 @@ public class IO { * @throws JsonMappingException * @throws IOException */ - public static void writeCardBase(File file, CardBase cardBase) throws JsonGenerationException, JsonMappingException, IOException { + public static void writeCardBase(File file, Cardbase cardBase) throws JsonGenerationException, JsonMappingException, IOException { mapper.writeValue(file, cardBase); } diff --git a/src/eu/equalparts/cardbase/query/Test.java b/src/eu/equalparts/cardbase/query/Test.java deleted file mode 100644 index e466c55..0000000 --- a/src/eu/equalparts/cardbase/query/Test.java +++ /dev/null @@ -1,70 +0,0 @@ -package eu.equalparts.cardbase.query; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.ObjectMapper; - -import eu.equalparts.cardbase.data.Card; -import eu.equalparts.cardbase.data.CardSet; - -public class Test { - -// public static void main(String[] args) throws JsonParseException, JsonMappingException, IOException { -// ObjectMapper mapper = new ObjectMapper(); -// mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); -// -// @SuppressWarnings("unchecked") -// List<Card> allCards = getAllCards((Map<String, CardSet>) mapper -// .readValue(new File("AllSets.json"), new TypeReference<Map<String, CardSet>>() {})); -// -// System.out.println("Number of cards: " + allCards.size()); -// } -// -// public static List<Card> getAllCards(Map<String, CardSet> sets) { -// List<Card> allCards = new ArrayList<Card>(); -// -// for (CardSet set : sets.values()) { -// for (Card card : set.getCards()) { -// card.setSetCode(set.getCode()); -// card.setSetName(set.getName()); -// // System.out.println(set.getName() + ": " + card.getName()); -// -// allCards.add(card); -// } -// } -// -// return allCards; -// } - - public static void main(String[] args) throws JsonParseException, JsonMappingException, IOException { - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - -// @SuppressWarnings("unchecked") - CardSet set = mapper.readValue(new File("M15.json"), CardSet.class); - System.out.println(set.getCardByNumber("281").name); - - } - - public static List<Card> getAllCards(Map<String, CardSet> sets) { - List<Card> allCards = new ArrayList<Card>(); - - for (CardSet set : sets.values()) { - for (Card card : set.cards) { - card.setCode = set.code; - // System.out.println(set.getName() + ": " + card.getName()); - - allCards.add(card); - } - } - - return allCards; - } -} |