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.
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 |
---|---|
String |
getCharset()
Get the character asSet 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
|
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 character asSet present in the content-type.
|
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 character asSet for this object's content (value).
|
RiakObject |
setContentType(String contentType)
Set the content type of the data payload (value) of the this RaikObject
|
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
|
public static final String DEFAULT_CONTENT_TYPE
public boolean hasValue()
public BinaryValue getValue()
public RiakObject setValue(BinaryValue value)
Note that if RiakObject.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.Unsafe modifications to the supplied BinaryValue's underlying byte[] would be a bad thing. |
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.RiakObject.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 valueRiakObject.setVClock(com.basho.riak.client.api.cap.VClock)
public RiakObject setContentType(String contentType)
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 valueRiakObject.setValue(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
RiakObject.setCharset(java.lang.String)
,
RiakObject.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 asSetRiakObject.setValue(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
that encapsulates any/all indexes for this RiakObjectThe returned RiakIndexes object encapsulates any/all
indexes for this RiakObject} , is mutable, and thread safe. Any changes
are directly applied to this RaikObject . |
public boolean hasLinks()
true
if links are present, false
otherwisepublic RiakLinks getLinks()
RiakIndexes
that encapsulates all/any links for this RiakObject
The returned RiakLinks object encapsulates any/all
links for this RaikObject , is mutable, and thread safe. Any changes
are directly applied to this RaikObject . |
public boolean hasUserMeta()
true
if user meta entries are present, false
otherwise.public RiakUserMetadata getUserMeta()
RiakUserMetadata
that containsKeyKey any/all User Meta entries for this RiakObject
The returned RiakUserMetadata} encapsulates any/all
user meta entries for this RaikObject , is mutable, and thread safe. Any changes
are directly applied to this RaikObject . |
public RiakObject setDeleted(boolean isDeleted)
isDeleted
- public boolean isDeleted()
true
is this RiakObject
is a tombstone, false
otherwiseCopyright © 2014. All rights reserved.