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 CachedResource

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

Direct Known Subclasses:
  EntityCachedResource

public abstract class CachedResource
extends AttributeHolder
implements TeeMonitor, LRUAble

Field Summary
`protected ArrayDictionary` | `a`
`protected static int` | `ATTR_CONTENT_ENCODING` Attribute index - The Content Encoding of the resource
`protected static int` | `ATTR_CONTENT_LANGUAGE` Attribute index - The Content Language of the resource
`protected static int` | `ATTR_CONTENT_LENGTH` Attribute index - The resource content length.
`protected static int` | `ATTR_CONTENT_MD5` Attribute index - The Content MD5 of the resource
`protected static int` | `ATTR_CURRENT_LENGTH` Attribute index - The resource current length.
`protected static int` | `ATTR_DATE` Attribute index - The Date of the resource
`protected static java.lang.String[]` | `ATTR_DESCR` The minimal attribute set used to describe a cachedresource without loading it entirely.
`protected static int` | `ATTR_ETAG` Attribute index - The entity tag (if any) associated with the resource.
`protected static int` | `ATTR_EXTRA_HEADERS` Attribute index - The extra headers attribute.
`protected static int` | `ATTR_FILE` Attribute index - The file
`protected static int` | `ATTR_IDENTIFIER` Attribute index - The identifier
`protected static int` | `ATTR_LOAD_STATE` Attribute index - The download state
`protected static int` | `ATTR_REPLY_LAST_MODIFIED` Attribute index - The Last modified of this resource
`protected static int` | `ATTR_STATUS` Attribute index - The reply status.
`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 CacheGeneration` | `generation`
`protected boolean` | `invalidated`
`protected static java.lang.String` | `NAME_CONTENT_LENGTH` Attribute name - The resource content length.
`protected static java.lang.String` | `NAME_CURRENT_LENGTH` Attribute name - The resource current length
`protected static java.lang.String` | `NAME_FILE` Attribute name - The identifier
`protected static java.lang.String` | `NAME_IDENTIFIER` Attribute name - The identifier
`protected LRUAble` | `next` LRU management - next entry.
`protected LRUAble` | `prev` LRU management - previous entry.
`static int` | `STATE_LOAD_COMPLETE` The download state of the resource, complete content
`static int` | `STATE_LOAD_ERROR` The download state of the resource, erroneous, something weird happened! but at least we know that :)
`static int` | `STATE_LOAD_PARTIAL` The download state of the resource, partial content
`static int` | `STATE_LOAD_UNKNOWN` The download state of the resource, unknown, probably an HTTP/1.0 reply without the Content-Length.
`static int` | `STATE_NOT_LOADED` The download state of the resource, currently not loaded

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

Constructor Summary
`CachedResource()`

