|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectyarfraw.io.FeedReader
yarfraw.io.CachedFeedReader
public class CachedFeedReader
This is a special FeedReader that supports "conditional get".
When a client first asks this reader to read from a remote source, this
reader automatically holds a reference to the returned ChannelFeed.
When a client asks this reader to read again from the remote source, this reader
first queries the server to check if there's any new changes (by checking its last
modified date). If there is new changes, it reads and parse the updated feed and updates
the cache ChannelFeed. If there is no new changes since the last read, it returns
the cached ChannelFeed since there's no new changes.
Since this reader only need to perform parsing when there's new changes, it will
have better performance than the normal FeedReader class.
for more information about conditional get, see <a href="http://fishbowl.pastiche.org/2002/10/21/http_conditional_get_for_rss_hackers" />
| Field Summary | |
|---|---|
protected File |
_file
|
protected FeedFormat |
_format
|
protected org.apache.commons.httpclient.methods.GetMethod |
_getMethod
|
protected org.apache.commons.httpclient.params.HttpClientParams |
_httpClientParams
|
protected org.apache.commons.httpclient.HttpURL |
_httpUrl
|
| Constructor Summary | |
|---|---|
CachedFeedReader(org.apache.commons.httpclient.HttpURL httpUrl)
Constructs a CachedFeedReader to read from a remote source using Http. |
|
CachedFeedReader(org.apache.commons.httpclient.HttpURL httpUrl,
org.apache.commons.httpclient.params.HttpClientParams params)
Constructs a CachedFeedReader to read from a remote source using Http. |
|
| Method Summary | |
|---|---|
ChannelFeed |
getCachedChannelFeed()
|
String |
getETag()
|
File |
getFile()
|
FeedFormat |
getFormat()
The FeedFormat this writer should be using.if this is not set, the default is RSS 2.0 format. |
org.apache.commons.httpclient.methods.GetMethod |
getGetMethod()
The GetMethod object to be used to remote from a remote source. |
org.apache.commons.httpclient.params.HttpClientParams |
getHttpClientParams()
|
String |
getLastModified()
|
protected InputStream |
getStream()
|
boolean |
isRemoteRead()
Is the reader reading the feed from a remote http link. |
ChannelFeed |
readChannel()
Reads a channel from a local or remote feed. |
ChannelFeed |
readChannel(ValidationEventHandler validationEventHandler)
Reads a channel from a local or remote feed with a custom ValidationEventHandler
This method performs conditional get, if the remote is not modified since last request, the cached feed will be returned. |
void |
setETag(String tag)
Setter for the "ETag" response header. |
void |
setFile(File file)
|
void |
setFormat(FeedFormat format)
The FeedFormat this writer should be using.if this is not set, the default is RSS 2.0 format. |
void |
setHttpClientParams(org.apache.commons.httpclient.params.HttpClientParams httpClientParams)
|
void |
setLastModified(String lastModified)
Setter for the "Last-Modified" response header. |
| Methods inherited from class yarfraw.io.FeedReader |
|---|
readChannel |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected org.apache.commons.httpclient.HttpURL _httpUrl
protected org.apache.commons.httpclient.params.HttpClientParams _httpClientParams
protected org.apache.commons.httpclient.methods.GetMethod _getMethod
protected File _file
protected FeedFormat _format
| Constructor Detail |
|---|
public CachedFeedReader(org.apache.commons.httpclient.HttpURL httpUrl,
org.apache.commons.httpclient.params.HttpClientParams params)
throws YarfrawException,
IOException
CachedFeedReader to read from a remote source using Http.
httpUrl - - the HttpURL of the remote sourceparams - - any HttpClientParams
YarfrawException - - if parse failed
IOException - - if format detection failed
public CachedFeedReader(org.apache.commons.httpclient.HttpURL httpUrl)
throws YarfrawException,
IOException
CachedFeedReader to read from a remote source using Http.
httpUrl - - the HttpURL of the remote source
YarfrawException - - if parse failed
IOException - - if format detection failed| Method Detail |
|---|
public ChannelFeed readChannel()
throws YarfrawException
readChannel in class FeedReaderChannelFeed object
YarfrawException - if read operation failed.
public ChannelFeed readChannel(ValidationEventHandler validationEventHandler)
throws YarfrawException
ValidationEventHandler
readChannel in class FeedReadervalidationEventHandler - a custom ValidationEventHandler
ChannelFeed object
YarfrawException - if read operation failed.
protected InputStream getStream()
throws IOException
IOExceptionpublic String getLastModified()
public String getETag()
public void setETag(String tag)
readChannel() method call.
tag - public void setLastModified(String lastModified)
readChannel() method call.
tag - public ChannelFeed getCachedChannelFeed()
public org.apache.commons.httpclient.params.HttpClientParams getHttpClientParams()
public void setHttpClientParams(org.apache.commons.httpclient.params.HttpClientParams httpClientParams)
public org.apache.commons.httpclient.methods.GetMethod getGetMethod()
GetMethod object to be used to remote from a remote source.
public boolean isRemoteRead()
public File getFile()
public void setFile(File file)
public FeedFormat getFormat()
FeedFormat this writer should be using.null format is ignored
rss 2.0 is recommended, use other format if you really need to
public void setFormat(FeedFormat format)
FeedFormat this writer should be using.null format is ignored
rss 2.0 is recommended, use other format if you really need to
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||