Top Description Fields Constructors Methods
jakarta.ws.rs.core

public Class CacheControl

extends Object
Class Inheritance
Imports
java.util.ArrayList, .Collection, .HashMap, .List, .Map, .Objects, jakarta.ws.rs.ext.RuntimeDelegate, .RuntimeDelegate.HeaderDelegate

An abstraction for the value of a HTTP Cache-Control response header.
Authors
Paul Sandoz, Marc Hadley
Since
1.0
See Also
HTTP/1.1 section 14.9

Field Summary

Modifier and TypeField and Description
private Map<String, String>
private static final RuntimeDelegate.HeaderDelegate<CacheControl>
HEADER_DELEGATE

Deprecated This field will be removed in a future version. See https://github.com/jakartaee/rest/issues/607
private int
private boolean
private boolean
private List<String>
private boolean
private boolean
private List<String>
private boolean
private boolean
private int

Constructor Summary

AccessConstructor and Description
public
CacheControl()

Create a new instance of CacheControl.

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if the two cache controls are the same, false otherwise.
equals
(final Object
the object to compare to
obj
)

Overrides java.lang.Object.equals.

Compares object argument to this cache control to see if they are the same considering all property values.

public Map<String, String>

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.
getCacheExtension
()

Corresponds to a set of extension cache control directives.

public int

Returns:

the value of the max-age cache control directive, -1 if the directive is disabled.
getMaxAge
()

Corresponds to the max-age cache control directive.

public List<String>

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.
getNoCacheFields
()

Corresponds to the value of the no-cache cache control directive.

public List<String>

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.
getPrivateFields
()

Corresponds to the value of the private cache control directive.

public int

Returns:

the value of the s-maxage cache control directive, -1 if the directive is disabled.
getSMaxAge
()

Corresponds to the s-maxage cache control directive.

public int

Returns:

the hashCode
hashCode
()

Overrides java.lang.Object.hashCode.

Generate hash code from cache control properties.

private static int

Returns:

hash code for the collection, if null or empty, the returned hash code is 0 (zero).
hashCodeOf
(final Collection<?>
collection, may be null.
instance
)

Compute a Object#hashCode of a collection.

private static int

Returns:

hash code for the map, if null or empty, the returned hash code is 0 (zero).
hashCodeOf
(final Map<?, ?>
map, may be null.
instance
)

Compute a Object#hashCode of a map.

public boolean

Returns:

true if the must-revalidate cache control directive will be included in the response, false otherwise.
isMustRevalidate
()

Corresponds to the must-revalidate cache control directive.

public boolean

Returns:

true if the no-cache cache control directive will be included in the response, false otherwise.
isNoCache
()

Corresponds to the no-cache cache control directive.

public boolean

Returns:

true if the no-store cache control directive will be included in the response, false otherwise.
isNoStore
()

Corresponds to the no-store cache control directive.

public boolean

Returns:

true if the no-transform cache control directive will be included in the response, false otherwise.
isNoTransform
()

Corresponds to the no-transform cache control directive.

public boolean

Returns:

true if the private cache control directive will be included in the response, false otherwise.
isPrivate
()

Corresponds to the private cache control directive.

public boolean

Returns:

true if the proxy-revalidate cache control directive will be included in the response, false otherwise.
isProxyRevalidate
()

Corresponds to the proxy-revalidate cache control directive.

private static boolean

Returns:

true if the two collections are not equal, false if the two collections are equal (or one of them is null and the other one is empty).
notEqual
(final Collection<?>
first collection. May be null.
first
,
final Collection<?>
second collection. May be null.
second
)

Check if two collections are not equal.

private static boolean

Returns:

true if the two maps are not equal, false if the two maps are equal (or one of them is null and the other one is empty).
notEqual
(final Map<?, ?>
first collection. May be null.
first
,
final Map<?, ?>
second collection. May be null.
second
)

Check if two maps are not equal.

public void
setMaxAge(final int
the value of the max-age cache control directive, a value of -1 will disable the directive.
maxAge
)

Corresponds to the max-age cache control directive.

public void
setMustRevalidate(final boolean
true if the must-revalidate cache control directive should be included in the response, false otherwise.
mustRevalidate
)

Corresponds to the must-revalidate cache control directive.

