Nuxeo Enterprise Platform 5.1

org.nuxeo.ecm.platform.transform.transformer
Class AbstractTransformer

java.lang.Object
  extended by org.nuxeo.ecm.platform.transform.transformer.AbstractTransformer
All Implemented Interfaces:
Serializable, Transformer
Direct Known Subclasses:
TransformerImpl

public abstract class AbstractTransformer
extends Object
implements Transformer

Abstract transformer.

Define default transformer implementation.

Author:
Julien Anguenot
See Also:
org.nuxeo.ecm.platform.transform.interfaces, Serialized Form

Field Summary
protected  Map<String,Map<String,Serializable>> defaultOptions
           
protected static Log log
           
protected  String name
           
protected  List<String> pluginsChain
           
 
Constructor Summary
protected AbstractTransformer()
           
protected AbstractTransformer(String name, List<String> pluginsChain)
           
 
Method Summary
protected  Blob[] filterSourcesFor(Blob[] blobs, Plugin plugin)
          Filter input blobs sources for a given plugin.
protected  TransformDocument[] filterSourcesFor(TransformDocument[] sources, Plugin plugin)
          Filter input transform document sources for a given plugin.
 Map<String,Map<String,Serializable>> getDefaultOptions()
          Returns the default transformer options.
 String getMimeTypeDestination()
          Returns the mimetype destination this transformer will return as a result.
 List<String> getMimeTypeSources()
          Returns the mimetype source types this transformer is expecting.
 String getName()
          Returns the transformer name.
protected static TransformService getNXTransform()
           
 List<Plugin> getPluginChains()
          Returns the list of plugins chain this transformer will use.
protected  Map<String,Serializable> mergeOptionsFor(Plugin plugin, Map<String,Serializable> options)
          Merge options from a given plugin with the ones the transformer defines for this as overrid purpose plugin.
 void setDefaultOptions(Map<String,Map<String,Serializable>> defaultOptions)
          Sets plugin default options.
 void setName(String name)
          Sets the transformer name.
 void setPluginChains(List<String> pluginsChain)
          Sets the plugin chains given plugin names.
 List<TransformDocument> transform(Map<String,Map<String,Serializable>> options, Blob... blobs)
          Transforms given sources and plugin options.
 List<TransformDocument> transform(Map<String,Map<String,Serializable>> options, TransformDocument... sources)
          Transforms given sources and plugin options.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static final Log log

name

protected String name

defaultOptions

protected Map<String,Map<String,Serializable>> defaultOptions

pluginsChain

protected List<String> pluginsChain
Constructor Detail

AbstractTransformer

protected AbstractTransformer()

AbstractTransformer

protected AbstractTransformer(String name,
                              List<String> pluginsChain)
Method Detail

getNXTransform

protected static TransformService getNXTransform()

getDefaultOptions

public Map<String,Map<String,Serializable>> getDefaultOptions()
Description copied from interface: Transformer
Returns the default transformer options.

The map keys are plugin names. The map values are maps which have string as keys and serializable objects as values.

Specified by:
getDefaultOptions in interface Transformer
Returns:
hashmap holding the default configuration

getMimeTypeDestination

public String getMimeTypeDestination()
Description copied from interface: Transformer
Returns the mimetype destination this transformer will return as a result.

Information taken from the last plugin defined in the plugins chain.

Specified by:
getMimeTypeDestination in interface Transformer
Returns:
string holding the destination mimetype.

getMimeTypeSources

public List<String> getMimeTypeSources()
Description copied from interface: Transformer
Returns the mimetype source types this transformer is expecting.

Information taken from the first plugin defined in the plugins chain.

Specified by:
getMimeTypeSources in interface Transformer
Returns:
list of string representing the mimetypes.

getName

public String getName()
Description copied from interface: Transformer
Returns the transformer name.

Specified by:
getName in interface Transformer
Returns:
string holding the name

getPluginChains

public List<Plugin> getPluginChains()
Description copied from interface: Transformer
Returns the list of plugins chain this transformer will use.

The plugins are registered in the order the transformer should call them to get the expected result.

Specified by:
getPluginChains in interface Transformer
Returns:
list of plugins

setDefaultOptions

public void setDefaultOptions(Map<String,Map<String,Serializable>> defaultOptions)
Description copied from interface: Transformer
Sets plugin default options.

The hashmap keys are plugin names. The hashmap values are hashmaps which have string as keys and serializable objects as values.

Specified by:
setDefaultOptions in interface Transformer

setPluginChains

public void setPluginChains(List<String> pluginsChain)
Description copied from interface: Transformer
Sets the plugin chains given plugin names.

Specified by:
setPluginChains in interface Transformer
Parameters:
pluginsChain - list of strings representing plugin names

setName

public void setName(String name)
Description copied from interface: Transformer
Sets the transformer name.

Specified by:
setName in interface Transformer
Parameters:
name - string containing the tranformer's name

transform

public List<TransformDocument> transform(Map<String,Map<String,Serializable>> options,
                                         Blob... blobs)
Description copied from interface: Transformer
Transforms given sources and plugin options.

Specified by:
transform in interface Transformer
Parameters:
options - plugin options (the keys are the plugin names)
blobs - list of sources as StreamingBlob instances.
Returns:
list of TransformDocument instances.

transform

public List<TransformDocument> transform(Map<String,Map<String,Serializable>> options,
                                         TransformDocument... sources)
Description copied from interface: Transformer
Transforms given sources and plugin options.

Specified by:
transform in interface Transformer
Parameters:
options - plugin options (the keys are the plugin names)
sources - list of sources as TransformDocument instances
Returns:
list of TransformDocument instances.

filterSourcesFor

protected TransformDocument[] filterSourcesFor(TransformDocument[] sources,
                                               Plugin plugin)
Filter input transform document sources for a given plugin.

Note the discrimination is done plugin instance side.

Parameters:
sources - : transform documents instances.
plugin - : a Nuxeo Transform Plugin instance.
Returns:
a filtered list of transform documents.

filterSourcesFor

protected Blob[] filterSourcesFor(Blob[] blobs,
                                  Plugin plugin)
Filter input blobs sources for a given plugin.

Note the discrimination is done plugin instance side.

Parameters:
sources - : Nuxeo Core blob instances.
plugin - : a Nuxeo Transform Plugin instance.
Returns:
a filtered list of blobs.

mergeOptionsFor

protected Map<String,Serializable> mergeOptionsFor(Plugin plugin,
                                                   Map<String,Serializable> options)
Merge options from a given plugin with the ones the transformer defines for this as overrid purpose plugin.

Parameters:
plugin - : a Nuxeo Transform plugin
Returns:
a map from string to serializable.

Nuxeo Enterprise Platform 5.1

Copyright ? 2007 Nuxeo SAS. All Rights Reserved.