站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > NetBeans API Javadoc (Current Development Version)

SearchGroup (Search API) - NetBeans API Javadoc (Current Development Version)

org.openidex.util/3 3.11

org.openidex.search
Class SearchGroup

java.lang.Object
  extended by org.openidex.search.SearchGroup
Direct Known Subclasses:
DataObjectSearchGroup, FileObjectSearchGroup

public abstract class SearchGroup
extends Object

Class which groups individual search types. It provides several services to provide search on them. The services are scanning node system to provide search object for group of search types -> efficient search.


Nested Class Summary
static interface SearchGroup.Factory
          Factory which creates SearchGroup.
static class SearchGroup.Registry
          Registry which registers search group factories (SearchGroup.Factory) for search object types.
 
Field Summary
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 resultObjects
          Set of objects which passed the search criteria (searchtypes).
protected  Set 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 Summary
SearchGroup()
           
 
Method Summary
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 getResultObjects()
          Getter for result object property.
 Node[] getSearchRoots()
          Gets search root nodes.
 SearchType[] getSearchTypes()
          Returns list of search types.
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROP_FOUND

public static final String PROP_FOUND
Property name which is fired when performing search and searched object passed criteria.

See Also:
Constant Field Values

PROP_RESULT

public static final 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. Interested listeners should then get the event with values
  • property change name = PROP_RESULT
  • property source = this search type instance
  • old value = detail which was changed or null there wasn't before for the node -> new value has to be non-null for the latter case.
  • new value = detail which was changed or null if the node was removed from the result -> old value has to be non-null for that case
This allows implementation of the dynamic changing of result suggested by Jesse and Sebastian (at least partially implemented now).

See Also:
Constant Field Values

searchTypes

protected SearchType[] searchTypes
search types added to this search group


searchRoots

protected final Set searchRoots
Set of nodes on which sub-system to search.


resultObjects

protected final Set resultObjects
Set of objects which passed the search criteria (searchtypes).


stopped

protected volatile boolean stopped
Flag indicating the search should be stopped.

Constructor Detail

SearchGroup

public SearchGroup()
Method Detail

add

protected void add(SearchType searchType)
Adds a search type to this search group. If the group already contains the search type, the group is left unmodified.

Parameters:
searchType - search type to be added

getSearchTypes

public SearchType[] getSearchTypes()
Returns list of search types.

Returns:
search types added to this group
See Also:
add(org.openidex.search.SearchType)

setSearchRootNodes

public void setSearchRootNodes(Node[] roots)
Sets roots of nodes in which its interested to search. This method is called at the first search type in the possible created chain of search types.


getSearchRoots

public Node[] getSearchRoots()
Gets search root nodes.


stopSearch

public final void stopSearch()
Stops searching.


search

public void search()
Does search.


prepareSearch

protected void prepareSearch()
Prepares search.


doSearch

protected abstract void doSearch()
Provides actual search. The subclasses implementating this method should scan the node system specified by 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 processSearchObject(java.lang.Object) method for each search object in the node systems.


processSearchObject

protected void processSearchObject(Object searchObject)
Provides search on one search object instance. The object is added to set of searched objects and passed to all search types encapsulated by this search group. In the case the object passes all search types is added to the result set and fired an event PROP_FOUND about successful match to interested property change listeners.

Parameters:
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

getNodeForFoundObject

public abstract Node getNodeForFoundObject(Object object)
Gets node for found object.


getResultObjects

public Set getResultObjects()
Getter for result object property.


addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener l)
Adds property change listener.


removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener l)
Removes property change listener.


firePropertyChange

protected void firePropertyChange(String name,
                                  Object oldValue,
                                  Object newValue)
Fires property change event.


createSearchGroups

public static SearchGroup[] createSearchGroups(SearchType[] items)
Creates a search group for each type of object searchable by all the specified search types.

At first, a set of object types common to all search types (i.e. Classs representing object types, common to all search types) is computed. Then a search group is created for each of the Classs.

Parameters:
search - types to create search groups for
Returns:
created search groups
See Also:
SearchType.getSearchTypeClasses()

org.openidex.util/3 3.11

Built on May 28 2007.  |  Portions Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.