Package ome.formats.importer
Class ImportCandidates
- java.lang.Object
-
- org.apache.commons.io.DirectoryWalker
-
- ome.formats.importer.ImportCandidates
-
public class ImportCandidates extends org.apache.commons.io.DirectoryWalker
Utility class which given anyFile
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
Nested Classes Modifier and Type Class Description static class
ImportCandidates.CANCEL
Marker exception raised if theImportCandidates.SCANNING.cancel()
method is called by anIObserver
instance.static class
ImportCandidates.SCANNING
Event raised during a pass through the directory structure given toImportCandidates
.
-
Field Summary
Fields Modifier and Type Field Description static int
DEPTH
static loci.formats.in.MetadataLevel
METADATA_LEVEL
-
Constructor Summary
Constructors Constructor Description ImportCandidates(int depth, OMEROWrapper reader, java.lang.String[] paths, IObserver observer)
Main constructor which starts depth-first descent into all the paths and permits a descent to the given depth.ImportCandidates(OMEROWrapper reader, java.lang.String[] paths, IObserver observer)
CallsImportCandidates(int, OMEROWrapper, String[], IObserver)
withDEPTH
as the first argument.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
execute(java.lang.String[] paths)
Method called duringImportCandidates(OMEROWrapper, String[], IObserver)
to operate on all the given paths.java.util.List<ImportContainer>
getContainers()
java.util.List<java.lang.String>
getPaths()
java.lang.String
getReaderType(java.lang.String path)
Retrieve reader type for file specified in pathjava.lang.String[]
getUsedFiles(java.lang.String path)
Return string of files used by container item at pathvoid
handleFile(java.io.File file, int depth, java.util.Collection collection)
Handle a file importvoid
print()
Prints the "standard" representation of the groups, which is parsed by other software layers.void
printYaml()
protected ImportContainer
singleFile(java.io.File file, ImportConfig config)
Return an import container for a single fileint
size()
boolean
wasCancelled()
-
-
-
Constructor Detail
-
ImportCandidates
public ImportCandidates(OMEROWrapper reader, java.lang.String[] paths, IObserver observer)
CallsImportCandidates(int, OMEROWrapper, String[], IObserver)
withDEPTH
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 duringReaderWrapper.setId(String)
. Otherwise no error reporting takes place.
-
ImportCandidates
public ImportCandidates(int depth, OMEROWrapper reader, java.lang.String[] paths, IObserver observer)
Main constructor which starts depth-first descent into all the paths and permits 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 duringReaderWrapper.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. The ordering of the used files is taken into account.
-
printYaml
public void printYaml()
-
size
public int size()
- Returns:
- containers size
-
wasCancelled
public boolean wasCancelled()
- Returns:
- if import was cancelled
-
getPaths
public java.util.List<java.lang.String> getPaths()
- Returns:
- array of string paths for files in containers
-
getReaderType
public java.lang.String getReaderType(java.lang.String path)
Retrieve reader type for file specified in path- Parameters:
path
- - absolute path for container- Returns:
- reader type
-
getUsedFiles
public java.lang.String[] getUsedFiles(java.lang.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 java.util.List<ImportContainer> getContainers()
- Returns:
- all containers as an array list
-
execute
protected void execute(java.lang.String[] paths)
Method called duringImportCandidates(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) usingreader
- Parameters:
paths
-
-
singleFile
protected ImportContainer singleFile(java.io.File file, ImportConfig config)
Return an import container for a single file- Parameters:
file
- - single file- Returns:
- importer container
-
handleFile
public void handleFile(java.io.File file, int depth, java.util.Collection collection)
Handle a file import- Overrides:
handleFile
in classorg.apache.commons.io.DirectoryWalker
- Parameters:
file
- the selected filedepth
- the depth of the scancollection
- the result objects, ignored
-
-