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
Base class for
BundleResource
implementations.- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionBundleResourceBase
(String displayName, String contentType, String format) Base constructor for creating a new bundle resource. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Get 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.int
hashCode()
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
.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
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 inBundleResourceType
.
-
-
Method Details
-
getDisplayName
Description copied from interface:BundleResource
Get the display name for this resource.- Specified by:
getDisplayName
in interfaceBundleResource
- Returns:
- the display name for this resource
-
getContentType
Description copied from interface:BundleResource
Get the content type for this resource.- Specified by:
getContentType
in interfaceBundleResource
- Returns:
- a string representing name of the content type for this resource
-
getFileFormat
Description copied from interface:BundleResource
Get the file format for this resource.- Specified by:
getFileFormat
in interfaceBundleResource
- Returns:
- the file format for this resource, or Optional.empty if not present
-
getIOPath
Description copied from interface:BundleResource
Get theIOPath
backing this resource, or Optional.empty.- Specified by:
getIOPath
in interfaceBundleResource
- Returns:
- the
IOPath
backing this resource, or Optional.empty if the resource has no backingIOPath
-
getInputStream
Description copied from interface:BundleResource
Get anInputStream
for this resource, or Optional.empty.- Specified by:
getInputStream
in interfaceBundleResource
- Returns:
- an
InputStream
for this resource, or Optional.empty ifBundleResource.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
Description copied from interface:BundleResource
Get anOutputStream
for this resource, or Optional.empty.- Specified by:
getOutputStream
in interfaceBundleResource
- Returns:
- an
OutputStream
for this resource, or Optional.empty ifBundleResource.hasOutputType()
is false for this resource
-
getSeekableStream
Description copied from interface:BundleResource
Get aSeekableStream
for this resource, or Optional.empty.- Specified by:
getSeekableStream
in interfaceBundleResource
- Returns:
- an
SeekableStream
for this resource, or Optional.empty if this is not an input type (seeBundleResource.hasInputType()
), or is an input type for which noSeekableStream
can be obtained (seeBundleResource.hasSeekableStream()
).
-
hasSeekableStream
public boolean hasSeekableStream()Description copied from interface:BundleResource
Returns true if this resource can be rendered as aSeekableStream
.- Specified by:
hasSeekableStream
in interfaceBundleResource
- Returns:
- true if this resource can be rendered as a
SeekableStream
(seeBundleResource.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 asInputStreamResource
, can be used for input but not for output (seeBundleResource.hasOutputType()
. 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.
- Specified by:
hasInputType
in interfaceBundleResource
- 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 asInputStreamResource
, can be used for input but not for output (seeBundleResource.hasOutputType()
. 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.
- Specified by:
hasOutputType
in interfaceBundleResource
- Returns:
- true if the type of this resource makes it suitable for use as target for output.
-
toString
-
equals
-
hashCode
public int hashCode()
-