public class CsvWriter extends ConditionedProcessor implements Service
This class implements a listener which will write all its incoming data into a one-by-one line output.
| Modifier and Type | Field and Description |
|---|---|
protected Boolean |
append |
protected boolean |
closed |
protected File |
file |
protected Expression<String> |
fileExpression |
protected String |
filter |
protected boolean |
header |
protected List<String> |
headers |
protected boolean |
headerWritten |
protected String[] |
keys |
protected String |
lastHeader |
protected String |
lastUrlString |
(package private) static org.slf4j.Logger |
log |
protected PrintStream |
p |
protected String |
separator |
protected URL |
url |
protected String |
urlString |
conditioncontext| Constructor and Description |
|---|
CsvWriter() |
CsvWriter(File file)
Create a new DataStreamWriter which writes all data to the given file.
|
CsvWriter(File file,
String separator) |
CsvWriter(OutputStream out) |
CsvWriter(OutputStream out,
String separator) |
CsvWriter(URL url) |
| Modifier and Type | Method and Description |
|---|---|
protected String |
createHeader(Data item) |
void |
finish() |
Boolean |
getAppend() |
List<String> |
getHeaderNames() |
String |
getSeparator() |
String |
getUrl() |
void |
init(ProcessContext ctx) |
boolean |
isHeader() |
Data |
processMatchingData(Data datum) |
void |
reset() |
void |
setAppend(Boolean append) |
void |
setAttributeFilter(String filter) |
void |
setHeader(boolean header) |
void |
setKeys(String[] str) |
void |
setSeparator(String separator) |
void |
setUrl(String url) |
void |
write(Data datum) |
void |
writeHeader(Data datum) |
getCondition, matches, process, setConditionresetStatestatic org.slf4j.Logger log
protected PrintStream p
protected String separator
protected String lastHeader
protected boolean headerWritten
protected String filter
protected boolean closed
protected String[] keys
protected String urlString
protected URL url
protected File file
protected String lastUrlString
protected Expression<String> fileExpression
protected boolean header
protected Boolean append
public CsvWriter()
public CsvWriter(File file) throws IOException
file - IOExceptionpublic CsvWriter(OutputStream out)
out - public CsvWriter(OutputStream out, String separator)
public CsvWriter(File file, String separator) throws IOException
IOException@Parameter(required=true, description="The url to write to.") public void setUrl(String url)
public String getUrl()
public void setAttributeFilter(String filter)
public String getSeparator()
@Parameter(required=false, description="The separator to separate columns, usually \',\'", defaultValue=",") public void setSeparator(String separator)
separator - the separator to set@Parameter(required=false, description="The attributes to write out, leave blank to write out all attributes.") public void setKeys(String[] str)
str - public boolean isHeader()
public void setHeader(boolean header)
public Boolean getAppend()
public void setAppend(Boolean append)
public void init(ProcessContext ctx) throws Exception
init in interface StatefulProcessorinit in class AbstractProcessorExceptionpublic Data processMatchingData(Data datum)
processMatchingData in class ConditionedProcessorstream.io.DataStreamListener#dataArrived(java.util.Map)public void writeHeader(Data datum)
public void write(Data datum)
public void finish()
throws Exception
finish in interface StatefulProcessorfinish in class AbstractProcessorExceptionCopyright © 2014. All rights reserved.