jadex.extension.envsupport.evaluation.CSVFileDataConsumer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jadex-kernel-extension-envsupport Show documentation
Show all versions of jadex-kernel-extension-envsupport Show documentation
The Jadex kernel extension envsupport allows for using 2D spaces in concert with components.
package jadex.extension.envsupport.evaluation;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.Writer;
import java.util.List;
import jadex.commons.SimplePropertyObject;
import jadex.extension.envsupport.environment.AbstractEnvironmentSpace;
/**
* Simple file consumer that writes data into a text file.
*/
public class CSVFileDataConsumer extends SimplePropertyObject implements ITableDataConsumer
{
//-------- constants --------
/** The linefeed separator. */
public static final String lf = (String)System.getProperty("line.separator");
//-------- attributes --------
/** The writer. */
protected Writer writer;
//-------- constructors --------
/**
*
*/
public CSVFileDataConsumer()
{
}
//-------- methods --------
/**
* Consume data from the provider.
*/
public void consumeData(long time, double tick)
{
try
{
ITableDataProvider provider = getTableDataProvider();
DataTable table = provider.getTableData(time, tick);
if(writer==null)
{
String filename = (String)getProperty("filename");
writer = new BufferedWriter(new FileWriter(filename));
String[] colnames = table.getColumnNames();
for(int i=0; i