View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.test.integration.endpoints;
8   
9   import org.mule.DefaultMuleMessage;
10  import org.mule.api.MuleEvent;
11  import org.mule.api.MuleException;
12  import org.mule.api.MuleMessage;
13  import org.mule.routing.AbstractSplitter;
14  
15  import java.util.ArrayList;
16  import java.util.List;
17  
18  public class CommaSplitter extends AbstractSplitter
19  {
20      @Override
21      protected List<MuleMessage> splitMessage(MuleEvent event) throws MuleException
22      {
23          ArrayList<MuleMessage> result = new ArrayList<MuleMessage>();
24          String[] parts = event.getMessageAsString().split(",");
25          for (int i = 0; i < parts.length; ++i)
26          {
27              result.add(new DefaultMuleMessage(parts[i], muleContext));
28          }
29          return result;
30      }
31  }
32  
33