public final class SearchInfoDefinitionFactory extends Object
SearchInfoDefinitions
objects.
It can be used if you want to add custom SearchInfoDefinitions to lookups of
nodes.SearchInfo
Modifier and Type | Field and Description |
---|---|
static List<SearchFilterDefinition> |
DEFAULT_FILTER_DEFS
List of default filter definitions.
|
static SearchFilterDefinition |
SHARABILITY_FILTER
Filter for unsharable files.
|
static SearchFilterDefinition |
VISIBILITY_FILTER
Filter for invisible files.
|
Modifier and Type | Method and Description |
---|---|
static SearchInfoDefinition |
createFlatSearchInfo(FileObject root)
Create a search info definition for non-recursive searching in a single
directory.
|
static SearchInfoDefinition |
createFlatSearchInfo(FileObject root,
SearchFilterDefinition[] filters)
Create a search definition info for non-recursive searching in a single
directory.
|
static SearchInfoDefinition |
createSearchInfo(FileObject root)
Convenience method for creating a search info definition for a root node
with default filters.
|
static SearchInfoDefinition |
createSearchInfo(FileObject[] roots)
Convenience method for creating search info for a list of roots with
default filters.
|
static SearchInfoDefinition |
createSearchInfo(FileObject[] roots,
SearchFilterDefinition[] filters)
Creates a
SearchInfoDefinition object for given folders. |
static SearchInfoDefinition |
createSearchInfo(FileObject root,
SearchFilterDefinition[] filters)
Creates a
SearchInfoDefinition object for a given folder. |
static SearchInfoDefinition |
createSearchInfoBySubnodes(Children children)
Creates a
SearchInfoDefinition object combining
SearchInfoDefinition objects of the node's
children. |
public static final SearchFilterDefinition SHARABILITY_FILTER
public static final SearchFilterDefinition VISIBILITY_FILTER
public static final List<SearchFilterDefinition> DEFAULT_FILTER_DEFS
@NonNull public static SearchInfoDefinition createSearchInfo(@NonNull FileObject root, @NonNull SearchFilterDefinition[] filters)
SearchInfoDefinition
object for a given folder. The returned
SearchInfoDefinition
object's method SearchInfoDefinition.canSearch()
always returns
true
and iterates through
FileObject
s found in the given folder. Files and folders
that do not pass any of the given filters are skipped (not searched). If
multiple filters are passed, the filters are applied on each file/folder
in the same order as in the array passed to this method.root
- File or folder where the search should startfilters
- filters to be used when searchingSearchInfo
object which iterates through
FileObject
s found in the specified folder and (optionally)
its subfoldersSearchFilterDefinition
@NonNull public static SearchInfoDefinition createFlatSearchInfo(@NonNull FileObject root, @NonNull SearchFilterDefinition[] filters)
root
- Directory or file. If file is passed, only that single file
will be searched.@NonNull public static SearchInfoDefinition createFlatSearchInfo(@NonNull FileObject root)
root
- Directory or file. If file is passed, only that single file
will be searched.@NonNull public static SearchInfoDefinition createSearchInfo(@NonNull FileObject root)
@NonNull public static SearchInfoDefinition createSearchInfo(@NonNull FileObject[] roots, @NonNull SearchFilterDefinition[] filters)
SearchInfoDefinition
object for given folders. The returned
SearchInfoDefinition
object's method SearchInfoDefinition.canSearch()
always returns true
and iterates through
FileObject
s found in the given folders. Files and folders
that do not pass any of the given filters are skipped (not searched). If
multiple filters are passed, the filters are applied on each file/folder
in the same order as in the array passed to this method.roots
- folders which should be searchedfilters
- filters to be used when searching; or
null
if no filters should be usedSearchInfo
object which iterates through
FileObject
s found in the specified folders and their
subfoldersSearchFilterDefinition
@NonNull public static SearchInfoDefinition createSearchInfo(@NonNull FileObject[] roots)
@NonNull public static SearchInfoDefinition createSearchInfoBySubnodes(@NonNull Children children)
SearchInfoDefinition
object combining
SearchInfoDefinition
objects of the node's
children.
Method SearchInfoDefinition.canSearch()
of the resulting
SearchInfoDefinition
objects returns always true.
The iterator iterates through all
FileObject
s returned by the subnode's
SearchInfoDefinition
iterators.
In case you want to create node children in the node constructor, you can create children in one constructor and pass them to another constructor:
public ExampleNode() {
this(Children.create(someChildrenFactory, true));
}
private ExampleNode(Children ch) {
super(ch, Lookups.singleton(
SearchInfoDefinitionFactory.createSearchInfoBySubnodes(ch)));
// ...
}
children
- Children to create
SearchInfoDefinition
forSearchInfoDefinition
object representing combination of
SearchInfoDefinition
objects of child nodes.