Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.w3c.www.protocol.http.cache
Class EntityCachedResource

    java.lang.Object
      |
      +--org.w3c.tools.resources.AttributeHolder
            |
            +--org.w3c.www.protocol.http.cache.CachedResource
                  |
                  +--org.w3c.www.protocol.http.cache.EntityCachedResource

public class EntityCachedResource
extends CachedResource

A cached resource with an entity

Field Summary
`protected static int` | `ATTR_CONTENT_TYPE` Attribute index - The Content-Type of the resource
`protected static int` | `ATTR_FRESHNESS_LIFETIME` Attribute index - The resource's max age.
`protected static int` | `ATTR_INITIAL_AGE` Attribute index - The initial age of this resource.
`protected static int` | `ATTR_LOAD_STATE` Attribute index - The download state
`protected static int` | `ATTR_RESPONSE_TIME` Attribute index - The response time
`protected static int` | `ATTR_REVALIDATE` Attribute index - Revalidate flag
`static int` | `COND_FAILED` Condition check return code - Condition existed but failed.
`static int` | `COND_OK` Condition check return code - Condition existed and succeeded.
`protected CacheFilter` | `filter`
`protected boolean` | `hasEntity`
`protected int` | `oldsize`
`protected boolean` | `regetting`
`protected boolean` | `revalidating`
`protected boolean` | `uploading`
`protected int` | `wantedsize`

Fields inherited from class org.w3c.www.protocol.http.cache.CachedResource
`a, ATTR_CONTENT_ENCODING, ATTR_CONTENT_LANGUAGE, ATTR_CONTENT_LENGTH, ATTR_CONTENT_MD5, ATTR_CURRENT_LENGTH, ATTR_DATE, ATTR_DESCR, ATTR_ETAG, ATTR_EXTRA_HEADERS, ATTR_FILE, ATTR_IDENTIFIER, ATTR_LOAD_STATE, ATTR_REPLY_LAST_MODIFIED, ATTR_STATUS, COND_FAILED, COND_OK, filter, generation, invalidated, NAME_CONTENT_LENGTH, NAME_CURRENT_LENGTH, NAME_FILE, NAME_IDENTIFIER, next, prev, STATE_LOAD_COMPLETE, STATE_LOAD_ERROR, STATE_LOAD_PARTIAL, STATE_LOAD_UNKNOWN, STATE_NOT_LOADED`

Fields inherited from class org.w3c.tools.resources.AttributeHolder
`attributes, values`

Constructor Summary
`EntityCachedResource()`
`EntityCachedResource(CacheFilter filter, Request req, Reply rep)` A constructor for new resources that will get some data directly FIXME params

Method Summary
`int` | `checkIfMatch(Request request)` Try to validate an `If-Match` request.
`int` | `checkIfModifiedSince(Request request)` Try to validate an `If-Modified-Since` request.
`int` | `checkIfNoneMatch(Request request)` Try to validate an `If-None-Match` request.
`int` | `checkIfUnmodifiedSince(Request request)` Try to validate an `If-Unmodified-Since` request.
`protected void` | `cleanUpload()`
`MimeType` | `getContentType()` Get the Content-Type of the cached resource of `null` if there is no mime type (it should NEVER happen!)
`int` | `getCurrentAge()` Get the current age of this resource
`int` | `getFreshnessLifetime()` Get this resource's freshness lifetime (RFC2616: 13.2.4).
`HttpEntityTag` | `getHETag()` Get the entity tag associated with that cached entry
`int` | `getInitialAge()` Get this cached entry initial age.
`java.io.InputStream` | `getInputStream()` Get the cached data for that cached entry.
`long` | `getResponseTime()` Get the time of the response used to cached that entry.
`boolean` | `getRevalidate()` Get the revalidate flag
`protected Reply` | `handleRangeRequest(Request request, HttpRange r)` handle a range request, according to the first range or the request FIXME we should handle all the ranges at some point...
`void` | `initialize(java.lang.Object[] values)` The basic initialization
`void` | `notifyTeeFailure(int size)` Called when the Tee stream fails, it allows you to notify a listener of an error in the stream.
`void` | `notifyTeeSuccess(int size)` Called when the tee succeed, it allows you to notify a listener of the Tee that the download completed succesfully with a specific size
`Reply` | `perform(Request request)` This cached entry has been checked valid, perform given request.
`void` | `setContentType(MimeType type)` Set the Content-Type of this cached resource
`void` | `setFreshnessLifetime(int freshnessLifetime)` Set this cached entry .
`void` | `setInitialAge(int initage)` Set this resource's initial age.
`protected Reply` | `setReplyHeaders(Reply reply)` decorate the reply header with some meta information taken from the cached resource
`Request` | `setRequestRevalidation(Request request)` This cached entry needs revalidation, it will modify the request to do that.
`void` | `setResponseTime(long responsetime)` Set this cached entry response time.
`void` | `setRevalidate(boolean validate)` Set this cached entry revalidate flag.
`java.io.InputStream` | `tryActiveCacheContent(java.io.InputStream in)` Try using an active stream to cache the content.
`protected void` | `updateInfo(Request request, Reply reply)` sets some useful information about the entity
`protected void` | `waitUpload()` FIXME Will be replaced soon, so that multiple people may share the same temporary resource.

