toxTree.io.batch
Class BatchProcessing

java.lang.Object
  extended by java.util.Observable
      extended by toxTree.io.batch.BatchProcessing
All Implemented Interfaces:
java.io.Serializable, IBatchProcessing
Direct Known Subclasses:
ChemObjectBatchProcessing

public abstract class BatchProcessing
extends java.util.Observable
implements IBatchProcessing

Accessing & serializing Array: Throwing exception in jre6 while it works in jre5 http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6554519 An abstract class to support Batch processing with several fail safe options

Author:
Nina jeliazkova Modified 2005-9-4
See Also:
Serialized Form

Field Summary
protected  java.io.File configFile
           
protected  java.util.Date dateCreated
           
protected  java.util.Date dateLastSaved
           
protected  boolean deleteConfigOnSuccess
           
protected  FileState inputFile
           
protected static TTLogger logger
           
protected static java.lang.String MSG_CANTCREATEFILE
           
protected static java.lang.String MSG_ERRORCOUNTING
           
protected static java.lang.String MSG_ERRORSAVE
           
protected static java.lang.String MSG_FILEDONOTEXISTS
           
protected static java.lang.String MSG_OPEN
           
protected static java.lang.String MSG_UNSUPPORTEDFORMAT
           
protected  FileState outputFile
           
protected  int saveStateFrequency
           
 int status
           
static int STATUS_ABORTED
           
static int STATUS_FINISHED
           
static int STATUS_NOTINITIALIZED
           
static int STATUS_NOTSTARTED
           
static int STATUS_PAUSED
           
static int STATUS_RUNNING
           
protected static java.lang.String[] statusMsg
           
protected  java.lang.String tmpDir
           
 
Constructor Summary
BatchProcessing()
          Creates empty BatchProcessing it should be configured prior to use
BatchProcessing(java.io.File input, java.io.File output)
          Creates BatchProcessing given input and output file names
BatchProcessing(java.lang.String input, java.lang.String output)
          Creates BatchProcessing given input and output file names
 
Method Summary
 void cancel()
           
 void close()
           
 java.io.File createConfigFile()
           
 void createOutputFile()
           
 boolean equals(java.lang.Object obj)
           
 java.io.File getConfigFile()
          Where to store batchprocessing configuration itself
 java.util.Date getDateCreated()
           
 java.util.Date getDateLastProcessed()
           
 FileState getInputFile()
           
 FileState getOutputFile()
           
 long getReadRecordsCount()
          Returns the number of records read from the input file
 int getSaveStateFrequency()
          BatchProcessing saves its state on each saveStateFrequency records
 int getStatus()
           
 java.lang.String getTempDir()
           
 long getWrittenRecordsCount()
          Returns the number of records written to the output file
 boolean isCancelled()
           
 boolean isPaused()
           
 boolean isRunning()
           
 boolean isStatus(int status)
           
 void loadConfig()
           
 void openInputFile()
           
 void pause()
           
 void saveConfig()
           
 void saveConfig(java.io.OutputStream out)
           
 void setConfigFile(java.io.File configFile)
           
 void setSaveStateFrequency(int saveStateFrequency)
          BatchProcessing saves its state on each saveStateFrequency records
protected  void setStatus(int status)
           
 void start()
           
 java.lang.String toString()
           
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface toxTree.io.batch.IBatchProcessing
closeInputFile, closeOutputFile, hasNextRecord, processRecord, readRecord, writeRecord
 

Field Detail

saveStateFrequency

protected int saveStateFrequency

inputFile

protected FileState inputFile

outputFile

protected FileState outputFile

dateCreated

protected java.util.Date dateCreated

dateLastSaved

protected java.util.Date dateLastSaved

configFile

protected transient java.io.File configFile

tmpDir

protected transient java.lang.String tmpDir

deleteConfigOnSuccess

protected transient boolean deleteConfigOnSuccess

MSG_FILEDONOTEXISTS

protected static transient java.lang.String MSG_FILEDONOTEXISTS

MSG_CANTCREATEFILE

protected static transient java.lang.String MSG_CANTCREATEFILE

MSG_OPEN

protected static transient java.lang.String MSG_OPEN

MSG_UNSUPPORTEDFORMAT

protected static transient java.lang.String MSG_UNSUPPORTEDFORMAT

MSG_ERRORSAVE

protected static transient java.lang.String MSG_ERRORSAVE

MSG_ERRORCOUNTING

protected static transient java.lang.String MSG_ERRORCOUNTING

logger

protected static transient TTLogger logger

statusMsg

protected static transient java.lang.String[] statusMsg

STATUS_NOTSTARTED

public static final transient int STATUS_NOTSTARTED
See Also:
Constant Field Values

STATUS_RUNNING

public static final transient int STATUS_RUNNING
See Also:
Constant Field Values

STATUS_FINISHED

