Package me.saro.commons.bytes
Class FixedDataFormat<T>
- java.lang.Object
-
- me.saro.commons.bytes.FixedDataFormat<T>
-
public class FixedDataFormat<T> extends java.lang.ObjectDataFormat- Since:
- 1.0
- Author:
- PARK Yong Seo
-
-
Method Summary
Modifier and Type Method Description voidbindBytes(byte[] outputBytes, int offset, T obj)to bytes and bind byte[]voidbindBytes(java.io.OutputStream out, T obj)to bytes and bind OutputStreamstatic <T> FixedDataFormat<T>create(java.lang.Class<T> clazz)create DataFormat
user defualt constructorstatic <T> FixedDataFormat<T>create(java.lang.Class<T> clazz, java.util.function.Supplier<T> newInstance)create DataFormatprotected java.util.Optional<java.lang.reflect.Method>getter(java.lang.Class<?> clazz, java.lang.String fieldName, boolean ignoreNotFound)getterprotected java.util.Optional<java.lang.reflect.Method>setter(java.lang.Class<?> clazz, java.lang.String fieldName, boolean ignoreNotFound)setterbyte[]toBytes(T obj)to bytesTtoClass(byte[] bytes)TtoClass(byte[] bytes, int offset)TtoClassWithCheckSize(byte[] bytes)TtoClassWithCheckSize(java.lang.String line)TtoClassWithCheckSize(java.lang.String line, java.lang.String charset)
-
-
-
Method Detail
-
create
public static <T> FixedDataFormat<T> create(java.lang.Class<T> clazz, java.util.function.Supplier<T> newInstance)
create DataFormat- Parameters:
clazz-newInstance-- Returns:
-
create
public static <T> FixedDataFormat<T> create(java.lang.Class<T> clazz)
create DataFormat
user defualt constructor- Parameters:
clazz-- Returns:
-
toClass
public T toClass(byte[] bytes, int offset)
-
toClass
public T toClass(byte[] bytes)
-
toClassWithCheckSize
public T toClassWithCheckSize(byte[] bytes)
- Parameters:
bytes-- Returns:
-
toClassWithCheckSize
public T toClassWithCheckSize(java.lang.String line)
- Parameters:
line-- Returns:
-
toClassWithCheckSize
public T toClassWithCheckSize(java.lang.String line, java.lang.String charset)
-
bindBytes
public void bindBytes(byte[] outputBytes, int offset, T obj)to bytes and bind byte[]- Parameters:
outputBytes-offset-obj-
-
bindBytes
public void bindBytes(java.io.OutputStream out, T obj) throws java.io.IOExceptionto bytes and bind OutputStream- Parameters:
out-obj-- Throws:
java.io.IOException
-
toBytes
public byte[] toBytes(T obj)
to bytes- Parameters:
obj-- Returns:
-
getter
protected java.util.Optional<java.lang.reflect.Method> getter(java.lang.Class<?> clazz, java.lang.String fieldName, boolean ignoreNotFound)getter- Parameters:
clazz-fieldName-- Returns:
-
setter
protected java.util.Optional<java.lang.reflect.Method> setter(java.lang.Class<?> clazz, java.lang.String fieldName, boolean ignoreNotFound)setter- Parameters:
clazz-fieldName-- Returns:
-
-