View Javadoc

1   /*
2    * $Id: UMOTransformer.java 7963 2007-08-21 08:53:15Z dirk.olmes $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  
11  package org.mule.umo.transformer;
12  
13  /**
14   * <code>UMOTransformer</code> can be chained together to covert message payloads
15   * from one object type to another.
16   */
17  public interface UMOTransformer extends UMOBaseTransformer
18  {
19  
20      /**
21       * Determines if a particular source class can be handled by this transformer
22       * 
23       * @param aClass The class to check for compatability
24       * @return true if the transformer supports this types of class or false
25       *         otherwise
26       */
27      boolean isSourceTypeSupported(Class aClass);
28  
29      /**
30       * Does this transformer allow null input?
31       * 
32       * @return true if this transformer can accept null input
33       */
34      boolean isAcceptNull();
35  
36      /**
37       * Thransforms the supplied data and returns the result
38       * 
39       * @param src the data to transform
40       * @return the transformed data
41       * @throws TransformerException if a error occurs transforming the data or if the
42       *             expected returnClass isn't the same as the transformed data
43       */
44      Object transform(Object src) throws TransformerException;
45  
46      /**
47       * Sets the expected return type for the transformed data. If the transformed
48       * data is not of this class type a <code>TransformerException</code> will be
49       * thrown.
50       * 
51       * @param theClass the expected return type class
52       */
53      void setReturnClass(Class theClass);
54  
55      /**
56       * @return the exceptedreturn type
57       */
58      Class getReturnClass();
59  
60      /**
61       * Transformers can be chained together and invoked in a series
62       * 
63       * @return the next transformer to invoke after this one
64       */
65      UMOTransformer getNextTransformer();
66  
67      /**
68       * Transformers can be chained together and invoked in a series
69       * 
70       * @param nextTransformer the next transforer to invoke
71       */
72      void setNextTransformer(UMOTransformer nextTransformer);
73  
74  }