|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.weborganic.bastille.cache.util.StaticResource
public final class StaticResource
A Serializable
representation of a cached resource designed for
static file based content.
The etag is based on the last modified date.
If the resource is considered to be gzippable, the body content is stored compressed, otherwise it is sent raw.
Constructor Summary | |
---|---|
StaticResource(int status,
String contentType,
byte[] body,
long modified,
String cacheControl,
long expires)
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 |
isOK()
Returns true if the response is OK (200). |
static long |
toLastModified(String etag)
Returns the last modified date form the etag. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public StaticResource(int status, String contentType, byte[] body, long modified, String cacheControl, long expires) throws IOException
status
- The HTTP status code of the responsecontentType
- The content typebody
- The body in bytes to storemodified
- The last modified date of the resource.cacheControl
- The cache control header for this static resourceexpires
- When this resource expires
IOException
- If the content was already gzippedMethod Detail |
---|
public String getContentType()
getContentType
in interface CachedResource
public int getStatusCode()
getStatusCode
in interface CachedResource
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 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 hasContent()
hasContent
in interface CachedResource
true
if the body is not null
and would not result in a 0-length content.public boolean hasGzippedBody()
hasGzippedBody
in interface CachedResource
true
if there is a non null
gzipped bodypublic 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 List<HttpHeader<? extends Serializable>> getHeaders(boolean gzipped)
getHeaders
in interface CachedResource
gzipped
- true
if the content is sent gzipped;
false
otherwise.
public void copyHeadersTo(javax.servlet.http.HttpServletResponse res, boolean gzipped)
CachedResource
copyHeadersTo
in interface CachedResource
res
- The HTTP servlet response where the headers should be copied.gzipped
- true
if the content is sent gzipped;
false
otherwise.public static long toLastModified(String etag)
etag
- the etag used
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |