|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.weborganic.bastille.cache.util.GenericResource
public final class GenericResource
A Serializable
representation of a cached resource.
Constructor Summary | |
---|---|
GenericResource(int status,
String contentType,
byte[] body,
boolean storeGzipped,
Collection<HttpHeader<? extends Serializable>> headers)
Creates a PageInfo object representing the "page". |
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. |
byte[] |
getGzippedBody()
Returns the gzip content if stored as such. |
List<HttpHeader<? extends Serializable>> |
getHeaders(boolean gzipped)
|
long |
getLastModified()
Returns the last modified date for this resource. |
int |
getStatusCode()
|
byte[] |
getUngzippedBody()
Returns the ungzipped content. |
boolean |
hasContent()
|
boolean |
hasGzippedBody()
|
boolean |
hasUngzippedBody()
|
boolean |
isOK()
Returns true if the response is OK (200). |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public GenericResource(int status, String contentType, byte[] body, boolean storeGzipped, Collection<HttpHeader<? extends Serializable>> headers) throws IOException
status
- The HTTP status code of the responsecontentType
- The content typebody
- The body in bytes to storestoreGzipped
- true
to store the content as compressed (for text);
false
otherwise (for image)headers
- The headers for this cached resource.
IOException
- If the content was already gzippedMethod Detail |
---|
public String getContentType()
getContentType
in interface CachedResource
public int getStatusCode()
getStatusCode
in interface CachedResource
public List<HttpHeader<? extends Serializable>> getHeaders(boolean gzipped)
getHeaders
in interface CachedResource
gzipped
- true
if the content is sent gzipped;
false
otherwise.
public boolean hasContent()
hasContent
in interface CachedResource
true
if the body is not null
and would not result in a 0-length content.public byte[] getGzippedBody()
null
public byte[] getUngzippedBody() throws IOException
If the content is stored gzipped, this method will unzip the content on demand.
IOException
- if thrown whil ungzippind the content.public boolean hasGzippedBody()
hasGzippedBody
in interface CachedResource
true
if there is a non null
gzipped bodypublic boolean hasUngzippedBody()
true
if there is a non null ungzipped bodypublic byte[] getBody(boolean gzipped) throws IOException
CachedResource
If the content is gzippable, this method will unzip the content on demand.
If the content is not gzippable, this method will trown a
getBody
in interface CachedResource
gzipped
- true
to request the gzipped content;
false
to get the raw content.
IOException
- if thrown while ungzipping the content.public boolean isOK()
true
if the response is OK (200).
isOK
in interface CachedResource
true
if the status code is 200;
false
for any other code.public long getLastModified()
getLastModified
in interface CachedResource
public String getETag(boolean gzipped)
CachedResource
getETag
in interface CachedResource
gzipped
- true
to get the etag for a gzipped content;
false
to get the etag for raw content.
null
otherwise.public void copyHeadersTo(javax.servlet.http.HttpServletResponse res, boolean gzipped)
copyHeadersTo
in interface CachedResource
res
- The HTTP servlet response where the headers should be copied.gzipped
- Whether the content was sent gzipped
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |