org.restlet.data

## Class CacheDirective

- java.lang.Object
- - org.restlet.util.Couple<java.lang.String,java.lang.String>
  - - org.restlet.data.Parameter
    - - org.restlet.data.CacheDirective

All Implemented Interfaces:
  java.lang.Comparable<Parameter>

    public final class CacheDirective
    extends Parameter

Directive for caching mechanisms along the call chain. This overrides the default behavior of those caches and proxies.
Note that when used with HTTP connectors, this class maps to the "Cache-Control" header.

Author:
  Jerome Louvel

### Constructor Summary

Constructors
Constructor and Description
`CacheDirective(java.lang.String name)` Constructor for directives with no value.
`CacheDirective(java.lang.String name, java.lang.String value)` Constructor for directives with a value.
`CacheDirective(java.lang.String name, java.lang.String value, boolean digit)` Constructor for directives with a value.

### Method Summary

Methods
`boolean` `isDigit()` Returns true if the directive contains a digit value.
`static CacheDirective` `maxAge(int maxAge)` Creates a "max-age" directive.
`static CacheDirective` `maxStale()` Creates a "max-stale" directive.
`static CacheDirective` `maxStale(int maxStale)` Creates a "max-stale" directive.
`static CacheDirective` `minFresh(int minFresh)` Creates a "min-fresh" directive.
`static CacheDirective` `mustRevalidate()` Creates a "must-revalidate" directive.
`static CacheDirective` `noCache()` Creates a "no-cache" directive.
`static CacheDirective` `noCache(java.util.List<java.lang.String> fieldNames)` Creates a "no-cache" directive.
`static CacheDirective` `noCache(java.lang.String fieldName)` Creates a "no-cache" directive.
`static CacheDirective` `noStore()` Creates a "no-store" directive.
`static CacheDirective` `noTransform()` Creates a "no-transform" directive.
`static CacheDirective` `onlyIfCached()` Creates a "onlyIfCached" directive.
`static CacheDirective` `privateInfo()` Creates a "private" directive.
`static CacheDirective` `privateInfo(java.util.List<java.lang.String> fieldNames)` Creates a "private" directive.
`static CacheDirective` `privateInfo(java.lang.String fieldName)` Creates a "private" directive.
`static CacheDirective` `proxyMustRevalidate()` Creates a "proxy-revalidate" directive.
`static CacheDirective` `publicInfo()` Creates a "public" directive.
`void` `setDigit(boolean digit)` Indicates if the directive is a digit value.
`static CacheDirective` `sharedMaxAge(int sharedMaxAge)` Creates a "s-maxage" directive.

### Methods inherited from class org.restlet.data.Parameter

`compareTo, create, encode, encode, getName, getValue, setName, setValue`

### Methods inherited from class org.restlet.util.Couple

`equals, getFirst, getSecond, hashCode, setFirst, setSecond, toString`

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

### Constructor Detail

#### CacheDirective

    public CacheDirective(java.lang.String name)

Constructor for directives with no value.

Parameters:
  `name` - The directive name.

#### CacheDirective

    public CacheDirective(java.lang.String name,
                  java.lang.String value)

Constructor for directives with a value.

Parameters:
  `name` - The directive name.
  `value` - The directive value.

#### CacheDirective

    public CacheDirective(java.lang.String name,
                  java.lang.String value,
                  boolean digit)

Constructor for directives with a value.

Parameters:
  `name` - The directive name.
  `value` - The directive value.
  `digit` - The kind of value (true for a digit value, false otherwise).

### Method Detail

#### maxAge

    public static CacheDirective maxAge(int maxAge)

Creates a "max-age" directive. Indicates that the client is willing to accept a response whose age is no greater than the specified time in seconds. Unless "max-stale" directive is also included, the client is not willing to accept a stale response.
Note that this directive can be used on requests or responses.

Parameters:
  `maxAge` - Maximum age in seconds.
Returns:
  A new "max-age" directive.
See Also:
  HTTP 1.1 - Modifications of the Basic Expiration Mechanism, HTTP 1.1 - Cache Revalidation and Reload Controls

#### maxStale

    public static CacheDirective maxStale()

Creates a "max-stale" directive. Indicates that the client is willing to accept a response that has exceeded its expiration time by any amount of time.
Note that this directive can be used on requests only.

Returns:
  A new "max-stale" directive.
See Also:
  HTTP 1.1 - Modifications of the Basic Expiration Mechanism

#### maxStale

    public static CacheDirective maxStale(int maxStale)

Creates a "max-stale" directive. Indicates that the client is willing to accept a response that has exceeded its expiration time by a given amount of time.
Note that this directive can be used on requests only.

Parameters:
  `maxStale` - Maximum stale age in seconds.
Returns:
  A new "max-stale" directive.
See Also:
  HTTP 1.1 - Modifications of the Basic Expiration Mechanism

#### minFresh

    public static CacheDirective minFresh(int minFresh)

Creates a "min-fresh" directive. Indicates that the client is willing to accept a response whose freshness lifetime is no less than its current age plus the specified time in seconds. That is, the client wants a response that will still be fresh for at least the specified number of seconds.
Note that this directive can be used on requests only.

Parameters:
  `minFresh` - Minimum freshness lifetime in seconds.
Returns:
  A new "min-fresh" directive.
