org.apache.commons.feedparser.network
Class BaseResourceRequest

java.lang.Object
  extended by org.apache.commons.feedparser.network.BaseResourceRequest
All Implemented Interfaces:
ResourceRequest
Direct Known Subclasses:
BlockingResourceRequest, HTTPClientNetworkResource, URLResourceRequest

public abstract class BaseResourceRequest
extends Object
implements ResourceRequest

Version:
$Id: BaseResourceRequest.java 373622 2006-01-30 22:53:00Z mvdb $
Author:
Kevin A. Burton

Field Summary
static boolean FOLLOW_REDIRECTS
           
 
Constructor Summary
BaseResourceRequest()
           
 
Method Summary
 void fireDataEvent(DataEvent event)
          Fire a new ArchiveEvent
 void fireDataEvent(long count)
          Fire a new ArchiveEvent
 void fireInit()
           
 void fireOnClosed()
           
 int getContentLength()
          Return the conent length of this request or -1 if not known.
 String getEtag()
          The HTTP ETag to use with If-None-Match
 boolean getFollowRedirects()
           
 String getHeaderField(String name)
          Get a given response header.
 long getIfModifiedSince()
          Set the If-Modified-Since header for HTTP URL connections and protocols that support similar operation.
 byte[] getInputStreamAsByteArray()
           
 String getInputStreamAsString()
          Get the given Input Stream as a String by calling read() until we have all the data locally.
 InputStream getLocalInputStream()
           
 byte[] getLocalInputStreamAsByteArray()
           
 String getRequestHeaderField(String name)
           
 Iterator getRequestHeaderFields()
          Get the names of all set request headers.
 String getResource()
          Get the value of resource.
 String getResourceFromRedirect()
          Get the resource but make sure all redirects are taken into consideration.
 long getResponseCode()
          Get and set an HTTP style response code.
 void setEtag(String etag)
           
 void setEventListener(NetworkEventListener eventListener)
           
 void setFollowRedirects(boolean v)
           
 void setIfModifiedSince(long ifModifiedSince)
           
 void setLocalCache(boolean v)
          When true we cache getLocalInputStream() so that multiple requests are returned from local data.
 void setRequestHeaderField(String name, String value)
          Set a given request header such as UserAgent, ETag, etc.
 void setRequestMethod(String method)
           
 void setResource(String resource)
          Set the value of resource.
 void setResponseCode(int responseCode)
           
 void toOutputStream(OutputStream out)
          Copy this resource request to the given OutputStream
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.commons.feedparser.network.ResourceRequest
getInputStream, init
 

Field Detail

FOLLOW_REDIRECTS

public static boolean FOLLOW_REDIRECTS
Constructor Detail

BaseResourceRequest

public BaseResourceRequest()
Method Detail

getResource

public String getResource()
Get the value of resource.

Specified by:
getResource in interface ResourceRequest

setResource

public void setResource(String resource)
Set the value of resource.

Specified by:
setResource in interface ResourceRequest

fireDataEvent

public void fireDataEvent(long count)
Fire a new ArchiveEvent


fireInit

public void fireInit()

fireDataEvent

public void fireDataEvent(DataEvent event)
Fire a new ArchiveEvent


fireOnClosed

public void fireOnClosed()

getInputStreamAsString

public String getInputStreamAsString()
                              throws IOException
Description copied from interface: ResourceRequest
Get the given Input Stream as a String by calling read() until we have all the data locally.

Specified by:
getInputStreamAsString in interface ResourceRequest
Throws:
IOException
See Also:
ResourceRequest

getInputStreamAsByteArray

public byte[] getInputStreamAsByteArray()
                                 throws IOException
Specified by:
getInputStreamAsByteArray in interface ResourceRequest
Throws:
IOException
See Also:
ResourceRequest

getLocalInputStream

public InputStream getLocalInputStream()
                                throws NetworkException
Specified by:
getLocalInputStream in interface ResourceRequest
Throws:
NetworkException
See Also:
ResourceRequest

getLocalInputStreamAsByteArray

public byte[] getLocalInputStreamAsByteArray()
                                      throws IOException
Specified by:
getLocalInputStreamAsByteArray in interface ResourceRequest
Throws:
IOException

setLocalCache

public void setLocalCache(boolean v)
Description copied from interface: ResourceRequest
When true we cache getLocalInputStream() so that multiple requests are returned from local data. Provides more flexibility but uses more memory.

Specified by:
setLocalCache in interface ResourceRequest

toOutputStream

public void toOutputStream(OutputStream out)
                    throws IOException
Copy this resource request to the given OutputStream

Specified by:
toOutputStream in interface ResourceRequest
Throws:
IOException

getIfModifiedSince

public long getIfModifiedSince()
Description copied from interface: ResourceRequest
Set the If-Modified-Since header for HTTP URL connections and protocols that support similar operation. A value of -1 means do not use the If-Modified-Since header Fri Jun 06 2003 08:34 PM (burton@peerfear.org): Currently just URLResourceRequest

Specified by:
getIfModifiedSince in interface ResourceRequest

setIfModifiedSince

public void setIfModifiedSince(long ifModifiedSince)
Specified by:
setIfModifiedSince in interface ResourceRequest

getEtag

public String getEtag()
Description copied from interface: ResourceRequest
The HTTP ETag to use with If-None-Match

Specified by:
getEtag in interface ResourceRequest

setEtag

public void setEtag(String etag)
Specified by:
setEtag in interface ResourceRequest

getResponseCode

public long getResponseCode()
Get and set an HTTP style response code. Only used with HTTP URLs.

Specified by:
getResponseCode in interface ResourceRequest

setResponseCode

public void setResponseCode(int responseCode)
Specified by:
setResponseCode in interface ResourceRequest

getContentLength

public int getContentLength()
                     throws IOException
Description copied from interface: ResourceRequest
Return the conent length of this request or -1 if not known.

Specified by:
getContentLength in interface ResourceRequest
Throws:
IOException

setEventListener

public void setEventListener(NetworkEventListener eventListener)
Specified by:
setEventListener in interface ResourceRequest

getHeaderField

public String getHeaderField(String name)
Description copied from interface: ResourceRequest
Get a given response header.

Specified by:
getHeaderField in interface ResourceRequest

setRequestHeaderField

public void setRequestHeaderField(String name,
                                  String value)
Description copied from interface: ResourceRequest
Set a given request header such as UserAgent, ETag, etc.

Specified by:
setRequestHeaderField in interface ResourceRequest

getRequestHeaderFields

public Iterator getRequestHeaderFields()
Description copied from interface: ResourceRequest
Get the names of all set request headers.

Specified by:
getRequestHeaderFields in interface ResourceRequest

getRequestHeaderField

public String getRequestHeaderField(String name)
Specified by:
getRequestHeaderField in interface ResourceRequest

setRequestMethod

public void setRequestMethod(String method)
                      throws NetworkException
Specified by:
setRequestMethod in interface ResourceRequest
Throws:
NetworkException

getFollowRedirects

public boolean getFollowRedirects()
Specified by:
getFollowRedirects in interface ResourceRequest

setFollowRedirects

public void setFollowRedirects(boolean v)
Specified by:
setFollowRedirects in interface ResourceRequest

getResourceFromRedirect

public String getResourceFromRedirect()
Description copied from interface: ResourceRequest
Get the resource but make sure all redirects are taken into consideration.

Specified by:
getResourceFromRedirect in interface ResourceRequest


Copyright © 2001-2010 The Apache Software Foundation. All Rights Reserved.