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 anInputStreamfor this resource, or Optional.empty.Get theIOPathbacking this resource, or Optional.empty.Get anOutputStreamfor this resource, or Optional.empty.Get aSeekableStreamfor this resource, or Optional.empty.getSignatureStream(int signatureProbeLength) Get aSignatureStreamfor this resource.booleanReturn true if is this resource is backed by a type that can be used for input.booleanReturn true if this resource is backed by a type that can be used for output.booleanReturns 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 theIOPathbacking this resource, or Optional.empty. -
getInputStream
Optional<InputStream> getInputStream()Get anInputStreamfor this resource, or Optional.empty.- Returns:
- an
InputStreamfor 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 anOutputStreamfor this resource, or Optional.empty.- Returns:
- an
OutputStreamfor this resource, or Optional.empty ifhasOutputType()is false for this resource
-
getSeekableStream
Optional<SeekableStream> getSeekableStream()Get aSeekableStreamfor this resource, or Optional.empty.- Returns:
- an
SeekableStreamfor this resource, or Optional.empty if this is not an input type (seehasInputType()), or is an input type for which noSeekableStreamcan be obtained (seehasSeekableStream()).
-
getSignatureStream
Get aSignatureStreamfor this resource. This method requires access to the firstsignatureProbeLengthbytes of the underlying resource.BundleResourceimplementations 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 theSignatureStreamstream.signatureProbeLengthshould be expressed in "compressed(/encrypted)" space rather than "plaintext" space. For example, a file format signature may consist ofnbytes of ASCII, but for formats that use compressed streams, the codec may need access to an entire compressed block in order to inspect thosenbytes.signatureProbeLengthshould use the compressed block size, in order to ensure that theSignatureStreamcontains a semantically meaningful fragment of the underlying input.- Returns:
- a
SignatureStreamover the firstsignatureProbeLengthbytes 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())
-