yarfraw.io
Class FeedReader

java.lang.Object
  extended by yarfraw.io.FeedReader
Direct Known Subclasses:
CachedFeedReader

public class FeedReader
extends Object

Provides a set of function to facilitate reading of a RSS feed.

Author:
jliang

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
FeedReader(File file)
          Constructs a FeedReader to read from a local file.
FeedReader(File file, FeedFormat format)
          Constructs a FeedReader to read from a local file.
FeedReader(org.apache.commons.httpclient.methods.GetMethod getMethod)
          Constructs a FeedReader to read from a remote source using Http.
FeedReader(org.apache.commons.httpclient.HttpURL httpUrl)
          Constructs a FeedReader to read from a remote source using Http.
FeedReader(org.apache.commons.httpclient.HttpURL httpUrl, org.apache.commons.httpclient.params.HttpClientParams params)
          Constructs a FeedReader to read from a remote source using Http.
FeedReader(String pathName)
          Constructs a FeedReader to read from a local file.
FeedReader(String pathName, FeedFormat format)
          Constructs a FeedReader to read from a local file.
FeedReader(URI uri)
          Constructs a FeedReader to read from a local file.
FeedReader(URI uri, FeedFormat format)
          Constructs a FeedReader to read from a local file.
 
Method Summary
 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()
           
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.
static ChannelFeed readChannel(FeedFormat format, InputStream inputStream)
          Reads a channel from a local or remote feed with a custom ValidationEventHandler
 ChannelFeed readChannel(ValidationEventHandler validationEventHandler)
          Reads a channel from a local or remote feed with a custom ValidationEventHandler
 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)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_httpUrl

protected org.apache.commons.httpclient.HttpURL _httpUrl

_httpClientParams

protected org.apache.commons.httpclient.params.HttpClientParams _httpClientParams

_getMethod

protected org.apache.commons.httpclient.methods.GetMethod _getMethod

_file

protected File _file

_format

protected FeedFormat _format
Constructor Detail

FeedReader

public FeedReader(File file,
                  FeedFormat format)
Constructs a FeedReader to read from a local file.

Parameters:
file - - the local file to be read from
format - - the FeedFormat of the feed.

FeedReader

public FeedReader(String pathName,
                  FeedFormat format)
Constructs a FeedReader to read from a local file.

Parameters:
pathName - - full path of the file
format - - the FeedFormat of the feed.

FeedReader

public FeedReader(URI uri,
                  FeedFormat format)
Constructs a FeedReader to read from a local file.

Parameters:
uri - - the URI that points to the file
format - - the FeedFormat of the feed.

FeedReader

public FeedReader(File file)
Constructs a FeedReader to read from a local file.
Note the FeedFormat will be set to default which is RSS 2.0

Parameters:
file - - a local file

FeedReader

public FeedReader(String pathName)
Constructs a FeedReader to read from a local file.
Note the FeedFormat will be set to default which is RSS 2.0

Parameters:
pathName - - full path of the file

FeedReader

public FeedReader(URI uri)
Constructs a FeedReader to read from a local file.
Note the FeedFormat will be set to default which is RSS 2.0

Parameters:
uri - - the uril that points to the file

FeedReader

public FeedReader(org.apache.commons.httpclient.HttpURL httpUrl,
                  org.apache.commons.httpclient.params.HttpClientParams params)
           throws YarfrawException,
                  IOException
Constructs a FeedReader to read from a remote source using Http.
Format detection will be automatically performed.

Parameters:
httpUrl - - the HttpURL of the remote source
params - - any HttpClientParams
Throws:
YarfrawException - - if parse failed
IOException - - if format detection failed

FeedReader

public FeedReader(org.apache.commons.httpclient.HttpURL httpUrl)
           throws YarfrawException,
                  IOException
Constructs a FeedReader to read from a remote source using Http.
Format detection will be automatically performed.

Parameters:
httpUrl - - the HttpURL of the remote source
Throws:
YarfrawException - - if parse failed
IOException - - if format detection failed

FeedReader

public FeedReader(org.apache.commons.httpclient.methods.GetMethod getMethod)
           throws YarfrawException,
                  IOException
Constructs a FeedReader to read from a remote source using Http.
Format detection will be automatically performed.

Parameters:
getMethod -
Throws:
YarfrawException - - if parse failed
IOException - - if format detection failed
Method Detail

readChannel

public static ChannelFeed readChannel(FeedFormat format,
                                      InputStream inputStream)
                               throws YarfrawException
Reads a channel from a local or remote feed with a custom ValidationEventHandler

Parameters:
format - any supported FeedFormat
inputStream - any InputStream
Returns:
a ChannelFeed object
Throws:
YarfrawException - if read operation failed.

readChannel

public ChannelFeed readChannel(ValidationEventHandler validationEventHandler)
                        throws YarfrawException
Reads a channel from a local or remote feed with a custom ValidationEventHandler

Parameters:
validationEventHandler - a custom ValidationEventHandler
Returns:
a ChannelFeed object
Throws:
YarfrawException - if read operation failed.

readChannel

public ChannelFeed readChannel()
                        throws YarfrawException
Reads a channel from a local or remote feed.

Returns:
a ChannelFeed object
Throws:
YarfrawException - if read operation failed.

getHttpClientParams

public org.apache.commons.httpclient.params.HttpClientParams getHttpClientParams()

setHttpClientParams

public void setHttpClientParams(org.apache.commons.httpclient.params.HttpClientParams httpClientParams)

getGetMethod

public org.apache.commons.httpclient.methods.GetMethod getGetMethod()
The GetMethod object to be used to remote from a remote source.

Returns:

isRemoteRead

public boolean isRemoteRead()
Is the reader reading the feed from a remote http link.

Returns:
true if reading remotely
false if reading from local file

getStream

protected InputStream getStream()
                         throws IOException
Throws:
IOException

getFile

public File getFile()

setFile

public void setFile(File file)

getFormat

public FeedFormat getFormat()
The FeedFormat this writer should be using.
if this is not set, the default is RSS 2.0 format. null format is ignored

rss 2.0 is recommended, use other format if you really need to


setFormat

public void setFormat(FeedFormat format)
The FeedFormat this writer should be using.
if this is not set, the default is RSS 2.0 format. null format is ignored

rss 2.0 is recommended, use other format if you really need to



Copyright © 2008. All Rights Reserved.