@UnstableApi
class ExtractorUtil


Extractor related utility methods.

Summary

Public functions

java-static Unit
@Pure
checkContainerInput(expression: Boolean, message: String?)

If expression is false, throws a container malformed ParserException with the given message.

java-static Boolean
peekFullyQuietly(
    input: ExtractorInput!,
    output: ByteArray!,
    offset: Int,
    length: Int,
    allowEndOfInput: Boolean
)

Peeks data from input, respecting allowEndOfInput.

java-static Int
peekToLength(
    input: ExtractorInput!,
    target: ByteArray!,
    offset: Int,
    length: Int
)

Peeks length bytes from the input peek position, or all the bytes to the end of the input if there was less than length bytes left.

java-static Boolean
readFullyQuietly(
    input: ExtractorInput!,
    output: ByteArray!,
    offset: Int,
    length: Int
)

Equivalent to readFully except that it returns false instead of throwing an EOFException if the end of input is encountered without having fully satisfied the read.

java-static Boolean
skipFullyQuietly(input: ExtractorInput!, length: Int)

Equivalent to skipFully except that it returns false instead of throwing an EOFException if the end of input is encountered without having fully satisfied the skip.

Public functions

checkContainerInput

@Pure
java-static fun checkContainerInput(expression: Boolean, message: String?): Unit

If expression is false, throws a container malformed ParserException with the given message. Otherwise, does nothing.

peekFullyQuietly

java-static fun peekFullyQuietly(
    input: ExtractorInput!,
    output: ByteArray!,
    offset: Int,
    length: Int,
    allowEndOfInput: Boolean
): Boolean

Peeks data from input, respecting allowEndOfInput. Returns true if the peek is successful.

If allowEndOfInput=false then encountering the end of the input (whether before or after reading some data) will throw EOFException.

If allowEndOfInput=true then encountering the end of the input (even after reading some data) will return false.

This is slightly different to the behaviour of peekFully, where allowEndOfInput=true only returns false (and suppresses the exception) if the end of the input is reached before reading any data.

peekToLength

java-static fun peekToLength(
    input: ExtractorInput!,
    target: ByteArray!,
    offset: Int,
    length: Int
): Int

Peeks length bytes from the input peek position, or all the bytes to the end of the input if there was less than length bytes left.

If an exception is thrown, there is no guarantee on the peek position.

Parameters
input: ExtractorInput!

The stream input to peek the data from.

target: ByteArray!

A target array into which data should be written.

offset: Int

The offset into the target array at which to write.

length: Int

The maximum number of bytes to peek from the input.

Returns
Int

The number of bytes peeked.

Throws
java.io.IOException

If an error occurs peeking from the input.

readFullyQuietly

java-static fun readFullyQuietly(
    input: ExtractorInput!,
    output: ByteArray!,
    offset: Int,
    length: Int
): Boolean

Equivalent to readFully except that it returns false instead of throwing an EOFException if the end of input is encountered without having fully satisfied the read.

skipFullyQuietly

java-static fun skipFullyQuietly(input: ExtractorInput!, length: Int): Boolean

Equivalent to skipFully except that it returns false instead of throwing an EOFException if the end of input is encountered without having fully satisfied the skip.