public abstract class AbstractTransformer extends AbstractAnnotatedObject implements Transformer
AbstractTransformer is a base class for all transformers.
Transformations transform one object into another.| Modifier and Type | Field and Description |
|---|---|
protected String |
encoding |
protected ImmutableEndpoint |
endpoint
The endpoint that this transformer instance is configured on
|
protected org.apache.commons.logging.Log |
logger |
protected String |
mimeType |
static DataType<MuleMessage> |
MULE_MESSAGE_DATA_TYPE |
protected MuleContext |
muleContext |
protected String |
name
The name that identifies this transformer.
|
protected DataType<?> |
returnType
The return type that will be returned by the
transform(java.lang.Object) method is
called |
protected List<DataType<?>> |
sourceTypes
A list of supported Class types that the source payload passed into this
transformer
|
PHASE_NAMEPHASE_NAMEPROPERTY_NAME| Constructor and Description |
|---|
AbstractTransformer()
default constructor required for discovery
|
| Modifier and Type | Method and Description |
|---|---|
void |
dispose()
Template method where deriving classes can do any clean up any resources or state
before the object is disposed.
|
protected abstract Object |
doTransform(Object src,
String enc) |
protected String |
generateTransformerName() |
String |
getEncoding()
Return the encoding returned by the transformer (if any).
|
protected String |
getEncoding(Object src) |
ImmutableEndpoint |
getEndpoint()
The endpoint that this transformer is attached to
|
String |
getMimeType()
Return the mime type returned by the transformer (if any).
|
String |
getName()
Gets the name of the object
|
Class<?> |
getReturnClass()
Deprecated.
|
DataType<?> |
getReturnDataType()
Specifies the return type of the result after this transformer has been executed.
|
List<DataType<?>> |
getSourceDataTypes()
Returns an unmodifiable list of Source types registered on this transformer
|
List<Class<?>> |
getSourceTypes()
Deprecated.
|
void |
initialise()
Template method where deriving classes can do any initialisation after the
properties have been set on this transformer
|
boolean |
isAcceptNull()
Does this transformer allow null input?
|
boolean |
isAllowNullReturn() |
protected boolean |
isConsumed(Class<?> srcCls) |
boolean |
isIgnoreBadInput()
By default, Mule will throw an exception if a transformer is invoked with a source object that is not compatible
with the transformer.
|
boolean |
isSourceDataTypeSupported(DataType<?> dataType)
Determines if a particular source class can be handled by this transformer
|
boolean |
isSourceDataTypeSupported(DataType<?> dataType,
boolean exactMatch)
Determines whether that data type passed in is supported by this transformer
|
boolean |
isSourceTypeSupported(Class<?> aClass)
Deprecated.
|
boolean |
isSourceTypeSupported(Class<MuleMessage> aClass,
boolean exactMatch)
|
MuleEvent |
process(MuleEvent event)
Invokes the MessageProcessor.
|
protected void |
registerSourceType(Class<?> aClass)
Deprecated.
use registerSourceType(DataType)
|
protected void |
registerSourceType(DataType<?> dataType)
Register a supported data type with this transformer.
|
void |
setAllowNullReturn(boolean allowNullReturn) |
void |
setEncoding(String encoding) |
void |
setEndpoint(ImmutableEndpoint endpoint) |
void |
setIgnoreBadInput(boolean ignoreBadInput) |
void |
setMimeType(String mimeType) |
void |
setMuleContext(MuleContext context) |
void |
setName(String string)
Sets the name of the object
|
void |
setReturnClass(Class<?> newClass)
Deprecated.
|
void |
setReturnDataType(DataType<?> type)
Sets the expected return type for the transformed data.
|
String |
toString() |
Object |
transform(Object src)
Transforms the supplied data and returns the result
|
Object |
transform(Object src,
String enc)
Transforms the supplied data and returns the result
|
protected void |
unregisterSourceType(Class<?> aClass)
Deprecated.
use unregisterSourceType(DataType)
|
protected void |
unregisterSourceType(DataType<?> dataType)
Unregister a supported source type from this transformer
|
getAnnotation, getAnnotations, setAnnotationspublic static final DataType<MuleMessage> MULE_MESSAGE_DATA_TYPE
protected MuleContext muleContext
protected final org.apache.commons.logging.Log logger
protected DataType<?> returnType
transform(java.lang.Object) method is
calledprotected String name
protected ImmutableEndpoint endpoint
protected final List<DataType<?>> sourceTypes
protected String mimeType
protected String encoding
public AbstractTransformer()
public MuleEvent process(MuleEvent event) throws MuleException
MessageProcessorprocess in interface MessageProcessorevent - MuleEvent to be processedMuleException@Deprecated protected void registerSourceType(Class<?> aClass)
aClass - the source type to allow@Deprecated protected void unregisterSourceType(Class<?> aClass)
aClass - the type to removeprotected void registerSourceType(DataType<?> dataType)
dataType - the source type to allowprotected void unregisterSourceType(DataType<?> dataType)
dataType - the type to removepublic String getName()
NamedObjectgetName in interface NamedObjectpublic void setName(String string)
NameableObjectsetName in interface NameableObjectstring - @Deprecated public Class<?> getReturnClass()
TransformergetReturnClass in interface Transformerpublic void setReturnDataType(DataType<?> type)
TransformerTransformerException will be
thrown.
This method supersedes Transformer.getReturnClass() because it allows Generics information to be associated with the
return type of the transformersetReturnDataType in interface Transformertype - the expected return type for this transformerpublic DataType<?> getReturnDataType()
TransformerTransformer.getReturnClass() because it allows Generics information to be associated with the
return type of the transformergetReturnDataType in interface Transformer@Deprecated public void setReturnClass(Class<?> newClass)
TransformerTransformerException will be
thrown.setReturnClass in interface TransformernewClass - the expected return type classpublic void setMimeType(String mimeType) throws MimeTypeParseException
MimeTypeParseExceptionpublic String getMimeType()
TransformergetMimeType in interface Transformerpublic String getEncoding()
TransformergetEncoding in interface Transformerpublic void setEncoding(String encoding)
public boolean isAllowNullReturn()
public void setAllowNullReturn(boolean allowNullReturn)
@Deprecated public boolean isSourceTypeSupported(Class<?> aClass)
TransformerisSourceTypeSupported in interface TransformeraClass - The class to check for compatibilitypublic boolean isSourceDataTypeSupported(DataType<?> dataType)
TransformerisSourceDataTypeSupported in interface TransformerdataType - The DataType to check for compatibility@Deprecated public boolean isSourceTypeSupported(Class<MuleMessage> aClass, boolean exactMatch)
aClass - the type to check againstexactMatch - if the source type on this transformer is open (can be anything) it will return true unless an
exact match is requested using this flagpublic boolean isSourceDataTypeSupported(DataType<?> dataType, boolean exactMatch)
dataType - the type to check againstexactMatch - if set to true, this method will look for an exact match to the data type, if false it will look
for a compatible data type.public final Object transform(Object src) throws TransformerException
Transformertransform in interface Transformersrc - the data to transformTransformerException - if a error occurs transforming the data or if the
expected returnClass isn't the same as the transformed datapublic Object transform(Object src, String enc) throws TransformerException
Transformertransform in interface Transformersrc - the data to transformenc - the encoding to use by this transformer. many transformations will not need encoding unless
dealing with text so you only need to use this method if yo wish to customize the encodingTransformerException - if a error occurs transforming the data or if the
expected returnClass isn't the same as the transformed dataprotected boolean isConsumed(Class<?> srcCls)
public ImmutableEndpoint getEndpoint()
TransformergetEndpoint in interface Transformerpublic void setEndpoint(ImmutableEndpoint endpoint)
setEndpoint in interface EndpointAwareprotected abstract Object doTransform(Object src, String enc) throws TransformerException
TransformerExceptionpublic void initialise()
throws InitialisationException
initialise in interface InitialisableInitialisationExceptionRecoverableException - if an error occurs that can be recovered frompublic void dispose()
dispose in interface Disposableprotected String generateTransformerName()
@Deprecated public List<Class<?>> getSourceTypes()
TransformergetSourceTypes in interface Transformerpublic List<DataType<?>> getSourceDataTypes()
TransformergetSourceDataTypes in interface Transformerpublic boolean isIgnoreBadInput()
TransformerisIgnoreBadInput in interface Transformerpublic void setIgnoreBadInput(boolean ignoreBadInput)
public boolean isAcceptNull()
TransformerisAcceptNull in interface Transformerpublic void setMuleContext(MuleContext context)
setMuleContext in interface MuleContextAwareCopyright © 2003–2015 MuleSoft, Inc.. All rights reserved.