org.apache.commons.feedparser.network
Interface ResourceRequest

All Known Implementing Classes:
BaseResourceRequest, BlockingResourceRequest, HTTPClientNetworkResource, URLResourceRequest

public interface ResourceRequest

A ResourceRequest is a generic interface to a network resource such as an HTTP URL.

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

Method Summary
 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.
 InputStream getInputStream()
          Get an input stream for this content.
 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()
          Set the resource for this request.
 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 init()
          Perform all initialization and connection to the remote server.
 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)
           
 void setResponseCode(int responseCode)
           
 void toOutputStream(OutputStream out)
          Copy this input stream to an OutputStream
 

Method Detail

init

void init()
          throws IOException
Perform all initialization and connection to the remote server. This should always be called BEFORE network getInputStream() if you want to perform other operations first. When using a HEAD request this must be used and not getInputStream()

Throws:
IOException

getInputStream

InputStream getInputStream()
                           throws IOException
Get an input stream for this content.

Throws:
IOException

getResource

String getResource()
Set the resource for this request.


setResource

void setResource(String resource)

getResourceFromRedirect

String getResourceFromRedirect()
Get the resource but make sure all redirects are taken into consideration.


getInputStreamAsString

String getInputStreamAsString()
                              throws IOException
Get the given Input Stream as a String by calling read() until we have all the data locally.

Throws:
IOException

getInputStreamAsByteArray

byte[] getInputStreamAsByteArray()
                                 throws IOException
Throws:
IOException

getLocalInputStream

InputStream getLocalInputStream()
                                throws NetworkException
Throws:
NetworkException

getLocalInputStreamAsByteArray

byte[] getLocalInputStreamAsByteArray()
                                      throws IOException
Throws:
IOException

setLocalCache

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


toOutputStream

void toOutputStream(OutputStream out)
                    throws IOException
Copy this input stream to an OutputStream

Throws:
IOException

getIfModifiedSince

long getIfModifiedSince()
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


setIfModifiedSince

void setIfModifiedSince(long ifModifiedSince)

getEtag

String getEtag()
The HTTP ETag to use with If-None-Match


setEtag

void setEtag(String etag)

getResponseCode

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


setResponseCode

void setResponseCode(int responseCode)

getContentLength

int getContentLength()
                     throws IOException
Return the conent length of this request or -1 if not known.

Throws:
IOException

setEventListener

void setEventListener(NetworkEventListener eventListener)

getHeaderField

String getHeaderField(String name)
Get a given response header.


setRequestHeaderField

void setRequestHeaderField(String name,
                           String value)
Set a given request header such as UserAgent, ETag, etc.


getRequestHeaderFields

Iterator getRequestHeaderFields()
Get the names of all set request headers.


getRequestHeaderField

String getRequestHeaderField(String name)

setRequestMethod

void setRequestMethod(String method)
                      throws NetworkException
Throws:
NetworkException

getFollowRedirects

boolean getFollowRedirects()

setFollowRedirects

void setFollowRedirects(boolean v)


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