ome.formats.importer
Class ImportCandidates

java.lang.Object
  extended by org.apache.commons.io.DirectoryWalker
      extended by ome.formats.importer.ImportCandidates

public class ImportCandidates
extends org.apache.commons.io.DirectoryWalker

Utility class which given any File object will determine the correct number and members of a given import. This facility permits iterating over a directory. This class is NOT thread-safe.

Since:
Beta4.1

Nested Class Summary
static class ImportCandidates.CANCEL
          Marker exception raised if the ImportCandidates.SCANNING.cancel() method is called by an IObserver instance.
static class ImportCandidates.SCANNING
          Event raised during a pass through the directory structure given to ImportCandidates.
 
Nested classes/interfaces inherited from class org.apache.commons.io.DirectoryWalker
org.apache.commons.io.DirectoryWalker.CancelException
 
Field Summary
static int DEPTH
           
static loci.formats.in.MetadataLevel METADATA_LEVEL
           
 
Constructor Summary
ImportCandidates(int depth, OMEROWrapper reader, String[] paths, IObserver observer)
          Main constructor which iterates over all the paths calling DirectoryWalker.walk(File, Collection) and permitting a descent to the given depth.
ImportCandidates(OMEROWrapper reader, String[] paths, IObserver observer)
          Calls ImportCandidates(int, OMEROWrapper, String[], IObserver) with DEPTH as the first argument.
 
Method Summary
protected  void execute(String[] paths)
          Method called during ImportCandidates(OMEROWrapper, String[], IObserver) to operate on all the given paths.
 List<ImportContainer> getContainers()
           
 List<String> getPaths()
           
 String getReaderType(String path)
          Retrieve reader type for file specified in path
 String[] getUsedFiles(String path)
          Return string of files used by container item at path
 void handleFile(File file, int depth, Collection collection)
          Handle a file import
 void print()
          Prints the "standard" representation of the groups, which is parsed by other software layers.
protected  ImportContainer singleFile(File file, ImportConfig config)
          Return an import container for a single file
 int size()
           
 boolean wasCancelled()
           
 
Methods inherited from class org.apache.commons.io.DirectoryWalker
checkIfCancelled, handleCancelled, handleDirectory, handleDirectoryEnd, handleDirectoryStart, handleEnd, handleIsCancelled, handleRestricted, handleStart, walk
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEPTH

public static final int DEPTH

METADATA_LEVEL

public static final loci.formats.in.MetadataLevel METADATA_LEVEL
Constructor Detail

ImportCandidates

public ImportCandidates(OMEROWrapper reader,
                        String[] paths,
                        IObserver observer)
Calls ImportCandidates(int, OMEROWrapper, String[], IObserver) with DEPTH as the first argument.

Parameters:
reader - instance used for parsing each of the paths. Not used once the constructor completes.
paths - file paths which are searched. May be directories.
observer - IObserver which will monitor any exceptions during ReaderWrapper.setId(String). Otherwise no error reporting takes place.

ImportCandidates

public ImportCandidates(int depth,
                        OMEROWrapper reader,
                        String[] paths,
                        IObserver observer)
Main constructor which iterates over all the paths calling DirectoryWalker.walk(File, Collection) and permitting a descent to the given depth.

Parameters:
depth - number of directory levels to search down.
reader - instance used for parsing each of the paths. Not used once the constructor completes.
paths - file paths which are searched. May be directories.
observer - IObserver which will monitor any exceptions during ReaderWrapper.setId(String). Otherwise no error reporting takes place.
Method Detail

print

public void print()
Prints the "standard" representation of the groups, which is parsed by other software layers. The format is: 1) any empty lines are ignored, 2) any blocks of comments separate groups, 3) each group is begun by the "key", 4) all other files in a group will also be imported. Similar logic is contained in Groups#print() but it does not take the ordering of the used files into account.


size

public int size()
Returns:
containers size

wasCancelled

public boolean wasCancelled()
Returns:
if import was cancelled

getPaths

public List<String> getPaths()
Returns:
array of string paths for files in containers

getReaderType

public String getReaderType(String path)
Retrieve reader type for file specified in path

Parameters:
path - - absolute path for container
Returns:
reader type

getUsedFiles

public String[] getUsedFiles(String path)
Return string of files used by container item at path

Parameters:
path - - absolute path for container
Returns:
string array of used files

getContainers

public List<ImportContainer> getContainers()
Returns:
all containers as a array list

execute

protected void execute(String[] paths)
Method called during ImportCandidates(OMEROWrapper, String[], IObserver) to operate on all the given paths. This will be called twice: once without reading the files, and once (with the known total) using reader

Parameters:
paths -

singleFile

protected ImportContainer singleFile(File file,
                                     ImportConfig config)
Return an import container for a single file

Parameters:
file - - single file
Returns:
importer container

handleFile

public void handleFile(File file,
                       int depth,
                       Collection collection)
Handle a file import

Overrides:
handleFile in class org.apache.commons.io.DirectoryWalker
Parameters:
file - - file selected
depth - - depth of scan
collection -


OmeroJava Api

Version: 4.3.4-dbcbce5a-b4

Copyright © 2009 The University of Dundee. All Rights Reserved.