org.gswing.components.output.exporter
Class AbstractDbToFile

java.lang.Object
  extended by org.gswing.components.output.exporter.AbstractDbToFile
All Implemented Interfaces:
IExporter
Direct Known Subclasses:
DbToCsv, DbToXml

public abstract class AbstractDbToFile
extends Object
implements IExporter

Purpose: Abstract class for writing election data to file.


Field Summary
protected  int constituencyNo
           
static String CSV
           
static String DATA
           
protected  IDbReadAccess dbAccess
           
protected  Election election
           
protected  Hashtable<Constituency,Result> results
           
protected static char SPACE
           
protected  String targetDir
           
protected static char UNDERSCORE
           
static String XML
           
 
Constructor Summary
AbstractDbToFile(IFramework framework, String gswingHome, String type, boolean uploadFiles)
          Constructor.
 
Method Summary
 void doExport()
          Kick off the export process.
 void export(Vector<Election> elections)
          Kick off the export process.
protected  String getFileName(String extension)
          Build generic file name with the given extension.
 IMessageHandling getLogger()
           
protected abstract  void writeFile()
          Write the election data to file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dbAccess

protected IDbReadAccess dbAccess

election

protected Election election

constituencyNo

protected int constituencyNo

results

protected Hashtable<Constituency,Result> results

DATA

public static final String DATA
See Also:
Constant Field Values

XML

public static final String XML
See Also:
Constant Field Values

CSV

public static final String CSV
See Also:
Constant Field Values

SPACE

protected static final char SPACE
See Also:
Constant Field Values

UNDERSCORE

protected static final char UNDERSCORE
See Also:
Constant Field Values

targetDir

protected String targetDir
Constructor Detail

AbstractDbToFile

public AbstractDbToFile(IFramework framework,
                        String gswingHome,
                        String type,
                        boolean uploadFiles)
Constructor.

Parameters:
framework - The framework object.
gswingHome - The path where gswing is installed.
type - export type string - csv or xml.
uploadFiles - Should files be uploaded to server?
Method Detail

doExport

public void doExport()
Kick off the export process.

Specified by:
doExport in interface IExporter

export

public void export(Vector<Election> elections)
Kick off the export process. Get the election number from the user, get the list of contituencies and get the results for each constituency. Finally write to file.

Parameters:
elections - Elections to be exported.

writeFile

protected abstract void writeFile()
Write the election data to file.


getFileName

protected String getFileName(String extension)
Build generic file name with the given extension.

Parameters:
extension - The file extension.
Returns:
The new file name.

getLogger

public IMessageHandling getLogger()
Returns:
The message handler.


Copyright © 2008. All Rights Reserved.