net.sf.eclipseexeditor.textfilter
Class Filter

java.lang.Object
  extended bynet.sf.eclipseexeditor.textfilter.Filter
Direct Known Subclasses:
ProgressFilter

public class Filter
extends Object

Filter runs a Unix style filter on an input string, returning the result as a String.

 
 Filter myFilter = new Filter("my-filter-command"};
 

Invoke the filter with input:

 String result = myFilter.filter("some text to process");
 
Filter then runs an external process, piping the input string to the process and returning the output.

You can also invoke the filter with an array of Strings to get an array of strings back (possibly of a different length, depending on the output of the filter) or simply provide an input stream.

Filter currently uses the default system encoding to transcode Unicode Java strings into byte arrays and back - the filter pipeline works on byte data.

Currently, any standard error output is lost.

Currently, there is no handling of return codes. The command may not exist or it may receive an error, but this information is lost, unless there is an exception reading the output.

This class (despite its package name) is meant to be usable outside of Eclipse and thus does not use any Eclipse API. Notably, it supports a callback API, intended for subclasses to override, for a progress monitor.