Package icyllis.modernui.util
Class Parcel
java.lang.Object
icyllis.modernui.util.Parcel
- Direct Known Subclasses:
IOStreamParcel
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 Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintcapacity()protected voidensureCapacity(int len) voidfreeData()intlimit()voidlimit(int newLimit) intposition()voidposition(int newPosition) <T> T[]readArray(ClassLoader loader, Class<T> clazz) Read an object array.booleanboolean[]bytereadByte()byte[]voidreadBytes(byte[] dst) voidreadBytes(byte[] dst, int off, int len) charreadChar()char[]Read a CharSequence value from the parcel.readDataSet(ClassLoader loader) Read a data set as a value.doubledouble[]floatfloat[]Read Instant as a value.intreadInt()int[]longreadLong()long[]<T> TreadParcelable(ClassLoader loader, Class<T> clazz) <T> TreadParcelable0(ClassLoader loader, Class<T> clazz) <T> Parcelable.Creator<T> readParcelableCreator(ClassLoader loader, Class<T> clazz) shortshort[]Read a string.Read a string in UTF-16 format.Read a string in UTF-8 format.readUUID()Read UUID as a value.<T> TreadValue(ClassLoader loader, Class<T> clazz, Class<?> elemType) protected voidsetCapacity(int size) voidwriteArray(Object[] a) Write an object array.voidwriteBoolean(boolean b) Write a boolean value into the parcel.voidwriteBooleanArray(boolean[] value) Write a boolean array.voidwriteByte(int v) Write a byte value into the parcel.voidwriteByteArray(byte[] b) Write a byte array.voidwriteByteArray(byte[] b, int off, int len) Write a byte array.voidwriteBytes(byte[] src) voidwriteBytes(byte[] src, int off, int len) voidwriteChar(int v) Write a char value into the parcel.voidwriteCharArray(char[] value) Write a char array.voidWrite a CharSequence value into the parcel.voidwriteDataSet(DataSet source) Write a data set.voidwriteDouble(double v) Write a double precision floating point value into the parcel.voidwriteDoubleArray(double[] value) Write a double array.voidwriteFloat(float v) Write a floating point value into the parcel.voidwriteFloatArray(float[] value) Write a float array.voidwriteInstant(Instant value) Write Instant as a value.voidwriteInt(int v) Write an integer value into the parcel.voidwriteIntArray(int[] value) Write an int array.voidWrite a list.voidwriteLong(long v) Write a long integer value into the parcel.voidwriteLongArray(long[] value) Write a long array.final voidwriteParcelable(Parcelable p, int parcelableFlags) Flatten the name of the class of the Parcelable and its contents into the parcel.final voidFlatten the name of the class of the Parcelable into this Parcel.voidwriteShort(int v) Write a short integer value into the parcel.voidwriteShortArray(short[] value) Write a short array.voidWrite a string.voidWrite a string in UTF-16 format.voidWrite a string in UTF-8 format.voidWrite UUID as a value.voidwriteValue(Object v) Write a value and its type.
-
Field Details
-
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
Write a value and its type.- Parameters:
v- the value to write
-
readValue
-
writeParcelable
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 perParcelable.writeToParcel().
-
writeParcelableCreator
Flatten the name of the class of the Parcelable into this Parcel.- Parameters:
p- The Parcelable object to be written.- See Also:
-
readParcelable
-
readParcelable0
-
readParcelableCreator
@Nullable public <T> Parcelable.Creator<T> readParcelableCreator(@Nullable ClassLoader loader, @NonNull Class<T> clazz) -
writeByteArray
Write a byte array.- Parameters:
b- the bytes to write
-
writeByteArray
Write a byte array.- Parameters:
b- the bytes to write
-
readByteArray
-
writeShortArray
Write a short array.- Parameters:
value- the short array to write
-
readShortArray
-
writeIntArray
Write an int array.- Parameters:
value- the int array to write
-
readIntArray
-
writeLongArray
Write a long array.- Parameters:
value- the long array to write
-
readLongArray
-
writeFloatArray
Write a float array.- Parameters:
value- the float array to write
-
readFloatArray
-
writeDoubleArray
Write a double array.- Parameters:
value- the double array to write
-
readDoubleArray
-
writeBooleanArray
Write a boolean array.- Parameters:
value- the boolean array to write
-
readBooleanArray
-
writeCharArray
Write a char array.- Parameters:
value- the char array to write
-
readCharArray
-
writeArray
Write an object array.- Parameters:
a- the object array to write
-
readArray
Read an object array. -
writeString
Write a string.- Parameters:
s- the string to write
-
writeString8
Write a string in UTF-8 format.- Parameters:
s- the string to write
-
writeString16
Write a string in UTF-16 format.- Parameters:
s- the string to write
-
readString
Read a string. -
readString8
Read a string in UTF-8 format. -
readString16
Read a string in UTF-16 format. -
writeCharSequence
Write a CharSequence value into the parcel. May be Spanned. -
readCharSequence
Read a CharSequence value from the parcel. May be Spanned. -
writeList
Write a list.- Parameters:
list- the list to write
-
writeDataSet
Write a data set.- Parameters:
source- the data set to write
-
readDataSet
Read a data set as a value.- Parameters:
loader- the class loader forParcelableclasses- Returns:
- the newly created data set
-
writeUUID
Write UUID as a value. -
readUUID
Read UUID as a value. -
writeInstant
Write Instant as a value. -
readInstant
Read Instant as a value. -
freeData
@Internal public void freeData()
-