Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.mule.transformer
Class AbstractTransformer

    java.lang.Object
      org.mule.transformer.AbstractTransformer

All Implemented Interfaces:
  MuleContextAware, MuleContextNotificationListener<MuleContextNotification>, ServerNotificationListener<MuleContextNotification>, Disposable, Initialisable, NamedObject, MessageProcessor, Transformer, EndpointAware

Direct Known Subclasses:
  AbstractCompressionTransformer, AbstractDiscoverableTransformer, AbstractEncryptionTransformer, AbstractEventTransformer, AbstractMessageTransformer, AddBookResponse, Base64Decoder, Base64Encoder, BeanToMap, ByteArrayToHexString, ByteArrayToSerializable, ChatStringToString, EmailMessageToString, ErrorMessageToException, ErrorMessageToExceptionBean, ExceptionBeanToErrorMessage, ExceptionToString, GetBeanProperty, HexStringToByteArray, HttpClientMethodResponseToObject, HttpRequestToNameString, HttpResponseToString, JAXBMarshallerTransformer, JAXBUnmarshallerTransformer, JXPathExtractor, MapLookup, MapToBean, MimeMessageToRfc822ByteArray, NameStringToChatString, NoActionTransformer, ObjectArrayToString, ObjectToOutputHandler, ObjectToRemoteInvocationResultTransformer, ObjectToRemoteInvocationTransformer, ObjectToString, OrderToEmailTransformer, Rfc822ByteArraytoMimeMessage, SerializableToByteArray, ServletRequestToOutputHandler, SimpleMathTransformer, StdinToNameString, StringAppendTransformer, StringToNameString, StringToNumber, StringToObjectArray, ValidateResponse, XmlEntityDecoder, XmlEntityEncoder, XmlPrettyPrinter, XPathExtractor

    public abstract class AbstractTransformer

extends Object
implements Transformer, MuleContextNotificationListener<MuleContextNotification>

`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?
`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)`
`void` | `onNotification(MuleContextNotification notification)`
`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)` 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)` 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

### MULE_MESSAGE_DATA_TYPE

    public static final DataType<MuleMessage> MULE_MESSAGE_DATA_TYPE

### muleContext

    protected MuleContext muleContext

### logger

    protected final Log logger

### returnType

    protected DataType<?> returnType

  The return type that will be returned by the `transform(java.lang.Object)` method is called

### name

    protected String name

  The name that identifies this transformer. If none is set the class name of the transformer is used

### endpoint

    protected ImmutableEndpoint endpoint

  The endpoint that this transformer instance is configured on

### sourceTypes

    protected final List<DataType<?>> sourceTypes

  A list of supported Class types that the source payload passed into this transformer

### mimeType

    protected String mimeType

### encoding

    protected String encoding

Constructor Detail

### AbstractTransformer

    public AbstractTransformer()

  default constructor required for discovery

Method Detail

### process

    public MuleEvent process(MuleEvent event)
                      throws MuleException

  Description copied from interface: `MessageProcessor`
  Invokes the MessageProcessor.

  Specified by:
    `process` in interface `MessageProcessor`
  Parameters:
    `event` - MuleEvent to be processed
  Returns:
    optional response MuleEvent
  Throws:
    `MuleException`

### checkReturnClass

    protected Object checkReturnClass(Object object)
                               throws TransformerException

  Throws:
    `TransformerException`

### registerSourceType

    @Deprecated
    protected void registerSourceType(Class<?> aClass)

  Deprecated. use registerSourceType(DataType)

  Register a supported data type with this transformer. The will allow objects that match this data type to be transformed by this transformer.

  Parameters:
    `aClass` - the source type to allow

### unregisterSourceType

    @Deprecated
    protected void unregisterSourceType(Class<?> aClass)

  Deprecated. use unregisterSourceType(DataType)

  Unregister a supported source type from this transformer

  Parameters:
    `aClass` - the type to remove

### registerSourceType

    protected void registerSourceType(DataType<?> dataType)

  Register a supported data type with this transformer. The will allow objects that match this data type to be transformed by this transformer.

  Parameters:
    `dataType` - the source type to allow

### unregisterSourceType

    protected void unregisterSourceType(DataType<?> dataType)

  Unregister a supported source type from this transformer

  Parameters:
    `dataType` - the type to remove

