Code that transforms a specific document type in a T-Engine generally implements the Transformer interface. In addition to the transform method, extractMetadata and embedMetadata methods will be called depending on the target media type. The implementing class is called from the transformImpl method of the controller class.
default void transform(String transformName, String sourceMimetype, String targetMimetype,
Map<String, String> transformOptions,
File sourceFile, File targetFile) throws Exception {
}
default void extractMetadata(String transformName, String sourceMimetype, String targetMimetype,
Map<String, String> transformOptions,
File sourceFile, File targetFile) throws Exception {
}
default void embedMetadata(String transformName, String sourceMimetype, String targetMimetype,
Map<String, String> transformOptions,
File sourceFile, File targetFile) throws Exception {
}
It is typical for the extractMetadata method to call another extractMetadata method on a sub class of AbstractMetadataExtractor as this class provides the bulk of the functionality needed to configure metadata extraction or embedding.
public void extractMetadata(String transformName, String sourceMimetype, String targetMimetype,
Map<String, String> transformOptions,
File sourceFile, File targetFile) throws Exception
{
AbstractMetadataExtractor extractor = ...
extractor.extractMetadata(sourceMimetype, transformOptions, sourceFile, targetFile);
}
// Similar code for embedMetadata