Toshio Koide | 58b3497 | 2014-02-12 14:54:47 -0800 | [diff] [blame] | 1 | package net.onrc.onos.intent; |
| 2 | |
Toshio Koide | 58b3497 | 2014-02-12 14:54:47 -0800 | [diff] [blame] | 3 | |
| 4 | /** |
| 5 | * @author Toshio Koide (t-koide@onlab.us) |
| 6 | */ |
| 7 | public class IntentDeserializer { |
| 8 | private String id; |
| 9 | private String className; |
| 10 | private Intent intent = null; |
Toshio Koide | 58b3497 | 2014-02-12 14:54:47 -0800 | [diff] [blame] | 11 | |
Toshio Koide | 0e4d8d2 | 2014-02-14 10:56:10 -0800 | [diff] [blame] | 12 | public IntentDeserializer(byte[] b) { |
Toshio Koide | 58b3497 | 2014-02-12 14:54:47 -0800 | [diff] [blame] | 13 | // TODO deserialize object and get (unique id, class name, object data) tuple. |
Toshio Koide | 58b3497 | 2014-02-12 14:54:47 -0800 | [diff] [blame] | 14 | 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 Koide | 0e4d8d2 | 2014-02-14 10:56:10 -0800 | [diff] [blame] | 35 | intent = new PathIntent(id, null, 0, null); |
Toshio Koide | 58b3497 | 2014-02-12 14:54:47 -0800 | [diff] [blame] | 36 | } |
| 37 | |
| 38 | private void parseShortestPathIntent(byte[] objectData) { |
| 39 | // TODO deserialize object and create instance |
Toshio Koide | 0e4d8d2 | 2014-02-14 10:56:10 -0800 | [diff] [blame] | 40 | intent = new ShortestPathIntent(id, 0L, 0L, 0L, 0L, 0L, 0L); |
Toshio Koide | 58b3497 | 2014-02-12 14:54:47 -0800 | [diff] [blame] | 41 | } |
| 42 | |
| 43 | private void parseConstrainedShortestPathIntent(byte[] objectData) { |
| 44 | // TODO deserialize object and create instance |
Toshio Koide | 0e4d8d2 | 2014-02-14 10:56:10 -0800 | [diff] [blame] | 45 | intent = new ConstrainedShortestPathIntent(id, 0L, 0L, 0L, 0L, 0L, 0L, 0.0); |
Toshio Koide | 58b3497 | 2014-02-12 14:54:47 -0800 | [diff] [blame] | 46 | } |
| 47 | |
| 48 | public Intent getIntent() { |
| 49 | return intent; |
| 50 | } |
| 51 | } |