Class CacheEntryAttributes
- java.lang.Object
-
- org.apache.commons.jcs3.engine.ElementAttributes
-
- org.openstreetmap.josm.data.cache.CacheEntryAttributes
-
- All Implemented Interfaces:
Serializable
,Cloneable
,org.apache.commons.jcs3.engine.behavior.IElementAttributes
public class CacheEntryAttributes extends org.apache.commons.jcs3.engine.ElementAttributes
Class that contains attributes for JCS cache entries. Parameters are used to properly handle HTTP caching, and metadata structures, that should be stored together with the cache entry- Since:
- 8168
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private Map<String,String>
attrs
private static String
ERROR_MESSAGE
private static String
ETAG
private static String
EXCEPTION
private static String
EXPIRATION_TIME
private static String
HTTP_RESPONSE_CODE
private static String
LAST_MODIFICATION
private static String
NO_TILE_AT_ZOOM
private static Set<String>
RESERVED_KEYS
private static long
serialVersionUID
-
Constructor Summary
Constructors Constructor Description CacheEntryAttributes()
Constructs a newCacheEntryAttributes
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getErrorMessage()
Returns error message returned while retrieving this object.String
getEtag()
Returns ETag header value, that was returned for this entry.Optional<Class<? extends Exception>>
getException()
Returns optional exception that was thrown when fetching resource.long
getExpirationTime()
Returns when the object expires in milliseconds from Epoch.long
getLastModification()
Returns last modification of the object in cache in milliseconds from Epoch.private long
getLongAttr(String key)
Utility for conversion from String to int, with default to 0, in case of any errorsMap<String,String>
getMetadata()
Returns an unmodifiable Map containing all metadata.int
getResponseCode()
Returns HTTP response code.boolean
isNoTileAtZoom()
Determines if the entry is marked as "no tile at this zoom level".void
setError(Exception error)
Sets error related to this object.void
setErrorMessage(String message)
Sets error message related to this object.void
setEtag(String etag)
Sets the ETag header that was set with this entryvoid
setException(Exception e)
Sets exception that caused error.void
setExpirationTime(long expirationTime)
sets expiration time for the object in cachevoid
setLastModification(long lastModification)
sets last modification of the object in cachevoid
setMetadata(Map<String,String> map)
Sets the metadata about cache entry.void
setNoTileAtZoom(boolean noTileAtZoom)
Sets the marker for "no tile at this zoom level"void
setResponseCode(int responseCode)
Sets the HTTP response code that was sent with the cache entry-
Methods inherited from class org.apache.commons.jcs3.engine.ElementAttributes
addElementEventHandler, addElementEventHandlers, clone, getCreateTime, getElementEventHandlers, getIdleTime, getIsEternal, getIsLateral, getIsRemote, getIsSpool, getLastAccessTime, getMaxLife, getSize, getTimeFactorForMilliseconds, getTimeToLiveSeconds, setCreateTime, setIdleTime, setIsEternal, setIsLateral, setIsRemote, setIsSpool, setLastAccessTime, setLastAccessTimeNow, setMaxLife, setSize, setTimeFactorForMilliseconds, toString
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
NO_TILE_AT_ZOOM
private static final String NO_TILE_AT_ZOOM
- See Also:
- Constant Field Values
-
ETAG
private static final String ETAG
- See Also:
- Constant Field Values
-
LAST_MODIFICATION
private static final String LAST_MODIFICATION
- See Also:
- Constant Field Values
-
EXPIRATION_TIME
private static final String EXPIRATION_TIME
- See Also:
- Constant Field Values
-
HTTP_RESPONSE_CODE
private static final String HTTP_RESPONSE_CODE
- See Also:
- Constant Field Values
-
ERROR_MESSAGE
private static final String ERROR_MESSAGE
- See Also:
- Constant Field Values
-
EXCEPTION
private static final String EXCEPTION
- See Also:
- Constant Field Values
-
RESERVED_KEYS
private static final Set<String> RESERVED_KEYS
-
-
Constructor Detail
-
CacheEntryAttributes
public CacheEntryAttributes()
Constructs a newCacheEntryAttributes
.
-
-
Method Detail
-
isNoTileAtZoom
public boolean isNoTileAtZoom()
Determines if the entry is marked as "no tile at this zoom level".- Returns:
- if the entry is marked as "no tile at this zoom level"
-
setNoTileAtZoom
public void setNoTileAtZoom(boolean noTileAtZoom)
Sets the marker for "no tile at this zoom level"- Parameters:
noTileAtZoom
- true if this entry is "no tile at this zoom level"
-
getEtag
public String getEtag()
Returns ETag header value, that was returned for this entry.- Returns:
- ETag header value, that was returned for this entry.
-
setEtag
public void setEtag(String etag)
Sets the ETag header that was set with this entry- Parameters:
etag
- Etag header
-
getLongAttr
private long getLongAttr(String key)
Utility for conversion from String to int, with default to 0, in case of any errors- Parameters:
key
- - integer as string- Returns:
- int value of the string
-
getLastModification
public long getLastModification()
Returns last modification of the object in cache in milliseconds from Epoch.- Returns:
- last modification of the object in cache in milliseconds from Epoch
-
setLastModification
public void setLastModification(long lastModification)
sets last modification of the object in cache- Parameters:
lastModification
- time in format of milliseconds from Epoch
-
getExpirationTime
public long getExpirationTime()
Returns when the object expires in milliseconds from Epoch.- Returns:
- when the object expires in milliseconds from Epoch
-
setExpirationTime
public void setExpirationTime(long expirationTime)
sets expiration time for the object in cache- Parameters:
expirationTime
- in format of milliseconds from epoch
-
setResponseCode
public void setResponseCode(int responseCode)
Sets the HTTP response code that was sent with the cache entry- Parameters:
responseCode
- http status code- Since:
- 8389
-
getResponseCode
public int getResponseCode()
Returns HTTP response code.- Returns:
- http status code
- Since:
- 8389
-
setMetadata
public void setMetadata(Map<String,String> map)
Sets the metadata about cache entry. As it stores all data together, with other attributes in common map, some keys might not be stored.- Parameters:
map
- metadata to save- Since:
- 8418
-
getMetadata
public Map<String,String> getMetadata()
Returns an unmodifiable Map containing all metadata. Unmodifiable prevents access to metadata within attributes.- Returns:
- unmodifiable Map with cache element metadata
- Since:
- 8418
-
getErrorMessage
public String getErrorMessage()
Returns error message returned while retrieving this object.- Returns:
- error message returned while retrieving this object
-
setError
public void setError(Exception error)
Sets error related to this object.- Parameters:
error
- error related to this object- Since:
- 10469
-
setErrorMessage
public void setErrorMessage(String message)
Sets error message related to this object.- Parameters:
message
- error message related to this object
-
setException
public void setException(Exception e)
Sets exception that caused error.- Parameters:
e
- exception that caused error
-
getException
public Optional<Class<? extends Exception>> getException()
Returns optional exception that was thrown when fetching resource.- Returns:
- Optional exception that was thrown when fetching resource
-
-