|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.mule.transformer.AbstractTransformer
public abstract class AbstractTransformer
AbstractTransformer is a base class for all transformers.
Transformations transform one object into another.
| Field Summary | |
|---|---|
protected String |
encoding
|
protected ImmutableEndpoint |
endpoint
The endpoint that this transformer instance is configured on |
protected 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 |
| Fields inherited from interface org.mule.api.lifecycle.Initialisable |
|---|
PHASE_NAME |
| Fields inherited from interface org.mule.api.lifecycle.Disposable |
|---|
PHASE_NAME |
| Constructor Summary | |
|---|---|
AbstractTransformer()
default constructor required for discovery |
|
| Method Summary | |
|---|---|
protected Object |
checkReturnClass(Object object)
|
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? |
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)
Deprecated. use isSourceDataTypeSupported(org.mule.api.transformer.DataType, boolean) |
void |
onNotification(MuleContextNotification notification)
|
MuleEvent |
process(MuleEvent event)
Invokes the MessageProcessor. |
protected void |
registerSourceType(Class<?> aClass)
Register a supported data type with this transformer. |
protected void |
registerSourceType(DataType<?> dataType)
Register a supported data type with this transformer. |
void |
setEncoding(String encoding)
|
void |
setEndpoint(ImmutableEndpoint endpoint)
Sets the endpoint associated with with this connector. |
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)
Thransforms the supplied data and returns the result |
Object |
transform(Object src,
String enc)
Thransforms the supplied data and returns the result |
protected void |
unregisterSourceType(Class<?> aClass)
Unregister a supported source type from this transformer |
protected void |
unregisterSourceType(DataType<?> dataType)
Unregister a supported source type from this transformer |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final DataType<MuleMessage> MULE_MESSAGE_DATA_TYPE
protected MuleContext muleContext
protected final Log logger
protected DataType<?> returnType
transform(java.lang.Object) method is
called
protected String name
protected ImmutableEndpoint endpoint
protected final List<DataType<?>> sourceTypes
protected String mimeType
protected String encoding
| Constructor Detail |
|---|
public AbstractTransformer()
| Method Detail |
|---|
public MuleEvent process(MuleEvent event)
throws MuleException
MessageProcessor
process in interface MessageProcessorevent - MuleEvent to be processed
MuleException
protected Object checkReturnClass(Object object)
throws TransformerException
TransformerExceptionprotected void registerSourceType(Class<?> aClass)
aClass - the source type to allowprotected 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()
NamedObject
getName in interface NamedObjectpublic void setName(String string)
NamedObject
setName in interface NamedObjectstring - @Deprecated public Class<?> getReturnClass()
Transformer
getReturnClass in interface Transformerpublic void setReturnDataType(DataType<?> type)
TransformerTransformerException will be
thrown.
This method superseeds Transformer.getReturnClass() because it allows Generics information to be associated with the
return type of the transformer
setReturnDataType 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 transformer
getReturnDataType in interface Transformer@Deprecated public void setReturnClass(Class<?> newClass)
TransformerTransformerException will be
thrown.
setReturnClass in interface TransformernewClass - the expected return type class
public void setMimeType(String mimeType)
throws MimeTypeParseException
MimeTypeParseExceptionpublic String getMimeType()
Transformer
getMimeType in interface Transformerpublic String getEncoding()
Transformer
getEncoding in interface Transformerpublic void setEncoding(String encoding)
@Deprecated public boolean isSourceTypeSupported(Class<?> aClass)
Transformer
isSourceTypeSupported in interface TransformeraClass - The class to check for compatability
public boolean isSourceDataTypeSupported(DataType<?> dataType)
Transformer
isSourceDataTypeSupported in interface TransformerdataType - The DataType to check for compatability
@Deprecated
public boolean isSourceTypeSupported(Class<MuleMessage> aClass,
boolean exactMatch)
isSourceDataTypeSupported(org.mule.api.transformer.DataType, boolean)
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 flag
public 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
Transformer
transform in interface Transformersrc - the data to transform
TransformerException - if a error occurs transforming the data or if the
expected returnClass isn't the same as the transformed data
public Object transform(Object src,
String enc)
throws TransformerException
Transformer
transform 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 encoding
TransformerException - if a error occurs transforming the data or if the
expected returnClass isn't the same as the transformed dataprotected String getEncoding(Object src)
protected boolean isConsumed(Class<?> srcCls)
public ImmutableEndpoint getEndpoint()
BaseTransformer
getEndpoint in interface BaseTransformerpublic void setEndpoint(ImmutableEndpoint endpoint)
BaseTransformer
setEndpoint in interface BaseTransformerendpoint - sets the endpoint associated with the transfromer
protected abstract Object doTransform(Object src,
String enc)
throws TransformerException
TransformerException
public void initialise()
throws InitialisationException
initialise in interface InitialisableInitialisationException
RecoverableException - if an error occurs that can be recovered frompublic void dispose()
dispose in interface Disposableprotected String generateTransformerName()
@Deprecated public List<Class<?>> getSourceTypes()
Transformer
getSourceTypes in interface Transformerpublic List<DataType<?>> getSourceDataTypes()
Transformer
getSourceDataTypes in interface Transformerpublic boolean isIgnoreBadInput()
Transformer
isIgnoreBadInput in interface Transformerpublic void setIgnoreBadInput(boolean ignoreBadInput)
public String toString()
toString in class Objectpublic boolean isAcceptNull()
Transformer
isAcceptNull in interface Transformerpublic void setMuleContext(MuleContext context)
setMuleContext in interface MuleContextAwarepublic void onNotification(MuleContextNotification notification)
onNotification in interface ServerNotificationListener<MuleContextNotification>
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||