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
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
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
boolean[]
byte
readByte()
byte[]
void
readBytes
(byte[] dst) void
readBytes
(byte[] dst, int off, int len) char
readChar()
char[]
Read a CharSequence value from the parcel.readDataSet
(ClassLoader loader) Read a data set as a value.double
double[]
float
float[]
Read Instant as a value.int
readInt()
int[]
long
readLong()
long[]
<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
short[]
Read a string.Read a string in UTF-16 format.Read a string in UTF-8 format.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
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
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
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
Write a string.void
Write a string in UTF-16 format.void
Write a string in UTF-8 format.void
Write UUID as a value.void
writeValue
(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 forParcelable
classes- 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()
-