Class ParsableByteArray
- java.lang.Object
-
- com.google.android.exoplayer2.util.ParsableByteArray
-
@Deprecated public final class ParsableByteArray extends Object
Deprecated.com.google.android.exoplayer2 is deprecated. Please migrate to androidx.media3 (which contains the same ExoPlayer code). See the migration guide for more details, including a script to help with the migration.Wraps a byte array, providing a set of methods for parsing data from it. Numerical values are parsed with the assumption that their constituent bytes are in big endian order.
-
-
Constructor Summary
Constructors Constructor Description ParsableByteArray()Deprecated.Creates a new instance that initially has no backing data.ParsableByteArray(byte[] data)Deprecated.Creates a new instance wrappingdata, and sets the limit todata.length.ParsableByteArray(byte[] data, int limit)Deprecated.Creates a new instance that wraps an existing array.ParsableByteArray(int limit)Deprecated.Creates a new instance withlimitbytes and sets the limit.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description intbytesLeft()Deprecated.Returns the number of bytes yet to be read.intcapacity()Deprecated.Returns the capacity of the array, which may be larger than the limit.voidensureCapacity(int requiredCapacity)Deprecated.Ensures the backing array is at leastrequiredCapacitylong.byte[]getData()Deprecated.Returns the underlying array.intgetPosition()Deprecated.Returns the current offset in the array, in bytes.intlimit()Deprecated.Returns the limit.charpeekChar()Deprecated.Peeks at the next char.charpeekChar(Charset charset)Deprecated.Peeks at the next char (as decoded bycharset)intpeekUnsignedByte()Deprecated.Peeks at the next byte as an unsigned value.voidreadBytes(byte[] buffer, int offset, int length)Deprecated.Reads the nextlengthbytes intobufferatoffset.voidreadBytes(ParsableBitArray bitArray, int length)Deprecated.Reads the nextlengthbytes intobitArray, and resets the position ofbitArrayto zero.voidreadBytes(ByteBuffer buffer, int length)Deprecated.Reads the nextlengthbytes intobuffer.StringreadDelimiterTerminatedString(char delimiter)Deprecated.Reads up to the next delimiter byte (or the limit) as UTF-8 characters.doublereadDouble()Deprecated.Reads the next eight bytes as a 64-bit floating point value.floatreadFloat()Deprecated.Reads the next four bytes as a 32-bit floating point value.intreadInt()Deprecated.Reads the next four bytes as a signed valueintreadInt24()Deprecated.Reads the next three bytes as a signed value.StringreadLine()Deprecated.Reads a line of text in UTF-8.StringreadLine(Charset charset)Deprecated.Reads a line of text incharset.intreadLittleEndianInt()Deprecated.Reads the next four bytes as a signed value in little endian order.intreadLittleEndianInt24()Deprecated.Reads the next three bytes as a signed value in little endian order.longreadLittleEndianLong()Deprecated.Reads the next eight bytes as a signed value in little endian order.shortreadLittleEndianShort()Deprecated.Reads the next two bytes as a signed value.longreadLittleEndianUnsignedInt()Deprecated.Reads the next four bytes as an unsigned value in little endian order.intreadLittleEndianUnsignedInt24()Deprecated.Reads the next three bytes as an unsigned value in little endian order.intreadLittleEndianUnsignedIntToInt()Deprecated.Reads the next four bytes as a little endian unsigned integer into an integer, if the top bit is a zero.intreadLittleEndianUnsignedShort()Deprecated.Reads the next two bytes as an unsigned value.longreadLong()Deprecated.Reads the next eight bytes as a signed value.StringreadNullTerminatedString()Deprecated.Reads up to the next NUL byte (or the limit) as UTF-8 characters.StringreadNullTerminatedString(int length)Deprecated.Reads the nextlengthbytes as UTF-8 characters.shortreadShort()Deprecated.Reads the next two bytes as a signed value.StringreadString(int length)Deprecated.Reads the nextlengthbytes as UTF-8 characters.StringreadString(int length, Charset charset)Deprecated.Reads the nextlengthbytes as characters in the specifiedCharset.intreadSynchSafeInt()Deprecated.Reads a Synchsafe integer.intreadUnsignedByte()Deprecated.Reads the next byte as an unsigned value.intreadUnsignedFixedPoint1616()Deprecated.Reads the next four bytes, returning the integer portion of the fixed point 16.16 integer.longreadUnsignedInt()Deprecated.Reads the next four bytes as an unsigned value.intreadUnsignedInt24()Deprecated.Reads the next three bytes as an unsigned value.intreadUnsignedIntToInt()Deprecated.Reads the next four bytes as an unsigned integer into an integer, if the top bit is a zero.longreadUnsignedLongToLong()Deprecated.Reads the next eight bytes as an unsigned long into a long, if the top bit is a zero.intreadUnsignedShort()Deprecated.Reads the next two bytes as an unsigned value.longreadUtf8EncodedLong()Deprecated.Reads a long value encoded by UTF-8 encodingCharsetreadUtfCharsetFromBom()Deprecated.Reads a UTF byte order mark (BOM) and returns the UTFCharsetit represents.voidreset(byte[] data)Deprecated.Updates the instance to wrapdata, and resets the position to zero and the limit todata.length.voidreset(byte[] data, int limit)Deprecated.Updates the instance to wrapdata, and resets the position to zero.voidreset(int limit)Deprecated.Resets the position to zero and the limit to the specified value.voidsetLimit(int limit)Deprecated.Sets the limit.voidsetPosition(int position)Deprecated.Sets the reading offset in the array.voidskipBytes(int bytes)Deprecated.Moves the reading offset bybytes.
-
-
-
Constructor Detail
-
ParsableByteArray
public ParsableByteArray()
Deprecated.Creates a new instance that initially has no backing data.
-
ParsableByteArray
public ParsableByteArray(int limit)
Deprecated.Creates a new instance withlimitbytes and sets the limit.- Parameters:
limit- The limit to set.
-
ParsableByteArray
public ParsableByteArray(byte[] data)
Deprecated.Creates a new instance wrappingdata, and sets the limit todata.length.- Parameters:
data- The array to wrap.
-
ParsableByteArray
public ParsableByteArray(byte[] data, int limit)Deprecated.Creates a new instance that wraps an existing array.- Parameters:
data- The data to wrap.limit- The limit to set.
-
-
Method Detail
-
reset
public void reset(int limit)
Deprecated.Resets the position to zero and the limit to the specified value. This might replace or wipe theunderlying array, potentially invalidating any local references.- Parameters:
limit- The limit to set.
-
reset
public void reset(byte[] data)
Deprecated.Updates the instance to wrapdata, and resets the position to zero and the limit todata.length.- Parameters:
data- The array to wrap.
-
reset
public void reset(byte[] data, int limit)Deprecated.Updates the instance to wrapdata, and resets the position to zero.- Parameters:
data- The array to wrap.limit- The limit to set.
-
ensureCapacity
public void ensureCapacity(int requiredCapacity)
Deprecated.Ensures the backing array is at leastrequiredCapacitylong.position,limit, and all data in the underlying array (including that beyondlimit()) are preserved.This might replace or wipe the
underlying array, potentially invalidating any local references.
-
bytesLeft
public int bytesLeft()
Deprecated.Returns the number of bytes yet to be read.
-
limit
public int limit()
Deprecated.Returns the limit.
-
setLimit
public void setLimit(int limit)
Deprecated.Sets the limit.- Parameters:
limit- The limit to set.
-
getPosition
public int getPosition()
Deprecated.Returns the current offset in the array, in bytes.
-
setPosition
public void setPosition(int position)
Deprecated.Sets the reading offset in the array.- Parameters:
position- Byte offset in the array from which to read.- Throws:
IllegalArgumentException- Thrown if the new position is neither in nor at the end of the array.
-
getData
public byte[] getData()
Deprecated.Returns the underlying array.Changes to this array are reflected in the results of the
read...()methods.This reference must be assumed to become invalid when
reset(int)orensureCapacity(int)are called (because the array might get reallocated).
-
capacity
public int capacity()
Deprecated.Returns the capacity of the array, which may be larger than the limit.
-
skipBytes
public void skipBytes(int bytes)
Deprecated.Moves the reading offset bybytes.- Parameters:
bytes- The number of bytes to skip.- Throws:
IllegalArgumentException- Thrown if the new position is neither in nor at the end of the array.
-
readBytes
public void readBytes(ParsableBitArray bitArray, int length)
Deprecated.Reads the nextlengthbytes intobitArray, and resets the position ofbitArrayto zero.- Parameters:
bitArray- TheParsableBitArrayinto which the bytes should be read.length- The number of bytes to write.
-
readBytes
public void readBytes(byte[] buffer, int offset, int length)Deprecated.Reads the nextlengthbytes intobufferatoffset.- Parameters:
buffer- The array into which the read data should be written.offset- The offset inbufferat which the read data should be written.length- The number of bytes to read.- See Also:
System.arraycopy(Object, int, Object, int, int)
-
readBytes
public void readBytes(ByteBuffer buffer, int length)
Deprecated.Reads the nextlengthbytes intobuffer.- Parameters:
buffer- TheByteBufferinto which the read data should be written.length- The number of bytes to read.- See Also:
ByteBuffer.put(byte[], int, int)
-
peekUnsignedByte
public int peekUnsignedByte()
Deprecated.Peeks at the next byte as an unsigned value.
-
peekChar
public char peekChar()
Deprecated.Peeks at the next char.Equivalent to passing
Charsets.UTF_16orCharsets.UTF_16BEtopeekChar(Charset).
-
peekChar
public char peekChar(Charset charset)
Deprecated.Peeks at the next char (as decoded bycharset)- Throws:
IllegalArgumentException- if charset is not supported. Only US_ASCII, UTF-8, UTF-16, UTF-16BE, and UTF-16LE are supported.
-
readUnsignedByte
public int readUnsignedByte()
Deprecated.Reads the next byte as an unsigned value.
-
readUnsignedShort
public int readUnsignedShort()
Deprecated.Reads the next two bytes as an unsigned value.
-
readLittleEndianUnsignedShort
public int readLittleEndianUnsignedShort()
Deprecated.Reads the next two bytes as an unsigned value.
-
readShort
public short readShort()
Deprecated.Reads the next two bytes as a signed value.
-
readLittleEndianShort
public short readLittleEndianShort()
Deprecated.Reads the next two bytes as a signed value.
-
readUnsignedInt24
public int readUnsignedInt24()
Deprecated.Reads the next three bytes as an unsigned value.
-
readInt24
public int readInt24()
Deprecated.Reads the next three bytes as a signed value.
-
readLittleEndianInt24
public int readLittleEndianInt24()
Deprecated.Reads the next three bytes as a signed value in little endian order.
-
readLittleEndianUnsignedInt24
public int readLittleEndianUnsignedInt24()
Deprecated.Reads the next three bytes as an unsigned value in little endian order.
-
readUnsignedInt
public long readUnsignedInt()
Deprecated.Reads the next four bytes as an unsigned value.
-
readLittleEndianUnsignedInt
public long readLittleEndianUnsignedInt()
Deprecated.Reads the next four bytes as an unsigned value in little endian order.
-
readInt
public int readInt()
Deprecated.Reads the next four bytes as a signed value
-
readLittleEndianInt
public int readLittleEndianInt()
Deprecated.Reads the next four bytes as a signed value in little endian order.
-
readLong
public long readLong()
Deprecated.Reads the next eight bytes as a signed value.
-
readLittleEndianLong
public long readLittleEndianLong()
Deprecated.Reads the next eight bytes as a signed value in little endian order.
-
readUnsignedFixedPoint1616
public int readUnsignedFixedPoint1616()
Deprecated.Reads the next four bytes, returning the integer portion of the fixed point 16.16 integer.
-
readSynchSafeInt
public int readSynchSafeInt()
Deprecated.Reads a Synchsafe integer.Synchsafe integers keep the highest bit of every byte zeroed. A 32 bit synchsafe integer can store 28 bits of information.
- Returns:
- The parsed value.
-
readUnsignedIntToInt
public int readUnsignedIntToInt()
Deprecated.Reads the next four bytes as an unsigned integer into an integer, if the top bit is a zero.- Throws:
IllegalStateException- Thrown if the top bit of the input data is set.
-
readLittleEndianUnsignedIntToInt
public int readLittleEndianUnsignedIntToInt()
Deprecated.Reads the next four bytes as a little endian unsigned integer into an integer, if the top bit is a zero.- Throws:
IllegalStateException- Thrown if the top bit of the input data is set.
-
readUnsignedLongToLong
public long readUnsignedLongToLong()
Deprecated.Reads the next eight bytes as an unsigned long into a long, if the top bit is a zero.- Throws:
IllegalStateException- Thrown if the top bit of the input data is set.
-
readFloat
public float readFloat()
Deprecated.Reads the next four bytes as a 32-bit floating point value.
-
readDouble
public double readDouble()
Deprecated.Reads the next eight bytes as a 64-bit floating point value.
-
readString
public String readString(int length)
Deprecated.Reads the nextlengthbytes as UTF-8 characters.- Parameters:
length- The number of bytes to read.- Returns:
- The string encoded by the bytes.
-
readString
public String readString(int length, Charset charset)
Deprecated.Reads the nextlengthbytes as characters in the specifiedCharset.- Parameters:
length- The number of bytes to read.charset- The character set of the encoded characters.- Returns:
- The string encoded by the bytes in the specified character set.
-
readNullTerminatedString
public String readNullTerminatedString(int length)
Deprecated.Reads the nextlengthbytes as UTF-8 characters. A terminating NUL byte is discarded, if present.- Parameters:
length- The number of bytes to read.- Returns:
- The string, not including any terminating NUL byte.
-
readNullTerminatedString
@Nullable public String readNullTerminatedString()
Deprecated.Reads up to the next NUL byte (or the limit) as UTF-8 characters.- Returns:
- The string not including any terminating NUL byte, or null if the end of the data has already been reached.
-
readDelimiterTerminatedString
@Nullable public String readDelimiterTerminatedString(char delimiter)
Deprecated.Reads up to the next delimiter byte (or the limit) as UTF-8 characters.- Returns:
- The string not including any terminating delimiter byte, or null if the end of the data has already been reached.
-
readLine
@Nullable public String readLine()
Deprecated.Reads a line of text in UTF-8.Equivalent to passing
Charsets.UTF_8toreadLine(Charset).
-
readLine
@Nullable public String readLine(Charset charset)
Deprecated.Reads a line of text incharset.A line is considered to be terminated by any one of a carriage return ('\r'), a line feed ('\n'), or a carriage return followed immediately by a line feed ('\r\n'). This method discards leading UTF byte order marks (BOM), if present.
The position is advanced to start of the next line (i.e. any line terminators are skipped).
- Parameters:
charset- The charset used to interpret the bytes as aString.- Returns:
- The line not including any line-termination characters, or null if the end of the data has already been reached.
- Throws:
IllegalArgumentException- if charset is not supported. Only US_ASCII, UTF-8, UTF-16, UTF-16BE, and UTF-16LE are supported.
-
readUtf8EncodedLong
public long readUtf8EncodedLong()
Deprecated.Reads a long value encoded by UTF-8 encoding- Returns:
- Decoded long value
- Throws:
NumberFormatException- if there is a problem with decoding
-
readUtfCharsetFromBom
@Nullable public Charset readUtfCharsetFromBom()
Deprecated.
-
-