Package htsjdk.beta.io.bundle
Class IOPathResource
java.lang.Object
htsjdk.beta.io.bundle.BundleResourceBase
htsjdk.beta.io.bundle.IOPathResource
- All Implemented Interfaces:
BundleResource,Serializable
A
BundleResource backed by an IOPath.- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionIOPathResource(IOPath ioPath, String contentType) Create aBundleResourcebacked by an IOPath, specifying a content type.IOPathResource(IOPath ioPath, String contentType, String format) Create aBundleResourcebacked by an IOPath, specifying a content type string and format string. -
Method Summary
Modifier and TypeMethodDescriptionbooleanGet 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.inthashCode()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.Methods inherited from class htsjdk.beta.io.bundle.BundleResourceBase
getContentType, getDisplayName, getFileFormat, toString
-
Constructor Details
-
IOPathResource
Create aBundleResourcebacked 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
Create aBundleResourcebacked 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
Description copied from interface:BundleResourceGet theIOPathbacking this resource, or Optional.empty.- Specified by:
getIOPathin interfaceBundleResource- Overrides:
getIOPathin classBundleResourceBase- Returns:
- the
IOPathbacking this resource, or Optional.empty if the resource has no backingIOPath
-
getInputStream
Get anInputStreamfor this resource, or Optional.empty. return a new stream for the IOPath managed by this resource- Specified by:
getInputStreamin interfaceBundleResource- Overrides:
getInputStreamin classBundleResourceBase- Returns:
- return a stream for the IOPath managed by this resource
-
getOutputStream
Description copied from interface:BundleResourceGet anOutputStreamfor this resource, or Optional.empty.- Specified by:
getOutputStreamin interfaceBundleResource- Overrides:
getOutputStreamin classBundleResourceBase- Returns:
- an
OutputStreamfor this resource, or Optional.empty ifBundleResource.hasOutputType()is false for this resource
-
hasInputType
public boolean hasInputType()Description copied from interface:BundleResourceReturn 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:
hasInputTypein interfaceBundleResource- Overrides:
hasInputTypein classBundleResourceBase- 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:BundleResourceReturn 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:
hasOutputTypein interfaceBundleResource- Overrides:
hasOutputTypein classBundleResourceBase- 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:BundleResourceReturns true if this resource can be rendered as aSeekableStream.- Specified by:
hasSeekableStreamin interfaceBundleResource- Overrides:
hasSeekableStreamin classBundleResourceBase- Returns:
- true if this resource can be rendered as a
SeekableStream(seeBundleResource.getSeekableStream())
-
getSeekableStream
Description copied from interface:BundleResourceGet aSeekableStreamfor this resource, or Optional.empty.- Specified by:
getSeekableStreamin interfaceBundleResource- Overrides:
getSeekableStreamin classBundleResourceBase- Returns:
- an
SeekableStreamfor this resource, or Optional.empty if this is not an input type (seeBundleResource.hasInputType()), or is an input type for which noSeekableStreamcan be obtained (seeBundleResource.hasSeekableStream()).
-
getSignatureStream
Description copied from interface:BundleResourceGet 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 theBundleResource.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 toBundleResource.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:
getSignatureStreamin interfaceBundleResource- 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 whichBundleResource.hasInputType()is true.
-
equals
- Overrides:
equalsin classBundleResourceBase
-
hashCode
public int hashCode()- Overrides:
hashCodein classBundleResourceBase
-