org.weborganic.bastille.cache.util
Interface CachedResource

All Known Implementing Classes:
GenericResource, StaticResource

public interface CachedResource

A interface for cached resources.


Method Summary
 void copyHeadersTo(javax.servlet.http.HttpServletResponse res, boolean gzipped)
          Copy the headers to the HTTP servlet response.
 byte[] getBody(boolean gzipped)
          Returns the body content as bytes.
 String getContentType()
           
 String getETag(boolean gzipped)
          Returns the etag for this resource.
 List<HttpHeader<? extends Serializable>> getHeaders(boolean gzipped)
           
 long getLastModified()
          Returns the last modified date for this resource.
 int getStatusCode()
           
 boolean hasContent()
           
 boolean hasGzippedBody()
           
 boolean isOK()
          Returns true if the response is OK (200).
 

Method Detail

getContentType

String getContentType()
Returns:
the content type of the response.

getStatusCode

int getStatusCode()
Returns:
the HTTP status code of the response.

getBody

byte[] getBody(boolean gzipped)
               throws IOException
Returns the body content as bytes.

If the content is gzippable, this method will unzip the content on demand.

If the content is not gzippable, this method will trown a

Parameters:
gzipped - true to request the gzipped content; false to get the raw content.
Returns:
the ungzipped version of the body.
Throws:
IOException - if thrown while ungzipping the content.

hasContent

boolean hasContent()
Returns:
true if the body is not null and would not result in a 0-length content.

hasGzippedBody

boolean hasGzippedBody()
Returns:
true if there is a non null gzipped body

isOK

boolean isOK()
Returns true if the response is OK (200).

Returns:
true if the status code is 200; false for any other code.

getLastModified

long getLastModified()
Returns the last modified date for this resource.

Returns:
the last modified date if there is an "Last-Modified" header defined; -1 otherwise.

getETag

String getETag(boolean gzipped)
Returns the etag for this resource.

Parameters:
gzipped - true to get the etag for a gzipped content; false to get the etag for raw content.
Returns:
the etag if there is an "Etag" header defined; null otherwise.

getHeaders

List<HttpHeader<? extends Serializable>> getHeaders(boolean gzipped)
Parameters:
gzipped - true if the content is sent gzipped; false otherwise.
Returns:
All of the headers set on the page.

copyHeadersTo

void copyHeadersTo(javax.servlet.http.HttpServletResponse res,
                   boolean gzipped)
Copy the headers to the HTTP servlet response.

Parameters:
res - The HTTP servlet response where the headers should be copied.
gzipped - true if the content is sent gzipped; false otherwise.