|
NIO2 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.classpath.icedtea.java.nio.file.DirectoryStreamFilters
public final class DirectoryStreamFilters
This class consists exclusively of static methods that construct or combine filters.
Method Summary | ||
---|---|---|
static
|
allOf(Iterable<? extends DirectoryStream.Filter<? super T>> filters)
Returns a directory stream filter that accepts a directory entry if the entry is accepted by all of the given
filters. |
|
static
|
anyOf(Iterable<? extends DirectoryStream.Filter<? super T>> filters)
Returns a directory stream filter that accepts a directory entry if the entry is accepted by one or more of
the given filters. |
|
static
|
complementOf(DirectoryStream.Filter<T> filter)
Returns a directory stream filter that is the complement of the given filter. |
|
static
|
newContentTypeFilter(String type)
Constructs a directory stream filter that filters directory entries by their MIME content type. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static <T extends FileRef> DirectoryStream.Filter<T> newContentTypeFilter(String type)
accept
method returns true
if the content type of the directory entry can be determined by
invoking the probeContentType
method, and
the content type matches the given content type.
The type
parameter is the value of a Multipurpose Internet
Mail Extension (MIME) content type as defined by RFC 2045: Multipurpose
Internet Mail Extensions (MIME) Part One: Format of Internet Message
Bodies. It is parsable according to the grammar in the RFC. Any
space characters ('\u0020'
) surrounding its components are
ignored. The type
parameter is parsed into its primary and subtype
components which are used to match the primary and subtype components of
each directory entry's content type. Parameters are not allowed. The
primary type matches if it has value '*'
or is equal to the
primary type of the directory entry's content type without regard to
case. The subtype matches if has the value '*'
or is equal to the
subtype of the directory entry's content type without regard to case. If
both the primary and subtype match then the filter's accept
method
returns true
. If the content type of a directory entry cannot be
determined then the entry is filtered.
The accept
method of the resulting directory stream filter
throws IOError
if the probing of the content type fails by
throwing an IOException
. Security exceptions are also propogated
to the caller of the accept
method.
Usage Example: Suppose we require to list only the HTML files in a directory.
DirectoryStream.Filter<FileRef> filter = DirectoryStreamFilters.newContentTypeFilter("text/html");
type
- The content type
IllegalArgumentException
- If the type
parameter cannot be parsed as a MIME type
or it has parameterspublic static <T> DirectoryStream.Filter<T> allOf(Iterable<? extends DirectoryStream.Filter<? super T>> filters)
accepts
a directory entry if the entry is accepted by all of the given
filters.
This method returns a filter that invokes, in iterator order, the
accept
method of each of the filters. If false
is returned
by any of the filters then the directory entry is filtered. If the
directory entry is not filtered then the resulting filter accepts the
entry. If the iterator returns zero elements then the resulting filter
accepts all directory entries.
Usage Example:
List<DirectoryStream.Filter<? super Path>> filters = ... DirectoryStream.Filter<Path> filter = DirectoryStreamFilters.allOf(filters);
filters
- The sequence of filters
public static <T> DirectoryStream.Filter<T> anyOf(Iterable<? extends DirectoryStream.Filter<? super T>> filters)
accepts
a directory entry if the entry is accepted by one or more of
the given filters.
This method returns a filter that invokes, in iteration order, the
accept
method of each of filter. If true
is returned by
any of the filters then the directory entry is accepted. If none of the
filters accepts the directory entry then it is filtered. If the iterator
returns zero elements then the resulting filter filters all directory
entries.
filters
- The sequence of filters
public static <T> DirectoryStream.Filter<T> complementOf(DirectoryStream.Filter<T> filter)
accepts
a directory entry
if filtered by the given filter, and filters any entries that are accepted
by the given filter.
filter
- The given filter
|
NIO2 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright © 2007, 2011, Oracle and/or its affiliates. All rights reserved.