blob: a3a6ae6309f812888db8fc309d96faf5015ea5c5 [file] [log] [blame]
Toshio Koide58b34972014-02-12 14:54:47 -08001package net.onrc.onos.intent;
2
Toshio Koide58b34972014-02-12 14:54:47 -08003
4/**
5 * @author Toshio Koide (t-koide@onlab.us)
6 */
7public class IntentDeserializer {
8 private String id;
9 private String className;
10 private Intent intent = null;
Toshio Koide58b34972014-02-12 14:54:47 -080011
Toshio Koide0e4d8d22014-02-14 10:56:10 -080012 public IntentDeserializer(byte[] b) {
Toshio Koide58b34972014-02-12 14:54:47 -080013 // TODO deserialize object and get (unique id, class name, object data) tuple.
Toshio Koide58b34972014-02-12 14:54:47 -080014 id = "id";
15 className = "pi";
16 byte[] objectData = null;
17
18 switch (className) {
19 case "pi":
20 parsePathIntent(objectData);
21 break;
22 case "spi":
23 parseShortestPathIntent(objectData);
24 break;
25 case "cspi":
26 parseConstrainedShortestPathIntent(objectData);
27 break;
28 default:
29 // TODO error
30 }
31 }
32
33 private void parsePathIntent(byte[] objectData) {
34 // TODO deserialize object and create instance
Toshio Koide0e4d8d22014-02-14 10:56:10 -080035 intent = new PathIntent(id, null, 0, null);
Toshio Koide58b34972014-02-12 14:54:47 -080036 }
37
38 private void parseShortestPathIntent(byte[] objectData) {
39 // TODO deserialize object and create instance
Toshio Koide0e4d8d22014-02-14 10:56:10 -080040 intent = new ShortestPathIntent(id, 0L, 0L, 0L, 0L, 0L, 0L);
Toshio Koide58b34972014-02-12 14:54:47 -080041 }
42
43 private void parseConstrainedShortestPathIntent(byte[] objectData) {
44 // TODO deserialize object and create instance
Toshio Koide0e4d8d22014-02-14 10:56:10 -080045 intent = new ConstrainedShortestPathIntent(id, 0L, 0L, 0L, 0L, 0L, 0L, 0.0);
Toshio Koide58b34972014-02-12 14:54:47 -080046 }
47
48 public Intent getIntent() {
49 return intent;
50 }
51}