程序包 io.packable
类 PackDecoder
java.lang.Object
io.packable.PackDecoder
PackDecoder
作用:将byte数组解码为目标对象。
如果要解码的数组是不完整的或者被损坏的,则解码过程可能会抛出异常,
所以解码时最好留意数据源的可靠性,如果数据源不可靠,请注意 catch 异常。
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明booleancontains(int index) static <T> Tdecode(byte[] bytes, int offset, int len, TypeAdapter<T> adapter) static <T> Tdecode(byte[] bytes, TypeAdapter<T> adapter) static int[]decodeIntArray(byte[] bytes) static long[]decodeLongArray(byte[] bytes) static <T> List<T>decodeObjectList(byte[] bytes, TypeAdapter<T> adapter) decodeStringList(byte[] bytes) booleangetBoolean(int index) booleangetBoolean(int index, boolean defValue) boolean[]getBooleanArray(int index) bytegetByte(int index) bytegetByte(int index, byte defValue) byte[]getByteArray(int index) doublegetDouble(int index) doublegetDouble(int index, double defValue) double[]getDoubleArray(int index) getDoubleList(int index) floatgetFloat(int index) floatgetFloat(int index, float defValue) float[]getFloatArray(int index) getFloatList(int index) intgetInt(int index) intgetInt(int index, int defValue) int[]getIntArray(int index) getIntList(int index) longgetLong(int index) longgetLong(int index, long defValue) long[]getLongArray(int index) getLongList(int index) <K,V> Map<K, V> getMap 不能像putMap那样根据map中的元素获取类型,所以只能手动传入了。<K,V> Map<K, V> getMap(int index, Class<K> keyType, Class<V> valueType, TypeAdapter<K> keyTypeAdapter, TypeAdapter<V> valueTypeAdapter) getNotNullString(int index) <T> TgetObject(int index, TypeAdapter<T> adapter) <T> TgetObject(int index, TypeAdapter<T> adapter, T defValue) <T> T[]getObjectArray(int index, TypeAdapter<T> adapter, T[] array) 获取对象数组<T> List<T>getObjectList(int index, TypeAdapter<T> adapter) shortgetShort(int index) shortgetShort(int index, short defValue) getString(int index) String[]getStringArray(int index) getStringList(int index)
-
构造器详细资料
-
PackDecoder
public PackDecoder(byte[] bytes) -
PackDecoder
public PackDecoder(byte[] bytes, int offset, int len)
-
-
方法详细资料
-
decode
-
decode
-
decodeIntArray
public static int[] decodeIntArray(byte[] bytes) -
decodeLongArray
public static long[] decodeLongArray(byte[] bytes) -
decodeStringList
-
decodeObjectList
-
contains
public boolean contains(int index) -
getBoolean
public boolean getBoolean(int index, boolean defValue) -
getBoolean
public boolean getBoolean(int index) -
getByte
public byte getByte(int index, byte defValue) -
getByte
public byte getByte(int index) -
getShort
public short getShort(int index, short defValue) -
getShort
public short getShort(int index) -
getInt
public int getInt(int index, int defValue) -
getInt
public int getInt(int index) -
getLong
public long getLong(int index, long defValue) -
getLong
public long getLong(int index) -
getFloat
public float getFloat(int index, float defValue) -
getFloat
public float getFloat(int index) -
getDouble
public double getDouble(int index, double defValue) -
getDouble
public double getDouble(int index) -
getString
-
getNotNullString
-
getString
-
getObject
-
getObject
-
getBooleanArray
public boolean[] getBooleanArray(int index) -
getByteArray
public byte[] getByteArray(int index) -
getIntArray
public int[] getIntArray(int index) -
getLongArray
public long[] getLongArray(int index) -
getFloatArray
public float[] getFloatArray(int index) -
getDoubleArray
public double[] getDoubleArray(int index) -
getStringArray
-
getObjectArray
获取对象数组- 类型参数:
T- 类型- 参数:
index- 编哈adapter- 解码器array- 可以传一个空数组。 因为 List 转 Array 需要类型信息, 而List本身被擦除了范型,所以需要传一个数组来构建Array。- 返回:
- 对象数组
-
getIntList
-
getLongList
-
getFloatList
-
getDoubleList
-
getObjectList
-
getStringList
-
getMap
getMap 不能像putMap那样根据map中的元素获取类型,所以只能手动传入了。- 类型参数:
K- key范型V- value范型- 参数:
index- 下标keyType- key类型valueType- value类型- 返回:
- Map对象
-
getMap
public <K,V> Map<K,V> getMap(int index, Class<K> keyType, Class<V> valueType, TypeAdapter<K> keyTypeAdapter, TypeAdapter<V> valueTypeAdapter)
-