Package htsjdk.beta.io.bundle
Class SeekableStreamResource
java.lang.Object
htsjdk.beta.io.bundle.BundleResourceBase
htsjdk.beta.io.bundle.InputStreamResource
htsjdk.beta.io.bundle.SeekableStreamResource
- All Implemented Interfaces:
BundleResource
,Serializable
A
BundleResource
backed by a SeekableStream
.- See Also:
-
Constructor Summary
ConstructorDescriptionSeekableStreamResource
(SeekableStream seekableStream, String displayName, String contentType) Create aBundleResource
backed by an SeekableStream, specifying a display name and content type.SeekableStreamResource
(SeekableStream seekableStream, String displayName, String contentType, String format) Create aBundleResource
backed by an SeekableStream, specifying a display name, content type and format. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Get theSeekableStream
managed by this resource as anInputStream
.Get aSeekableStream
for this resource, or Optional.empty.getSignatureStream
(int signatureProbeLength) Get aSignatureStream
for this resource.int
hashCode()
boolean
Return true if is this resource is backed by a type that can be used for input.boolean
Returns true if this resource can be rendered as aSeekableStream
.toString()
Methods inherited from class htsjdk.beta.io.bundle.BundleResourceBase
getContentType, getDisplayName, getFileFormat, getIOPath, getOutputStream, hasOutputType
-
Constructor Details
-
SeekableStreamResource
public SeekableStreamResource(SeekableStream seekableStream, String displayName, String contentType) Create aBundleResource
backed by an SeekableStream, specifying a display name and content type.- Parameters:
seekableStream
- TheSeekableStream
to use for this resource. May not be null.displayName
- The display name for this resource. May not be null or 0-length.contentType
- The content type for this resource. May not be null or 0-length.
-
SeekableStreamResource
public SeekableStreamResource(SeekableStream seekableStream, String displayName, String contentType, String format) Create aBundleResource
backed by an SeekableStream, specifying a display name, content type and format.- Parameters:
seekableStream
- TheSeekableStream
to use for this resource. May not be null.displayName
- The display name for this resource. May not be null or 0-length.contentType
- The content type for this resource. May not be null or 0-length.format
- The format for this resource. May not be null or 0-length.
-
-
Method Details
-
getInputStream
Get theSeekableStream
managed by this resource as anInputStream
. Does not alter or reset the underlying stream.- Specified by:
getInputStream
in interfaceBundleResource
- Overrides:
getInputStream
in classInputStreamResource
- Returns:
- the seekable stream managed by this resource, without resetting the stream's state
-
getSeekableStream
Description copied from interface:BundleResource
Get aSeekableStream
for this resource, or Optional.empty.- Specified by:
getSeekableStream
in interfaceBundleResource
- Overrides:
getSeekableStream
in classBundleResourceBase
- Returns:
- an
SeekableStream
for this resource, or Optional.empty if this is not an input type (seeBundleResource.hasInputType()
), or is an input type for which noSeekableStream
can be obtained (seeBundleResource.hasSeekableStream()
).
-
getSignatureStream
Get aSignatureStream
for this resource. This method requires access to the firstsignatureProbeLength
bytes of the underlying resource.BundleResource
implementations that are backed by raw streams that can only be consumed once, such asInputStreamResource
, may consume and buffer a portion of the underlying resource's stream in order to allow subsequent callers of theBundleResource.getInputStream()
) method to be presented with the entire stream, including the signature. Calls to this method may have the side effect of changing or resetting the current position of the underlying stream; serial calls toBundleResource.getSignatureStream(int)
on the same object are not necessarily idempotent; and implementations are free to throw to prevent serial calls to this method.- Specified by:
getSignatureStream
in interfaceBundleResource
- Overrides:
getSignatureStream
in classInputStreamResource
- Parameters:
signatureProbeLength
- the number of bytes of the underlying resource to include in theSignatureStream
stream.signatureProbeLength
should be expressed in "compressed(/encrypted)" space rather than "plaintext" space. For example, a file format signature may consist ofn
bytes of ASCII, but for formats that use compressed streams, the codec may need access to an entire compressed block in order to inspect thosen
bytes.signatureProbeLength
should use the compressed block size, in order to ensure that theSignatureStream
contains a semantically meaningful fragment of the underlying input.- Returns:
- Get a SignatureProbeStream on this resource. Resets the underlying seekable stream.
-
hasInputType
public boolean hasInputType()Description copied from interface:BundleResource
Return true if is this resource is backed by a type that can be used for input. Some resource types, such asInputStreamResource
, can be used for input but not for output (seeBundleResource.hasOutputType()
. Others, such asOutputStreamResource
, can be used for output but not for input. Some resource types may be suitable for both (for example seeIOPathResource
).The determination is based only on the type of the resource, and does not imply a guarantee about whether the resource type is actually readable.
- Specified by:
hasInputType
in interfaceBundleResource
- Overrides:
hasInputType
in classInputStreamResource
- Returns:
- true if the type of this resource makes it suitable for use as a source of input.
-
hasSeekableStream
public boolean hasSeekableStream()Description copied from interface:BundleResource
Returns true if this resource can be rendered as aSeekableStream
.- Specified by:
hasSeekableStream
in interfaceBundleResource
- Overrides:
hasSeekableStream
in classBundleResourceBase
- Returns:
- true if this resource can be rendered as a
SeekableStream
(seeBundleResource.getSeekableStream()
)
-
equals
- Overrides:
equals
in classInputStreamResource
-
hashCode
public int hashCode()- Overrides:
hashCode
in classInputStreamResource
-
toString
- Overrides:
toString
in classInputStreamResource
-