Package htsjdk.beta.io.bundle
Interface BundleResource
- All Known Implementing Classes:
BundleResourceBase
,InputStreamResource
,IOPathResource
,OutputStreamResource
,SeekableStreamResource
public interface BundleResource
Interface defined for bundle resource objects that may be included in a
Bundle
.-
Method Summary
Modifier and TypeMethodDescriptionGet the content type for this resource.Get the display name for this resource.Get the file format for this resource.Get anInputStream
for this resource, or Optional.empty.Get theIOPath
backing this resource, or Optional.empty.Get anOutputStream
for this resource, or Optional.empty.Get aSeekableStream
for this resource, or Optional.empty.getSignatureStream
(int signatureProbeLength) Get aSignatureStream
for this resource.boolean
Return true if is this resource is backed by a type that can be used for input.boolean
Return true if this resource is backed by a type that can be used for output.boolean
Returns true if this resource can be rendered as aSeekableStream
.
-
Method Details
-
getDisplayName
String getDisplayName()Get the display name for this resource.- Returns:
- the display name for this resource
-
getContentType
String getContentType()Get the content type for this resource.- Returns:
- a string representing name of the content type for this resource
-
getFileFormat
Get the file format for this resource.- Returns:
- the file format for this resource, or Optional.empty if not present
-
getIOPath
Get theIOPath
backing this resource, or Optional.empty. -
getInputStream
Optional<InputStream> getInputStream()Get anInputStream
for this resource, or Optional.empty.- Returns:
- an
InputStream
for this resource, or Optional.empty ifhasInputType()
is false for this resource. The stream returned by this method may be buffered or use read-ahead, which may not be suitable for applications such as index creation that need control over the position of the underlying stream.
-
getOutputStream
Optional<OutputStream> getOutputStream()Get anOutputStream
for this resource, or Optional.empty.- Returns:
- an
OutputStream
for this resource, or Optional.empty ifhasOutputType()
is false for this resource
-
getSeekableStream
Optional<SeekableStream> getSeekableStream()Get aSeekableStream
for this resource, or Optional.empty.- Returns:
- an
SeekableStream
for this resource, or Optional.empty if this is not an input type (seehasInputType()
), or is an input type for which noSeekableStream
can be obtained (seehasSeekableStream()
).
-
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 thegetInputStream()
) 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 togetSignatureStream(int)
on the same object are not necessarily idempotent; and implementations are free to throw to prevent serial calls to this method.- 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:
- a
SignatureStream
over the firstsignatureProbeLength
bytes of this resource, for use with signature probing for codec resolution. Only applicable to resources for whichhasInputType()
is true. - Throws:
IllegalArgumentException
- if this method has previously been called on this resource, or ifhasInputType()
is false for this resource
-
hasInputType
boolean hasInputType()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 (seehasOutputType()
. 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.
- Returns:
- true if the type of this resource makes it suitable for use as a source of input.
-
hasOutputType
boolean hasOutputType()Return true if this resource is backed by a type that can be used for output. Some resource types, such asInputStreamResource
, can be used for input but not for output (seehasOutputType()
. 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 is actually writeable.
- Returns:
- true if the type of this resource makes it suitable for use as target for output.
-
hasSeekableStream
boolean hasSeekableStream()Returns true if this resource can be rendered as aSeekableStream
.- Returns:
- true if this resource can be rendered as a
SeekableStream
(seegetSeekableStream()
)
-