JXTA

net.jxta.instantp2p
Class Search

java.lang.Object
  |
  +--net.jxta.instantp2p.Search

public class Search
extends java.lang.Object
implements java.lang.Runnable


Field Summary
static java.lang.String DEFAULT_DIR
           
 
Constructor Summary
Search(net.jxta.peergroup.PeerGroup inGroup, java.io.File inDir)
          Creates a new Search instance.
 
Method Summary
 void addListener(SearchListener l)
          Adds a new SearchListener to this Search instance
 void cancel()
          Cancels a previously started search This is done by calling cancel for each ListRequestor instance in request
 SearchResult[] getResults()
          Returns a list of SearchResult instances that where found
 void removeListener(SearchListener l)
          Removes a SearchListener from this Search instance
 void run()
          The thread starts the remote discovery of PipeAdvertisement and then checks back periodically whether some where found.
 void search(java.lang.String subString, ProgressReporter reporter)
          Start a search in the given peer group.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_DIR

public static final java.lang.String DEFAULT_DIR
Constructor Detail

Search

public Search(net.jxta.peergroup.PeerGroup inGroup,
              java.io.File inDir)
Creates a new Search instance. This means, we start a new thread which immediately starts to execute the run method in this class
Parameters:
inGroup - the peer group for which to do the search
inDir - the directory in which CMS stores data for peer group inGroup
Method Detail

search

public void search(java.lang.String subString,
                   ProgressReporter reporter)
Start a search in the given peer group. Any previous search is canceled. The search is done by starting a ListRequestor instance for each PipeAdvertisement in pipes
Parameters:
subString - the string for which to search
reporter - ProgressReporter that shows the progress

cancel

public void cancel()
Cancels a previously started search This is done by calling cancel for each ListRequestor instance in request

addListener

public void addListener(SearchListener l)
Adds a new SearchListener to this Search instance
Parameters:
l - the SearchListener to add

removeListener

public void removeListener(SearchListener l)
Removes a SearchListener from this Search instance
Parameters:
l - the SearchListener to remove

getResults

public SearchResult[] getResults()
Returns a list of SearchResult instances that where found
Returns:
a list of SearchResult instances that where found

run

public void run()
The thread starts the remote discovery of PipeAdvertisement and then checks back periodically whether some where found. If so, we add them to our list of pipes. Initiation of remote discovery is also started periodically.
Specified by:
run in interface java.lang.Runnable

JXTA