public class ReadResult
extends java.lang.Object
An object that reflects the results of a Read operation. In particular,
getStatus()
allows you to determine the outcome of the operation,
and getBytes()
or getCachedObject()
allow you to retrieve
the results of the operation.
ReadOptions.ObjectMayNotExist
flag or
ReadOptions.ObjectMayBeLocked
flag is specified via the
ReadOptions
parameter to Read, the value returned from
getStatus()
will always be StateServerResult.Success
. Any
errors occuring during the Read operation will result in exceptions.Modifier and Type | Method and Description |
---|---|
byte[] |
getBytes()
If the corresponding Read operation was successful (e.g.
|
java.lang.Object |
getCachedObject()
If the corresponding
DataAccessor.read() operation was successful (e.g. |
StateServerResult |
getStatus()
Return the StateServerResult value indicating whether the Read operation
completed successfully or whether any expected errors were encountered.
|
boolean |
isCachedObjectValid()
Returns
true if the Read request has been satisfied from
the client-side cache (the object was present and had not been modified
by any other StateServer client since it was cached). |
boolean |
isStale() |
void |
setStale(boolean stale) |
public StateServerResult getStatus()
public byte[] getBytes()
getStatus()
returns StateServerResult.Success
) and the
Read operation was not supplied by the client-side cache (e.g.
isCachedObjectValid()
is false
) then return the
data read from the StateServer. Otherwise, return null
.java.lang.UnsupportedOperationException
- thrown if the this ReadResult
holds a deserialized,
cached object from the client-side cache (in which case, no
byte stream was read from StateServer).public java.lang.Object getCachedObject()
If the corresponding DataAccessor.read()
operation was successful (e.g.
getStatus()
returns StateServerResult.Success
) and the
object was found and was valid in the client-side cache (e.g.
isCachedObjectValid()
returns true
) then then
this method returns the (deserialized) object retrieved from the
client-side cache.
Unless the ReadOptions specified in the DataAccessor.read()
request include
ReturnCachedObjectIfValid the client-side cache is not consulted for read
operations. In that case, IsCachedObjectValid will always be false and
any attempt to reference this property will result in an
InvalidOperationException being thrown.
ReadOptions.ReturnCachedObjectIfValid
then the read operation may
be satisfied by returning an object held in the client-side cache. In
that case, the caller must examine isCachedObjectValid()
to
determine whether the cached object is available and unmodified by any
StateServer client. If isCachedObjectValid()
returns
true
, then CachedObject will return the (deserialized)
object from the cache. Attempts to access this property when the cached
object is unavailable will result in an
UnsupportedOperationException
being thrown.java.lang.UnsupportedOperationException
- thrown if the this ReadResult
holds a serialized byte
stream.public boolean isCachedObjectValid()
true
if the Read request has been satisfied from
the client-side cache (the object was present and had not been modified
by any other StateServer client since it was cached). Returns
false
otherwise.true
if the Read request has been satisfied from
the client-side cache. Otherwise, false
otherwise.public boolean isStale()
public void setStale(boolean stale)