Constructor and Description |
---|
FileSniffer()
Default constructor - exhaustive search is disabled
|
FileSniffer(boolean exhaustive)
Instantiate a new sniffer
|
Modifier and Type | Method and Description |
---|---|
void |
addDICOMExtension(java.lang.String extension)
Adds a DICOM file extension to the current case-insensitive set e.g.
|
void |
addImageExtension(java.lang.String extension)
Adds an image file extensions to the case-insensitive set e.g.
|
void |
addTextExtension(java.lang.String extension)
Adds a text file extension to the case-insensitive set e.g.
|
void |
delDICOMExtension(java.lang.String extension)
Removes a DICOM/DICONDE extension if present.
|
void |
delImageExtension(java.lang.String extension)
Removes an image file extension if present.
|
void |
delTextExtension(java.lang.String extension)
Removes a text file extension if present
|
java.util.Set<java.lang.String> |
getDicomExtensions()
Retrieves the current set of case-insensitive DICOM/DICONDE file extensions (no leading ".")
|
java.util.Set<java.lang.String> |
getImageExtensions()
Retrieves the current list of case-insensitive image file extensions (no leading ".")
|
java.util.Set<java.lang.String> |
getTextExtensions()
Retrieves current list of text file extensions (no leading ".")
|
boolean |
isExhaustive()
Whether an input file is read based on extension or by an exhaustive match.
|
static boolean |
isText(java.io.File file)
Attempts to determine whether a file consists of text or is binary.
|
static IODataset |
read(java.io.File inputFile)
Attempts to automatically identify the contents of the specified file.
|
static IODataset |
read(java.io.File inputFile,
boolean loadContents)
Attempts to automatically identify the contents in the specified file.
|
DicomDataset |
readAsDICOM(java.io.File inputFile)
Reads a DICOM/DICONDE file.
|
ImageDataset |
readAsImage(java.io.File inputFile)
Reads an image.
|
TextDataset |
readAsText(java.io.File inputFile)
Reads a text file
|
void |
setExhaustive(boolean exhaustive)
Sets whether to perform exhaustive matching or not.
|
IODataset |
sniff(java.io.File inputFile)
Attempts to automatically return a Dataset from a supported file format.
|
public FileSniffer(boolean exhaustive)
exhaustive
- whether to match by filename only (false) or to attempt every match (true).public FileSniffer()
public IODataset sniff(java.io.File inputFile) throws java.io.IOException
sniff
in interface Sniffer
inputFile
- File to examinejava.io.IOException
- if an I/O error occursexhaustive
public static IODataset read(java.io.File inputFile) throws java.io.IOException
inputFile
- file to readjava.io.IOException
- if an error occurspublic static IODataset read(java.io.File inputFile, boolean loadContents) throws java.io.IOException
inputFile
- file to readloadContents
- whether to load the contents (true) or just initialize (false)java.io.IOException
- if an error occurspublic static boolean isText(java.io.File file) throws java.io.IOException
file
- file to examinejava.io.IOException
- if an I/O error occurspublic TextDataset readAsText(java.io.File inputFile)
inputFile
- file to readpublic ImageDataset readAsImage(java.io.File inputFile)
inputFile
- file to readpublic DicomDataset readAsDICOM(java.io.File inputFile)
inputFile
- file to readpublic java.util.Set<java.lang.String> getTextExtensions()
public void addTextExtension(java.lang.String extension)
extension
- extension to addpublic void delTextExtension(java.lang.String extension)
extension
- extension to removepublic java.util.Set<java.lang.String> getImageExtensions()
public void addImageExtension(java.lang.String extension)
extension
- extension to addpublic void delImageExtension(java.lang.String extension)
extension
- extension to removepublic java.util.Set<java.lang.String> getDicomExtensions()
public void addDICOMExtension(java.lang.String extension)
extension
- extension to addpublic void delDICOMExtension(java.lang.String extension)
extension
- extension to removepublic void setExhaustive(boolean exhaustive)
exhaustive
- false to rely on filename extension alone, or true to attempt to read the file regardless of
extension.public boolean isExhaustive()