Package gov.nih.mipav.model.file
Class MetadataExtractor.SequentialByteArrayReader
- java.lang.Object
-
- gov.nih.mipav.model.file.MetadataExtractor.SequentialReader
-
- gov.nih.mipav.model.file.MetadataExtractor.SequentialByteArrayReader
-
- Enclosing class:
- MetadataExtractor
public class MetadataExtractor.SequentialByteArrayReader extends MetadataExtractor.SequentialReader
- Author:
- Drew Noakes https://drewnoakes.com
-
-
Constructor Summary
Constructors Constructor Description SequentialByteArrayReader(byte[] bytes)
SequentialByteArrayReader(byte[] bytes, int baseIndex)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
available()
Returns an estimate of the number of bytes that can be read (or skipped over) from thisMetadataExtractor.SequentialReader
without blocking by the next invocation of a method for this input stream.byte
getByte()
Gets the next byte in the sequence.void
getBytes(byte[] buffer, int offset, int count)
Retrieves bytes, writing them into a caller-provided buffer.byte[]
getBytes(int count)
Returns the required number of bytes from the sequence.long
getPosition()
void
skip(long n)
Skips forward in the sequence.boolean
trySkip(long n)
Skips forward in the sequence, returning a boolean indicating whether the skip succeeded, or whether the sequence ended.-
Methods inherited from class gov.nih.mipav.model.file.MetadataExtractor.SequentialReader
getDouble64, getFloat32, getInt16, getInt32, getInt64, getInt8, getNullTerminatedBytes, getNullTerminatedString, getNullTerminatedStringValue, getS15Fixed16, getString, getString, getString, getStringValue, getUInt16, getUInt32, getUInt8, isMotorolaByteOrder, setMotorolaByteOrder
-
-
-
-
Method Detail
-
getPosition
public long getPosition()
- Specified by:
getPosition
in classMetadataExtractor.SequentialReader
-
getByte
public byte getByte() throws java.io.IOException
Description copied from class:MetadataExtractor.SequentialReader
Gets the next byte in the sequence.- Specified by:
getByte
in classMetadataExtractor.SequentialReader
- Returns:
- The read byte value
- Throws:
java.io.IOException
-
getBytes
public byte[] getBytes(int count) throws java.io.IOException
Description copied from class:MetadataExtractor.SequentialReader
Returns the required number of bytes from the sequence.- Specified by:
getBytes
in classMetadataExtractor.SequentialReader
- Parameters:
count
- The number of bytes to be returned- Returns:
- The requested bytes
- Throws:
java.io.IOException
-
getBytes
public void getBytes(byte[] buffer, int offset, int count) throws java.io.IOException
Description copied from class:MetadataExtractor.SequentialReader
Retrieves bytes, writing them into a caller-provided buffer.- Specified by:
getBytes
in classMetadataExtractor.SequentialReader
- Parameters:
buffer
- The array to write bytes to.offset
- The starting position within buffer to write to.count
- The number of bytes to be written.- Throws:
java.io.IOException
-
skip
public void skip(long n) throws java.io.IOException
Description copied from class:MetadataExtractor.SequentialReader
Skips forward in the sequence. If the sequence ends, anEOFException
is thrown.- Specified by:
skip
in classMetadataExtractor.SequentialReader
- Parameters:
n
- the number of byte to skip. Must be zero or greater.- Throws:
java.io.EOFException
- the end of the sequence is reached.java.io.IOException
- an error occurred reading from the underlying source.
-
trySkip
public boolean trySkip(long n) throws java.io.IOException
Description copied from class:MetadataExtractor.SequentialReader
Skips forward in the sequence, returning a boolean indicating whether the skip succeeded, or whether the sequence ended.- Specified by:
trySkip
in classMetadataExtractor.SequentialReader
- Parameters:
n
- the number of byte to skip. Must be zero or greater.- Returns:
- a boolean indicating whether the skip succeeded, or whether the sequence ended.
- Throws:
java.io.IOException
- an error occurred reading from the underlying source.
-
available
public int available()
Description copied from class:MetadataExtractor.SequentialReader
Returns an estimate of the number of bytes that can be read (or skipped over) from thisMetadataExtractor.SequentialReader
without blocking by the next invocation of a method for this input stream. A single read or skip of this many bytes will not block, but may read or skip fewer bytes.Note that while some implementations of
MetadataExtractor.SequentialReader
likeMetadataExtractor.SequentialByteArrayReader
will return the total remaining number of bytes in the stream, others will not. It is never correct to use the return value of this method to allocate a buffer intended to hold all data in this stream.- Specified by:
available
in classMetadataExtractor.SequentialReader
- Returns:
- an estimate of the number of bytes that can be read (or skipped
over) from this
MetadataExtractor.SequentialReader
without blocking or0
when it reaches the end of the input stream.
-
-