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, Initialisable, NamedObject, BaseTransformer, Transformer

Direct Known Subclasses:
  AbstractCompressionTransformer, AbstractDiscoverableTransformer, AbstractEncryptionTransformer, AbstractEventTransformer, AbstractMessageAwareTransformer, AddBookResponse, Base64Decoder, Base64Encoder, BeanToMap, ByteArrayToHexString, ByteArrayToSerializable, ChatStringToString, CreditProfileXmlToCreditProfile, EmailMessageToString, ErrorMessageToException, ErrorMessageToExceptionBean, ExceptionBeanToErrorMessage, ExceptionToString, GetBeanProperty, HexStringToByteArray, HttpClientMethodResponseToObject, HttpRequestToNameString, HttpResponseToString, IPToSender, JXPathExtractor, LoanQuoteRequestToCreditProfileArgs, 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

`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`
`protected MuleContext` | `muleContext`
`protected String` | `name` The name that identifies this transformer.
`protected Class` | `returnClass` The return type that will be returned by the `transform(java.lang.Object)` method is called
`protected List<Class>` | `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.
`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` | `isSourceTypeSupported(Class aClass)` Determines if a particular source class can be handled by this transformer
`boolean` | `isSourceTypeSupported(Class aClass, boolean exactMatch)`
`protected void` | `registerSourceType(Class aClass)`
`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.
`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)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### DEFAULT_TRUNCATE_LENGTH

    protected static final int DEFAULT_TRUNCATE_LENGTH

See Also:
  Constant Field Values

### muleContext

    protected MuleContext muleContext

### logger

    protected final Log logger

### returnClass

    protected Class returnClass

  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<Class> sourceTypes

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

Constructor Detail

### AbstractTransformer

    public AbstractTransformer()

  default constructor required for discovery

Method Detail

### checkReturnClass

    protected Object checkReturnClass(Object object)
                               throws TransformerException

  Throws:
    `TransformerException`

### registerSourceType

    protected void registerSourceType(Class aClass)

### unregisterSourceType

    protected void unregisterSourceType(Class aClass)

### 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

    public Class getReturnClass()

  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

### setReturnClass

    public void setReturnClass(Class newClass)

  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

### isSourceTypeSupported

    public boolean isSourceTypeSupported(Class aClass)

  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

### isSourceTypeSupported

    public boolean isSourceTypeSupported(Class aClass,
                                         boolean exactMatch)

### 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 encoding)
                     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
    `encoding` - 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: `BaseTransformer`
  The endpoint that this transformer is attached to

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

### setEndpoint

    public void setEndpoint(ImmutableEndpoint endpoint)

  Description copied from interface: `BaseTransformer`
  Sets the endpoint associated with with this connector. This should be idempotent, since endpoints do not guarantee it will only be called once.

  Specified by:
    `setEndpoint` in interface `BaseTransformer`
  Parameters:
    `endpoint` - sets the endpoint associated with the transfromer

### doTransform

    protected abstract Object doTransform(Object src,
                                          String encoding)
                                   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

### generateTransformerName

    protected String generateTransformerName()

### getSourceTypes

    public List<Class> getSourceTypes()

  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

### 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`

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-2009 MuleSource, Inc.. All Rights Reserved.