public static final transient int STATUS_FINISHED
See Also:
Constant Field Values

STATUS_PAUSED

public static final transient int STATUS_PAUSED
See Also:
Constant Field Values

STATUS_ABORTED

public static final transient int STATUS_ABORTED
See Also:
Constant Field Values

STATUS_NOTINITIALIZED

public static final transient int STATUS_NOTINITIALIZED
See Also:
Constant Field Values

status

public int status
Constructor Detail

BatchProcessing

public BatchProcessing()
Creates empty BatchProcessing it should be configured prior to use


BatchProcessing

public BatchProcessing(java.lang.String input,
                       java.lang.String output)
                throws BatchProcessingException
Creates BatchProcessing given input and output file names

Parameters:
input - Input filename; should exists
output - Results (output) filename ; deleted if exists
Throws:
BatchProcessingException - - if input file do not exists - if output file can't be deleted and a new one created; - on any IOException

BatchProcessing

public BatchProcessing(java.io.File input,
                       java.io.File output)
                throws BatchProcessingException
Creates BatchProcessing given input and output file names

Parameters:
input - Input filename; should exists
output - Results (output) filename ; deleted if exists
Throws:
BatchProcessingException - - if input file do not exists - if output file can't be deleted and a new one created; - on any IOException
Method Detail

openInputFile

public void openInputFile()
                   throws BatchProcessingException
Specified by:
openInputFile in interface IBatchProcessing
Throws:
BatchProcessingException

createOutputFile

public void createOutputFile()
                      throws BatchProcessingException
Specified by:
createOutputFile in interface IBatchProcessing
Throws:
BatchProcessingException

start

public void start()
           throws BatchProcessingException
Specified by:
start in interface IBatchProcessing
Throws:
BatchProcessingException

close

public void close()
           throws BatchProcessingException
Specified by:
close in interface IBatchProcessing
Throws:
BatchProcessingException

pause

public void pause()
           throws BatchProcessingException
Specified by:
pause in interface IBatchProcessing
Throws:
BatchProcessingException

cancel

public void cancel()
            throws BatchProcessingException
Specified by:
cancel in interface IBatchProcessing
Throws:
BatchProcessingException

saveConfig

public void saveConfig()
                throws BatchProcessingException
Specified by:
saveConfig in interface IBatchProcessing
Throws:
BatchProcessingException

saveConfig

public void saveConfig(java.io.OutputStream out)
                throws BatchProcessingException
Throws:
BatchProcessingException

loadConfig

public void loadConfig()
                throws BatchProcessingException
Specified by:
loadConfig in interface IBatchProcessing
Throws:
BatchProcessingException

isStatus

public boolean isStatus(int status)
Returns:
Returns the status.

setStatus

protected void setStatus(int status)
Parameters:
status - The status to set.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getSaveStateFrequency

public int getSaveStateFrequency()
BatchProcessing saves its state on each saveStateFrequency records

Returns:
Returns the saveStateFrequency.

setSaveStateFrequency

public void setSaveStateFrequency(int saveStateFrequency)
BatchProcessing saves its state on each saveStateFrequency records

Parameters:
saveStateFrequency - The saveStateFrequency to set.

getTempDir

public java.lang.String getTempDir()

createConfigFile

public java.io.File createConfigFile()

getConfigFile

public java.io.File getConfigFile()
Where to store batchprocessing configuration itself

Returns:
Returns the configFile.

setConfigFile

public void setConfigFile(java.io.File configFile)
Specified by:
setConfigFile in interface IBatchProcessing
Parameters:
configFile - The configFile to set.

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

getStatus

public int getStatus()
Returns:
Returns the status.

getReadRecordsCount

public long getReadRecordsCount()
Returns the number of records read from the input file

Specified by:
getReadRecordsCount in interface IBatchProcessing

getWrittenRecordsCount

public long getWrittenRecordsCount()
Returns the number of records written to the output file

Specified by:
getWrittenRecordsCount in interface IBatchProcessing

getInputFile

public FileState getInputFile()
Returns:
Returns the inputFile.

getOutputFile

public FileState getOutputFile()
Returns:
Returns the outputFile.

isRunning

public boolean isRunning()
Specified by:
isRunning in interface IBatchProcessing

isPaused

public boolean isPaused()
Specified by:
isPaused in interface IBatchProcessing

isCancelled

public boolean isCancelled()
Specified by:
isCancelled in interface IBatchProcessing

getDateCreated

public java.util.Date getDateCreated()
Specified by:
getDateCreated in interface IBatchProcessing
Returns:
Date when batch job was first created

getDateLastProcessed

public java.util.Date getDateLastProcessed()
Specified by:
getDateLastProcessed in interface IBatchProcessing
Returns:
Date when batch job was processed last


Copyright © 2004-2012 Ideaconsult Ltd.. All Rights Reserved.