public void
setNoCache(final boolean
true if the no-cache cache control directive should be included in the response, false otherwise.
noCache
)

Corresponds to the no-cache cache control directive.

public void
setNoStore(final boolean
true if the no-store cache control directive should be included in the response, false otherwise.
noStore
)

Corresponds to the no-store cache control directive.

public void
setNoTransform(final boolean
true if the no-transform cache control directive should be included in the response, false otherwise.
noTransform
)

Corresponds to the no-transform cache control directive.

public void
setPrivate(final boolean
true if the private cache control directive should be included in the response, false otherwise.
flag
)

Corresponds to the private cache control directive.

public void
setProxyRevalidate(final boolean
true if the proxy-revalidate cache control directive should be included in the response, false otherwise.
proxyRevalidate
)

Corresponds to the must-revalidate cache control directive.

public void
setSMaxAge(final int
the value of the s-maxage cache control directive, a value of -1 will disable the directive.
smaxAge
)

Corresponds to the s-maxage cache control directive.

public String

Returns:

a stringified cache control
toString
()

Overrides java.lang.Object.toString.

Deprecated The format of the toString() method is subject to change in a future version. Please use RuntimeDelegate.getInstance().createHeaderDelegate(CacheControl.class).toString(value) instead if you rely on the format of this method.

Convert the cache control to a string suitable for use as the value of the corresponding HTTP header.

public static CacheControl

Returns:

the newly created CacheControl
valueOf
(final String
the cache control string
value
)
Deprecated This method will be removed in a future version. Please use RuntimeDelegate.getInstance().createHeaderDelegate(CacheControl.class).fromString(value) instead.

Creates a new instance of CacheControl by parsing the supplied string.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

cacheExtensionback to summary
private Map<String, String> cacheExtension
HEADER_DELEGATEback to summary
private static final RuntimeDelegate.HeaderDelegate<CacheControl> HEADER_DELEGATE

Deprecated

This field will be removed in a future version. See https://github.com/jakartaee/rest/issues/607

Annotations
@Deprecated
maxAgeback to summary
private int maxAge
mustRevalidateback to summary
private boolean mustRevalidate
noCacheback to summary
private boolean noCache
noCacheFieldsback to summary
private List<String> noCacheFields
noStoreback to summary
private boolean noStore
noTransformback to summary
private boolean noTransform
privateFieldsback to summary
private List<String> privateFields
privateFlagback to summary
private boolean privateFlag
proxyRevalidateback to summary
private boolean proxyRevalidate
sMaxAgeback to summary
private int sMaxAge

Constructor Detail

CacheControlback to summary
public CacheControl()

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

  • 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 map of cache extensions

Method Detail

equalsback to summary
public boolean equals(final Object obj)

Overrides java.lang.Object.equals.

Compares object argument to this cache control to see if they are the same considering all property values.

Parameters
obj:Object

the object to compare to

Returns:boolean

true if the two cache controls are the same, false otherwise.

Annotations
@Override
getCacheExtensionback to summary
public Map<String, String> getCacheExtension()

Corresponds to a set of extension cache control directives.

Returns:Map<String, String>

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
getMaxAgeback to summary
public int getMaxAge()

Corresponds to the max-age cache control directive.

Returns:int

the value of the max-age cache control directive, -1 if the directive is disabled.

See Also
HTTP/1.1 section 14.9.3
getNoCacheFieldsback to summary
public List<String> getNoCacheFields()

Corresponds to the value of the no-cache cache control directive.

Returns:List<String>

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
getPrivateFieldsback to summary
public List<String> getPrivateFields()

Corresponds to the value of the private cache control directive.

Returns:List<String>

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
getSMaxAgeback to summary
public int getSMaxAge()

Corresponds to the s-maxage cache control directive.

Returns:int

the value of the s-maxage cache control directive, -1 if the directive is disabled.

See Also
HTTP/1.1 section 14.9.3
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Generate hash code from cache control properties.

Returns:int

the hashCode

Annotations
@Override
hashCodeOfback to summary
private static int hashCodeOf(final Collection<?> instance)

Compute a Object#hashCode of a collection. If the collection is null or empty, the returned hash code is 0 (zero). Otherwise, the collection's hashCode() method is called to compute the hash code.

Parameters
instance:Collection<?>

collection, may be null.

