Class IncrementalFile

java.lang.Object
gda.data.scan.datawriter.DataWriterBase
gda.data.scan.datawriter.IncrementalFile
All Implemented Interfaces:
DataWriter, IDataWriterExtender
Direct Known Subclasses:
AsciiDataWriter, SrsDataFile

public abstract class IncrementalFile extends DataWriterBase
This class is for writing ascii files of tabulated data, with a header and footer.

This class is abstract as it does not dictate the format used when writing to the file.

The files created use names which are an increment from the last name. Files are named in the format 0001.dat

  • Field Details

    • thisFileNumber

      protected int thisFileNumber
    • fileNumberConfigured

      protected boolean fileNumberConfigured
    • fileExtension

      protected String fileExtension
    • filePrefix

      protected String filePrefix
    • dataDir

      protected String dataDir
    • file

      protected FileWriter file
    • fileName

      protected String fileName
    • fileUrl

      protected String fileUrl
    • firstData

      protected boolean firstData
    • currentFileName

      protected String currentFileName
  • Constructor Details

    • IncrementalFile

      public IncrementalFile()
      Constructor which determines the name of the next file.
  • Method Details

    • destroy

      public void destroy()
      Close down the file.
    • prepareForCollection

      public void prepareForCollection() throws Exception
      Open files and writes out headers.
      Throws:
      Exception
    • completeCollection

      public void completeCollection() throws Exception
      Writes any file footers and closes file.
      Specified by:
      completeCollection in interface DataWriter
      Overrides:
      completeCollection in class DataWriterBase
      Throws:
      Exception
    • configureScanNumber

      public void configureScanNumber(int scanNumber) throws Exception
      Description copied from class: DataWriterBase
      If filenumber not set then read from scandatapoint or from num tracker
      Specified by:
      configureScanNumber in interface DataWriter
      Overrides:
      configureScanNumber in class DataWriterBase
      Parameters:
      scanNumber -
      Throws:
      Exception
    • setFilePrefix

      public void setFilePrefix(String filePrefix)
    • createNextFile

      public void createNextFile() throws Exception
      Closes current file and opens a new file with an incremental number. For use when many files being created instead of a single file being appended to.
      Throws:
      Exception
    • releaseFile

      public void releaseFile()
      Releases the file handle.
    • writeHeader

      public abstract void writeHeader()
      This should be extended by inheriting classes.
    • writeColumnHeadings

      public abstract void writeColumnHeadings()
      This should be extended by inheriting classes.
    • writeFooter

      public abstract void writeFooter()
      This should be extended by inheriting classes.
    • getDataDir

      public String getDataDir()
      Returns the full path of the folder which data files are written to.
      Returns:
      the full path of the folder which data files are written
    • getDelimiter

      public String getDelimiter()
      Get the delimiter used between columns
      Returns:
      the delimiter used between columns
    • setDelimiter

      public void setDelimiter(String delimiter)
      Set the delimiter used between columns (default is a tab '\t')
      Parameters:
      delimiter - String
    • getFileNumber

      public int getFileNumber() throws Exception
      Returns the number of the last file written to.
      Returns:
      Long
      Throws:
      Exception
    • getCurrentFileName

      public String getCurrentFileName()
      Description copied from interface: DataWriter
      Get the absFilePath for this scan
      Returns:
      String
    • getCurrentScanIdentifier

      public int getCurrentScanIdentifier()
      Description copied from interface: DataWriter
      Get the current scan identifier (ie scan number)
      Returns:
      String