blob: 8ebb0e680a92fccd6a7e133a4c56dd48833c9dc2 [file] [log] [blame]
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07001/*
2 * Copyright 2014 Open Networking Laboratory
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
Yuta HIGUCHIad4c2182014-09-29 11:16:23 -070016package org.onlab.onos.store.serializers;
17
Yuta HIGUCHIf6d11702014-09-30 19:18:59 -070018import java.nio.ByteBuffer;
19
Yuta HIGUCHIad4c2182014-09-29 11:16:23 -070020// TODO: To be replaced with SerializationService from IOLoop activity
21/**
22 * Service to serialize Objects into byte array.
23 */
Yuta HIGUCHI971addc2014-10-07 23:23:17 -070024public interface StoreSerializer {
Yuta HIGUCHIad4c2182014-09-29 11:16:23 -070025
26 /**
Yuta HIGUCHI672488d2014-10-07 09:23:43 -070027 * Serializes the specified object into bytes.
Yuta HIGUCHIad4c2182014-09-29 11:16:23 -070028 *
29 * @param obj object to be serialized
30 * @return serialized bytes
31 */
Yuta HIGUCHI53a285d2014-10-06 23:58:01 -070032 public byte[] encode(final Object obj);
Yuta HIGUCHIad4c2182014-09-29 11:16:23 -070033
34 /**
Yuta HIGUCHI672488d2014-10-07 09:23:43 -070035 * Serializes the specified object into bytes.
Yuta HIGUCHIf6d11702014-09-30 19:18:59 -070036 *
37 * @param obj object to be serialized
38 * @param buffer to write serialized bytes
39 */
Yuta HIGUCHI53a285d2014-10-06 23:58:01 -070040 public void encode(final Object obj, ByteBuffer buffer);
Yuta HIGUCHIf6d11702014-09-30 19:18:59 -070041
42 /**
Yuta HIGUCHI672488d2014-10-07 09:23:43 -070043 * Deserializes the specified bytes into an object.
Yuta HIGUCHIad4c2182014-09-29 11:16:23 -070044 *
45 * @param bytes bytes to be deserialized
46 * @return deserialized object
Yuta HIGUCHI5c947272014-11-03 21:39:21 -080047 * @param <T> decoded type
Yuta HIGUCHIad4c2182014-09-29 11:16:23 -070048 */
Yuta HIGUCHI53a285d2014-10-06 23:58:01 -070049 public <T> T decode(final byte[] bytes);
Yuta HIGUCHIad4c2182014-09-29 11:16:23 -070050
Yuta HIGUCHIf6d11702014-09-30 19:18:59 -070051 /**
Yuta HIGUCHI672488d2014-10-07 09:23:43 -070052 * Deserializes the specified bytes into an object.
Yuta HIGUCHIf6d11702014-09-30 19:18:59 -070053 *
54 * @param buffer bytes to be deserialized
55 * @return deserialized object
Yuta HIGUCHI5c947272014-11-03 21:39:21 -080056 * @param <T> decoded type
Yuta HIGUCHIf6d11702014-09-30 19:18:59 -070057 */
Yuta HIGUCHI53a285d2014-10-06 23:58:01 -070058 public <T> T decode(final ByteBuffer buffer);
Yuta HIGUCHIad4c2182014-09-29 11:16:23 -070059}