maito.browsing.fileexport
Class CSVResourceListFormat

java.lang.Object
  extended by maito.browsing.fileexport.CSVResourceListFormat
All Implemented Interfaces:
FileFormat

public class CSVResourceListFormat
extends java.lang.Object
implements FileFormat

A FileFormat implementation for CSV resource / relation lists.

Author:
Väinö Ala-Härkönen

Constructor Summary
CSVResourceListFormat()
           
 
Method Summary
 void setRelations(ResourceRelation[] relations)
          Sets the relations that are to be written to the file.
 void setResources(Resource[] resources)
          Sets the resources that are to be written to the file.
 boolean writeFile(java.lang.String filename)
          Writes the data set by setResources and setRelations to a file that's in CSV list format: first row has headers of the fields and the following rows have the data.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CSVResourceListFormat

public CSVResourceListFormat()
Method Detail

setResources

public void setResources(Resource[] resources)
Sets the resources that are to be written to the file.

Specified by:
setResources in interface FileFormat
Parameters:
resources - The resources that are to be written to the file. The possible previous set will be replaced.

setRelations

public void setRelations(ResourceRelation[] relations)
Sets the relations that are to be written to the file.

Specified by:
setRelations in interface FileFormat
Parameters:
relations - The relations that are to be written to the file. The possible previous set will be replaced.

writeFile

public boolean writeFile(java.lang.String filename)
Writes the data set by setResources and setRelations to a file that's in CSV list format: first row has headers of the fields and the following rows have the data. The data fields are separated with commas and enclosed in double quotes. If resources or relations have been set, writes one file with the non-null set. If both resources and relations have been set, writes two separate files with suffixes -resources and -relations before the first dot in the filename (ie. dump-resources.csv, dump-relations.csv). The fields included in export are defined in configuration file csvlistexport.properties.

Specified by:
writeFile in interface FileFormat
Parameters:
filename - the full path and name of the file to write the data to
Returns:
true if succeeded, false if there was an error: either the file could not be written or source data was invalid.