p2ps.imp.discovery
Class FileDiscoveryCache

java.lang.Object
  extended byp2ps.imp.discovery.FileDiscoveryCache

public class FileDiscoveryCache
extends java.lang.Object

A file cache of advertisements and queries. Methods are provided to query the cached advertisements and queries.

Version:
$Revision: 295 $
Author:
Ian Wang

Constructor Summary
FileDiscoveryCache()
           
 
Method Summary
 java.util.Iterator advertIterator()
           
 java.util.Iterator advertIterator(Query query)
           
 void cache(Advertisement advert)
          Adds an advertisement/query to the cache
 void init(java.lang.String name, Peer peer)
           
static boolean isMatch(Query query, Advertisement advert)
           
 boolean isQuery(Advertisement advert)
           
 java.util.Iterator queryIterator()
           
 java.util.Iterator queryIterator(Advertisement advert)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileDiscoveryCache

public FileDiscoveryCache()
Method Detail

init

public void init(java.lang.String name,
                 Peer peer)

isQuery

public boolean isQuery(Advertisement advert)
Returns:
true if the specified advert is a query

cache

public void cache(Advertisement advert)
Adds an advertisement/query to the cache


advertIterator

public java.util.Iterator advertIterator()
Returns:
an iterator over all advertisements (including queries) in the cache

queryIterator

public java.util.Iterator queryIterator()
Returns:
an iterator over all queries in the cache

advertIterator

public java.util.Iterator advertIterator(Query query)
Returns:
an iterator over the advertisements that match the specified query

queryIterator

public java.util.Iterator queryIterator(Advertisement advert)
Returns:
an iterator over the queries that would match the specified advertisement

isMatch

public static boolean isMatch(Query query,
                              Advertisement advert)
Returns:
true if the advert matches the query according to the P2PS query naming conventions.