-
- All Superinterfaces:
Comparable<org.scijava.Prioritized>,org.scijava.Contextual,org.scijava.Disposable,org.scijava.plugin.HasPluginInfo,org.scijava.Identifiable,org.scijava.Initializable,org.scijava.Locatable,org.scijava.log.Logged,org.scijava.Prioritized,org.scijava.plugin.RichPlugin,SCIFIOService,org.scijava.plugin.SciJavaPlugin,org.scijava.service.Service,org.scijava.Versioned
- All Known Implementing Classes:
DefaultFormatService
public interface FormatService extends SCIFIOService
A collection of methods for findingFormatinstances given a child class, discovering available formats, and managing the list of available formats.- Author:
- Mark Hiner
- See Also:
Format
-
-
Field Summary
Fields Modifier and Type Field Description static doublePRIORITY
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaddComponents(Format format)Creates mappings between this Format and its components.<M extends Metadata>
booleanaddFormat(Format format)Makes the providedFormatavailable for image IO operations in this context.Set<Format>getAllFormats()Returns a list of all Formats within this context.FormatgetFormat(org.scijava.io.handle.DataHandle<org.scijava.io.location.Location> source)AsgetFormat(Location)but takes an initializedDataHandle.FormatgetFormat(org.scijava.io.handle.DataHandle<org.scijava.io.location.Location> source, SCIFIOConfig config)AsgetFormat(Location, SCIFIOConfig)but takes an initializedDataHandle.FormatgetFormat(org.scijava.io.location.Location id)Returns the firstFormatknown to be compatible with the source provided.FormatgetFormat(org.scijava.io.location.Location id, SCIFIOConfig config)Returns the first Format known to be compatible with the source provided.<C extends Checker>
FormatgetFormatFromChecker(Class<C> checkerClass)Formatlookup method using theCheckercomponent.<F extends Format>
FgetFormatFromClass(Class<F> formatClass)Lookup method for the Format map.FormatgetFormatFromComponent(Class<?> componentClass)Returns the Format compatible with this component class, or null if no matching Format can be found.<M extends Metadata>
FormatgetFormatFromMetadata(Class<M> metadataClass)Formatlookup method using theMetadatacomponent.<P extends Parser>
FormatgetFormatFromParser(Class<P> parserClass)Formatlookup method using theParsercomponent.<R extends Reader>
FormatgetFormatFromReader(Class<R> readerClass)Formatlookup method using theReadercomponent<W extends Writer>
FormatgetFormatFromWriter(Class<W> writerClass)Formatlookup method using theWritercomponent.List<Format>getFormatList(org.scijava.io.handle.DataHandle<org.scijava.io.location.Location> source)AsgetFormatList(Location)but takes an initializedDataHandle.List<Format>getFormatList(org.scijava.io.handle.DataHandle<org.scijava.io.location.Location> source, SCIFIOConfig config, boolean greedy)AsgetFormatList(Location, SCIFIOConfig, boolean)but takes an initializedDataHandle.List<Format>getFormatList(org.scijava.io.location.Location id)Returns a list of all formats that are compatible with the source provided, ordered by their priority.List<Format>getFormatList(org.scijava.io.location.Location id, SCIFIOConfig config, boolean greedy)Returns a list of all formats that are compatible with the source provided, ordered by their priority.Collection<Format>getOutputFormats()String[]getSuffixes()Returns a complete list of all suffixes supported within this context.WritergetWriterForLocation(org.scijava.io.location.Location fileId)Writerlookup method using the suffix or other methods to locate a fitting writer.voidremoveComponents(Format format)Removes any mappings involving this Format's components.booleanremoveFormat(Format format)Removes the providedFormatfrom this context, if it was previously available.-
Methods inherited from interface org.scijava.Contextual
context, getContext, setContext
-
Methods inherited from interface org.scijava.Disposable
dispose
-
Methods inherited from interface org.scijava.plugin.HasPluginInfo
getInfo, setInfo
-
Methods inherited from interface org.scijava.Locatable
getLocation
-
Methods inherited from interface org.scijava.Prioritized
compareTo, getPriority, setPriority
-
Methods inherited from interface org.scijava.plugin.RichPlugin
getIdentifier, log
-
Methods inherited from interface org.scijava.service.Service
initialize, registerEventHandlers
-
Methods inherited from interface org.scijava.Versioned
getVersion
-
-
-
-
Field Detail
-
PRIORITY
static final double PRIORITY
- See Also:
- Constant Field Values
-
-
Method Detail
-
getSuffixes
String[] getSuffixes()
Returns a complete list of all suffixes supported within this context.
-
addFormat
<M extends Metadata> boolean addFormat(Format format)
Makes the providedFormatavailable for image IO operations in this context.No effect if the format is already known.
- Parameters:
format- a newFormatto support in this context.- Returns:
- True if the
Formatwas added successfully.
-
addComponents
void addComponents(Format format)
Creates mappings between this Format and its components.
-
removeComponents
void removeComponents(Format format)
Removes any mappings involving this Format's components.
-
removeFormat
boolean removeFormat(Format format)
Removes the providedFormatfrom this context, if it was previously available.- Parameters:
format- theFormatto stop supporting in this context.- Returns:
- True if a format was successfully removed.
-
getFormatFromClass
<F extends Format> F getFormatFromClass(Class<F> formatClass)
Lookup method for the Format map. Use this method when you want a concrete type reference instead of trying to construct a newFormat.NB: because SezPoz is used for automatic detection of
Formatsin SCIFIO, all concreteFormatimplementations have a zero-parameter constructor. If you manually invoke that constructor and then try to link yourFormatto an existing context, e.g. via theaddFormat(Format)method, it will fail if theFormatwas already discovered. The same principle is true if the context-based constructor is invoked.- Parameters:
formatClass- the class of the desiredFormat- Returns:
- A reference to concrete class of the queried
Format, or null if theFormatwas not found.
-
getFormatFromComponent
Format getFormatFromComponent(Class<?> componentClass)
Returns the Format compatible with this component class, or null if no matching Format can be found.
-
getFormatFromReader
<R extends Reader> Format getFormatFromReader(Class<R> readerClass)
Formatlookup method using theReadercomponent- Parameters:
readerClass- the class of theReadercomponent for the desiredFormat- Returns:
- A reference to the queried
Format, or null if theFormatwas not found.
-
getFormatFromWriter
<W extends Writer> Format getFormatFromWriter(Class<W> writerClass)
Formatlookup method using theWritercomponent.- Parameters:
writerClass- the class of theWritercomponent for the desiredFormat- Returns:
- A reference to the queried
Format, or null if theFormatwas not found.
-
getWriterForLocation
Writer getWriterForLocation(org.scijava.io.location.Location fileId) throws FormatException
Writerlookup method using the suffix or other methods to locate a fitting writer. This bypasses theCheckerlogic, and thus does not guarantee the associatedFormatcan read image sources of the provided type.- Throws:
FormatException- if now writer could be found
-
getFormatFromChecker
<C extends Checker> Format getFormatFromChecker(Class<C> checkerClass)
Formatlookup method using theCheckercomponent.- Parameters:
checkerClass- the class of theCheckercomponent for the desiredFormat- Returns:
- A reference to the queried
Format, or null if theFormatwas not found.
-
getFormatFromParser
<P extends Parser> Format getFormatFromParser(Class<P> parserClass)
Formatlookup method using theParsercomponent.- Parameters:
parserClass- the class of theParsercomponent for the desiredFormat- Returns:
- A reference to the queried
Format, or null if theFormatwas not found.
-
getFormatFromMetadata
<M extends Metadata> Format getFormatFromMetadata(Class<M> metadataClass)
Formatlookup method using theMetadatacomponent.- Parameters:
metadataClass- the class of theMetadatacomponent for the desiredFormat- Returns:
- A reference to the queried
Format, or null if theFormatwas not found.
-
getFormat
Format getFormat(org.scijava.io.location.Location id) throws FormatException
Returns the firstFormatknown to be compatible with the source provided. Formats are checked in ascending order of their priority. The source is read if necessary to determine compatibility.- Parameters:
id- the source- Returns:
- A
Formatcompatible with the provided source - Throws:
FormatException- if no compatible format was found, or if something goes wrong checking the source
-
getFormat
Format getFormat(org.scijava.io.location.Location id, SCIFIOConfig config) throws FormatException
Returns the first Format known to be compatible with the source provided. Formats are checked in ascending order of their priority.- Parameters:
id- the sourceconfig- Configuration for this method execution.- Returns:
- A
Formatcompatible with the provided source - Throws:
FormatException- if no compatible format was found, or if something goes wrong checking the source
-
getFormatList
List<Format> getFormatList(org.scijava.io.location.Location id) throws FormatException
Returns a list of all formats that are compatible with the source provided, ordered by their priority. The source is read if necessary to determine compatibility.- Parameters:
id- the source- Returns:
- A list of
Formats compatible with the provided source, which will be an empty list if no compatible formats are found. - Throws:
FormatException- if something goes wrong checking the source.
-
getFormatList
List<Format> getFormatList(org.scijava.io.location.Location id, SCIFIOConfig config, boolean greedy) throws FormatException
Returns a list of all formats that are compatible with the source provided, ordered by their priority.- Parameters:
id- the sourceconfig- Configuration for this method execution.greedy- if true, the search will terminate after finding the first compatible format- Returns:
- A list of
Formats compatible with the provided source, which will be an empty list if no compatible formats are found. - Throws:
FormatException- if something goes wrong checking the source.
-
getFormat
Format getFormat(org.scijava.io.handle.DataHandle<org.scijava.io.location.Location> source) throws FormatException
AsgetFormat(Location)but takes an initializedDataHandle.- Parameters:
source- the source- Returns:
- A
Formatcompatible with the provided source - Throws:
FormatException- if no compatible format was found, or if something goes wrong checking the source
-
getFormat
Format getFormat(org.scijava.io.handle.DataHandle<org.scijava.io.location.Location> source, SCIFIOConfig config) throws FormatException
AsgetFormat(Location, SCIFIOConfig)but takes an initializedDataHandle.- Parameters:
source- the sourceconfig- Configuration for this method execution.- Returns:
- A
Formatcompatible with the provided source - Throws:
FormatException- if no compatible format was found, or if something goes wrong checking the source
-
getFormatList
List<Format> getFormatList(org.scijava.io.handle.DataHandle<org.scijava.io.location.Location> source) throws FormatException
AsgetFormatList(Location)but takes an initializedDataHandle.- Parameters:
source- the source- Returns:
- A list of
Formats compatible with the provided source, which will be an empty list if no compatible formats are found. - Throws:
FormatException- if something goes wrong checking the source.
-
getFormatList
List<Format> getFormatList(org.scijava.io.handle.DataHandle<org.scijava.io.location.Location> source, SCIFIOConfig config, boolean greedy) throws FormatException
AsgetFormatList(Location, SCIFIOConfig, boolean)but takes an initializedDataHandle.- Parameters:
source- the sourceconfig- Configuration for this method execution.greedy- if true, the search will terminate after finding the first compatible format- Returns:
- A list of
Formats compatible with the provided source, which will be an empty list if no compatible formats are found. - Throws:
FormatException- if something goes wrong checking the source.
-
getOutputFormats
Collection<Format> getOutputFormats()
- Returns:
- A list of all Formats that have
Writerimplementations.
-
-