public abstract class SearchGroup extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
SearchGroup.Factory
Factory which creates
SearchGroup . |
static class |
SearchGroup.Registry
Registry which registers search group factories
(
SearchGroup.Factory ) for search object types. |
Modifier and Type | Field and Description |
---|---|
static String |
PROP_FOUND
Property name which is fired when performing search and searched object
passed criteria.
|
static String |
PROP_RESULT
Property name which is fired for in for the case original
node 's has
changed the way result was changed based on set criteria. |
protected Set<Object> |
resultObjects
Set of objects which passed the search criteria (searchtypes).
|
protected Set<Node> |
searchRoots
Set of nodes on which sub-system to search.
|
protected SearchType[] |
searchTypes
search types added to this search group
|
protected boolean |
stopped
Flag indicating the search should be stopped.
|
Constructor and Description |
---|
SearchGroup() |
Modifier and Type | Method and Description |
---|---|
protected void |
add(SearchType searchType)
Adds a search type to this search group.
|
void |
addPropertyChangeListener(PropertyChangeListener l)
Adds property change listener.
|
static SearchGroup[] |
createSearchGroups(SearchType[] items)
Creates a search group for each type of object searchable by all
the specified search types.
|
protected abstract void |
doSearch()
Provides actual search.
|
protected void |
firePropertyChange(String name,
Object oldValue,
Object newValue)
Fires property change event.
|
abstract Node |
getNodeForFoundObject(Object object)
Gets node for found object.
|
Set<Object> |
getResultObjects()
Getter for result object property.
|
Node[] |
getSearchRoots()
Gets search root nodes.
|
SearchType[] |
getSearchTypes()
Returns list of search types.
|
protected void |
onStopSearch()
This method is invoked when the current search is being stopped.
|
protected void |
prepareSearch()
Prepares search.
|
protected void |
processSearchObject(Object searchObject)
Provides search on one search object instance.
|
void |
removePropertyChangeListener(PropertyChangeListener l)
Removes property change listener.
|
void |
search()
Does search.
|
void |
setSearchRootNodes(Node[] roots)
Sets roots of nodes in which its interested to search.
|
void |
stopSearch()
Stops searching.
|
public static final String PROP_FOUND
public static final String PROP_RESULT
node
's has
changed the way result
was changed based on set criteria.
Interested listeners should then get the event with values
null
there wasn't before for the node -> new value has to be non-null
for the latter case.
protected SearchType[] searchTypes
protected final Set<Object> resultObjects
protected volatile boolean stopped
protected void add(SearchType searchType)
searchType
- search type to be addedpublic SearchType[] getSearchTypes()
SearchGroup.add(org.openidex.search.SearchType)
public void setSearchRootNodes(Node[] roots)
public Node[] getSearchRoots()
protected void onStopSearch()
public final void stopSearch()
public void search()
RuntimeException
- USER level annotated runtime exception
on low memory condition (instead of OutOfMemoryError)protected void prepareSearch()
protected abstract void doSearch()
searchRoots
, extract search objects from them, add them
to the search object set, test over all search type items in this group,
in case if satisfied all it should fire PROP_FOUND
property change and add
the object to resultObjects
set.
The method implemenatation should call SearchGroup.processSearchObject(java.lang.Object)
method for each
search object in the node systems.protected void processSearchObject(Object searchObject)
PROP_FOUND
about successful
match to interested property change listeners.searchObject
- object to provide actuall test on it. The actual instance
has to be of type returned by all SearchKey.getSearchObjectType
returned by SearchType
of this SearchGroup
public abstract Node getNodeForFoundObject(Object object)
public void addPropertyChangeListener(PropertyChangeListener l)
public void removePropertyChangeListener(PropertyChangeListener l)
protected void firePropertyChange(String name, Object oldValue, Object newValue)
public static SearchGroup[] createSearchGroups(SearchType[] items)
At first, a set of object types common to all search types
(i.e. Class
s representing object types, common
to all search types) is computed. Then a search group is created
for each of the Class
s.
items
- search types to create search groups forSearchType.getSearchTypeClasses()