Class ImagesDirectoryHighMemoryParser

java.lang.Object
be.gaudry.model.file.AbstractFileParser<Long>
be.gaudry.bibliobrol.dao.derby.tools.ImagesDirectoryHighMemoryParser
All Implemented Interfaces:
PropertyChangeListener, EventListener

public abstract class ImagesDirectoryHighMemoryParser extends AbstractFileParser<Long>
This is the first version of ImagesDirectoryParser, that parses all files before inserting matching files into the database.
OutOfMemoryError: Java heap space may occurs
Since:
1.0 Feb 2, 2009
Author:
Steph GAUDRY
See Also:
ImagesDirectoryParser
  • Constructor Details

    • ImagesDirectoryHighMemoryParser

      public ImagesDirectoryHighMemoryParser()
  • Method Details

    • getInsertImageStatement

      public abstract PreparedStatement getInsertImageStatement()
      Returns:
      the insertImageStatement
    • getUpdateImageStatement

      public abstract PreparedStatement getUpdateImageStatement()
      Returns:
      the updateImageStatement
    • getSelectMatchingIdsQuery

      public abstract String getSelectMatchingIdsQuery()
      Returns the query to load the identifiers from a database table for that here is not yet an associated image.
      The general contract of getSelectConflictIdsQuery is that the first column of the results is the identifier value as INTEGER SQL data type.
      Example of query:
       SELECT itemId FROM item WHERE itemImage IS NULL
       
      Returns:
      the selectMatchingIdsQuery
    • getSelectConflictIdsQuery

      public abstract String getSelectConflictIdsQuery()
      Returns the query to load the identifiers from a database table for that associated image is found (conflict).
      The general contract of getSelectConflictIdsQuery is that the first column of the results is the identifier value as INTEGER SQL data type.
      Example of query:
       SELECT itemId FROM item WHERE itemImage IS NOT NULL
       
      Returns:
      the selectConflictIdsQuery
    • confirmReplacement

      protected abstract boolean confirmReplacement(File file, int id)
      Override this method if you want to display some GUI confirmation.
      Parameters:
      file - possible matching file.
      id - matching id, but with an existing file.
      Returns:
      always false in this basic implementation.
    • parse

      public long parse(AbstractBrolWorker<Long> bgw)
      Description copied from class: AbstractFileParser
      Parses files from the defined start path, and call the AbstractFileParser.performOnFile(AbstractBrolWorker, File, int, int) on each file.
      Overrides:
      parse in class AbstractFileParser<Long>
      Returns:
      the size of the matching files, not the size of the parsed directory
    • readIds

      public void readIds(AbstractBrolWorker<Long> bgw)
    • performOnFile

      protected boolean performOnFile(AbstractBrolWorker<Long> bgw, File file, int progressPercent, int subDirDeep)
      Description copied from class: AbstractFileParser
      Do something on each file
      Specified by:
      performOnFile in class AbstractFileParser<Long>
      Parameters:
      bgw - AbstractBrolWorker to perform cancel if needed, and report progress
      file - file to check
      progressPercent - Progress percentage
      subDirDeep - Deep of the directory in comparison with start directory
      Returns:
      true if we must stop the parsing of current directory (ie. if we have a vob file, we don't check the other files in this directory) false otherwise