net.spy.net
Class URLItem

java.lang.Object
  extended by net.spy.SpyObject
      extended by net.spy.net.URLItem
All Implemented Interfaces:
Runnable

public class URLItem
extends SpyObject
implements Runnable

A particular URL that's being watched.


Constructor Summary
URLItem(URL u)
          Get an instance of URLItem.
URLItem(URL u, int i)
          Get an instance of URLItem.
 
Method Summary
 String getContent()
          Get the content from the last fetch.
protected  HTTPFetch getFetcher(Map<String,List<String>> headers)
          Get a fetcher (override for testing).
 long getLastRequest()
          Find out when the last request was.
 int getMaxIdleTime()
          Get the maximum number of milliseconds this URL will remain in the container if nothing requests it.
 int getUpdateFrequency()
          Get the update frequency.
 URL getURL()
          Get the URL this thing is watching.
 boolean isRunning()
          True if this is still running.
 void run()
           
 void setMaxIdleTime(int to)
          Set the maximum number of milliseconds this URL will remain in the container if nothing requests it.
 String waitForContent(long dur, TimeUnit timeunit)
          Wait for content to arrive.
 
Methods inherited from class net.spy.SpyObject
getLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

URLItem

public URLItem(URL u)
Get an instance of URLItem.

Parameters:
u - URL to watch

URLItem

public URLItem(URL u,
               int i)
Get an instance of URLItem.

Parameters:
u - URL to watch
i - the update frequency
Method Detail

getFetcher

protected HTTPFetch getFetcher(Map<String,List<String>> headers)
Get a fetcher (override for testing).


getContent

public String getContent()
                  throws IOException
Get the content from the last fetch.

Throws:
IOException

waitForContent

public String waitForContent(long dur,
                             TimeUnit timeunit)
                      throws InterruptedException,
                             TimeoutException
Wait for content to arrive.

Throws:
InterruptedException
TimeoutException

getLastRequest

public long getLastRequest()
Find out when the last request was.

Returns:
the timestamp of the last request.

getURL

public URL getURL()
Get the URL this thing is watching.

Returns:
the URL

setMaxIdleTime

public void setMaxIdleTime(int to)
Set the maximum number of milliseconds this URL will remain in the container if nothing requests it.


getMaxIdleTime

public int getMaxIdleTime()
Get the maximum number of milliseconds this URL will remain in the container if nothing requests it.


isRunning

public boolean isRunning()
True if this is still running.


getUpdateFrequency

public int getUpdateFrequency()
Get the update frequency.


run

public void run()
Specified by:
run in interface Runnable


Copyright © 1995-2007 SPY Internetworking. All Rights Reserved.