Class CacheEntryAttributes
- java.lang.Object
-
- org.apache.commons.jcs3.engine.ElementAttributes
-
- org.openstreetmap.josm.data.cache.CacheEntryAttributes
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.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 java.util.Map<java.lang.String,java.lang.String>attrsprivate static java.lang.StringERROR_MESSAGEprivate static java.lang.StringETAGprivate static java.lang.StringEXCEPTIONprivate static java.lang.StringEXPIRATION_TIMEprivate static java.lang.StringHTTP_RESPONSE_CODEprivate static java.lang.StringLAST_MODIFICATIONprivate static java.lang.StringNO_TILE_AT_ZOOMprivate static java.util.Set<java.lang.String>RESERVED_KEYSprivate static longserialVersionUID
-
Constructor Summary
Constructors Constructor Description CacheEntryAttributes()Constructs a newCacheEntryAttributes.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetErrorMessage()Returns error message returned while retrieving this object.java.lang.StringgetEtag()Returns ETag header value, that was returned for this entry.java.util.Optional<java.lang.Class<? extends java.lang.Exception>>getException()Returns optional exception that was thrown when fetching resource.longgetExpirationTime()Returns when the object expires in milliseconds from Epoch.longgetLastModification()Returns last modification of the object in cache in milliseconds from Epoch.private longgetLongAttr(java.lang.String key)Utility for conversion from String to int, with default to 0, in case of any errorsjava.util.Map<java.lang.String,java.lang.String>getMetadata()Returns an unmodifiable Map containing all metadata.intgetResponseCode()Returns HTTP response code.booleanisNoTileAtZoom()Determines if the entry is marked as "no tile at this zoom level".voidsetError(java.lang.Exception error)Sets error related to this object.voidsetErrorMessage(java.lang.String message)Sets error message related to this object.voidsetEtag(java.lang.String etag)Sets the ETag header that was set with this entryvoidsetException(java.lang.Exception e)Sets exception that caused error.voidsetExpirationTime(long expirationTime)sets expiration time for the object in cachevoidsetLastModification(long lastModification)sets last modification of the object in cachevoidsetMetadata(java.util.Map<java.lang.String,java.lang.String> map)Sets the metadata about cache entry.voidsetNoTileAtZoom(boolean noTileAtZoom)Sets the marker for "no tile at this zoom level"voidsetResponseCode(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
-
attrs
private final java.util.Map<java.lang.String,java.lang.String> attrs
-
NO_TILE_AT_ZOOM
private static final java.lang.String NO_TILE_AT_ZOOM
- See Also:
- Constant Field Values
-
ETAG
private static final java.lang.String ETAG
- See Also:
- Constant Field Values
-
LAST_MODIFICATION
private static final java.lang.String LAST_MODIFICATION
- See Also:
- Constant Field Values
-
EXPIRATION_TIME
private static final java.lang.String EXPIRATION_TIME
- See Also:
- Constant Field Values
-
HTTP_RESPONSE_CODE
private static final java.lang.String HTTP_RESPONSE_CODE
- See Also:
- Constant Field Values
-
ERROR_MESSAGE
private static final java.lang.String ERROR_MESSAGE
- See Also:
- Constant Field Values
-
EXCEPTION
private static final java.lang.String EXCEPTION
- See Also:
- Constant Field Values
-
RESERVED_KEYS
private static final java.util.Set<java.lang.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 java.lang.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(java.lang.String etag)
Sets the ETag header that was set with this entry- Parameters:
etag- Etag header
-
getLongAttr
private long getLongAttr(java.lang.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(java.util.Map<java.lang.String,java.lang.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 java.util.Map<java.lang.String,java.lang.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 java.lang.String getErrorMessage()
Returns error message returned while retrieving this object.- Returns:
- error message returned while retrieving this object
-
setError
public void setError(java.lang.Exception error)
Sets error related to this object.- Parameters:
error- error related to this object- Since:
- 10469
-
setErrorMessage
public void setErrorMessage(java.lang.String message)
Sets error message related to this object.- Parameters:
message- error message related to this object
-
setException
public void setException(java.lang.Exception e)
Sets exception that caused error.- Parameters:
e- exception that caused error
-
getException
public java.util.Optional<java.lang.Class<? extends java.lang.Exception>> getException()
Returns optional exception that was thrown when fetching resource.- Returns:
- Optional exception that was thrown when fetching resource
-
-