### getName

    public String getName()

  Description copied from interface: `NamedObject`
  Gets the name of the object

  Specified by:
    `getName` in interface `NamedObject`
  Returns:
    transformer name

### setName

    public void setName(String string)

  Description copied from interface: `NamedObject`
  Sets the name of the object

  Specified by:
    `setName` in interface `NamedObject`
  Parameters:
    `string` -

### getReturnClass

    @Deprecated
    public Class<?> getReturnClass()

  Deprecated.

  Description copied from interface: `Transformer`
  Specifies the Java type of the result after this transformer has been executed. Mule will use this to validate the return type but also allow users to perform automatic transformations based on the source type of the object to transform and this return type.

  Specified by:
    `getReturnClass` in interface `Transformer`
  Returns:
    the excepted return type from this transformer

### setReturnDataType

    public void setReturnDataType(DataType<?> type)

  Description copied from interface: `Transformer`
  Sets the expected return type for the transformed data. If the transformed data is not of this class type a `TransformerException` will be thrown.

  This method superseeds `Transformer.getReturnClass()` because it allows Generics information to be associated with the return type of the transformer

  Specified by:
    `setReturnDataType` in interface `Transformer`
  Parameters:
    `type` - the expected return type for this transformer

### getReturnDataType

    public DataType<?> getReturnDataType()

  Description copied from interface: `Transformer`
  Specifies the return type of the result after this transformer has been executed. Mule will use this to validate the return type but also allow users to perform automatic transformations based on the source type of the object to transform and this return type.

  This method superseeds `Transformer.getReturnClass()` because it allows Generics information to be associated with the return type of the transformer

  Specified by:
    `getReturnDataType` in interface `Transformer`
  Returns:
    the excepted return type for this transformer

### setReturnClass

    @Deprecated
    public void setReturnClass(Class<?> newClass)

  Deprecated.

  Description copied from interface: `Transformer`
  Sets the expected return type for the transformed data. If the transformed data is not of this class type a `TransformerException` will be thrown.

  Specified by:
    `setReturnClass` in interface `Transformer`
  Parameters:
    `newClass` - the expected return type class

### setMimeType

    public void setMimeType(String mimeType)
                     throws MimeTypeParseException

  Throws:
    `MimeTypeParseException`

### getMimeType

    public String getMimeType()

  Description copied from interface: `Transformer`
  Return the mime type returned by the transformer (if any).

  Specified by:
    `getMimeType` in interface `Transformer`

### getEncoding

    public String getEncoding()

  Description copied from interface: `Transformer`
  Return the encoding returned by the transformer (if any).

  Specified by:
    `getEncoding` in interface `Transformer`

### setEncoding

    public void setEncoding(String encoding)

### isAllowNullReturn

    public boolean isAllowNullReturn()

### setAllowNullReturn

    public void setAllowNullReturn(boolean allowNullReturn)

### isSourceTypeSupported

    @Deprecated
    public boolean isSourceTypeSupported(Class<?> aClass)

  Deprecated.

  Description copied from interface: `Transformer`
  Determines if a particular source class can be handled by this transformer

  Specified by:
    `isSourceTypeSupported` in interface `Transformer`
  Parameters:
    `aClass` - The class to check for compatability
  Returns:
    true if the transformer supports this type of class or false otherwise

### isSourceDataTypeSupported

    public boolean isSourceDataTypeSupported(DataType<?> dataType)

  Description copied from interface: `Transformer`
  Determines if a particular source class can be handled by this transformer

  Specified by:
    `isSourceDataTypeSupported` in interface `Transformer`
  Parameters:
    `dataType` - The DataType to check for compatability
  Returns:
    true if the transformer supports this type of class or false otherwise

### isSourceTypeSupported

    @Deprecated
    public boolean isSourceTypeSupported(Class<MuleMessage> aClass,
                                                    boolean exactMatch)

  Deprecated. use `isSourceDataTypeSupported(org.mule.api.transformer.DataType, boolean)`

  Determines whether that data type passed in is supported by this transformer

  Parameters:
    `aClass` - the type to check against
    `exactMatch` - 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
  Returns:
    true if the source type is supported by this transformer, false otherwise

