Created
July 27, 2015 12:17
-
-
Save ricston-git/3d1aa59a1fe6bda29fcf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.ricston.transformers; | |
import org.mule.api.transformer.TransformerException; | |
import org.mule.transformer.AbstractTransformer; | |
import java.util.Collection; | |
public class CollectionToStringTransformer extends AbstractTransformer{ | |
protected static final String XML_HEADER = "<!--?xml version="1.0" encoding="UTF-8"?-->"; | |
protected static final String PEOPLE1 = ""; | |
protected static final String PEOPLE2 = ""; | |
public String collectionToString(Collection collection){ | |
StringBuilder builder = new StringBuilder(XML_HEADER + "n" + PEOPLE1); | |
for(String s : collection){ | |
builder.append(s.replace(XML_HEADER, "") + "n"); | |
} | |
builder.append(PEOPLE2); | |
return builder.toString(); | |
} | |
@Override | |
protected Object doTransform(Object payload, String encoding) throws TransformerException { | |
return collectionToString((Collection)payload); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment