ucar.nc2.ncml
Class DatasetCollectionManager2

java.lang.Object
  extended by ucar.nc2.ncml.DatasetCollectionManager2

public class DatasetCollectionManager2
extends java.lang.Object

Manage a list of Scanners that find Files (actually finds MFile). Tracks when they need to be rescanned.

Since:
Aug 10, 2007
Author:
caron

Constructor Summary
DatasetCollectionManager2(java.lang.String recheckS)
           
 
Method Summary
 void addDirectoryScan(java.lang.String dirName, java.lang.String suffix, java.lang.String regexpPatternString, java.lang.String subdirsS, java.lang.String olderS, java.lang.String dateFormatString)
           
 java.util.Collection<MFile> getFiles()
          Get the current collection of MFile, since last scan or rescan.
 long getLastScanned()
          Get the last time scanned
 TimeUnit getRecheck()
          Get how often to rescan
 boolean rescan()
          Rescan directories.
 void scan(CancelTask cancelTask)
          Scan the directory(ies) and create MFile objects.
 boolean timeToRescan()
          Compute if rescan is needed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DatasetCollectionManager2

public DatasetCollectionManager2(java.lang.String recheckS)
Method Detail

addDirectoryScan

public void addDirectoryScan(java.lang.String dirName,
                             java.lang.String suffix,
                             java.lang.String regexpPatternString,
                             java.lang.String subdirsS,
                             java.lang.String olderS,
                             java.lang.String dateFormatString)

scan

public void scan(CancelTask cancelTask)
          throws java.io.IOException
Scan the directory(ies) and create MFile objects. Get the results from getFiles()

Parameters:
cancelTask - allow user to cancel
Throws:
java.io.IOException - if io error

timeToRescan

public boolean timeToRescan()
Compute if rescan is needed. True if scanList not empty, recheckEvery not null, and recheckEvery time has passed since last scanned.

Returns:
true is rescan time has passed

rescan

public boolean rescan()
               throws java.io.IOException
Rescan directories. Files may be deleted or added. If the MFile already exists in the current list, leave it in the list. If returns true, get the results from getFiles(), otherwise nothing has changed.

Returns:
true if anything actually changed.
Throws:
java.io.IOException - on I/O error

getRecheck

public TimeUnit getRecheck()
Get how often to rescan

Returns:
time dureation of rescan period, or null if none.

getLastScanned

public long getLastScanned()
Get the last time scanned

Returns:
msecs since 1970

getFiles

public java.util.Collection<MFile> getFiles()
Get the current collection of MFile, since last scan or rescan.

Returns:
current list of MFile