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 Type
Method
Description
`String`
`getContentType()`
Get the content type for this resource.
`String`
`getDisplayName()`
Get the display name for this resource.
`Optional<String>`
`getFileFormat()`
Get the file format for this resource.
`Optional<InputStream>`
`getInputStream()`
Get an `InputStream` for this resource, or Optional.empty.
`Optional<IOPath>`
`getIOPath()`
Get the `IOPath` backing this resource, or Optional.empty.
`Optional<OutputStream>`
`getOutputStream()`
Get an `OutputStream` for this resource, or Optional.empty.
`Optional<SeekableStream>`
`getSeekableStream()`
Get a `SeekableStream` for this resource, or Optional.empty.
`SignatureStream`
`getSignatureStream(int signatureProbeLength)`
Get a `SignatureStream` for this resource.
`boolean`
`hasInputType()`
Return true if is this resource is backed by a type that can be used for input.
`boolean`
`hasOutputType()`
Return true if this resource is backed by a type that can be used for output.
`boolean`
`hasSeekableStream()`
Returns true if this resource can be rendered as a `SeekableStream`.

## 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

Optional<String> getFileFormat()
Get the file format for this resource.

Returns:
  the file format for this resource, or Optional.empty if not present

### getIOPath

Optional<IOPath> getIOPath()
Get the `IOPath` backing this resource, or Optional.empty.

Returns:
  the `IOPath` backing this resource, or Optional.empty if the resource has no backing `IOPath`

### getInputStream

Optional<InputStream> getInputStream()
Get an `InputStream` for this resource, or Optional.empty.

Returns:
  an `InputStream` for this resource, or Optional.empty if `hasInputType()` 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 an `OutputStream` for this resource, or Optional.empty.

Returns:
  an `OutputStream` for this resource, or Optional.empty if `hasOutputType()` is false for this resource

### getSeekableStream

Optional<SeekableStream> getSeekableStream()
Get a `SeekableStream` for this resource, or Optional.empty.

Returns:
  an `SeekableStream` for this resource, or Optional.empty if this is not an input type (see `hasInputType()`), or is an input type for which no `SeekableStream` can be obtained (see `hasSeekableStream()`).

### getSignatureStream

SignatureStream getSignatureStream(int signatureProbeLength)
Get a `SignatureStream` for this resource. This method requires access to the first `signatureProbeLength` bytes of the underlying resource. `BundleResource` implementations that are backed by raw streams that can only be consumed once, such as `InputStreamResource`, may consume and buffer a portion of the underlying resource's stream in order to allow subsequent callers of the `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 to `getSignatureStream(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 the `SignatureStream` stream. `signatureProbeLength` should be expressed in "compressed(/encrypted)" space rather than "plaintext" space. For example, a file format signature may consist of `n` bytes of ASCII, but for formats that use compressed streams, the codec may need access to an entire compressed block in order to inspect those `n` bytes. `signatureProbeLength` should use the compressed block size, in order to ensure that the `SignatureStream` contains a semantically meaningful fragment of the underlying input.
Returns:
  a `SignatureStream` over the first `signatureProbeLength` bytes of this resource, for use with signature probing for codec resolution. Only applicable to resources for which `hasInputType()` is true.
Throws:
  `IllegalArgumentException` - if this method has previously been called on this resource, or if `hasInputType()` 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 as `InputStreamResource`, can be used for input but not for output (see `hasOutputType()`. Others, such as `OutputStreamResource`, can be used for output but not for input. Some resource types may be suitable for both (for example see `IOPathResource`).

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 as `InputStreamResource`, can be used for input but not for output (see `hasOutputType()`. Others, such as `OutputStreamResource`, can be used for output but not for input. Some resource types may be suitable for both (for example see `IOPathResource`).

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 a `SeekableStream`.

Returns:
  true if this resource can be rendered as a `SeekableStream` (see `getSeekableStream()`)