javax.ws.rs.core
Class CacheControl

java.lang.Object
  extended by javax.ws.rs.core.CacheControl

public class CacheControl
extends java.lang.Object

An abstraction for the value of a HTTP Cache-Control response header.

See Also:
HTTP/1.1 section 14.9

Constructor Summary
CacheControl()
          Create a new instance of CacheControl.
 
Method Summary
 boolean equals(java.lang.Object obj)
          Compares obj to this cache control to see if they are the same considering all property values.
 java.util.Map<java.lang.String,java.lang.String> getCacheExtension()
          Corresponds to a set of extension cache control directives.
 int getMaxAge()
          Corresponds to the max-age cache control directive.
 java.util.List<java.lang.String> getNoCacheFields()
          Corresponds to the value of the no-cache cache control directive.
 java.util.List<java.lang.String> getPrivateFields()
          Corresponds to the value of the private cache control directive.
 int getSMaxAge()
          Corresponds to the s-maxage cache control directive.
 int hashCode()
          Generate hash code from cache control properties.
 boolean isMustRevalidate()
          Corresponds to the must-revalidate cache control directive.
 boolean isNoCache()
          Corresponds to the no-cache cache control directive.
 boolean isNoStore()
          Corresponds to the no-store cache control directive.
 boolean isNoTransform()
          Corresponds to the no-transform cache control directive.
 boolean isPrivate()
          Corresponds to the private cache control directive.
 boolean isProxyRevalidate()
          Corresponds to the proxy-revalidate cache control directive.
 void setMaxAge(int maxAge)
          Corresponds to the max-age cache control directive.
 void setMustRevalidate(boolean mustRevalidate)
          Corresponds to the must-revalidate cache control directive.
 void setNoCache(boolean noCache)
          Corresponds to the no-cache cache control directive.
 void setNoStore(boolean noStore)
          Corresponds to the no-store cache control directive.
 void setNoTransform(boolean noTransform)
          Corresponds to the no-transform cache control directive.
 void setPrivate(boolean _private)
          Corresponds to the private cache control directive.
 void setProxyRevalidate(boolean proxyRevalidate)
          Corresponds to the must-revalidate cache control directive.
 void setSMaxAge(int sMaxAge)
          Corresponds to the s-maxage cache control directive.
 java.lang.String toString()
          Convert the cache control to a string suitable for use as the value of the corresponding HTTP header.
static CacheControl valueOf(java.lang.String value)
          Creates a new instance of CacheControl by parsing the supplied string.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CacheControl

public CacheControl()
Create a new instance of CacheControl. The new instance will have the following default settings:

Method Detail

valueOf

public static CacheControl valueOf(java.lang.String value)
                            throws java.lang.IllegalArgumentException
Creates a new instance of CacheControl by parsing the supplied string.

Parameters:
value - the cache control string
Returns:
the newly created CacheControl
Throws:
java.lang.IllegalArgumentException - if the supplied string cannot be parsed or is null

isMustRevalidate

public boolean isMustRevalidate()
Corresponds to the must-revalidate cache control directive.

Returns:
true if the must-revalidate cache control directive will be included in the response, false otherwise.
See Also:
HTTP/1.1 section 14.9.4

setMustRevalidate

public void setMustRevalidate(boolean mustRevalidate)
Corresponds to the must-revalidate cache control directive.

Parameters:
mustRevalidate - true if the must-revalidate cache control directive should be included in the response, false otherwise.
See Also:
HTTP/1.1 section 14.9.4

isProxyRevalidate

public boolean isProxyRevalidate()
Corresponds to the proxy-revalidate cache control directive.

Returns:
true if the proxy-revalidate cache control directive will be included in the response, false otherwise.
See Also:
HTTP/1.1 section 14.9.4

setProxyRevalidate

public void setProxyRevalidate(boolean proxyRevalidate)
Corresponds to the must-revalidate cache control directive.

Parameters:
proxyRevalidate - true if the proxy-revalidate cache control directive should be included in the response, false otherwise.
See Also:
HTTP/1.1 section 14.9.4

getMaxAge

public int getMaxAge()
Corresponds to the max-age cache control directive.

Returns:
the value of the max-age cache control directive, -1 if the directive is disabled.
See Also:
HTTP/1.1 section 14.9.3

setMaxAge

public void setMaxAge(int maxAge)
Corresponds to the max-age cache control directive.

