Package org.rostore.mapper
Class BinaryMapper
java.lang.Object
org.rostore.mapper.BinaryMapper
A class to serialize and deserialize java classes to the binary stream.
It uses some properties of the rostore, e.g. the binary length of block indexes or block offset.
Depending on the parameters of the storage it can vary.
Use BlockIndex
annotation to mark fields that store the block index,
and BlockOffset
that represents the offset within a block.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> T
deserialize
(MapperProperties mediaProperties, Type type, InputStream inputStream) static <T> T
deserialize
(MapperProperties mapperProperties, Type type, InputStream inputStream, int limit) static int
readLength
(InputStream data) static String
readString
(InputStream data) static <T> void
serialize
(MapperProperties mediaProperties, T object, OutputStream outputStream) static <T> void
serialize
(MapperProperties mediaProperties, T object, Type type, OutputStream outputStream) static void
write
(OutputStream data, String value) static void
writeLength
(OutputStream data, int dataLength)
-
Constructor Details
-
BinaryMapper
public BinaryMapper()
-
-
Method Details
-
write
- Throws:
IOException
-
writeLength
- Throws:
IOException
-
readString
- Throws:
IOException
-
readLength
- Throws:
IOException
-
serialize
public static <T> void serialize(MapperProperties mediaProperties, T object, OutputStream outputStream) -
serialize
public static <T> void serialize(MapperProperties mediaProperties, T object, Type type, OutputStream outputStream) -
deserialize
public static <T> T deserialize(MapperProperties mediaProperties, Type type, InputStream inputStream) -
deserialize
public static <T> T deserialize(MapperProperties mapperProperties, Type type, InputStream inputStream, int limit) - Type Parameters:
T
-- Parameters:
mapperProperties
-type
-inputStream
-limit
- it will stop after deserializing that many fields- Returns:
-