Methods inherited from class org.w3c.www.protocol.http.cache.CachedResource
`delete, getContentEncoding, getContentLanguage, getContentLength, getContentMD5, getCurrentLength, getDate, getETag, getExtraHeaders, getFile, getIdentifier, getLastModified, getLoadState, getNext, getPrev, getStatus, getWillRevalidate, lookupResource, setContentEncoding, setContentLanguage, setContentLength, setContentMD5, setCurrentLength, setDate, setETag, setExtraHeaders, setFile, setLastModified, setLoadState, setNext, setPrev, setStatus, setValue, setWillRevalidate`

Methods inherited from class org.w3c.tools.resources.AttributeHolder
`definesAttribute, definesAttribute, getAttributes, getBoolean, getChar, getClone, getClone, getClone, getDouble, getFloat, getInt, getLong, getString, getValue, getValue, initialize, lookupAttribute, pickleValues, print, setBoolean, setChar, setDouble, setFloat, setInt, setLong, setString, setValue`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### COND_FAILED

    public static final int COND_FAILED

  Condition check return code - Condition existed but failed.

### COND_OK

    public static final int COND_OK

  Condition check return code - Condition existed and succeeded.

### ATTR_CONTENT_TYPE

    protected static int ATTR_CONTENT_TYPE

  Attribute index - The Content-Type of the resource

### ATTR_FRESHNESS_LIFETIME

    protected static int ATTR_FRESHNESS_LIFETIME

  Attribute index - The resource's max age.

### ATTR_INITIAL_AGE

    protected static int ATTR_INITIAL_AGE

  Attribute index - The initial age of this resource.

### ATTR_RESPONSE_TIME

    protected static int ATTR_RESPONSE_TIME

  Attribute index - The response time

### ATTR_REVALIDATE

    protected static int ATTR_REVALIDATE

  Attribute index - Revalidate flag

### ATTR_LOAD_STATE

    protected static int ATTR_LOAD_STATE

  Attribute index - The download state

### uploading

    protected boolean uploading

### revalidating

    protected boolean revalidating

### regetting

    protected boolean regetting

### hasEntity

    protected boolean hasEntity

### oldsize

    protected int oldsize

### wantedsize

    protected int wantedsize

### filter

    protected CacheFilter filter

Constructor Detail

### EntityCachedResource

    public EntityCachedResource(CacheFilter filter,
                                Request req,
                                Reply rep)

  A constructor for new resources that will get some data directly FIXME params

### EntityCachedResource

    public EntityCachedResource()

Method Detail

### getContentType

    public MimeType getContentType()

  Get the Content-Type of the cached resource of `null` if there is no mime type (it should NEVER happen!)
  Overrides:
    getContentType in class CachedResource
  Returns:
    a MimeType

### setContentType

    public void setContentType(MimeType type)

  Set the Content-Type of this cached resource
  Overrides:
    setContentType in class CachedResource
  Parameters:
    `a` - MimeType, the mime type of this resource

### getFreshnessLifetime

    public int getFreshnessLifetime()

  Get this resource's freshness lifetime (RFC2616: 13.2.4).
  Overrides:
    getFreshnessLifetime in class CachedResource
  Returns:
    A long number of seconds for which that entry will remain valid, or -1 if undefined.

### setFreshnessLifetime

    public void setFreshnessLifetime(int freshnessLifetime)

  Set this cached entry . freshness lifetime (RFC2616: 13.2.4).
  Parameters:
    `maxage` - A number of seconds during which the entry will remain valid, or -1 to undefine previous setting.

### getInitialAge

    public int getInitialAge()

  Get this cached entry initial age.
  Returns:
    A long number of seconds giving the initial age or -1 if undefined.

### setInitialAge

    public void setInitialAge(int initage)

  Set this resource's initial age.
  Parameters:
    `initage` - The initial age as a number of seconds or -1 to undefine previous setting.

### getResponseTime

    public long getResponseTime()

  Get the time of the response used to cached that entry.
  Returns:
    A long number of milliseconds since Java epoch, or -1 if undefined.

