Package icyllis.modernui.util

# 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:
  - `Parcelable`

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected ByteBuffer`
  `mNativeBuffer`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Parcel()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `int`
  `capacity()`
  `protected void`
  `ensureCapacity(int len)`
  `void`
  `freeData()`
  `int`
  `limit()`
  `void`
  `limit(int newLimit)`
  `int`
  `position()`
  `void`
  `position(int newPosition)`
  `<T> T[]`
  `readArray(ClassLoader loader, Class<T> clazz)`
  Read an object array.
  `boolean`
  `readBoolean()`
  `boolean[]`
  `readBooleanArray()`
  `byte`
  `readByte()`
  `byte[]`
  `readByteArray()`
  `void`
  `readBytes(byte[] dst)`
  `void`
  `readBytes(byte[] dst, int off, int len)`
  `char`
  `readChar()`
  `char[]`
  `readCharArray()`
  `CharSequence`
  `readCharSequence()`
  Read a CharSequence value from the parcel.
  `DataSet`
  `readDataSet(ClassLoader loader)`
  Read a data set as a value.
  `double`
  `readDouble()`
  `double[]`
  `readDoubleArray()`
  `float`
  `readFloat()`
  `float[]`
  `readFloatArray()`
  `Instant`
  `readInstant()`
  Read Instant as a value.
  `int`
  `readInt()`
  `int[]`
  `readIntArray()`
  `long`
  `readLong()`
  `long[]`
  `readLongArray()`
  `<T> T`
  `readParcelable(ClassLoader loader, Class<T> clazz)`
  `<T> T`
  `readParcelable0(ClassLoader loader, Class<T> clazz)`
  `<T> Parcelable.Creator<T>`
  `readParcelableCreator(ClassLoader loader, Class<T> clazz)`
  `short`
  `readShort()`
  `short[]`
  `readShortArray()`
  `String`
  `readString()`
  Read a string.
  `String`
  `readString16()`
  Read a string in UTF-16 format.
  `String`
  `readString8()`
  Read a string in UTF-8 format.
  `UUID`
  `readUUID()`
  Read UUID as a value.
  `<T> T`
  `readValue(ClassLoader loader, Class<T> clazz, Class<?> elemType)`
  `protected void`
  `setCapacity(int size)`
  `void`
  `writeArray(Object[] a)`
  Write an object array.
  `void`
  `writeBoolean(boolean b)`
  Write a boolean value into the parcel.
  `void`
  `writeBooleanArray(boolean[] value)`
  Write a boolean array.
  `void`
  `writeByte(int v)`
  Write a byte value into the parcel.
  `void`
  `writeByteArray(byte[] b)`
  Write a byte array.
  `void`
  `writeByteArray(byte[] b, int off, int len)`
  Write a byte array.
  `void`
  `writeBytes(byte[] src)`
  `void`
  `writeBytes(byte[] src, int off, int len)`
  `void`
  `writeChar(int v)`
  Write a char value into the parcel.
  `void`
  `writeCharArray(char[] value)`
  Write a char array.
  `void`
  `writeCharSequence(CharSequence cs)`
  Write a CharSequence value into the parcel.
  `void`
  `writeDataSet(DataSet source)`
  Write a data set.
  `void`
  `writeDouble(double v)`
  Write a double precision floating point value into the parcel.
  `void`
  `writeDoubleArray(double[] value)`
  Write a double array.
  `void`
  `writeFloat(float v)`
  Write a floating point value into the parcel.
  `void`
  `writeFloatArray(float[] value)`
  Write a float array.
  `void`
  `writeInstant(Instant value)`
  Write Instant as a value.
  `void`
  `writeInt(int v)`
  Write an integer value into the parcel.
  `void`
  `writeIntArray(int[] value)`
  Write an int array.
  `void`
  `writeList(List<?> list)`
  Write a list.
  `void`
  `writeLong(long v)`
  Write a long integer value into the parcel.
  `void`
  `writeLongArray(long[] value)`
  Write a long array.
  `final void`
  `writeParcelable(Parcelable p, int parcelableFlags)`
  Flatten the name of the class of the Parcelable and its contents into the parcel.
  `final void`
  `writeParcelableCreator(Parcelable p)`
  Flatten the name of the class of the Parcelable into this Parcel.
  `void`
  `writeShort(int v)`
  Write a short integer value into the parcel.
  `void`
  `writeShortArray(short[] value)`
  Write a short array.
  `void`
  `writeString(String s)`
  Write a string.
  `void`
  `writeString16(String s)`
  Write a string in UTF-16 format.
  `void`
  `writeString8(String s)`
  Write a string in UTF-8 format.
  `void`
  `writeUUID(UUID value)`
  Write UUID as a value.
  `void`
  `writeValue(Object v)`
  Write a value and its type.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### mNativeBuffer

    protected ByteBuffer mNativeBuffer

- ## Constructor Details

  - ### Parcel

    @Internal public Parcel()
    See Also:
      - `freeData()`

- ## 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:
      - `readParcelableCreator(java.lang.ClassLoader, java.lang.Class<T>)`

  - ### 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()