@NotThreadSafe public final class ExtensionSet extends CanonicalStringSet
ExtensionSet
can be converted into a string representation by
calling CanonicalStringSet.toString()
.
An extension is the part of a file name string after the last dot.
It must not contain the character '|'
.
An extension in canonical form (or canonicalized extension for short)
is a lowercase string which is not empty and does not start with a
dot ('.'
).
For example, the extension "zip"
is in canonical form,
while the extensions
""
,
"Zip"
,
"ZIP"
,
".zip"
,
".Zip"
,
".ZIP"
, and
"zip|Zip|ZIP|.zip|.Zip|.ZIP"
aren't.
An extension list is a string which consists of zero or more
extensions which are separated by the character '|'
.
Note that in general, an extension list is just a sequence of extensions.
In particular, an extension list may be empty (but not null
) and
its extensions don't have to be in canonical form, may be duplicated in the
list and may appear in arbitrary order.
Extension lists have a canonical form, too: An extension list in canonical form (or canonical extension list for short) is an extension list which contains only canonical extensions in natural sort order and does not contain any duplicates (so it's actually a set).
An extension list can be canonicalized using this class by calling
new ExtensionSet(list)
.toString()
.
Unless otherwise documented, all Set
methods work on the
canonical form of the extensions in this set.
Null extensions are not permitted in this set.
CanonicalStringSet.Canonicalizer
Modifier and Type | Field and Description |
---|---|
static char |
PREFIX
The optional prefix for extensions, which is 46.
|
static char |
SEPARATOR
The separator for extensions in lists, which is 124.
|
Constructor and Description |
---|
ExtensionSet()
Constructs a new, empty extension set.
|
ExtensionSet(Collection<String> c)
Constructs a new extension set by adding the canonical form of all
extensions for all extension lists in the given collection.
|
ExtensionSet(String extensions)
Constructs a new extension set from the given extension list.
|
Modifier and Type | Method and Description |
---|---|
Pattern |
toPattern()
Returns a case insensitive regular expression to match (file) paths
against the extensions in this set.
|
add, addAll, addAll, clear, contains, containsAll, containsAll, isEmpty, iterator, remove, removeAll, removeAll, retainAll, retainAll, size, toArray, toArray, toString
equals, hashCode, removeAll
addAll, containsAll, retainAll
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
addAll, containsAll, retainAll, spliterator
parallelStream, removeIf, stream
public static final char PREFIX
public static final char SEPARATOR
public ExtensionSet()
public ExtensionSet(Collection<String> c)
c
- A collection of extension lists.public ExtensionSet(String extensions)
extensions
- A list of extensions.public Pattern toPattern()
Copyright © 2012–2017 Schlichtherle IT Services. All rights reserved.