|
||||||||||
| 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 static int |
DEFAULT_TRUNCATE_LENGTH
|
protected ImmutableEndpoint |
endpoint
The endpoint that this transformer instance is configured on |
protected Log |
logger
|
static DataType |
MULE_MESSAGE_ADAPTER_DATA_TYPE
|
static DataType |
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 |
| Constructor Summary | |
|---|---|
AbstractTransformer()
default constructor required for discovery |
|
| Method Summary | |
|---|---|
protected Object |
checkReturnClass(Object object)
|
protected abstract Object |
doTransform(Object src,
String encoding)
|
protected String |
generateTransformerName()
|
protected String |
getEncoding(Object src)
|
ImmutableEndpoint |
getEndpoint()
The endpoint that this transformer is attached to |
String |
getName()
Gets the name of the object |
Class |
getReturnClass()
Specifies the Java type of the result after this transformer has been executed. |
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()
Returns an unmodifiable list of Source types registered on this transformer |
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)
Determines if a particular source class can be handled by this transformer |
boolean |
isSourceTypeSupported(Class aClass,
boolean exactMatch)
Deprecated. use isSourceDataTypeSupported(org.mule.api.transformer.DataType, boolean) |
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 |
setEndpoint(ImmutableEndpoint endpoint)
Sets the endpoint associated with with this connector. |
void |
setIgnoreBadInput(boolean ignoreBadInput)
|
void |
setMuleContext(MuleContext context)
|
void |
setName(String string)
Sets the name of the object |
void |
setReturnClass(Class newClass)
Sets the expected return type for the transformed data. |
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 encoding)
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 MULE_MESSAGE_DATA_TYPE
public static final DataType MULE_MESSAGE_ADAPTER_DATA_TYPE
protected static final int DEFAULT_TRUNCATE_LENGTH
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
| Constructor Detail |
|---|
public AbstractTransformer()
| Method Detail |
|---|
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 - 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 Transformerpublic void setReturnClass(Class newClass)
TransformerTransformerException will be
thrown.
setReturnClass in interface TransformernewClass - the expected return type classpublic 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 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 encoding)
throws TransformerException
Transformer
transform in interface Transformersrc - the data to transformencoding - 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 encoding)
throws TransformerException
TransformerException
public void initialise()
throws InitialisationException
initialise in interface InitialisableInitialisationException
RecoverableException - if an error occurs that can be recovered fromprotected String generateTransformerName()
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 MuleContextAware
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||