@UnstableApi
public final class ExtractorUtil


Extractor related utility methods.

Summary

Public methods

static void
@Pure
checkContainerInput(boolean expression, @Nullable String message)

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

static boolean
peekFullyQuietly(
    ExtractorInput input,
    byte[] output,
    int offset,
    int length,
    boolean allowEndOfInput
)

Peeks data from input, respecting allowEndOfInput.

static int
peekToLength(ExtractorInput input, byte[] target, int offset, int length)

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.

static boolean
readFullyQuietly(
    ExtractorInput input,
    byte[] output,
    int offset,
    int length
)

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.

static boolean
skipFullyQuietly(ExtractorInput input, int length)

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 methods

checkContainerInput

@Pure
public static void checkContainerInput(boolean expression, @Nullable String message)

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

peekFullyQuietly

public static boolean peekFullyQuietly(
    ExtractorInput input,
    byte[] output,
    int offset,
    int length,
    boolean allowEndOfInput
)

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

public static int peekToLength(ExtractorInput input, byte[] target, int offset, int length)

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
ExtractorInput input

The stream input to peek the data from.

byte[] target

A target array into which data should be written.

int offset

The offset into the target array at which to write.

int length

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

public static boolean readFullyQuietly(
    ExtractorInput input,
    byte[] output,
    int offset,
    int length
)

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

public static boolean skipFullyQuietly(ExtractorInput input, int length)

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.