Class Parcel

java.lang.Object
icyllis.modernui.util.Parcel
Direct Known Subclasses:
IOStreamParcel

public class Parcel extends Object
A Parcel is a message container for a sequence of bytes, that performs non-blocking binary I/O on various data objects.

Parcel provides methods for converting arbitrary objects to and from binaries. This is mainly used for in-memory communication between activities, network communication between clients, and inter-process communication. It may not be ideal for persistent storage.

Since:
3.9
See Also:
  • Field Details

    • mNativeBuffer

      protected ByteBuffer mNativeBuffer
  • Constructor Details

    • Parcel

      @Internal public Parcel()
      See Also:
  • Method Details

    • ensureCapacity

      protected void ensureCapacity(int len)
    • setCapacity

      protected void setCapacity(int size)
    • position

      public int position()
    • position

      public void position(int newPosition)
    • limit

      public int limit()
    • limit

      public void limit(int newLimit)
    • capacity

      public int capacity()
    • writeBytes

      public void writeBytes(byte[] src)
    • writeBytes

      public void writeBytes(byte[] src, int off, int len)
    • writeBoolean

      public void writeBoolean(boolean b)
      Write a boolean value into the parcel.
    • writeChar

      public void writeChar(int v)
      Write a char value into the parcel.
    • writeByte

      public void writeByte(int v)
      Write a byte value into the parcel.
    • writeShort

      public void writeShort(int v)
      Write a short integer value into the parcel.
    • writeInt

      public void writeInt(int v)
      Write an integer value into the parcel.
    • writeLong

      public void writeLong(long v)
      Write a long integer value into the parcel.
    • writeFloat

      public void writeFloat(float v)
      Write a floating point value into the parcel.
    • writeDouble

      public void writeDouble(double v)
      Write a double precision floating point value into the parcel.
    • readBytes

      public void readBytes(byte[] dst)
    • readBytes

      public void readBytes(byte[] dst, int off, int len)
    • readBoolean

      public boolean readBoolean()
    • readChar

      public char readChar()
    • readByte

      public byte readByte()
    • readShort

      public short readShort()
    • readInt

      public int readInt()
    • readLong

      public long readLong()
    • readFloat

      public float readFloat()
    • readDouble

      public double readDouble()
    • writeValue

      public void writeValue(@Nullable Object v)
      Write a value and its type.
      Parameters:
      v - the value to write
    • readValue

      @Nullable public <T> T readValue(@Nullable ClassLoader loader, @Nullable Class<T> clazz, @Nullable Class<?> elemType)
    • writeParcelable

      public final void writeParcelable(@Nullable Parcelable p, int parcelableFlags)
      Flatten the name of the class of the Parcelable and its contents into the parcel.
      Parameters:
      p - The Parcelable object to be written.
      parcelableFlags - Contextual flags as per Parcelable.writeToParcel().
    • writeParcelableCreator

      public final void writeParcelableCreator(@NonNull Parcelable p)
      Flatten the name of the class of the Parcelable into this Parcel.
      Parameters:
      p - The Parcelable object to be written.
      See Also:
    • readParcelable

      @Nullable public <T> T readParcelable(@Nullable ClassLoader loader, @NonNull Class<T> clazz)
    • readParcelable0

      @Nullable public <T> T readParcelable0(@Nullable ClassLoader loader, @Nullable Class<T> clazz)
    • readParcelableCreator

      @Nullable public <T> Parcelable.Creator<T> readParcelableCreator(@Nullable ClassLoader loader, @NonNull Class<T> clazz)
    • writeByteArray

      public void writeByteArray(@Nullable byte[] b)
      Write a byte array.
      Parameters:
      b - the bytes to write
    • writeByteArray

      public void writeByteArray(@Nullable byte[] b, int off, int len)
      Write a byte array.
      Parameters:
      b - the bytes to write
    • readByteArray

      @Nullable public byte[] readByteArray()
    • writeShortArray

      public void writeShortArray(@Nullable short[] value)
      Write a short array.
      Parameters:
      value - the short array to write
    • readShortArray

      @Nullable public short[] readShortArray()
    • writeIntArray

      public void writeIntArray(@Nullable int[] value)
      Write an int array.
      Parameters:
      value - the int array to write
    • readIntArray

      @Nullable public int[] readIntArray()
    • writeLongArray

      public void writeLongArray(@Nullable long[] value)
      Write a long array.
      Parameters:
      value - the long array to write
    • readLongArray

      @Nullable public long[] readLongArray()
    • writeFloatArray

      public void writeFloatArray(@Nullable float[] value)
      Write a float array.
      Parameters:
      value - the float array to write
    • readFloatArray

      @Nullable public float[] readFloatArray()
    • writeDoubleArray

      public void writeDoubleArray(@Nullable double[] value)
      Write a double array.
      Parameters:
      value - the double array to write
    • readDoubleArray

      @Nullable public double[] readDoubleArray()
    • writeBooleanArray

      public void writeBooleanArray(@Nullable boolean[] value)
      Write a boolean array.
      Parameters:
      value - the boolean array to write
    • readBooleanArray

      @Nullable public boolean[] readBooleanArray()
    • writeCharArray

      public void writeCharArray(@Nullable char[] value)
      Write a char array.
      Parameters:
      value - the char array to write
    • readCharArray

      @Nullable public char[] readCharArray()
    • writeArray

      public void writeArray(@Nullable Object[] a)
      Write an object array.
      Parameters:
      a - the object array to write
    • readArray

      @Nullable public <T> T[] readArray(@Nullable ClassLoader loader, @NonNull Class<T> clazz)
      Read an object array.
    • writeString

      public void writeString(@Nullable String s)
      Write a string.
      Parameters:
      s - the string to write
    • writeString8

      public void writeString8(@Nullable String s)
      Write a string in UTF-8 format.
      Parameters:
      s - the string to write
    • writeString16

      public void writeString16(@Nullable String s)
      Write a string in UTF-16 format.
      Parameters:
      s - the string to write
    • readString

      @Nullable public String readString()
      Read a string.
    • readString8

      @Nullable public String readString8()
      Read a string in UTF-8 format.
    • readString16

      @Nullable public String readString16()
      Read a string in UTF-16 format.
    • writeCharSequence

      public void writeCharSequence(@Nullable CharSequence cs)
      Write a CharSequence value into the parcel. May be Spanned.
    • readCharSequence

      @Nullable public CharSequence readCharSequence()
      Read a CharSequence value from the parcel. May be Spanned.
    • writeList

      public void writeList(@Nullable List<?> list)
      Write a list.
      Parameters:
      list - the list to write
    • writeDataSet

      public void writeDataSet(@Nullable DataSet source)
      Write a data set.
      Parameters:
      source - the data set to write
    • readDataSet

      @Nullable public DataSet readDataSet(@Nullable ClassLoader loader)
      Read a data set as a value.
      Parameters:
      loader - the class loader for Parcelable classes
      Returns:
      the newly created data set
    • writeUUID

      public void writeUUID(@NonNull UUID value)
      Write UUID as a value.
    • readUUID

      @NonNull public UUID readUUID()
      Read UUID as a value.
    • writeInstant

      public void writeInstant(@NonNull Instant value)
      Write Instant as a value.
    • readInstant

      @NonNull public Instant readInstant()
      Read Instant as a value.
    • freeData

      @Internal public void freeData()