Mp3dings 
20100427

net.sourceforge.mp3dings.export
Class CSVExporter

java.lang.Object
  extended by net.sourceforge.mp3dings.export.AbstractExporter
      extended by net.sourceforge.mp3dings.export.CSVExporter
All Implemented Interfaces:
Serializable, Exporter

public class CSVExporter
extends AbstractExporter
implements Serializable

Exports data as a comma separated file (csv, spreadsheet interchange format).

Version:
$Revision: 13 $ ($Date: 2007-07-27 11:52:39 +0200 (Fr, 27 Jul 2007) $)
Author:
Moritz Ringler
See Also:
Serialized Form

Constructor Summary
CSVExporter()
          Creates a new csv exporter with the encoding set to ISO-8859-1.
 
Method Summary
 String getBlock(int fileIndex, Map blockdata)
          Produces a single data record for the exported file.
 String getExtension()
          Returns the file extension for this exporter's target file type.
protected  String getFooter(int numEntries)
          Produces an empty footer.
protected  String getHeader()
          Produces a header for the exported csv file consisting of a single line containing the column names separated by the current separator character.
 String getName()
          Returns a string description of this exporter's target type.
 void setSeparator(char delim)
          Changes the character that will separate the fields in a record.
 
Methods inherited from class net.sourceforge.mp3dings.export.AbstractExporter
export, export, getBlockKeys, getFileFallback, getFileFilter, getFooterData, getFooterKeys, getHeaderData, getHeaderKeys, getImplementations, getKeys, getNumberOfEntries, setEncoding, setFileFallback, setFooterData, setHeaderData, setKeys
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CSVExporter

public CSVExporter()
Creates a new csv exporter with the encoding set to ISO-8859-1.

Method Detail

setSeparator

public void setSeparator(char delim)
Changes the character that will separate the fields in a record. If this character occurs in one of the exported values it will be replaced by a blank ' '.
The default separator is a tab '\t' (ASCII character 9).


getBlock

public String getBlock(int fileIndex,
                       Map blockdata)
Produces a single data record for the exported file. Blockdata will be merged into a single string separated by the current separator character. The order of the entries is determined by the order of the keys in the array returned by AbstractExporter.getBlockKeys().

Specified by:
getBlock in class AbstractExporter
Parameters:
fileIndex - ignored
blockdata - the data of a single record as a map. The map will not be changed by this method, and can be reused for further calls to this method.
Returns:
a single data record as a single line string including a final line terminator
See Also:
AbstractExporter.export(Object[] keys, Object[][] data)

getHeader

protected String getHeader()
Produces a header for the exported csv file consisting of a single line containing the column names separated by the current separator character.

Specified by:
getHeader in class AbstractExporter
Returns:
the single-line csv header including a final line terminator

getFooter

protected String getFooter(int numEntries)
Produces an empty footer.

Specified by:
getFooter in class AbstractExporter
Parameters:
numEntries - ignored
Returns:
an empty string

getName

public String getName()
Returns a string description of this exporter's target type.

Specified by:
getName in interface Exporter
Specified by:
getName in class AbstractExporter
Returns:
the name of the target type. Currently this is "Comma separated file (*.csv)", but this may change in future versions.

getExtension

public String getExtension()
Returns the file extension for this exporter's target file type.

Overrides:
getExtension in class AbstractExporter
Returns:
a file extension including the leading dot. Currently this is ".csv", but this may change in future versions.

Mp3dings 
20100427