Returns:int

hash code for the collection, if null or empty, the returned hash code is 0 (zero).

hashCodeOfback to summary
private static int hashCodeOf(final Map<?, ?> instance)

Compute a Object#hashCode of a map. If the map is null or empty, the returned hash code is 0 (zero). Otherwise, the map's hashCode() method is called to compute the hash code.

Parameters
instance:Map<?, ?>

map, may be null.

Returns:int

hash code for the map, if null or empty, the returned hash code is 0 (zero).

isMustRevalidateback to summary
public boolean isMustRevalidate()

Corresponds to the must-revalidate cache control directive.

Returns:boolean

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
isNoCacheback to summary
public boolean isNoCache()

Corresponds to the no-cache cache control directive.

Returns:boolean

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
isNoStoreback to summary
public boolean isNoStore()

Corresponds to the no-store cache control directive.

Returns:boolean

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
isNoTransformback to summary
public boolean isNoTransform()

Corresponds to the no-transform cache control directive.

Returns:boolean

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
isPrivateback to summary
public boolean isPrivate()

Corresponds to the private cache control directive.

Returns:boolean

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
isProxyRevalidateback to summary
public boolean isProxyRevalidate()

Corresponds to the proxy-revalidate cache control directive.

Returns:boolean

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
notEqualback to summary
private static boolean notEqual(final Collection<?> first, final Collection<?> second)

Check if two collections are not equal. If one of the collections is null and the other is empty, consider the collections to be equal.

Parameters
first:Collection<?>

first collection. May be null.

second:Collection<?>

second collection. May be null.

Returns:boolean

true if the two collections are not equal, false if the two collections are equal (or one of them is null and the other one is empty).

notEqualback to summary
private static boolean notEqual(final Map<?, ?> first, final Map<?, ?> second)

Check if two maps are not equal. If one of the maps is null and the other is empty, consider the maps to be equal.

Parameters
first:Map<?, ?>

first collection. May be null.

second:Map<?, ?>

second collection. May be null.

Returns:boolean

true if the two maps are not equal, false if the two maps are equal (or one of them is null and the other one is empty).

setMaxAgeback to summary
public void setMaxAge(final int maxAge)

Corresponds to the max-age cache control directive.

Parameters
maxAge:int

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
setMustRevalidateback to summary
public void setMustRevalidate(final boolean mustRevalidate)

Corresponds to the must-revalidate cache control directive.

Parameters
mustRevalidate:boolean

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
setNoCacheback to summary
public void setNoCache(final boolean noCache)

Corresponds to the no-cache cache control directive.

Parameters
noCache:boolean

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
setNoStoreback to summary
public void setNoStore(final boolean noStore)

Corresponds to the no-store cache control directive.

Parameters
noStore:boolean

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
setNoTransformback to summary
public void setNoTransform(final boolean noTransform)

Corresponds to the no-transform cache control directive.

Parameters
noTransform:boolean

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
setPrivateback to summary
public void setPrivate(final boolean flag)

Corresponds to the private cache control directive.

Parameters
flag:boolean

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
setProxyRevalidateback to summary
public void setProxyRevalidate(final boolean proxyRevalidate)

Corresponds to the must-revalidate cache control directive.

Parameters
proxyRevalidate:boolean

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
setSMaxAgeback to summary
public void setSMaxAge(final int smaxAge)

Corresponds to the s-maxage cache control directive.

Parameters
smaxAge:int

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
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Deprecated

The format of the toString() method is subject to change in a future version. Please use RuntimeDelegate.getInstance().createHeaderDelegate(CacheControl.class).toString(value) instead if you rely on the format of this method.

Convert the cache control to a string suitable for use as the value of the corresponding HTTP header.

Returns:String

a stringified cache control

Annotations
@Override
@Deprecated
valueOfback to summary
public static CacheControl valueOf(final String value)

Deprecated

This method will be removed in a future version. Please use RuntimeDelegate.getInstance().createHeaderDelegate(CacheControl.class).fromString(value) instead.

Creates a new instance of CacheControl by parsing the supplied string.

Parameters
value:String

the cache control string

Returns:CacheControl

the newly created CacheControl

Annotations
@Deprecated
Exceptions
IllegalArgumentException:
if the supplied string cannot be parsed or is null