com.openharbor.beck.map
Class PollableURL

java.lang.Object
  extended bycom.openharbor.beck.map.PollableURL
All Implemented Interfaces:
PollableInput

public class PollableURL
extends java.lang.Object
implements PollableInput

A document identified by a URL, with a relatively efficient method to check whether it has changed. This class is not thread-safe.


Nested Class Summary
protected static class PollableURL.Description
          Properties of a document that are examined to decide whether it has changed.
 
Field Summary
protected  long expirationTime
           
protected  org.apache.commons.logging.Log log
           
protected static long NEVER
           
protected static long UNKNOWN
           
protected static long UNKNOWN_TIME
           
 
Fields inherited from interface com.openharbor.beck.map.PollableInput
SECONDS
 
Constructor Summary
PollableURL(java.net.URL url)
           
 
Method Summary
protected  PollableURL.Description getDescription(java.net.URLConnection connection)
          This method must not consume data from getInputStream(connection).
protected  void getExpirationTime(java.net.URLConnection connection)
          Note the document's expiration time (if any).
protected  java.io.InputStream getInputStream(java.net.URLConnection connection)
           
 java.lang.String getSystemID()
          The SystemID that identifies the input source, or null if its SystemID is unknown.
 java.net.URL getURL()
           
 java.io.InputStream input()
          Begin reading the data (as a stream of bytes).
 java.io.InputStream inputIfModified()
          Begin reading the data (as a stream of bytes) if it has changed since the last call to input() or inputIfModified().
 void pollSoon()
          Check for a change in the data next time inputIfModified is called, regardless of the currently acceptable staleness.
 void setAcceptableStaleness(long msec)
          Set the maximum amount of time that may elapse from a change in the data until the change is detected by this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected final org.apache.commons.logging.Log log

expirationTime

protected long expirationTime

UNKNOWN

protected static final long UNKNOWN
See Also:
Constant Field Values

UNKNOWN_TIME

protected static final long UNKNOWN_TIME
See Also:
Constant Field Values

NEVER

protected static final long NEVER
See Also:
Constant Field Values
Constructor Detail

PollableURL

public PollableURL(java.net.URL url)
Method Detail

getURL

public java.net.URL getURL()

setAcceptableStaleness

public void setAcceptableStaleness(long msec)
Description copied from interface: PollableInput
Set the maximum amount of time that may elapse from a change in the data until the change is detected by this object.

Specified by:
setAcceptableStaleness in interface PollableInput
Parameters:
msec - the acceptable staleness, in units of milliseconds.

getSystemID

public java.lang.String getSystemID()
Description copied from interface: PollableInput
The SystemID that identifies the input source, or null if its SystemID is unknown.

Specified by:
getSystemID in interface PollableInput

input

public java.io.InputStream input()
                          throws java.io.IOException
Description copied from interface: PollableInput
Begin reading the data (as a stream of bytes).

Specified by:
input in interface PollableInput
Throws:
java.io.IOException

inputIfModified

public java.io.InputStream inputIfModified()
                                    throws java.io.IOException
Description copied from interface: PollableInput
Begin reading the data (as a stream of bytes) if it has changed since the last call to input() or inputIfModified().

Specified by:
inputIfModified in interface PollableInput
Returns:
a stream that will produce the data, or null to indicate that the data have not changed.
Throws:
java.io.IOException

pollSoon

public void pollSoon()
Description copied from interface: PollableInput
Check for a change in the data next time inputIfModified is called, regardless of the currently acceptable staleness.

Specified by:
pollSoon in interface PollableInput

getDescription

protected PollableURL.Description getDescription(java.net.URLConnection connection)
                                          throws java.io.IOException
This method must not consume data from getInputStream(connection). If it must consume connection.getInputStream(), then this.getInputStream must be overridden to compensate; e.g. using a 'read-ahead' buffer.

Throws:
java.io.IOException

getExpirationTime

protected void getExpirationTime(java.net.URLConnection connection)
Note the document's expiration time (if any).


getInputStream

protected java.io.InputStream getInputStream(java.net.URLConnection connection)
                                      throws java.io.IOException
Throws:
java.io.IOException