See Also:
  HTTP 1.1 - Modifications of the Basic Expiration Mechanism

#### mustRevalidate

    public static CacheDirective mustRevalidate()

Creates a "must-revalidate" directive. Indicates that the origin server requires revalidation of a cache entry on any subsequent use.
Note that this directive can be used on responses only.

Returns:
  A new "must-revalidate" directive.
See Also:
  HTTP 1.1 - Cache Revalidation and Reload Controls

#### noCache

    public static CacheDirective noCache()

Creates a "no-cache" directive. Indicates that a cache must not use the response to satisfy subsequent requests without successful revalidation with the origin server.
Note that this directive can be used on requests or responses.

Returns:
  A new "no-cache" directive.
See Also:
  HTTP 1.1 - What is Cacheable

#### noCache

    public static CacheDirective noCache(java.util.List<java.lang.String> fieldNames)

Creates a "no-cache" directive. Indicates that a cache must not use the response to satisfy subsequent requests without successful revalidation with the origin server.
Note that this directive can be used on requests or responses.

Parameters:
  `fieldNames` - Field names, typically a HTTP header name, that must not be sent by caches.
Returns:
  A new "no-cache" directive.
See Also:
  HTTP 1.1 - What is Cacheable

#### noCache

    public static CacheDirective noCache(java.lang.String fieldName)

Creates a "no-cache" directive. Indicates that a cache must not use the response to satisfy subsequent requests without successful revalidation with the origin server.
Note that this directive can be used on requests or responses.

Parameters:
  `fieldName` - A field name, typically a HTTP header name, that must not be sent by caches.
Returns:
  A new "no-cache" directive.
See Also:
  HTTP 1.1 - What is Cacheable

#### noStore

    public static CacheDirective noStore()

Creates a "no-store" directive. Indicates that a cache must not release or retain any information about the call. This applies to both private and shared caches.
Note that this directive can be used on requests or responses.

Returns:
  A new "no-store" directive.
See Also:
  HTTP 1.1 - What May be Stored by Caches

#### noTransform

    public static CacheDirective noTransform()

Creates a "no-transform" directive. Indicates that a cache or intermediary proxy must not transform the response entity.
Note that this directive can be used on requests or responses.

Returns:
  A new "no-transform" directive.
See Also:
  HTTP 1.1 - No-Transform Directive

#### onlyIfCached

    public static CacheDirective onlyIfCached()

Creates a "onlyIfCached" directive. Indicates that only cached responses should be returned to the client.
Note that this directive can be used on requests only.

Returns:
  A new "only-if-cached" directive.
See Also:
  HTTP 1.1 - Cache Revalidation and Reload Controls

#### privateInfo

    public static CacheDirective privateInfo()

Creates a "private" directive. Indicates that all or part of the response message is intended for a single user and must not be cached by a shared cache.
Note that this directive can be used on responses only.

Returns:
  A new "private" directive.
See Also:
  HTTP 1.1 - What is Cacheable

#### privateInfo

    public static CacheDirective privateInfo(java.util.List<java.lang.String> fieldNames)

Creates a "private" directive. Indicates that all or part of the response message is intended for a single user and must not be cached by a shared cache.
Note that this directive can be used on responses only.

Parameters:
  `fieldNames` - Field names, typically a HTTP header name, that must be private.
Returns:
  A new "private" directive.
See Also:
  HTTP 1.1 - What is Cacheable

#### privateInfo

    public static CacheDirective privateInfo(java.lang.String fieldName)

Creates a "private" directive. Indicates that all or part of the response message is intended for a single user and must not be cached by a shared cache.
Note that this directive can be used on responses only.

Parameters:
  `fieldName` - A field name, typically a HTTP header name, that is private.
Returns:
  A new "private" directive.
See Also:
  HTTP 1.1 - What is Cacheable

#### proxyMustRevalidate

    public static CacheDirective proxyMustRevalidate()

Creates a "proxy-revalidate" directive. Indicates that the origin server requires revalidation of a cache entry on any subsequent use, except that it does not apply to non-shared user agent caches
Note that this directive can be used on responses only.

Returns:
  A new "proxy-revalidate" directive.
See Also:
  HTTP 1.1 - Cache Revalidation and Reload Controls

#### publicInfo

    public static CacheDirective publicInfo()

Creates a "public" directive. Indicates that the response may be cached by any cache, even if it would normally be non-cacheable or cacheable only within a non-shared cache.
Note that this directive can be used on responses only.

Returns:
  A new "public" directive.
See Also:
  HTTP 1.1 - What is Cacheable

#### sharedMaxAge

    public static CacheDirective sharedMaxAge(int sharedMaxAge)

Creates a "s-maxage" directive. Indicates that the client is willing to accept a response from a shared cache (but not a private cache) whose age is no greater than the specified time in seconds.
Note that this directive can be used on responses only.

Parameters:
  `sharedMaxAge` - Maximum age in seconds.
Returns:
  A new "s-maxage" directive.
See Also:
  HTTP 1.1 - Modifications of the Basic Expiration Mechanism

#### isDigit

    public boolean isDigit()

Returns true if the directive contains a digit value.

Returns:
  True if the directive contains a digit value.

#### setDigit

    public void setDigit(boolean digit)

Indicates if the directive is a digit value.

Parameters:
  `digit` - True if the directive contains a digit value.