### isSourceDataTypeSupported

    public boolean isSourceDataTypeSupported(DataType<?> dataType,
                                             boolean exactMatch)

  Determines whether that data type passed in is supported by this transformer

  Parameters:
    `dataType` - the type to check against
    `exactMatch` - 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.
  Returns:
    true if the source type is supported by this transformer, false otherwise

### transform

    public final Object transform(Object src)
                           throws TransformerException

  Description copied from interface: `Transformer`
  Thransforms the supplied data and returns the result

  Specified by:
    `transform` in interface `Transformer`
  Parameters:
    `src` - the data to transform
  Returns:
    the transformed data
  Throws:
    `TransformerException` - if a error occurs transforming the data or if the expected returnClass isn't the same as the transformed data

### transform

    public Object transform(Object src,
                            String enc)
                     throws TransformerException

  Description copied from interface: `Transformer`
  Thransforms the supplied data and returns the result

  Specified by:
    `transform` in interface `Transformer`
  Parameters:
    `src` - the data to transform
    `enc` - 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
  Returns:
    the transformed data
  Throws:
    `TransformerException` - if a error occurs transforming the data or if the expected returnClass isn't the same as the transformed data

### getEncoding

    protected String getEncoding(Object src)

### isConsumed

    protected boolean isConsumed(Class<?> srcCls)

### getEndpoint

    public ImmutableEndpoint getEndpoint()

  Description copied from interface: `Transformer`
  The endpoint that this transformer is attached to

  Specified by:
    `getEndpoint` in interface `Transformer`
  Returns:
    the endpoint associated with the transformer

### setEndpoint

    public void setEndpoint(ImmutableEndpoint endpoint)

  Specified by:
    `setEndpoint` in interface `EndpointAware`

### doTransform

    protected abstract Object doTransform(Object src,
                                          String enc)
                                   throws TransformerException

  Throws:
    `TransformerException`

### initialise

    public void initialise()
                    throws InitialisationException

  Template method where deriving classes can do any initialisation after the properties have been set on this transformer

  Specified by:
    `initialise` in interface `Initialisable`
  Throws:
    `InitialisationException`
    `RecoverableException` - if an error occurs that can be recovered from

### dispose

    public void dispose()

  Template method where deriving classes can do any clean up any resources or state before the object is disposed.

  Specified by:
    `dispose` in interface `Disposable`

### generateTransformerName

    protected String generateTransformerName()

### getSourceTypes

    @Deprecated
    public List<Class<?>> getSourceTypes()

  Deprecated.

  Description copied from interface: `Transformer`
  Returns an unmodifiable list of Source types registered on this transformer

  Specified by:
    `getSourceTypes` in interface `Transformer`
  Returns:
    an unmodifiable list of Source types registered on this transformer

### getSourceDataTypes

    public List<DataType<?>> getSourceDataTypes()

  Description copied from interface: `Transformer`
  Returns an unmodifiable list of Source types registered on this transformer

  Specified by:
    `getSourceDataTypes` in interface `Transformer`
  Returns:
    an unmodifiable list of Source types registered on this transformer

### isIgnoreBadInput

    public boolean isIgnoreBadInput()

  Description copied from interface: `Transformer`
  By default, Mule will throw an exception if a transformer is invoked with a source object that is not compatible with the transformer. Since transformers are often chained, it is useful to be able to ignore a transformer in the chain and move to the next one.

  Specified by:
    `isIgnoreBadInput` in interface `Transformer`
  Returns:
    true if the transformer can be ignorred if the currnet source type is not supported, false if an exception should be throw due to an incompatible source type being passed in.

### setIgnoreBadInput

    public void setIgnoreBadInput(boolean ignoreBadInput)

### toString

    public String toString()

  Overrides:
    `toString` in class `Object`

### isAcceptNull

    public boolean isAcceptNull()

  Description copied from interface: `Transformer`
  Does this transformer allow null input?

  Specified by:
    `isAcceptNull` in interface `Transformer`
  Returns:
    true if this transformer can accept null input

### setMuleContext

    public void setMuleContext(MuleContext context)

  Specified by:
    `setMuleContext` in interface `MuleContextAware`

### onNotification

    public void onNotification(MuleContextNotification notification)

  Specified by:
    `onNotification` in interface `ServerNotificationListener<MuleContextNotification>`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2003-2010 MuleSoft, Inc.. All Rights Reserved.