summaryrefslogtreecommitdiff
path: root/src/main/java/design/persistence/XMLHandler.java
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/main/java/design/persistence/XMLHandler.java66
1 files changed, 0 insertions, 66 deletions
diff --git a/src/main/java/design/persistence/XMLHandler.java b/src/main/java/design/persistence/XMLHandler.java
deleted file mode 100644
index 706dabd..0000000
--- a/src/main/java/design/persistence/XMLHandler.java
+++ /dev/null
@@ -1,66 +0,0 @@
-package design.persistence;
-import java.io.File;
-import java.io.IOException;
-import design.model.DataHandler;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-import design.model.Golfer;
-import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-
-
-
-public class XMLHandler implements DataHandler
-{
- private final ObjectMapper jsonMapper = new ObjectMapper();
- private final XmlMapper xmlMapper = new XmlMapper();
-
- public void exportPersonalData(File file) throws IOException {
- // get our json data just from the JSON database
- File jsonData = JSONPersonalDatabase.instance().exportData(file);
-
- // read the the data from the JSON, as a JsonNode.
- JsonNode golfersNode = jsonMapper.readTree(jsonData);
-
- // XML requires a parent node, we can't just throw the golfersnode into the xml or else it will only produce the first element
- ObjectNode root = xmlMapper.createObjectNode();
- root.set("golfer", golfersNode);
-
- //write to the xml file.
- xmlMapper.writerWithDefaultPrettyPrinter().writeValue(file, root);
- }
-
- public void importPersonalData(File file) throws IOException {
-
- // read our root, the object node
- JsonNode root = xmlMapper.readTree(file);
-
- // debug print line
- System.out.println(root.toPrettyString());
-
- // !!! here is where it's failing...our root is not serializable to an array of golfers. !!!
- Golfer[] golfers = xmlMapper.treeToValue(root, Golfer[].class);
-
- // from here out should be good
- File tempJson = File.createTempFile("imported", ".json");
- jsonMapper.writerWithDefaultPrettyPrinter().writeValue(tempJson, golfers);
- JSONPersonalDatabase.instance().importData(tempJson);
- tempJson.delete();
- }
-
-
-
- public void exportLeagueData(File file) throws IOException
- {
- // TO DO: exporting league data
- }
-
- public void importLeagueData(File file) throws IOException
- {
- // TO DO: importing league data
- }
-}
-
-