blob: 6c43a1b9659473f0e9ceccc7c20dd8a00657d38c [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 */
Yuta HIGUCHI971addc2014-10-07 23:23:17 -07009public interface StoreSerializer {
Yuta HIGUCHIad4c2182014-09-29 11:16:23 -070010
11 /**
Yuta HIGUCHI672488d2014-10-07 09:23:43 -070012 * Serializes the specified object into bytes.
Yuta HIGUCHIad4c2182014-09-29 11:16:23 -070013 *
14 * @param obj object to be serialized
15 * @return serialized bytes
16 */
Yuta HIGUCHI53a285d2014-10-06 23:58:01 -070017 public byte[] encode(final Object obj);
Yuta HIGUCHIad4c2182014-09-29 11:16:23 -070018
19 /**
Yuta HIGUCHI672488d2014-10-07 09:23:43 -070020 * Serializes the specified object into bytes.
Yuta HIGUCHIf6d11702014-09-30 19:18:59 -070021 *
22 * @param obj object to be serialized
23 * @param buffer to write serialized bytes
24 */
Yuta HIGUCHI53a285d2014-10-06 23:58:01 -070025 public void encode(final Object obj, ByteBuffer buffer);
Yuta HIGUCHIf6d11702014-09-30 19:18:59 -070026
27 /**
Yuta HIGUCHI672488d2014-10-07 09:23:43 -070028 * Deserializes the specified bytes into an object.
Yuta HIGUCHIad4c2182014-09-29 11:16:23 -070029 *
30 * @param bytes bytes to be deserialized
31 * @return deserialized object
32 */
Yuta HIGUCHI53a285d2014-10-06 23:58:01 -070033 public <T> T decode(final byte[] bytes);
Yuta HIGUCHIad4c2182014-09-29 11:16:23 -070034
Yuta HIGUCHIf6d11702014-09-30 19:18:59 -070035 /**
Yuta HIGUCHI672488d2014-10-07 09:23:43 -070036 * Deserializes the specified bytes into an object.
Yuta HIGUCHIf6d11702014-09-30 19:18:59 -070037 *
38 * @param buffer bytes to be deserialized
39 * @return deserialized object
40 */
Yuta HIGUCHI53a285d2014-10-06 23:58:01 -070041 public <T> T decode(final ByteBuffer buffer);
Yuta HIGUCHIad4c2182014-09-29 11:16:23 -070042}