org.exoplatform.services.rest
Class CacheControl

java.lang.Object
  extended by org.exoplatform.services.rest.CacheControl

public class CacheControl
extends 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.
The new instance will have the following default settings: public = true private = false noCache = false noStore = false noTransform = true mustRevalidate = false proxyRevalidate = false An empty list of private fields An empty list of no-cache fields An empty list of cache extensions
 
Method Summary
 String getAsString()
          String representation of CacheControl.
 Map<String,String> getCacheExtension()
          Corresponds to a set of extension cache control directives.
 int getMaxAge()
          Corresponds to the max-age cache control directive.
 List<String> getNoCacheFields()
          Corresponds to the value of the no-cache cache control directive.
 List<String> getPrivateFields()
          Corresponds to the value of the private cache control directive.
 int getSMaxAge()
          Corresponds to the s-maxage cache control directive.
 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 isPrivateCacheable()
          Corresponds to the private cache control directive.
 boolean isProxyRevalidate()
          Corresponds to the proxy-revalidate cache control directive.
 boolean isPublicCacheable()
          Corresponds to the public cache control directive.
 void setCacheExtension(Map<String,String> extensions)
          Corresponds to a set of extension cache control directives.
 void setMaxAge(int age)
          Corresponds to the max-age cache control directive.
 void setMustRevalidate(boolean status)
          Corresponds to the must-revalidate cache control directive.
 void setNoCache(boolean state)
          Corresponds to the no-cache cache control directive.
 void setNoCache(boolean state, List<String> fields)
          Corresponds to the no-cache cache control directive.
 void setNoStore(boolean status)
          Corresponds to the no-store cache control directive.
 void setNoTransform(boolean status)
          Corresponds to the no-transform cache control directive.
 void setPrivateCacheable(boolean status)
          Corresponds to the private cache control directive.
 void setPrivateCacheable(boolean status, List<String> fields)
          Corresponds to the private cache control directive.
 void setProxyRevalidate(boolean status)
          Corresponds to the must-revalidate cache control directive.
 void setPublicCacheable(boolean status)
          Corresponds to the public cache control directive.
 void setSMaxAge(int age)
          Corresponds to the s-maxage cache control directive.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, 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

getAsString

public String getAsString()
String representation of CacheControl. This string should be included in response as header.

Returns:
String representation of CasheControl.

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 status)
Corresponds to the must-revalidate cache control directive.

Parameters:
status - 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 status)
Corresponds to the must-revalidate cache control directive.

Parameters:
status - 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 age)
Corresponds to the max-age cache control directive.

Parameters:
age - 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 age)
Corresponds to the s-maxage cache control directive.

Parameters:
age - 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

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:
HTTP/1.1 section 14.9.1

setNoCache

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

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

setNoCache

public void setNoCache(boolean state,
                       List<String> fields)
Corresponds to the no-cache cache control directive.

Parameters:
state - true if the no-cache cache control directive should be included in the response, false otherwise.
fields - array of fields.
See Also:
HTTP/1.1 section 14.9.1

getNoCacheFields

public List<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:
HTTP/1.1 section 14.9.1

isPublicCacheable

public boolean isPublicCacheable()
Corresponds to the public cache control directive.

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

setPublicCacheable

public void setPublicCacheable(boolean status)
Corresponds to the public cache control directive.

Parameters:
status - true if the public cache control directive should be included in the response, false otherwise.
See Also:
HTTP/1.1 section 14.9.1

isPrivateCacheable

public boolean isPrivateCacheable()
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:
HTTP/1.1 section 14.9.1

setPrivateCacheable

public void setPrivateCacheable(boolean status)
Corresponds to the private cache control directive.

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

setPrivateCacheable

public void setPrivateCacheable(boolean status,
                                List<String> fields)
Corresponds to the private cache control directive.

Parameters:
status - true if the private cache control directive should be included in the response, false otherwise.
fields - array of fields.
See Also:
HTTP/1.1 section 14.9.1

getPrivateFields

public List<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:
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 status)
Corresponds to the no-transform cache control directive.

Parameters:
status - 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 status)
Corresponds to the no-store cache control directive.

Parameters:
status - 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

setCacheExtension

public void setCacheExtension(Map<String,String> extensions)
Corresponds to a set of extension cache control directives. 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.

Parameters:
extensions - the cache extensions.
See Also:
HTTP/1.1 section 14.9.6

getCacheExtension

public Map<String,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


Copyright © 2009 eXo Platform SAS. All Rights Reserved.