As an example, consider a plugin that removes all occurrences of the ASCII 1 (one) character, '\1', by replacing it with an empty string. Such a plugin could be implemented according to the following:
public class AsciiOneRemover { public static void main(String[] args) { String regex = "\\x01"; String replacement = ""; new RegExReplacePlugin(regex, replacement).run(); } }Note that in this implementation, the class AsciiOneRemover itself is not a
PipelinePlugin
; it only has a main method that is invoked by the Jitterbit Pipeline Plugin Framework. The PipelinePlugin
is created and executed in that method. In a slightly modified version of the above example, the following plugin implementation removes all occurrences of '\1', and writes the result to output files having the name [input file name]_modified.[input file extension]
:
public class AsciiOneRemover extends RegExReplacePlugin { public AsciiOneRemover() { super("\\x01", ""); } public File getOutputFilePath(InputFile inputFile) { File f0 = inputFile.getFile(); File parent = f0.getParentFile(); String name = f0.getName(); String extension = getExtension(name); String newName = name + "_modified" + extension; return new File(parent, newName); } private static String getExtension(String name) { int pos = name.lastIndexOf('.'); return (pos >= 0) ? name.substring(pos) : ""; } public static void main(String[] args) { new AsciiOneRemover().run(); } }Note that in this case, the
AsciiOneRemover
class must extend RegExReplacePlugin
, so that it can provide a customize implementation of the getOutputFilePath
method.
|
|