Commit e067c94a authored by Andre Freyssinet's avatar Andre Freyssinet
Browse files

Code cleaning.

parent 744d1a28
/*
* Copyright (C) 2013 ScalAgent Distributed Technologies
* Copyright (C) 2013 - 2022 ScalAgent Distributed Technologies
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -27,14 +27,10 @@ import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import fr.dyade.aaa.common.encoding.Decoder;
import fr.dyade.aaa.common.encoding.Encodable;
import fr.dyade.aaa.common.encoding.Encoder;
/**
* Encodable object that wraps a serializable object.
*/
public class SerializableWrapper implements Encodable {
public final class SerializableWrapper implements Encodable {
private Serializable value;
......@@ -43,7 +39,6 @@ public class SerializableWrapper implements Encodable {
public SerializableWrapper() {}
public SerializableWrapper(Serializable value) {
super();
this.value = value;
}
......@@ -51,13 +46,15 @@ public class SerializableWrapper implements Encodable {
return value;
}
@Override
public int getEncodableClassId() {
return EncodableFactoryRepository.SERIALIZABLE_WRAPPER_CLASS_ID;
}
@Override
public int getEncodedSize() throws Exception {
serialize();
return bytes.length + 4;
return Encodable.INT_ENCODED_SIZE + bytes.length;
}
private void serialize() throws Exception {
......@@ -74,11 +71,13 @@ public class SerializableWrapper implements Encodable {
}
}
@Override
public void encode(Encoder encoder) throws Exception {
serialize();
encoder.encodeByteArray(bytes);
}
@Override
public void decode(Decoder decoder) throws Exception {
byte[] bytes = decoder.decodeByteArray();
ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
......@@ -87,11 +86,8 @@ public class SerializableWrapper implements Encodable {
}
public static class Factory implements EncodableFactory {
public Encodable createEncodable() {
return new SerializableWrapper();
}
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment