# Class IOPathResource

java.lang.Object
htsjdk.beta.io.bundle.BundleResourceBase
htsjdk.beta.io.bundle.IOPathResource

All Implemented Interfaces:
  `BundleResource, Serializable`

public class IOPathResource extends BundleResourceBase implements Serializable
A `BundleResource` backed by an `IOPath`.

See Also:
  - Serialized Form

## Constructor Summary

Constructors
Constructor
Description
`IOPathResource(IOPath ioPath, String contentType)`
Create a `BundleResource` backed by an IOPath, specifying a content type.
`IOPathResource(IOPath ioPath, String contentType, String format)`
Create a `BundleResource` backed by an IOPath, specifying a content type string and format string.

## Method Summary

Modifier and Type
Method
Description
`boolean`
`equals(Object o)`
`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.
`int`
`hashCode()`
`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`.

### Methods inherited from class BundleResourceBase

`getContentType, getDisplayName, getFileFormat, toString`

### Methods inherited from class Object

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

## Constructor Details

### IOPathResource

public IOPathResource(IOPath ioPath, String contentType)
Create a `BundleResource` backed by an IOPath, specifying a content type.

Parameters:
  `ioPath` - The IOPath for this resource. May not be null.
  `contentType` - The content type for this resource. May not be null or 0-length.

### IOPathResource

public IOPathResource(IOPath ioPath, String contentType, String format)
Create a `BundleResource` backed by an IOPath, specifying a content type string and format string.

Parameters:
  `ioPath` - The IOPath for this resource. May not be null.
  `contentType` - The content type for this resource. May not be mull or 0-length.
  `format` - The format for this resource. May not be null or 0-length.

## Method Details

### getIOPath

public Optional<IOPath> getIOPath()
Description copied from interface: `BundleResource`
Get the `IOPath` backing this resource, or Optional.empty.

Specified by:
  `getIOPath` in interface `BundleResource`
Overrides:
  `getIOPath` in class `BundleResourceBase`
Returns:
  the `IOPath` backing this resource, or Optional.empty if the resource has no backing `IOPath`

### getInputStream

public Optional<InputStream> getInputStream()
Get an `InputStream` for this resource, or Optional.empty. return a new stream for the IOPath managed by this resource

Specified by:
  `getInputStream` in interface `BundleResource`
Overrides:
  `getInputStream` in class `BundleResourceBase`
Returns:
  return a stream for the IOPath managed by this resource

### getOutputStream

public Optional<OutputStream> getOutputStream()
Description copied from interface: `BundleResource`
Get an `OutputStream` for this resource, or Optional.empty.

Specified by:
  `getOutputStream` in interface `BundleResource`
Overrides:
  `getOutputStream` in class `BundleResourceBase`
Returns:
  an `OutputStream` for this resource, or Optional.empty if `BundleResource.hasOutputType()` is false for this resource

### 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 as `InputStreamResource`, can be used for input but not for output (see `BundleResource.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.

Specified by:
  `hasInputType` in interface `BundleResource`
Overrides:
  `hasInputType` in class `BundleResourceBase`
Returns:
  true if the type of this resource makes it suitable for use as a source of input.

### hasOutputType

public boolean hasOutputType()
Description copied from interface: `BundleResource`
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 `BundleResource.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.

Specified by:
  `hasOutputType` in interface `BundleResource`
Overrides:
  `hasOutputType` in class `BundleResourceBase`
Returns:
  true if the type of this resource makes it suitable for use as target for output.

### hasSeekableStream

public boolean hasSeekableStream()
Description copied from interface: `BundleResource`
Returns true if this resource can be rendered as a `SeekableStream`.

Specified by:
  `hasSeekableStream` in interface `BundleResource`
Overrides:
  `hasSeekableStream` in class `BundleResourceBase`
Returns:
  true if this resource can be rendered as a `SeekableStream` (see `BundleResource.getSeekableStream()`)

### getSeekableStream

public Optional<SeekableStream> getSeekableStream()
Description copied from interface: `BundleResource`
Get a `SeekableStream` for this resource, or Optional.empty.

Specified by:
  `getSeekableStream` in interface `BundleResource`
Overrides:
  `getSeekableStream` in class `BundleResourceBase`
Returns:
  an `SeekableStream` for this resource, or Optional.empty if this is not an input type (see `BundleResource.hasInputType()`), or is an input type for which no `SeekableStream` can be obtained (see `BundleResource.hasSeekableStream()`).

### getSignatureStream

public SignatureStream getSignatureStream(int signatureProbeLength)
Description copied from interface: `BundleResource`
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 `BundleResource.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 `BundleResource.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 interface `BundleResource`
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 `BundleResource.hasInputType()` is true.

### equals

public boolean equals(Object o)

Overrides:
  `equals` in class `BundleResourceBase`

### hashCode

public int hashCode()

Overrides:
  `hashCode` in class `BundleResourceBase`