Package digilib.io
Class FileOps
java.lang.Object
digilib.io.FileOps
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
(package private) static class
FileFilter for image types (helper class for getFile)(package private) static class
FileFilter for general files(package private) static class
FileFilter for text types (helper class for getFile) -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String
Extract the base of a file name (sans extension).static FileOps.FileClass
get the file class for the filename (by extension)static FileOps.FileClass
returns the file class for a mime-typestatic void
emptyDirectory
(File dir) clean up any broken and unfinished files from the temporary directory.static String
Extract the extension of a file name.static DocuDirent
fileForClass
(FileOps.FileClass fileClass, File file, FsDirectory[] scaleDirs) Factory for DocuDirents based on file class.static String
Extract the file name of a (digilib) path name.static File[]
filterFiles
(File[] files, FileFilter filter) Filters a list of Files through a FileFilter.static FileFilter
filterForClass
(FileOps.FileClass fileClass) Factory for FileFilters (image or text).static boolean
isMimeTypeSendable
(String mimeType) Returns if the mime-type is browser compatible.static boolean
isValidFilename
(String filename) Returns if the filename is valid.static String
mimeForFile
(File f) get the mime type for a file format (by extension)Creates a new hints Map with the given first element.static String
normalName
(String pathname) Normalize a path name.static String
Extract the parent directory of a (digilib) path name.static String[]
pathToArray
(String paths) convert a string with a list of pathnames into an array of strings using the system's path separator stringstreamFilterForClass
(FileOps.FileClass fileClass) Factory for DirectoryStream.Filters (image or text).
-
Field Details
-
fileTypes
-
imageExtensions
-
textExtensions
-
HINT_BASEDIRS
-
HINT_FILEEXT
-
HINT_DIRS
-
-
Constructor Details
-
FileOps
public FileOps()
-
-
Method Details
-
classForMimetype
returns the file class for a mime-type- Parameters:
mt
- the mime type- Returns:
- the FileClass
-
mimeForFile
get the mime type for a file format (by extension)- Parameters:
f
- the File- Returns:
- the mime type
-
classForFilename
get the file class for the filename (by extension)- Parameters:
fn
- the fn- Returns:
- the FileClass
-
getImageExtensionIterator
- Returns:
- the Iterator
-
getImageExtensions
- Returns:
- the image extensions
-
getTextExtensionIterator
- Returns:
- the Iterator
-
getTextExtensions
- Returns:
- the extensions
-
pathToArray
convert a string with a list of pathnames into an array of strings using the system's path separator string- Parameters:
paths
- the paths string- Returns:
- the paths
-
basename
Extract the base of a file name (sans extension). Returns the filename without the extension. The extension is the part behind the last dot in the filename. If the filename contains no dot the full file name is returned.- Parameters:
fn
- the fn- Returns:
- the base name
-
extname
Extract the extension of a file name. Returns the extension of a file name. The extension is the part behind the last dot in the filename. If the filename has no dot the empty string is returned.- Parameters:
fn
- the fn- Returns:
- the extension
-
parent
Extract the parent directory of a (digilib) path name. Returns the parent directory of a path name. The parent is the part before the last slash in the path name. If the path name has no slash the empty string is returned.- Parameters:
fn
- the fn- Returns:
- the parent
-
filename
Extract the file name of a (digilib) path name. Returns the file name of a path name. The file name is the part after the last slash in the path name. If the path name has no slash the original string is returned.- Parameters:
fn
- the fn- Returns:
- the file name
-
normalName
Normalize a path name. Removes leading and trailing slashes. Returns null if there is other unwanted stuff in the path name.- Parameters:
pathname
- the pathname- Returns:
- the pathname
-
isValidFilename
Returns if the filename is valid. Currently only checks if filename starts with a dot.- Parameters:
filename
- the filename- Returns:
- is valid
-
filterForClass
Factory for FileFilters (image or text).- Parameters:
fileClass
- the FileClass- Returns:
- the FileFilter
-
streamFilterForClass
Factory for DirectoryStream.Filters (image or text).- Parameters:
fileClass
- the FileClass- Returns:
- the FileFilter
-
fileForClass
public static DocuDirent fileForClass(FileOps.FileClass fileClass, File file, FsDirectory[] scaleDirs) Factory for DocuDirents based on file class. Returns an ImageSet, TextFile or SVGFile. scaleDirs are only for ImageFilesets.- Parameters:
fileClass
- the FileClassfile
- the FilescaleDirs
- optional additional parameters- Returns:
- the DocuDirent
-
filterFiles
Filters a list of Files through a FileFilter.- Parameters:
files
- the Filesfilter
- the FileFilter- Returns:
- the Files
-
newHints
Creates a new hints Map with the given first element.- Parameters:
type
- the typevalue
- the value- Returns:
- the Map
-
emptyDirectory
clean up any broken and unfinished files from the temporary directory.- Parameters:
dir
- the File
-
isMimeTypeSendable
Returns if the mime-type is browser compatible.- Parameters:
mimeType
-- Returns:
-