### setResponseTime

    public void setResponseTime(long responsetime)

  Set this cached entry response time.
  Parameters:
    `responsetime` - A long number of milliseconds indicating the response time relative to Java epoch, or -1 to undefined previous setting.

### getRevalidate

    public boolean getRevalidate()

  Get the revalidate flag
  Returns:
    a boolean, `true` if the proxy must revalidate stale entries -1 if undefined.

### setRevalidate

    public void setRevalidate(boolean validate)

  Set this cached entry revalidate flag.
  Parameters:
    `validate,` - a boolean, `true` if this entry needs to be revalidated while stale.

### getHETag

    public HttpEntityTag getHETag()

  Get the entity tag associated with that cached entry
  Returns:
    the entity tag or null if undefined

### getInputStream

    public java.io.InputStream getInputStream()
                                       throws java.io.IOException

  Get the cached data for that cached entry.
  Returns:
    A non-buffered output stream.

### getCurrentAge

    public int getCurrentAge()

  Get the current age of this resource
  Overrides:
    getCurrentAge in class CachedResource
  Returns:
    a long the current age of this resource

### checkIfModifiedSince

    public int checkIfModifiedSince(Request request)

  Try to validate an `If-Modified-Since` request.
  Parameters:
    `request` - The request to validate.
  Returns:
    An integer, `COND_FAILED`, if the condition was checked, but failed; `COND_OK` of condition was checked and succeeded, 0 otherwise.

### checkIfUnmodifiedSince

    public int checkIfUnmodifiedSince(Request request)

  Try to validate an `If-Unmodified-Since` request.
  Parameters:
    `request` - The request to validate.
  Returns:
    An integer, `COND_FAILED`, if the condition was checked, but failed; `COND_OK` of condition was checked and succeeded, 0 otherwise.

### checkIfMatch

    public int checkIfMatch(Request request)

  Try to validate an `If-Match` request.
  Parameters:
    `request` - The request to validate.
  Returns:
    An integer, `COND_FAILED`, if the condition was checked, but failed; `COND_OK` of condition was checked and succeeded, 0 otherwise.

### checkIfNoneMatch

    public int checkIfNoneMatch(Request request)

  Try to validate an `If-None-Match` request.
  Parameters:
    `request` - The request to validate.
  Returns:
    An integer, `COND_FAILED`, if the condition was checked, but failed; `COND_OK` of condition was checked and succeeded, 0 otherwise.

### notifyTeeSuccess

    public void notifyTeeSuccess(int size)

  Called when the tee succeed, it allows you to notify a listener of the Tee that the download completed succesfully with a specific size
  Overrides:
    notifyTeeSuccess in class CachedResource

### notifyTeeFailure

    public void notifyTeeFailure(int size)

  Description copied from interface: TeeMonitor
  Called when the Tee stream fails, it allows you to notify a listener of an error in the stream.
  Overrides:
    notifyTeeFailure in class CachedResource

### cleanUpload

    protected void cleanUpload()

### waitUpload

    protected final void waitUpload()

  FIXME Will be replaced soon, so that multiple people may share the same temporary resource. Wait for the upload to finish, if needed.

### handleRangeRequest

    protected Reply handleRangeRequest(Request request,
                                       HttpRange r)

  handle a range request, according to the first range or the request FIXME we should handle all the ranges at some point...

### setReplyHeaders

    protected Reply setReplyHeaders(Reply reply)

  decorate the reply header with some meta information taken from the cached resource
  Returns:
    a reply, the one we just updated

### perform

    public Reply perform(Request request)
                  throws HttpException

  This cached entry has been checked valid, perform given request.
  Overrides:
    perform in class CachedResource
  Parameters:
    `request` - The request to perform.
  Returns:
    An Reply instance.
  Throws:
    HttpException - If something went wrong.

### tryActiveCacheContent

    public java.io.InputStream tryActiveCacheContent(java.io.InputStream in)
                                              throws java.io.IOException

  Try using an active stream to cache the content. Byte size usage is taken care of only at the end of the download to make sure we get the right sizes (might different from the advertized ones).
  Returns:
    An InputStream instance if active caching was possible, null otherwise.

### initialize

    public void initialize(java.lang.Object[] values)

  The basic initialization
  Overrides:
    initialize in class AttributeHolder
  Tags copied from class: AttributeHolder
  Parameters:
    `values` - The attribute values the holder should initialize from.

### updateInfo

    protected void updateInfo(Request request,
                              Reply reply)

  sets some useful information about the entity
  Parameters:
    `the` - request that requested this entity
    `the` - reply triggered by this request

### setRequestRevalidation

    public Request setRequestRevalidation(Request request)

  This cached entry needs revalidation, it will modify the request to do that.
  Overrides:
    setRequestRevalidation in class CachedResource

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD