C
- the HtsCodec type managed by this resolverpublic class HtsCodecResolver<C extends HtsCodec<?,?>>
extends java.lang.Object
HtsCodec
s
of a single HtsContentType
type, defined by the type parameters used to
instantiate the resolver.
Methods in this class accept a bundle, and/or additional arguments, and return one or more matching codecs. The resolution methods use a series of probes to inspect resource structure and format to determine the file format in order to find codecs that claim to be able to process the resource.
Constructor and Description |
---|
HtsCodecResolver(java.lang.String requiredContentType)
Create a resolver for a given
HtsCodec type, defined by the type parameter C . |
Modifier and Type | Method and Description |
---|---|
java.util.List<C> |
getCodecs()
Get a list of all codecs of the type
C managed by this resolver. |
C |
registerCodec(C codec)
Register a codec of type
C . |
C |
resolveForDecoding(Bundle bundle)
Inspect a bundle and find a codec that can decode the primary resource.
|
C |
resolveForEncoding(Bundle bundle)
Inspect a bundle and find a codec that can encode to the primary resource.
|
C |
resolveForEncoding(Bundle bundle,
HtsVersion htsVersion)
Inspect a bundle and find a codec that can encode to the primary resource using the format version
requested.
|
java.util.List<C> |
resolveForFormat(java.lang.String format)
Get a list of codecs that claim to support file format
format string |
C |
resolveFormatAndVersion(java.lang.String format,
HtsVersion formatVersion)
Get a list of codecs that claim to support version
formatVersion of file format
format . |
public HtsCodecResolver(java.lang.String requiredContentType)
HtsCodec
type, defined by the type parameter C
.requiredContentType
- the primary content type this resolver will use to interrogate a bundle
to locate the primary resource when attempting to resolve the bundle to a codecpublic C registerCodec(C codec)
C
. If a codec for the same format and version is already registered with
this resolver, the resolver is updated with the new codec, and the previously registered codec is returned.codec
- a codec of type C
public C resolveForDecoding(Bundle bundle)
The resolution process starts with a list of candidate codecs consisting of all registered codecs that match this resolver's required content type. The bundle is then inspected to determine whether the primary resource is an IOPath or a stream, and the list of candidate codecs is reduced as follows:
If the primary resource is an IOPath:
HtsCodec.ownsURI(htsjdk.io.IOPath)
method. If any codec
returns true:
HtsCodec.ownsURI(htsjdk.io.IOPath)
HtsCodec.canDecodeURI(IOPath)
.
HtsCodec.canDecodeURI(IOPath)
HtsCodec.canDecodeSignature(SignatureStream, String)
If the primary resource is a stream:
HtsCodec.canDecodeSignature(SignatureStream, String)
If a single codec remains in the candidate list after the resolution process described above, that codec is returned. It is an error if more than one codec is remaining in the candidate list after codec resolution. This usually indicates that the registry contains an ill-behaved codec implementation.
Note: HtsCodec.canDecodeSignature(SignatureStream, String)
will never be
called by the framework on a resource if any codec returns true from HtsCodec.ownsURI(htsjdk.io.IOPath)
for
that resource.
bundle
- the bundle to resolve to a codecHtsjdkException
- if no registered codecs can handle the resourceHtsjdkPluginException
- if more than one codec claims to handle the resource. this usually indicates
that the registry contains an incorrectly written codec.public C resolveForEncoding(Bundle bundle)
IOPath
, the structure of the IOPath (protocol scheme,
file extension, and query parameters) are used to determine the file format to be used.
For resources that are ambiguous (i.e., a stream, which has no file extension that can be used
to infer a format), the bundle resource must specify a format
(see BundleResource.getFileFormat()
) that corresponds to one of the formats for the
content type used by this codec type. The newest available version of that file format will
be used.
To request a specific version, see resolveForEncoding(Bundle, HtsVersion)
. To request a
specific format and version, use resolveFormatAndVersion(String, HtsVersion)
.
bundle
- the bundle to resolve to a codec for encodingHtsjdkException
- if no registered codecs can handle the resourceHtsjdkPluginException
- if more than one codec claims to handle the resource. this usually indicates
that the registry contains an incorrectly written codec.public C resolveForEncoding(Bundle bundle, HtsVersion htsVersion)
IOPath
, the structure of the IOPath
(protocol scheme, file extension, and query parameters) are used to determine the file format used.
For resources that are ambiguous (i.e., a stream which has no file extension that can be used to infer
a file format), the bundle resource must specify a format (see BundleResource.getFileFormat()
)
that corresponds to one of the formats for the requiredContentType
used by this resolver.
bundle
- the bundle to use for encodinghtsVersion
- the version being requested (use HtsVersion.NEWEST_VERSION to use the newest
version codec registered)HtsjdkException
- if no registered codecs can handle the resourceHtsjdkPluginException
- if more than one codec claims to handle the resource. this usually indicates
that the registry contains an incorrectly written codec.public java.util.List<C> resolveForFormat(java.lang.String format)
format
stringformat
- the format string of the inputformat
public C resolveFormatAndVersion(java.lang.String format, HtsVersion formatVersion)
formatVersion
of file format
format
.format
- the input formatformatVersion
- the version of format
requestedformatVersion
of file
format format
HtsjdkException
- if no registered codecs can handle the resourcepublic java.util.List<C> getCodecs()
C
managed by this resolver.C
managed by this resolver