Package htsjdk.beta.io.bundle

# Class BundleResourceBase

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

All Implemented Interfaces:
  `BundleResource`, `Serializable`

Direct Known Subclasses:
  `InputStreamResource`, `IOPathResource`, `OutputStreamResource`

public abstract class BundleResourceBase extends Object implements BundleResource, Serializable
Base class for `BundleResource` implementations.

See Also:
  - Serialized Form

## Constructor Summary

Constructors
Constructor
Description
`BundleResourceBase(String displayName, String contentType, String format)`
Base constructor for creating a new bundle resource.

## Method Summary

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

### Methods inherited from class java.lang.Object

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

### Methods inherited from interface htsjdk.beta.io.bundle.BundleResource

`getSignatureStream`

## Constructor Details

### BundleResourceBase

public BundleResourceBase(String displayName, String contentType, String format)
Base constructor for creating a new bundle resource.

Parameters:
  `displayName` - A user-recognizable name for this resource. Used for error messages. May not be null or 0 length.
  `contentType` - The content type for this resource. Can be any string, but it must be unique within a given bundle. May not be null or zero length.
  `format` - The (optional) format for this resource. Can be any string, i.e, "BAM" for a resource with content type "READS". Predefined format strings are defined in `BundleResourceType`.

## Method Details

### getDisplayName

public String getDisplayName()
Description copied from interface: `BundleResource`
Get the display name for this resource.

Specified by:
  `getDisplayName` in interface `BundleResource`
Returns:
  the display name for this resource

### getContentType

public String getContentType()
Description copied from interface: `BundleResource`
Get the content type for this resource.

Specified by:
  `getContentType` in interface `BundleResource`
Returns:
  a string representing name of the content type for this resource

### getFileFormat

public Optional<String> getFileFormat()
Description copied from interface: `BundleResource`
Get the file format for this resource.

Specified by:
  `getFileFormat` in interface `BundleResource`
Returns:
  the file format for this resource, or Optional.empty if not present

### 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`
Returns:
  the `IOPath` backing this resource, or Optional.empty if the resource has no backing `IOPath`

### getInputStream

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

Specified by:
  `getInputStream` in interface `BundleResource`
Returns:
  an `InputStream` for this resource, or Optional.empty if `BundleResource.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

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

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

### 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`
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()`).

### 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`
Returns:
  true if this resource can be rendered as a `SeekableStream` (see `BundleResource.getSeekableStream()`)

### 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`
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`
Returns:
  true if the type of this resource makes it suitable for use as target for output.

### toString

public String toString()

Overrides:
  `toString` in class `Object`

### equals

public boolean equals(Object o)

Overrides:
  `equals` in class `Object`

### hashCode

public int hashCode()

Overrides:
  `hashCode` in class `Object`