程序包 io.packable

类 PackDecoder

java.lang.Object
io.packable.PackDecoder

public final class PackDecoder extends Object
PackDecoder 作用:将byte数组解码为目标对象。 如果要解码的数组是不完整的或者被损坏的,则解码过程可能会抛出异常, 所以解码时最好留意数据源的可靠性,如果数据源不可靠,请注意 catch 异常。
  • 构造器详细资料

    • PackDecoder

      public PackDecoder(byte[] bytes)
    • PackDecoder

      public PackDecoder(byte[] bytes, int offset, int len)
  • 方法详细资料

    • decode

      public static <T> T decode(byte[] bytes, TypeAdapter<T> adapter)
    • decode

      public static <T> T decode(byte[] bytes, int offset, int len, TypeAdapter<T> adapter)
    • decodeIntArray

      public static int[] decodeIntArray(byte[] bytes)
    • decodeLongArray

      public static long[] decodeLongArray(byte[] bytes)
    • decodeStringList

      public static List<String> decodeStringList(byte[] bytes)
    • decodeObjectList

      public static <T> List<T> decodeObjectList(byte[] bytes, TypeAdapter<T> adapter)
    • 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

      public String getString(int index, String defValue)
    • getNotNullString

      public String getNotNullString(int index)
    • getString

      public String getString(int index)
    • getObject

      public <T> T getObject(int index, TypeAdapter<T> adapter)
    • getObject

      public <T> T getObject(int index, TypeAdapter<T> adapter, T defValue)
    • 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

      public String[] getStringArray(int index)
    • getObjectArray

      public <T> T[] getObjectArray(int index, TypeAdapter<T> adapter, T[] array)
      获取对象数组
      类型参数:
      T - 类型
      参数:
      index - 编哈
      adapter - 解码器
      array - 可以传一个空数组。 因为 List 转 Array 需要类型信息, 而List本身被擦除了范型,所以需要传一个数组来构建Array。
      返回:
      对象数组
    • getIntList

      public List<Integer> getIntList(int index)
    • getLongList

      public List<Long> getLongList(int index)
    • getFloatList

      public List<Float> getFloatList(int index)
    • getDoubleList

      public List<Double> getDoubleList(int index)
    • getObjectList

      public <T> List<T> getObjectList(int index, TypeAdapter<T> adapter)
    • getStringList

      public List<String> getStringList(int index)
    • getMap

      public <K, V> Map<K,V> getMap(int index, Class<K> keyType, Class<V> valueType)
      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)