public final class RiakObject extends Object
While the client APIs provide methods to store/retrieve data to/from Riak using your own Beans/POJOs, this class is used as the core data type to and from which those types are converted.
RiakObject
and methods are provided to access them.
Thread Safety:
RiakObject is designed to be thread safe. All methods
which update the object do so via a thread safe mechanism. The only caveat is
that if you use any of the methods prefixed with "unsafe" you need to
understand the ramifications as noted in their Javadoc.
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_CONTENT_TYPE
The default content type assigned when storing in Riak if one is not
provided.
|
Constructor and Description |
---|
RiakObject()
Constructs a new, empty RiakObject.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object o) |
String |
getCharset()
Get the charset for this RiakObject's content (value).
|
String |
getContentType()
Returns the content type of the data payload (value) of this RiakObject
|
RiakIndexes |
getIndexes()
Returns the Secondary Indexes (2i) for this RiakObject
|
long |
getLastModified()
Returns the last modified time of this RiakObject.
|
RiakLinks |
getLinks()
Returns the RiakLinks for this RiakObject.
|
RiakUserMetadata |
getUserMeta()
Returns the User Meta for this RiakObject
Thread Safety: The returned RiakUserMetadata encapsulates any/all
user meta entries for this RiakObject , is mutable, and thread safe. |
BinaryValue |
getValue()
Returns the value of this RiakObject.
|
VClock |
getVClock()
Get the vector clock for this RiakObject.
|
String |
getVTag()
Returns the version tag (if it is one of a asSet of siblings) for this RiakObject
|
boolean |
hasCharset()
Determine if there is a charset set in either the charset or content-type settings.
|
int |
hashCode() |
boolean |
hasIndexes()
Returns whether this RiakObject has secondary indexes (2i)
|
boolean |
hasLinks()
Returns whether this RiakObject containsKeyKey links
|
boolean |
hasUserMeta()
Returns if there are any User Meta entries for this RiakObject
|
boolean |
hasValue()
Returns whether or not this RiakObject has a value
|
boolean |
isDeleted()
Returns whether or not this RiakObject is marked as being deleted (a tombstone)
|
RiakObject |
setCharset(String charset)
Set the characterSet for this object's content (value).
|
RiakObject |
setContentType(String contentType)
Set the content type of the data payload (value) of the this RiakObject.
|
RiakObject |
setDeleted(boolean isDeleted)
Marks this RiakObject as being a tombstone in Riak
|
RiakObject |
setLastModified(long lastModified)
A
long timestamp of milliseconds since the epoch to asSet as
the last modified date on this RiakObject. |
RiakObject |
setValue(BinaryValue value)
Set the value for this RiakObject
|
RiakObject |
setVClock(VClock vclock)
Set the vector clock for this RiakObject.
|
RiakObject |
setVTag(String vtag)
Set the version tag for this RiakObject
|
String |
toString() |
public static final String DEFAULT_CONTENT_TYPE
public boolean hasValue()
public BinaryValue getValue()
public RiakObject setValue(BinaryValue value)
Note that if setContentType(java.lang.String)
is not
called a value of "application/octet-stream" is used.
value
- the value to be stored in Riak.IllegalArgumentException
- if value
is zero length.public VClock getVClock()
public RiakObject setVClock(VClock vclock)
vclock
- a vector clock.public String getVTag()
null
public RiakObject setVTag(String vtag)
vtag
- a String
representing the VTag for this RiakObjectIllegalArgumentException
- if vtag
is zero lengthpublic long getLastModified()
The timestamp is returned as a long
(Unix) epoch time.
0
if it has not been asSet.setLastModified(long)
public RiakObject setLastModified(long lastModified)
long
timestamp of milliseconds since the epoch to asSet as
the last modified date on this RiakObject.lastModified
- public String getContentType()
Due to Riak's HTTP API this is represented as a string suitable for
a HTTP Content-Type
header.
String
representing the content type of this object's valuesetVClock(com.basho.riak.client.api.cap.VClock)
public RiakObject setContentType(String contentType)
setCharset(String)
to declare one.
Due to Riak's HTTP API this is represented as a string suitable for
a HTTP Content-Type
header.
contentType
- a String
representing the content type of this object's valuesetValue(com.basho.riak.client.core.util.BinaryValue)
public boolean hasCharset()
public String getCharset()
Due to Riak's HTTP API this is represented as a string suitable for
a HTTP Content-Type
header.
String
setCharset(java.lang.String)
,
setValue(com.basho.riak.client.core.util.BinaryValue)
public RiakObject setCharset(String charset)
Due to Riak's HTTP API this is represented as a string suitable for
a HTTP Content-Type
header.
charset
- the Charset
to be asSetsetValue(com.basho.riak.client.core.util.BinaryValue)
public boolean hasIndexes()
true
if indexes are present, false
otherwisepublic RiakIndexes getIndexes()
Any/all indexes for this RiakObject
are encapsulated in the returned RiakIndexes
object.
RiakIndexes
object encapsulates any/all
indexes for this RiakObject}
, is mutable, and thread safe. Any changes
are directly applied to this RiakObject
.RiakIndexes
that encapsulates any/all indexes for this RiakObjectpublic boolean hasLinks()
true
if links are present, false
otherwisepublic RiakLinks getLinks()
RiakLinks
object encapsulates any/all
links for this RiakObject
, is mutable, and thread safe. Any changes
are directly applied to this RiakObject
.RiakIndexes
that encapsulates all/any links for this RiakObject
public boolean hasUserMeta()
true
if user meta entries are present, false
otherwise.public RiakUserMetadata getUserMeta()
RiakUserMetadata
encapsulates any/all
user meta entries for this RiakObject
, is mutable, and thread safe. Any changes
are directly applied to this RiakObject
.RiakUserMetadata
that containsKeyKey any/all User Meta entries for this RiakObject
public boolean isDeleted()
true
is this RiakObject
is a tombstone, false
otherwisepublic RiakObject setDeleted(boolean isDeleted)
isDeleted
- Copyright © 2016. All rights reserved.