blob: 8a98ccf1496c94534903592c8c6e6be90d938ae2 [file] [log] [blame]
Yuta HIGUCHIad4c2182014-09-29 11:16:23 -07001package org.onlab.onos.store.serializers;
2
Yuta HIGUCHIf6d11702014-09-30 19:18:59 -07003import java.nio.ByteBuffer;
4
Yuta HIGUCHIad4c2182014-09-29 11:16:23 -07005// TODO: To be replaced with SerializationService from IOLoop activity
6/**
7 * Service to serialize Objects into byte array.
8 */
9public interface KryoSerializationService {
10
11 /**
12 * Serializes the specified object into bytes using one of the
13 * pre-registered serializers.
14 *
15 * @param obj object to be serialized
16 * @return serialized bytes
17 */
Yuta HIGUCHI53a285d2014-10-06 23:58:01 -070018 public byte[] encode(final Object obj);
Yuta HIGUCHIad4c2182014-09-29 11:16:23 -070019
20 /**
Yuta HIGUCHIf6d11702014-09-30 19:18:59 -070021 * Serializes the specified object into bytes using one of the
22 * pre-registered serializers.
23 *
24 * @param obj object to be serialized
25 * @param buffer to write serialized bytes
26 */
Yuta HIGUCHI53a285d2014-10-06 23:58:01 -070027 public void encode(final Object obj, ByteBuffer buffer);
Yuta HIGUCHIf6d11702014-09-30 19:18:59 -070028
29 /**
Yuta HIGUCHIad4c2182014-09-29 11:16:23 -070030 * Deserializes the specified bytes into an object using one of the
31 * pre-registered serializers.
32 *
33 * @param bytes bytes to be deserialized
34 * @return deserialized object
35 */
Yuta HIGUCHI53a285d2014-10-06 23:58:01 -070036 public <T> T decode(final byte[] bytes);
Yuta HIGUCHIad4c2182014-09-29 11:16:23 -070037
Yuta HIGUCHIf6d11702014-09-30 19:18:59 -070038 /**
39 * Deserializes the specified bytes into an object using one of the
40 * pre-registered serializers.
41 *
42 * @param buffer bytes to be deserialized
43 * @return deserialized object
44 */
Yuta HIGUCHI53a285d2014-10-06 23:58:01 -070045 public <T> T decode(final ByteBuffer buffer);
Yuta HIGUCHIad4c2182014-09-29 11:16:23 -070046}