|
||||||||||
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 |
Fields inherited from interface org.mule.api.AnnotatedObject |
---|
PROPERTY_NAME |
Constructor Summary | |
---|---|
AbstractTransformer()
default constructor required for discovery |
Method Summary | |
---|---|
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()
|
Object |
getAnnotation(QName name)
Gets the value of specified annotation. |
Map<QName,Object> |
getAnnotations()
Gets all annotations. |
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)
Deprecated. use isSourceDataTypeSupported(org.mule.api.transformer.DataType, boolean) |
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 |
setAnnotations(Map<QName,Object> newAnnotations)
Sets annotations to the object. |
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 |
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 MessageProcessor
event
- MuleEvent to be processed
MuleException
@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()
NamedObject
getName
in interface NamedObject
public void setName(String string)
NameableObject
setName
in interface NameableObject
string
- @Deprecated public Class<?> getReturnClass()
Transformer
getReturnClass
in interface Transformer
public void setReturnDataType(DataType<?> type)
Transformer
TransformerException
will be
thrown.
This method supersedes Transformer.getReturnClass()
because it allows Generics information to be associated with the
return type of the transformer
setReturnDataType
in interface Transformer
type
- the expected return type for this transformerpublic DataType<?> getReturnDataType()
Transformer
Transformer.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)
Transformer
TransformerException
will be
thrown.
setReturnClass
in interface Transformer
newClass
- the expected return type classpublic void setMimeType(String mimeType) throws MimeTypeParseException
MimeTypeParseException
public String getMimeType()
Transformer
getMimeType
in interface Transformer
public String getEncoding()
Transformer
getEncoding
in interface Transformer
public void setEncoding(String encoding)
public boolean isAllowNullReturn()
public void setAllowNullReturn(boolean allowNullReturn)
@Deprecated public boolean isSourceTypeSupported(Class<?> aClass)
Transformer
isSourceTypeSupported
in interface Transformer
aClass
- The class to check for compatibility
public boolean isSourceDataTypeSupported(DataType<?> dataType)
Transformer
isSourceDataTypeSupported
in interface Transformer
dataType
- The DataType to check for compatibility
@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 Transformer
src
- the data to transform
TransformerException
- 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
Transformer
transform
in interface Transformer
src
- 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()
Transformer
getEndpoint
in interface Transformer
public void setEndpoint(ImmutableEndpoint endpoint)
setEndpoint
in interface EndpointAware
protected abstract Object doTransform(Object src, String enc) throws TransformerException
TransformerException
public void initialise() throws InitialisationException
initialise
in interface Initialisable
InitialisationException
RecoverableException
- if an error occurs that can be recovered frompublic void dispose()
dispose
in interface Disposable
protected String generateTransformerName()
@Deprecated public List<Class<?>> getSourceTypes()
Transformer
getSourceTypes
in interface Transformer
public List<DataType<?>> getSourceDataTypes()
Transformer
getSourceDataTypes
in interface Transformer
public boolean isIgnoreBadInput()
Transformer
isIgnoreBadInput
in interface Transformer
public void setIgnoreBadInput(boolean ignoreBadInput)
public String toString()
toString
in class Object
public boolean isAcceptNull()
Transformer
isAcceptNull
in interface Transformer
public void setMuleContext(MuleContext context)
setMuleContext
in interface MuleContextAware
public final Object getAnnotation(QName name)
AnnotatedObject
getAnnotation
in interface AnnotatedObject
public final Map<QName,Object> getAnnotations()
AnnotatedObject
getAnnotations
in interface AnnotatedObject
public final void setAnnotations(Map<QName,Object> newAnnotations)
AnnotatedObject
setAnnotations
in interface AnnotatedObject
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |