ucar.nc2.ncml
Class DatasetCollectionManager

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

public class DatasetCollectionManager
extends java.lang.Object

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

Since:
Aug 10, 2007
Author:
caron

Field Summary
protected static org.slf4j.Logger logger
           
 
Constructor Summary
DatasetCollectionManager(java.lang.String recheckS)
           
 
Method Summary
 void addDirectoryScan(Scanner scan)
           
 java.util.Collection<ucar.nc2.ncml.MyCrawlableDataset> getFiles()
          Get the current collection of MyCrawlableDataset, 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 MyCrawlableDataset 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
 

Field Detail

logger

protected static org.slf4j.Logger logger
Constructor Detail

DatasetCollectionManager

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

addDirectoryScan

public void addDirectoryScan(Scanner scan)

scan

public void scan(CancelTask cancelTask)
          throws java.io.IOException
Scan the directory(ies) and create MyCrawlableDataset 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 MyCrawlableDataset 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<ucar.nc2.ncml.MyCrawlableDataset> getFiles()
Get the current collection of MyCrawlableDataset, since last scan or rescan.

Returns:
current list of MyCrawlableDataset