Method Summary
`long` | `delete()` Delete this resource (and its associated file).
`java.lang.String[]` | `getContentEncoding()` Get the Content-Encoding associated with that cached entry.
`java.lang.String[]` | `getContentLanguage()` Get the Content-Language associated with that cached entry.
`int` | `getContentLength()` Get this cached entry content length.
`java.lang.String` | `getContentMD5()` Get the Content-MD5 associated with that cached entry.
`abstract MimeType` | `getContentType()` Get the Content-Type of the cached resource of `null` if there is no mime type (it should NEVER happen!)
`abstract int` | `getCurrentAge()` returns the current age of this cached resource
`int` | `getCurrentLength()` Get this cached entry current content length.
`long` | `getDate()` Get this date, as a long
`java.lang.String` | `getETag()` Get the entity tag associated with that cached entry.
`ArrayDictionary` | `getExtraHeaders()` Get the extra headers stored for that resource.
`java.io.File` | `getFile()` Get the cached File.
`abstract int` | `getFreshnessLifetime()` returns the current freshness lifetime of this resource
`java.lang.String` | `getIdentifier()` Get this cached entry identifier
`long` | `getLastModified()` Get this Cached Resource last modification time.
`int` | `getLoadState()` Get the load state value
`LRUAble` | `getNext()` LRU management - Get next node.
`LRUAble` | `getPrev()` LRU management - Get previous node.
`int` | `getStatus()` Get the HTTP status of that cached entry.
`boolean` | `getWillRevalidate()` Get state of the resource, did someone ask for revalidation for the next request?
`CachedResource` | `lookupResource(Request request)` This methods return the CachedResource matching this request it allows lookup in the cache for alternatives
`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
`abstract Reply` | `perform(Request request)` This cached entry has been checked valid, perform given request.
`void` | `setContentEncoding(java.lang.String[] sum)` Associate a Content-Encoding with that cached enrty.
`void` | `setContentLanguage(java.lang.String[] language)` Associate a Content-Language with that cached enrty.
`void` | `setContentLength(int length)` Set the content length of that cached entry.
`void` | `setContentMD5(java.lang.String sum)` Associate a Content-MD5 with that cached enrty.
`abstract void` | `setContentType(MimeType type)` Set the Content-Type of this cached resource
`void` | `setCurrentLength(int length)` Set the current length of that cached entry.
`void` | `setDate(long date)` Set the content length of that cached entry.
`void` | `setETag(java.lang.String etag)` Associate an entity tag with that cached enrty.
`void` | `setExtraHeaders(ArrayDictionary a)` Set a new set of extra headers for that resource.
`void` | `setFile(java.io.File file)` Set the cached file
`void` | `setLastModified(long lastmodified)` Set the last modified time of that cached entry.
`void` | `setLoadState(int state)` Set the loading state of this resource
`void` | `setNext(LRUAble next)` LRU management - Set next node.
`void` | `setPrev(LRUAble prev)` LRU management - Set previous node.
`abstract Request` | `setRequestRevalidation(Request request)` This cached entry needs revalidation, it will modify the request to do that.
`void` | `setStatus(int status)` Set the reply status for that entry.
`void` | `setValue(int idx, java.lang.Object value)` overrides the default setValue to invalidate the ETag
`void` | `setWillRevalidate(boolean invalidated)` Set this cached entry revalidate-on-next-request flag

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, 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.

### STATE_NOT_LOADED

    public static final int STATE_NOT_LOADED

  The download state of the resource, currently not loaded

### STATE_LOAD_COMPLETE

    public static final int STATE_LOAD_COMPLETE

  The download state of the resource, complete content

### STATE_LOAD_PARTIAL

    public static final int STATE_LOAD_PARTIAL

  The download state of the resource, partial content

### STATE_LOAD_UNKNOWN

    public static final int STATE_LOAD_UNKNOWN

  The download state of the resource, unknown, probably an HTTP/1.0 reply without the Content-Length.

### STATE_LOAD_ERROR

    public static final int STATE_LOAD_ERROR

  The download state of the resource, erroneous, something weird happened! but at least we know that :)

### ATTR_IDENTIFIER

    protected static int ATTR_IDENTIFIER

  Attribute index - The identifier

### ATTR_CONTENT_LENGTH

    protected static int ATTR_CONTENT_LENGTH

  Attribute index - The resource content length.

### ATTR_CURRENT_LENGTH

    protected static int ATTR_CURRENT_LENGTH

  Attribute index - The resource current length.

### ATTR_FILE

    protected static int ATTR_FILE

  Attribute index - The file

### NAME_CONTENT_LENGTH

    protected static final java.lang.String NAME_CONTENT_LENGTH

  Attribute name - The resource content length.

### NAME_CURRENT_LENGTH

    protected static final java.lang.String NAME_CURRENT_LENGTH

  Attribute name - The resource current length

### NAME_IDENTIFIER

    protected static final java.lang.String NAME_IDENTIFIER

  Attribute name - The identifier

### NAME_FILE

    protected static final java.lang.String NAME_FILE

  Attribute name - The identifier

### ATTR_LOAD_STATE

    protected static int ATTR_LOAD_STATE

  Attribute index - The download state

### ATTR_ETAG

    protected static int ATTR_ETAG

  Attribute index - The entity tag (if any) associated with the resource.

### ATTR_STATUS

    protected static int ATTR_STATUS

  Attribute index - The reply status.

### ATTR_REPLY_LAST_MODIFIED

    protected static int ATTR_REPLY_LAST_MODIFIED

  Attribute index - The Last modified of this resource

### ATTR_DATE

    protected static int ATTR_DATE

  Attribute index - The Date of the resource

### ATTR_CONTENT_MD5

    protected static int ATTR_CONTENT_MD5

  Attribute index - The Content MD5 of the resource

### ATTR_CONTENT_ENCODING

    protected static int ATTR_CONTENT_ENCODING

  Attribute index - The Content Encoding of the resource

### ATTR_CONTENT_LANGUAGE

    protected static int ATTR_CONTENT_LANGUAGE

  Attribute index - The Content Language of the resource

### ATTR_EXTRA_HEADERS

    protected static int ATTR_EXTRA_HEADERS

  Attribute index - The extra headers attribute.

### ATTR_DESCR

    protected static java.lang.String[] ATTR_DESCR

  The minimal attribute set used to describe a cachedresource without loading it entirely.

### invalidated

    protected boolean invalidated

### generation

    protected CacheGeneration generation

### a

    protected ArrayDictionary a

### filter

    protected CacheFilter filter

### prev

    protected LRUAble prev

  LRU management - previous entry.

### next

    protected LRUAble next

  LRU management - next entry.

Constructor Detail

### CachedResource

    public CachedResource()

Method Detail

### 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.
  Specified by:
    notifyTeeFailure in interface TeeMonitor

### notifyTeeSuccess

    public void notifyTeeSuccess(int size)

  Description copied from interface: TeeMonitor
  Called when the tee succeed, it allows you to notify a listener of the Tee that the download completed succesfully with a specific size
  Specified by:
    notifyTeeSuccess in interface TeeMonitor

### getNext

    public LRUAble getNext()

  LRU management - Get next node.
  Specified by:
    getNext in interface LRUAble
  Returns:
    A CvsDirectory instance.

### getPrev

    public LRUAble getPrev()

  LRU management - Get previous node.
  Specified by:
    getPrev in interface LRUAble
  Returns:
    A CvsDirectory instance.

### setNext

    public void setNext(LRUAble next)

  LRU management - Set next node.
  Specified by:
    setNext in interface LRUAble
  Returns:
    A CvsDirectory instance.

### setPrev

    public void setPrev(LRUAble prev)

  LRU management - Set previous node.
  Specified by:
    setPrev in interface LRUAble
  Returns:
    A CvsDirectory instance.

### setValue

    public void setValue(int idx,
                         java.lang.Object value)

  overrides the default setValue to invalidate the ETag
  Overrides:
    setValue in class AttributeHolder
  Tags copied from class: AttributeHolder
  Parameters:
    `idx` - The attribute index, in the list of attributes advertized by the resource.
    `value` - The new value for this attribute.
  Throws:
    IllegalAttributeAccess - if the provided value doesn't match the attribute expected type.

### getCurrentAge

    public abstract int getCurrentAge()

  returns the current age of this cached resource
  Returns:
    an integer, the current age in seconds

### getFreshnessLifetime

    public abstract int getFreshnessLifetime()

  returns the current freshness lifetime of this resource
  Returns:
    a long, the freshness lifetime, in seconds

### lookupResource

    public CachedResource lookupResource(Request request)

  This methods return the CachedResource matching this request it allows lookup in the cache for alternatives
  Returns:
    a CachedResource depending on the request

### getIdentifier

    public java.lang.String getIdentifier()

  Get this cached entry identifier
  Returns:
    a String, usually the URL of the resource

### getContentLength

    public int getContentLength()

  Get this cached entry content length.
  Returns:
    An integer, giving the content length, or -1 if undefined.

### setContentLength

    public void setContentLength(int length)

  Set the content length of that cached entry.
  Parameters:
    `length` - The new content length of that entry.

### getCurrentLength

    public int getCurrentLength()

  Get this cached entry current content length.
  Returns:
    An integer, giving the current content length, or -1 if undefined

### setCurrentLength

    public void setCurrentLength(int length)

  Set the current length of that cached entry.
  Parameters:
    `length` - The current length of that entry.

### getLoadState

    public int getLoadState()

  Get the load state value
  Returns:
    an integer, as defined in CachedResource
  See Also:
    `The default is STATE_NOT_LOADED`

### setLoadState

    public void setLoadState(int state)

  Set the loading state of this resource
  Parameters:
    `an` - integer, one of the state defined in CachedResource
  See Also:
    `CachedResource`

### getStatus

    public int getStatus()

  Get the HTTP status of that cached entry.
  Returns:
    An integer HTTP status code, or -1 if undefined.

### setStatus

    public void setStatus(int status)

  Set the reply status for that entry.
  Parameters:
    `status` - The HTTP status code of that entry, or -1 to undefine the previous setting.

### getLastModified

    public long getLastModified()

  Get this Cached Resource last modification time.
  Returns:
    A long giving the date of the last modification time, or -1 if undefined.

### setLastModified

    public void setLastModified(long lastmodified)

  Set the last modified time of that cached entry.
  Parameters:
    `lastmodified` - The last modification date as a number of milliseconds since Java epoch, or -1 to undefine previous setting.

### getContentType

    public abstract MimeType getContentType()

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

### setContentType

    public abstract void setContentType(MimeType type)

  Set the Content-Type of this cached resource
  Parameters:
    `a` - MimeType, the mime type of this resource

### getWillRevalidate

    public boolean getWillRevalidate()

  Get state of the resource, did someone ask for revalidation for the next request?
  Returns:
    a boolean, `true` if it will. -1 if undefined.

### setWillRevalidate

    public void setWillRevalidate(boolean invalidated)

  Set this cached entry revalidate-on-next-request flag
  Parameters:
    `validate,` - a boolean, `true` if it will be revalidated next time.

### getDate

    public long getDate()

  Get this date, as a long
  Returns:
    a long, the date if undefined.

### setDate

    public void setDate(long date)

  Set the content length of that cached entry.
  Parameters:
    `length` - The new content length of that entry.

### setFile

    public void setFile(java.io.File file)

  Set the cached file
  Parameters:
    `file` -

### getFile

    public java.io.File getFile()

  Get the cached File.
  Returns:
    a File instance

### getETag

    public java.lang.String getETag()

  Get the entity tag associated with that cached entry.
  Returns:
    The String encoded entity tag, or null if undefined.

### setETag

    public void setETag(java.lang.String etag)

  Associate an entity tag with that cached enrty.
  Parameters:
    `etag` - The entity tag of the entry, or null to reset the value.

### getContentMD5

    public java.lang.String getContentMD5()

  Get the Content-MD5 associated with that cached entry.
  Returns:
    The String encoded Content-MD5, or null if undefined.

### setContentMD5

    public void setContentMD5(java.lang.String sum)

  Associate a Content-MD5 with that cached enrty.
  Parameters:
    `sum,` - the md5 sum as a string, see RFC2616, or null to reset the value.

### getContentEncoding

    public java.lang.String[] getContentEncoding()

  Get the Content-Encoding associated with that cached entry.
  Returns:
    The String Content-Encoding, or null if undefined.

### setContentEncoding

    public void setContentEncoding(java.lang.String[] sum)

  Associate a Content-Encoding with that cached enrty.
  Parameters:
    `sum,` - the encoding as a string, or null to reset the value.

### getContentLanguage

    public java.lang.String[] getContentLanguage()

  Get the Content-Language associated with that cached entry.
  Returns:
    The String Content-Language, or null if undefined.

### setContentLanguage

    public void setContentLanguage(java.lang.String[] language)

  Associate a Content-Language with that cached enrty.
  Parameters:
    `sum,` - the encoding as a string, or null to reset the value.

### getExtraHeaders

    public ArrayDictionary getExtraHeaders()

  Get the extra headers stored for that resource.
  Returns:
    An ArrayDictionary with the extra headers, or null if undefined.

### setExtraHeaders

    public void setExtraHeaders(ArrayDictionary a)

  Set a new set of extra headers for that resource.
  Parameters:
    `headers` - The new set of headers.

### delete

    public long delete()

  Delete this resource (and its associated file).
  Returns:
    the number of bytes saved.

### perform

    public abstract Reply perform(Request request)
                           throws HttpException

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

### setRequestRevalidation

    public abstract Request setRequestRevalidation(Request request)

  This cached entry needs revalidation, it will modify the request to do that.

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