org.lobobrowser.clientlet
Interface ClientletResponse


public interface ClientletResponse

Represents a URL response such as an HTTP or file protocol response.


Method Summary
 java.lang.String getCharset()
          Gets the charset specified with the content type.
 int getContentLength()
          Gets the content length of the reponse.
 java.lang.String getContentType()
          Gets the response content type.
 java.util.Date getDate()
          Gets the value of the "Date" header.
 java.lang.String getHeader(java.lang.String name)
          Gets a response header.
 java.util.Iterator getHeaderNames()
          Gets an iterator of response header names.
 java.lang.String[] getHeaders(java.lang.String name)
          Gets all values for a particular header.
 java.io.InputStream getInputStream()
          Gets the response stream.
 java.lang.String getLastRequestMethod()
          Gets the request method for the response URL.
 java.lang.String getMimeType()
          Gets only the mime-type part of the content type, e.g.
 java.lang.Object getPersistentCachedObject(java.lang.ClassLoader classLoader)
          If available, gets an object previously persisted along with the cached document.
 RequestType getRequestType()
          Gets the type of request.
 int getResponseCode()
          Gets the HTTP response or status code.
 java.lang.String getResponseMessage()
          Gets the HTTP response message.
 java.net.URL getResponseURL()
          Gets the response URL.
 java.lang.Object getTransientCachedObject()
          If available, gets an object previously cached in main memory associated with the response URL.
 int getTransientCachedObjectSize()
          Gets the approximate size in bytes of the transient cached object previously associated with the response.
 boolean isCacheable()
          Returns true only if the response is allowed to be cached.
 boolean isCharsetProvided()
          Determines whether a charset has been provided with the Content-Type header.
 boolean isFromCache()
          Returns true only if the response comes from a local cache.
 boolean isNewNavigationAction()
          Returns true only if the response does not result from a reload, forward or back.
 boolean matches(java.lang.String mimeType, java.lang.String[] fileExtension)
          A convenience method used to match parameters provided against the response mime-type or the "file extension" of the response URL's file path.
 void setNewPersistentCachedObject(java.io.Serializable object)
          Caches the object provided in persistent memory and associates it with the reponse URL, if caching is allowed.
 void setNewTransientCachedObject(java.lang.Object object, int approxSize)
          Caches an object in main memory, provided caching is allowed and there's enough memory to do so.
 

Method Detail

getResponseURL

java.net.URL getResponseURL()
Gets the response URL. This may be different to the request URL in the case of a redirect.


getLastRequestMethod

java.lang.String getLastRequestMethod()
Gets the request method for the response URL. This may be different to the original request method in case of a redirect.


getHeader

java.lang.String getHeader(java.lang.String name)
Gets a response header.

Parameters:
name - The header name.

getHeaders

java.lang.String[] getHeaders(java.lang.String name)
Gets all values for a particular header.

Parameters:
name - The header name.

getHeaderNames

java.util.Iterator getHeaderNames()
Gets an iterator of response header names.


getInputStream

java.io.InputStream getInputStream()
                                   throws java.io.IOException
Gets the response stream.

Throws:
java.io.IOException

getContentType

java.lang.String getContentType()
Gets the response content type. This can also contain a character encoding, e.g. text/html; charset=ISO-8859-1.

See Also:
getMimeType()

getMimeType

java.lang.String getMimeType()
Gets only the mime-type part of the content type, e.g. text/html.

See Also:
getContentType()

matches

boolean matches(java.lang.String mimeType,
                java.lang.String[] fileExtension)
A convenience method used to match parameters provided against the response mime-type or the "file extension" of the response URL's file path. The file extension is matched only when the mime type of the response is either application/octet-stream, content/unknown, or not provided.

Parameters:
mimeType - A mime type, e.g. application/x-acme.
fileExtension - A collection of file extensions, each starting with a dot, e.g. new String[] { ".acme", ".acm" }.
Returns:
True if the navigator considers there is a match.

getContentLength

int getContentLength()
Gets the content length of the reponse. This may be -1 if the content length is not known.


isFromCache

boolean isFromCache()
Returns true only if the response comes from a local cache.


getCharset

java.lang.String getCharset()
Gets the charset specified with the content type. If no such charset has been provided, the implementation may recommend a default.


isCharsetProvided

boolean isCharsetProvided()
Determines whether a charset has been provided with the Content-Type header.


getResponseCode

int getResponseCode()
                    throws java.io.IOException
Gets the HTTP response or status code.

Throws:
java.io.IOException

getResponseMessage

java.lang.String getResponseMessage()
                                    throws java.io.IOException
Gets the HTTP response message.

Throws:
java.io.IOException

isCacheable

boolean isCacheable()
Returns true only if the response is allowed to be cached.


isNewNavigationAction

boolean isNewNavigationAction()
Returns true only if the response does not result from a reload, forward or back. Generally, this method indicates that a response is not related to an entry already in the navigation history.


getPersistentCachedObject

java.lang.Object getPersistentCachedObject(java.lang.ClassLoader classLoader)
If available, gets an object previously persisted along with the cached document.

Parameters:
classLoader - A class loader that can load an object of the type expected.
See Also:
setNewPersistentCachedObject(Serializable)

setNewPersistentCachedObject

void setNewPersistentCachedObject(java.io.Serializable object)
Caches the object provided in persistent memory and associates it with the reponse URL, if caching is allowed.

Parameters:
object - A Serializable object.

getTransientCachedObject

java.lang.Object getTransientCachedObject()
If available, gets an object previously cached in main memory associated with the response URL.

Note: Most callers should only use the persistent cached object if isFromCache() returns true.

See Also:
setNewTransientCachedObject(Object, int)

setNewTransientCachedObject

void setNewTransientCachedObject(java.lang.Object object,
                                 int approxSize)
Caches an object in main memory, provided caching is allowed and there's enough memory to do so. The object is associated with the current response URL.

Parameters:
object - An object.
approxSize - The approximate byte size the object occupies in memory. Note that values less than the size of the response in bytes are assumed to be in error.

getTransientCachedObjectSize

int getTransientCachedObjectSize()
Gets the approximate size in bytes of the transient cached object previously associated with the response.

Note: Most callers should only use the transient cached object if isFromCache() returns true.


getDate

java.util.Date getDate()
Gets the value of the "Date" header. This method returns null if the header is not available.


getRequestType

RequestType getRequestType()
Gets the type of request.



SourceForge.net LogoCopyright © 2005, 2006, 2007 The Lobo Project. All Rights Reserved.
[Lobo Home]