de.hpi.fgis.dude.output.statisticoutput
Class CSVStatisticOutput

java.lang.Object
  extended by de.hpi.fgis.dude.output.statisticoutput.AbstractStatisticOutput
      extended by de.hpi.fgis.dude.output.statisticoutput.CSVStatisticOutput
All Implemented Interfaces:
StatisticOutput, AutoJsonable, Jsonable

public class CSVStatisticOutput
extends AbstractStatisticOutput
implements Jsonable

CSVStatisticOutput writes the statistics provided by a StatisticComponent instance into a CSV file.

Author:
Ziawasch Abedjan, Matthias Pohl, Fabian Lindenberg, Uwe Draisbach, Cindy Faehnrich

Field Summary
 
Fields inherited from class de.hpi.fgis.dude.output.statisticoutput.AbstractStatisticOutput
defaultLabels
 
Constructor Summary
protected CSVStatisticOutput()
          Internal constructor for Jsonable deserialization.
  CSVStatisticOutput(File csvFile, char sep)
          Initializes a CSVStatisticOutput with no statistics.
  CSVStatisticOutput(File csvFile, StatisticComponent statistics, char sep)
          Initializes the CSVStatisticOutput.
  CSVStatisticOutput(OutputStream out, char sep)
          Initializes a CSVStatisticOutput with no statistics.
  CSVStatisticOutput(OutputStream out, StatisticComponent statistics, char sep)
          Initializes the CSVStatisticOutput.
 
Method Summary
 void close()
          Closes the CSVWriter.
 void disableHeader()
          Disables writing the header into the output.
 void enableHeader()
          Enables writing the header into the output.
 void fromJson(DuDeJsonParser<?> jsonParser)
          Initializes the current instance using the passed DuDeJsonParser.
protected  Map<String,String> getConvertedStatistics()
          Converts the data of the StatisticComponent into a Map.
 void toJson(DuDeJsonGenerator jsonGenerator)
          Generates the Json code using the passed DuDeJsonGenerator.
 boolean writeHeader()
          Checks whether the header information will be written into the output.
 void writeStatistics()
          Writes the stored statistics.
 
Methods inherited from class de.hpi.fgis.dude.output.statisticoutput.AbstractStatisticOutput
getLabels, getOptionalEntries, getStatistics, resetOptionalStatisticEntries, setOptionalStatisticEntry, setOptionalStatisticEntry, setStatistics
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CSVStatisticOutput

public CSVStatisticOutput(OutputStream out,
                          char sep)
Initializes a CSVStatisticOutput with no statistics. The statistics need to be set later on.

Parameters:
out - The output stream that is used for the output.
sep - The used separator character.

CSVStatisticOutput

public CSVStatisticOutput(OutputStream out,
                          StatisticComponent statistics,
                          char sep)
Initializes the CSVStatisticOutput.

Parameters:
out - The output stream that is used for the output.
statistics - The StatisticComponent instance that provides all the statistics.
sep - The used separator character.

CSVStatisticOutput

public CSVStatisticOutput(File csvFile,
                          char sep)
                   throws FileNotFoundException
Initializes a CSVStatisticOutput with no statistics. The statistics need to be set later on.

Parameters:
csvFile - The file to write to.
sep - The used separator character.
Throws:
FileNotFoundException

CSVStatisticOutput

public CSVStatisticOutput(File csvFile,
                          StatisticComponent statistics,
                          char sep)
                   throws FileNotFoundException
Initializes the CSVStatisticOutput.

Parameters:
csvFile - The file to write to.
statistics - The StatisticComponent instance that provides all the statistics.
sep - The used separator character.
Throws:
FileNotFoundException

CSVStatisticOutput

protected CSVStatisticOutput()
Internal constructor for Jsonable deserialization.

Method Detail

disableHeader

public void disableHeader()
Disables writing the header into the output.


enableHeader

public void enableHeader()
Enables writing the header into the output.


writeHeader

public boolean writeHeader()
Checks whether the header information will be written into the output.

Returns:
true, if the header information will be written into the output; otherwise false.

getConvertedStatistics

protected Map<String,String> getConvertedStatistics()
Converts the data of the StatisticComponent into a Map.

Returns:
A Map containing the converted statistics.

writeStatistics

public void writeStatistics()
                     throws IOException
Description copied from interface: StatisticOutput
Writes the stored statistics. May throw an IOException.

Specified by:
writeStatistics in interface StatisticOutput
Specified by:
writeStatistics in class AbstractStatisticOutput
Throws:
IOException - If an error occurs while writing to the output.

close

public void close()
Closes the CSVWriter.

Specified by:
close in interface StatisticOutput
Specified by:
close in class AbstractStatisticOutput

fromJson

public void fromJson(DuDeJsonParser<?> jsonParser)
              throws org.codehaus.jackson.JsonParseException,
                     IOException
Description copied from interface: Jsonable
Initializes the current instance using the passed DuDeJsonParser.

Specified by:
fromJson in interface Jsonable
Parameters:
jsonParser - The parser that is used for extracting the data out of the Json.
Throws:
org.codehaus.jackson.JsonParseException - If an error occurs while parsing the Json.
IOException - If an error occurs while reading from the stream.

toJson

public void toJson(DuDeJsonGenerator jsonGenerator)
            throws org.codehaus.jackson.JsonGenerationException,
                   IOException
Description copied from interface: Jsonable
Generates the Json code using the passed DuDeJsonGenerator.

Specified by:
toJson in interface Jsonable
Parameters:
jsonGenerator - The DuDeJsonGenerator that is used internally.
Throws:
org.codehaus.jackson.JsonGenerationException - If an error occurs while generating the Json syntax.
IOException - If an error occurs while writing to the output.


Copyright © 2011 Hasso Plattner Institute - Chair of Information Systems. All Rights Reserved.