cz.cuni.pogamut.posh.explorer
Class Crawler<T>

Package class diagram package Crawler
java.lang.Object
  extended by cz.cuni.pogamut.posh.explorer.Crawler<T>
Type Parameters:
T - what is crawler crawling

public abstract class Crawler<T>
extends Object

One time use class for crawling the primitives and providing them to the explorer.

Author:
Honza

Field Summary
protected  Set<T> cache
          Set of all values found by this crawler.
protected  Set<T> cacheUm
          Unmodifiable wrapper of cache.
protected  Set<CrawlerListener<T>> listeners
          Set of listeners for crawler.
protected  Set<CrawlerListener<T>> listenersUm
          Unmodifiable wrapper of listeners.
 
Constructor Summary
Crawler()
           
 
Method Summary
 boolean addListener(CrawlerListener<T> listener)
          Add listener for crawler.
abstract  void crawl()
          Start crawling for the primitives.
abstract  void die()
          Terminate the crawler, once this is called, crawler should die and liseners shouldn't recieve any further messages.
abstract  String getDescription()
          Get description of the primitive.
abstract  String getName()
          Get name of primitive this provider is crawling
protected  void notifyCrawledData(Collection<T> data)
          Notify all listeners that we have new data as result of diligent crawling.
protected  void notifyFinished(boolean error)
          Notify all listeners that crawling has been finished.
protected  void notifyStarted()
          Notify all listeners that crawling has started.
 boolean removeListener(CrawlerListener<T> listener)
          Remove crawler listener from set of listeners.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

listeners

protected final Set<CrawlerListener<T>> listeners
Set of listeners for crawler. Please use unmodifiable version.


listenersUm

protected final Set<CrawlerListener<T>> listenersUm
Unmodifiable wrapper of listeners.


cache

protected final Set<T> cache
Set of all values found by this crawler.


cacheUm

protected final Set<T> cacheUm
Unmodifiable wrapper of cache.

Constructor Detail

Crawler

public Crawler()
Method Detail

getName

public abstract String getName()
Get name of primitive this provider is crawling

Returns:
name of primitive (lower case, human readable)

getDescription

public abstract String getDescription()
Get description of the primitive. What does it do ect.

Returns:
description of primitive

crawl

public abstract void crawl()
Start crawling for the primitives. All you need to do is to call this method, it will notify listeners about progress and in due time it terminates itself (no need for programmer to take care about that).
DO NOT CALL TWICE, create new crawler in you need to.
Once crawling starts, it will notify listeners about progress(using CrawlerListener).
If you have to stop the crawling prematurely, use {@link Crawler#die() }.

See Also:
CrawlerListener

die

public abstract void die()
Terminate the crawler, once this is called, crawler should die and liseners shouldn't recieve any further messages. This will notify all listeners with CrawlerListener#finished(boolean) .


addListener

public final boolean addListener(CrawlerListener<T> listener)
Add listener for crawler.

Parameters:
listener - listener to add
Returns:
true if listener wans't already in the set of all listeners

removeListener

public final boolean removeListener(CrawlerListener<T> listener)
Remove crawler listener from set of listeners.

Parameters:
listener - listener to remove
Returns:
true if listener was in set of crawler listeners.

notifyStarted

protected final void notifyStarted()
Notify all listeners that crawling has started.


notifyCrawledData

protected final void notifyCrawledData(Collection<T> data)
Notify all listeners that we have new data as result of diligent crawling.


notifyFinished

protected final void notifyFinished(boolean error)
Notify all listeners that crawling has been finished.

Parameters:
error - am I ending due to an error?


Copyright © 2013 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.