Class Overview
Data and metadata for an entry returned by the cache.
DefaultCacheEntry
enables the cache data to be refreshed only if a
network connection is available. If not, the cache data will be returned. It
allows to implement simple cache to handle the offline mode of an
application.
To use this class, the NETWORK_STATE
permission must be declared
in the URS file.
To work with more complicated cases where the cache must be updated according
to the data on the server, refer to CacheEntry
.
Summary
Public Methods |
boolean
|
isExpired()
Always false in this implementation, the cache updates will be
based only on refreshNeeded() .
|
boolean
|
refreshNeeded()
Returns true if a network is connected.
|
[Expand]
Inherited Methods |
From class
com.neomades.content.cache.CacheEntry
byte[]
|
getData()
Returns the raw data in the cache.
|
Object
|
getDeserializedData()
Returns the deserialized data in the cache.
|
String
|
getEtag()
Gets the value associated with the ETag header found when the
data was saved in the cache.
|
Map<String, String>
|
getResponseHeaders()
Returns all the headers returned by the response that were used to download
the data.
|
long
|
getServerDate()
Returns the date returned by the server in the header Date when
the response with the data was returned (in ms).
|
long
|
getSoftTTL()
Returns the time when the data will require an update.
|
long
|
getTTL()
Returns the validity time in ms of the cache data.
|
boolean
|
isExpired()
Returns if the entry is expired.
|
boolean
|
refreshNeeded()
Returns true if a refresh is needed from the original data
source.
|
void
|
setData(byte[] data)
Inserts a byte array of data inside the cache entry in order to get it.
|
void
|
setDeserializedData(Object data)
Inserts a deserialized object inside the cache entry in order to get it.
|
void
|
setEtag(String etag)
Saves the value associated with the ETag header found in the
response that get the data.
|
void
|
setResponseHeaders(Map<String, String> responseHeaders)
Saves all the headers returned by the response that were used to download the
data.
|
void
|
setServerDate(long serverDate)
Saves the date returned by the server in the header Date when
the response with the data is returned (in ms).
|
void
|
setSoftTtl(long softTtl)
Sets the time when the data will require an update.
|
void
|
setTtl(long ttl)
Saves the validity time in ms of the cache data.
|
|
From class
java.lang.Object
boolean
|
equals(Object obj)
Indicates whether some other object is "equal to" this one.
|
final
Class<?>
|
getClass()
Returns the runtime class of an object.
|
int
|
hashCode()
Returns a hash code value for the object.
|
final
void
|
notify()
Wakes up a single thread that is waiting on this object's monitor.
|
final
void
|
notifyAll()
Wakes up all threads that are waiting on this object's monitor.
|
String
|
toString()
Returns a string representation of the object.
|
final
void
|
wait(long timeout, int nanos)
Causes current thread to wait until another thread invokes the
notify() method or the
notifyAll() method for this object, or some other
thread interrupts the current thread, or a certain amount of real time has
elapsed.
|
final
void
|
wait(long timeout)
Causes current thread to wait until either another thread invokes the
notify() method or the
notifyAll() method for this object, or a specified
amount of time has elapsed.
|
final
void
|
wait()
Causes current thread to wait until another thread invokes the
notify() method or the
notifyAll() method for this object.
|
|
Public Constructors
public
DefaultCacheEntry
()
Creates a DefaultCacheEntry
.
Public Methods
public
boolean
isExpired
()
Always false
in this implementation, the cache updates will be
based only on refreshNeeded()
.
public
boolean
refreshNeeded
()
Returns true
if a network is connected. If not, the request will
responds with the data in cache and no network connection will be done.
However, if there are no data in cache, the request will try to connect and
an error will be sent.
Returns
true
if a network is connected