Parameters:
maxAge - the value of the max-age cache control directive, a value of -1 will disable the directive.
See Also:
HTTP/1.1 section 14.9.3

getSMaxAge

public int getSMaxAge()
Corresponds to the s-maxage cache control directive.

Returns:
the value of the s-maxage cache control directive, -1 if the directive is disabled.
See Also:
HTTP/1.1 section 14.9.3

setSMaxAge

public void setSMaxAge(int sMaxAge)
Corresponds to the s-maxage cache control directive.

Parameters:
sMaxAge - the value of the s-maxage cache control directive, a value of -1 will disable the directive.
See Also:
HTTP/1.1 section 14.9.3

getNoCacheFields

public java.util.List<java.lang.String> getNoCacheFields()
Corresponds to the value of the no-cache cache control directive.

Returns:
a mutable list of field-names that will form the value of the no-cache cache control directive. An empty list results in a bare no-cache directive.
See Also:
isNoCache(), setNoCache(boolean), HTTP/1.1 section 14.9.1

setNoCache

public void setNoCache(boolean noCache)
Corresponds to the no-cache cache control directive.

Parameters:
noCache - true if the no-cache cache control directive should be included in the response, false otherwise.
See Also:
getNoCacheFields(), HTTP/1.1 section 14.9.1

isNoCache

public boolean isNoCache()
Corresponds to the no-cache cache control directive.

Returns:
true if the no-cache cache control directive will be included in the response, false otherwise.
See Also:
getNoCacheFields(), HTTP/1.1 section 14.9.1

isPrivate

public boolean isPrivate()
Corresponds to the private cache control directive.

Returns:
true if the private cache control directive will be included in the response, false otherwise.
See Also:
getPrivateFields(), HTTP/1.1 section 14.9.1

getPrivateFields

public java.util.List<java.lang.String> getPrivateFields()
Corresponds to the value of the private cache control directive.

Returns:
a mutable list of field-names that will form the value of the private cache control directive. An empty list results in a bare no-cache directive.
See Also:
isPrivate(), setPrivate(boolean), HTTP/1.1 section 14.9.1

setPrivate

public void setPrivate(boolean _private)
Corresponds to the private cache control directive.

Parameters:
_private - true if the private cache control directive should be included in the response, false otherwise.
See Also:
getPrivateFields(), HTTP/1.1 section 14.9.1

isNoTransform

public boolean isNoTransform()
Corresponds to the no-transform cache control directive.

Returns:
true if the no-transform cache control directive will be included in the response, false otherwise.
See Also:
HTTP/1.1 section 14.9.5

setNoTransform

public void setNoTransform(boolean noTransform)
Corresponds to the no-transform cache control directive.

Parameters:
noTransform - true if the no-transform cache control directive should be included in the response, false otherwise.
See Also:
HTTP/1.1 section 14.9.5

isNoStore

public boolean isNoStore()
Corresponds to the no-store cache control directive.

Returns:
true if the no-store cache control directive will be included in the response, false otherwise.
See Also:
HTTP/1.1 section 14.9.2

setNoStore

public void setNoStore(boolean noStore)
Corresponds to the no-store cache control directive.

Parameters:
noStore - true if the no-store cache control directive should be included in the response, false otherwise.
See Also:
HTTP/1.1 section 14.9.2

getCacheExtension

public java.util.Map<java.lang.String,java.lang.String> getCacheExtension()
Corresponds to a set of extension cache control directives.

Returns:
a mutable map of cache control extension names and their values. If a key has a null value, it will appear as a bare directive. If a key has a value that contains no whitespace then the directive will appear as a simple name=value pair. If a key has a value that contains whitespace then the directive will appear as a quoted name="value" pair.
See Also:
HTTP/1.1 section 14.9.6

toString

public java.lang.String toString()
Convert the cache control to a string suitable for use as the value of the corresponding HTTP header.

Overrides:
toString in class java.lang.Object
Returns:
a stringified cache control

hashCode

public int hashCode()
Generate hash code from cache control properties.

Overrides:
hashCode in class java.lang.Object
Returns:
the hashCode

equals

public boolean equals(java.lang.Object obj)
Compares obj to this cache control to see if they are the same considering all property values.

Overrides:
equals in class java.lang.Object
Parameters:
obj - the object to compare to
Returns:
true if the two cache controls are the same, false otherwise.


Copyright © 2009. All Rights Reserved.