java.lang.Object
org.sejda.commons.util.NumericalSortFilenameComparator
- All Implemented Interfaces:
Comparator<File>
Comparator for filenames that performs a numerical sort if the file names start or end with digits. It allows to specify a fallback comparator to use in case the numerical sort
fails. The goal is to behave as close as possible to file managers sorting results.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Comparator<String>private static final Function<String,BigInteger> private final Comparator<File>private static final Comparator<Matcher>private static final Patternprivate static final Comparator<String> -
Constructor Summary
ConstructorsConstructorDescriptionComparator performing numerical sort with fallback to file name case-insensitive compare in case numerical sort failsNumericalSortFilenameComparator(Comparator<File> fallback) -
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Comparator
equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Field Details
-
PATTERN
-
DIGITS_EXTRACTOR
-
BIG_INT_COMPARATOR
-
STRING_COMPARATOR
-
MATCHER_COMPARATOR
-
fallback
-
-
Constructor Details
-
NumericalSortFilenameComparator
- Parameters:
fallback- the comparator to use when numerical sorting fails. Default is file name case-insensitive compare
-
NumericalSortFilenameComparator
public NumericalSortFilenameComparator()Comparator performing numerical sort with fallback to file name case-insensitive compare in case numerical sort fails
-
-
Method Details
-
basename
-
compare
- Specified by:
comparein interfaceComparator<File>
-