View Javadoc

1   /*
2    * $Id: CommaSplitter.java 19191 2010-08-25 21:05:23Z tcarlson $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.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.test.integration.endpoints;
12  
13  import org.mule.DefaultMuleMessage;
14  import org.mule.api.MuleEvent;
15  import org.mule.api.MuleException;
16  import org.mule.api.MuleMessage;
17  import org.mule.routing.AbstractSplitter;
18  
19  import java.util.ArrayList;
20  import java.util.List;
21  
22  public class CommaSplitter extends AbstractSplitter
23  {
24      @Override
25      protected List<MuleMessage> splitMessage(MuleEvent event) throws MuleException
26      {
27          ArrayList<MuleMessage> result = new ArrayList<MuleMessage>();
28          String[] parts = event.getMessageAsString().split(",");
29          for (int i = 0; i < parts.length; ++i)
30          {
31              result.add(new DefaultMuleMessage(parts[i], muleContext));
32          }
33          return result;
34      }
35  }
36  
37