Package org.anchoranalysis.core.format
Class FormatExtensions
Object
FormatExtensions
File extensions for various formats.
- Author:
- Owen Feehan
-
Method Summary
Modifier and TypeMethodDescriptionstatic String[]The extensions of all image file formats as enumerated inImageFileFormat.static PathchangeExtension(Path path, NonImageFileFormat formatToChangeFrom, FileFormat formatToAssign) Change the extension in a path.static booleanDoes a filePath match an extension?static StringnormalizeToLowerCase(String extension) Normalize an extension to lower-case.static StringRemoves a single leading period from a string, if one exists.
-
Method Details
-
allImageExtensions
The extensions of all image file formats as enumerated inImageFileFormat.Note that some formats may have more than one extension e.g.
tifandtiff.- Returns:
- an array of extensions for all the image file formats.
-
matches
Does a filePath match an extension?- Parameters:
filePath- file-path to match, case irrelevantextensionWithoutLeadingPeriod- the extension to match (in lower-case, without a leading period)- Returns:
- true if the filePath ends with the expected extension
-
changeExtension
public static Path changeExtension(Path path, NonImageFileFormat formatToChangeFrom, FileFormat formatToAssign) throws OperationFailedException Change the extension in a path.- Parameters:
path- the path to change if the extension matchesformatToChangeFrom- the format to change from (a match occurs against the associated extension)formatToAssign- the format to assign (the default extension is assigned)- Returns:
- a path with the extension changed
- Throws:
OperationFailedException- if the unchanged path does not matchformatToChangeFrom.
-
removeAnyLeadingPeriod
Removes a single leading period from a string, if one exists.- Parameters:
str- a string that may or may not have a leading period.- Returns:
- a string with the leading period remove, if it exists.
-
normalizeToLowerCase
Normalize an extension to lower-case.This function exists to achieve normalization in a consistent way across many calls.
- Parameters:
extension- the extension to normalize.- Returns:
- a lower-case version of
extension.
-