M - - The source Metadata type required by this TranslatorN - - The destination Metadata type required by this Translatorpublic abstract class AbstractTranslator<M extends Metadata,N extends Metadata> extends AbstractSCIFIOPlugin implements Translator
Translator components.
NB: this class provides a special abstract method:
typedTranslate(Metadata, Metadata). That is the method which should
be overridden when extending this class, and not
translate(Metadata, Metadata) - which has been set up to translate
the type-general Metadata information, delegate to typedTranslate,
and then populate the ImageMetadata of the destination.
Translator,
TranslatorService,
Metadata| Constructor and Description |
|---|
AbstractTranslator() |
| Modifier and Type | Method and Description |
|---|---|
void |
translate(Metadata source,
List<ImageMetadata> sourceImgMeta,
Metadata dest)
As
Translator.translate(Metadata, Metadata) with the format-specific and
image metadata explicitly split out. |
void |
translate(Metadata source,
Metadata dest)
Uses the source
Metadata to populate the destination
Metadata. |
protected void |
translateFormatMetadata(M source,
N dest)
Use format-specific metadata from the source to populate the destination's
format-specific metadata.
|
protected abstract void |
translateImageMetadata(List<ImageMetadata> source,
N dest)
Use format-agnostic metadata (
ImageMetadata to populate the
destination's format-specific metadata. |
protected void |
typedTranslate(M typedSource,
List<ImageMetadata> sourceImgMeta,
N typedDest)
This method provides a hook for subclasses that need access to both the
Metadata and ImageMetadata. |
getVersion, loggetInfo, getPriority, setInfo, setPriority, toStringcontext, getContextclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitdest, sourcegetVersion, loggetIdentifiercontext, getContext, setContextcompareTo, getPriority, setPrioritygetInfo, setInfogetLocationpublic void translate(Metadata source, Metadata dest)
TranslatorMetadata to populate the destination
Metadata. Specifically, the format-specific metadata and/or
ImageMetadata of the source are used to populate the format-
specific metadata of the destination (from which the destination's
ImageMetadata can be derived}.
Note that the destination does not have to be empty, but can be built up through multiple translations. However each translation step is assumed to overwrite any previously existing data.
For a reference to a fresh Metadata instance to use in translation,
consider the Format.createMetadata() method.
translate in interface Translatorsource - Metadata to use to populatedest - Metadata to be populatedFormat.createMetadata()public void translate(Metadata source, List<ImageMetadata> sourceImgMeta, Metadata dest)
TranslatorTranslator.translate(Metadata, Metadata) with the format-specific and
image metadata explicitly split out.
NB: it is NOT GUARANTEED that the Metadata.getAll() method of the
source here will provide equivalent ImageMetadata as sourceImgMeta.
For example, if a MetadataWrapper was used, the two are unlikely to
match up. This is necessary, as Translator discovery depends on the
format of source and destination, but augmentation via wrapping must affect
the underlying ImageMetadata non-destructively.
translate in interface Translatorsource - Metadata to use to populatesourceImgMeta - ImageMetadata to use to populatedest - Metadata to be populatedprotected void typedTranslate(M typedSource, List<ImageMetadata> sourceImgMeta, N typedDest)
Metadata and ImageMetadata. It is provided with concrete
typing for convenience and to limit code duplication.
NB: if this method is just used as a hook to perform some operation
mid-translation, then super.typedTranslate should be called at the
end of the method to continue the normal translation process.
protected abstract void translateImageMetadata(List<ImageMetadata> source, N dest)
ImageMetadata to populate the
destination's format-specific metadata.
This method must be implemented by every AbstractTranslator subclass, as it covers the general case - agnostic of the source.
source - dest - Copyright © 2011–2026 SCIFIO. All rights reserved.