public abstract class BmcFSInputStream extends FSInputStream
FSInputStream
that has basic read support, along with state validation.
Implementations should inherit from this class when there is not too much custom logic required to implement seek
behavior.Modifier and Type | Field and Description |
---|---|
protected boolean |
closed |
protected long |
currentPosition |
protected com.oracle.bmc.objectstorage.ObjectStorage |
objectStorage |
protected Supplier<com.oracle.bmc.objectstorage.requests.GetObjectRequest.Builder> |
requestBuilder |
protected InputStream |
sourceInputStream |
protected FileSystem.Statistics |
statistics |
protected FileStatus |
status |
Constructor and Description |
---|
BmcFSInputStream(com.oracle.bmc.objectstorage.ObjectStorage objectStorage,
FileStatus status,
Supplier<com.oracle.bmc.objectstorage.requests.GetObjectRequest.Builder> requestBuilder,
FileSystem.Statistics statistics) |
Modifier and Type | Method and Description |
---|---|
int |
available() |
void |
close() |
protected abstract long |
doSeek(long position)
Perform the requested seek operation.
|
long |
getPos() |
protected InputStream |
getSourceInputStream() |
protected FileSystem.Statistics |
getStatistics() |
int |
read() |
int |
read(byte[] b,
int off,
int len) |
void |
seek(long position) |
boolean |
seekToNewSource(long arg0)
There are no new sources, this method always returns false.
|
protected void |
setSourceInputStream(InputStream sourceInputStream) |
protected void |
validateState(long startPosition)
Allows subclasses to validate the state of this stream.
|
protected InputStream |
wrap(InputStream rawInputStream)
Allows the subclass to wrap the raw input stream from Casper in another one if desired.
|
read, readFully, readFully, toString, validatePositionedReadArgs
mark, markSupported, read, reset, skip
protected final com.oracle.bmc.objectstorage.ObjectStorage objectStorage
protected final FileStatus status
protected final Supplier<com.oracle.bmc.objectstorage.requests.GetObjectRequest.Builder> requestBuilder
protected final FileSystem.Statistics statistics
protected InputStream sourceInputStream
protected long currentPosition
protected boolean closed
@ConstructorProperties(value={"objectStorage","status","requestBuilder","statistics"}) public BmcFSInputStream(com.oracle.bmc.objectstorage.ObjectStorage objectStorage, FileStatus status, Supplier<com.oracle.bmc.objectstorage.requests.GetObjectRequest.Builder> requestBuilder, FileSystem.Statistics statistics)
public long getPos() throws IOException
getPos
in interface Seekable
getPos
in class FSInputStream
IOException
public void seek(long position) throws IOException
seek
in interface Seekable
seek
in class FSInputStream
IOException
protected abstract long doSeek(long position) throws IOException
setSourceInputStream(InputStream)
before returning. The input stream that was
originally created (and wrapped by wrap(InputStream)
can be obtained from
getSourceInputStream()
.position
- The position to seek to.IOException
- if the operation could not be completedpublic boolean seekToNewSource(long arg0) throws IOException
seekToNewSource
in interface Seekable
seekToNewSource
in class FSInputStream
IOException
public int read() throws IOException
read
in class InputStream
IOException
public int read(byte[] b, int off, int len) throws IOException
read
in class InputStream
IOException
public int available() throws IOException
available
in class InputStream
IOException
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in class InputStream
IOException
protected InputStream wrap(InputStream rawInputStream) throws IOException
rawInputStream
- The raw input stream.IOException
- if the operation could not be completed.protected void validateState(long startPosition) throws IOException
wrap(InputStream)
)startPosition
- The starting byte offset.IOException
- if the filesystem could not be initializedprotected FileSystem.Statistics getStatistics()
protected void setSourceInputStream(InputStream sourceInputStream)
protected InputStream getSourceInputStream()
Copyright © 2016–2023. All rights reserved.