All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jadex.extension.envsupport.evaluation.CSVFileDataConsumer Maven / Gradle / Ivy

Go to download

The Jadex kernel extension envsupport allows for using 2D spaces in concert with components.

There is a newer version: 3.0.117
Show newest version
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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy