View Javadoc

1   /*
2    * $Id: GZipUncompressTransformer.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.transformers.compression;
12  
13  import org.mule.config.i18n.MessageFactory;
14  import org.mule.umo.transformer.TransformerException;
15  
16  import java.io.IOException;
17  
18  import org.apache.commons.lang.SerializationUtils;
19  
20  /**
21   * <code>GZipCompressTransformer</code> TODO
22   */
23  public class GZipUncompressTransformer extends GZipCompressTransformer
24  {
25  
26      public GZipUncompressTransformer()
27      {
28          super();
29      }
30  
31      // @Override
32      public Object doTransform(Object src, String encoding) throws TransformerException
33      {
34          byte[] buffer = null;
35  
36          try
37          {
38              buffer = getStrategy().uncompressByteArray((byte[]) src);
39          }
40          catch (IOException e)
41          {
42              throw new TransformerException(MessageFactory.createStaticMessage("Failed to uncompress message."),
43                  this, e);
44          }
45  
46          if (!getReturnClass().equals(byte[].class))
47          {
48              return SerializationUtils.deserialize(buffer);
49          }
50  
51          return buffer;
52      }
53  
54  }