WIP: Deserializer of Intent classes
Change-Id: I8d4994e048fdf388de07cebe741bdeffa085dc44
diff --git a/src/main/java/net/onrc/onos/intent/IntentDeserializer.java b/src/main/java/net/onrc/onos/intent/IntentDeserializer.java
new file mode 100644
index 0000000..c146698
--- /dev/null
+++ b/src/main/java/net/onrc/onos/intent/IntentDeserializer.java
@@ -0,0 +1,54 @@
+package net.onrc.onos.intent;
+
+import net.onrc.onos.ofcontroller.networkgraph.NetworkGraph;
+
+/**
+ * @author Toshio Koide (t-koide@onlab.us)
+ */
+public class IntentDeserializer {
+ private String id;
+ private String className;
+ private Intent intent = null;
+ private NetworkGraph g;
+
+ public IntentDeserializer(NetworkGraph graph, byte[] b) {
+ // TODO deserialize object and get (unique id, class name, object data) tuple.
+ g = graph;
+ id = "id";
+ className = "pi";
+ byte[] objectData = null;
+
+ switch (className) {
+ case "pi":
+ parsePathIntent(objectData);
+ break;
+ case "spi":
+ parseShortestPathIntent(objectData);
+ break;
+ case "cspi":
+ parseConstrainedShortestPathIntent(objectData);
+ break;
+ default:
+ // TODO error
+ }
+ }
+
+ private void parsePathIntent(byte[] objectData) {
+ // TODO deserialize object and create instance
+ intent = new PathIntent(id, null, null, null);
+ }
+
+ private void parseShortestPathIntent(byte[] objectData) {
+ // TODO deserialize object and create instance
+ intent = new ShortestPathIntent(g, id, 0L, 0L, 0L, 0L, 0L, 0L);
+ }
+
+ private void parseConstrainedShortestPathIntent(byte[] objectData) {
+ // TODO deserialize object and create instance
+ intent = new ConstrainedShortestPathIntent(g, id, 0L, 0L, 0L, 0L, 0L, 0L, 0.0);
+ }
+
+ public Intent getIntent() {
+ return intent;
+ }
+}