Yuta HIGUCHI | ad4c218 | 2014-09-29 11:16:23 -0700 | [diff] [blame] | 1 | package org.onlab.onos.store.serializers; |
| 2 | |
Yuta HIGUCHI | f6d1170 | 2014-09-30 19:18:59 -0700 | [diff] [blame] | 3 | import java.nio.ByteBuffer; |
| 4 | |
Yuta HIGUCHI | ad4c218 | 2014-09-29 11:16:23 -0700 | [diff] [blame] | 5 | // TODO: To be replaced with SerializationService from IOLoop activity |
| 6 | /** |
| 7 | * Service to serialize Objects into byte array. |
| 8 | */ |
Yuta HIGUCHI | 672488d | 2014-10-07 09:23:43 -0700 | [diff] [blame] | 9 | public interface Serializer { |
Yuta HIGUCHI | ad4c218 | 2014-09-29 11:16:23 -0700 | [diff] [blame] | 10 | |
| 11 | /** |
Yuta HIGUCHI | 672488d | 2014-10-07 09:23:43 -0700 | [diff] [blame] | 12 | * Serializes the specified object into bytes. |
Yuta HIGUCHI | ad4c218 | 2014-09-29 11:16:23 -0700 | [diff] [blame] | 13 | * |
| 14 | * @param obj object to be serialized |
| 15 | * @return serialized bytes |
| 16 | */ |
Yuta HIGUCHI | 53a285d | 2014-10-06 23:58:01 -0700 | [diff] [blame] | 17 | public byte[] encode(final Object obj); |
Yuta HIGUCHI | ad4c218 | 2014-09-29 11:16:23 -0700 | [diff] [blame] | 18 | |
| 19 | /** |
Yuta HIGUCHI | 672488d | 2014-10-07 09:23:43 -0700 | [diff] [blame] | 20 | * Serializes the specified object into bytes. |
Yuta HIGUCHI | f6d1170 | 2014-09-30 19:18:59 -0700 | [diff] [blame] | 21 | * |
| 22 | * @param obj object to be serialized |
| 23 | * @param buffer to write serialized bytes |
| 24 | */ |
Yuta HIGUCHI | 53a285d | 2014-10-06 23:58:01 -0700 | [diff] [blame] | 25 | public void encode(final Object obj, ByteBuffer buffer); |
Yuta HIGUCHI | f6d1170 | 2014-09-30 19:18:59 -0700 | [diff] [blame] | 26 | |
| 27 | /** |
Yuta HIGUCHI | 672488d | 2014-10-07 09:23:43 -0700 | [diff] [blame] | 28 | * Deserializes the specified bytes into an object. |
Yuta HIGUCHI | ad4c218 | 2014-09-29 11:16:23 -0700 | [diff] [blame] | 29 | * |
| 30 | * @param bytes bytes to be deserialized |
| 31 | * @return deserialized object |
| 32 | */ |
Yuta HIGUCHI | 53a285d | 2014-10-06 23:58:01 -0700 | [diff] [blame] | 33 | public <T> T decode(final byte[] bytes); |
Yuta HIGUCHI | ad4c218 | 2014-09-29 11:16:23 -0700 | [diff] [blame] | 34 | |
Yuta HIGUCHI | f6d1170 | 2014-09-30 19:18:59 -0700 | [diff] [blame] | 35 | /** |
Yuta HIGUCHI | 672488d | 2014-10-07 09:23:43 -0700 | [diff] [blame] | 36 | * Deserializes the specified bytes into an object. |
Yuta HIGUCHI | f6d1170 | 2014-09-30 19:18:59 -0700 | [diff] [blame] | 37 | * |
| 38 | * @param buffer bytes to be deserialized |
| 39 | * @return deserialized object |
| 40 | */ |
Yuta HIGUCHI | 53a285d | 2014-10-06 23:58:01 -0700 | [diff] [blame] | 41 | public <T> T decode(final ByteBuffer buffer); |
Yuta HIGUCHI | ad4c218 | 2014-09-29 11:16:23 -0700 | [diff] [blame] | 42 | } |