public class DefaultRiakObject extends Object implements IRiakObject
IRiakObject
Is as immutable as possible. Value, content-type, links and user meta data are all mutable.
It is safe to use the instances of this class from multiple threads.
Due to the large number of arguments to the constructor the *best* way to create instances is with a RiakObjectBuilder.
| Modifier and Type | Field and Description |
|---|---|
static String |
DEFAULT_CONTENT_TYPE
The default content type assigned when persisted in Riak if non is provided.
|
| Constructor and Description |
|---|
DefaultRiakObject(String bucket,
String key,
VClock vclock,
String vtag,
Date lastModified,
String contentType,
byte[] value,
Collection<RiakLink> links,
Map<String,String> userMeta,
RiakIndexes indexes,
boolean isDeleted)
Large number of arguments due to largely immutable nature.
|
| Modifier and Type | Method and Description |
|---|---|
IRiakObject |
addIndex(String index,
long value)
Add an int index to this objects indexes.
|
IRiakObject |
addIndex(String index,
String value)
Add a String index to this objects indexes.
|
IRiakObject |
addLink(RiakLink link)
Add link to this RiakObject's links.
|
IRiakObject |
addUsermeta(String key,
String value)
Adds the key, value to the collection of user meta data for this object.
|
Map<BinIndex,Set<String>> |
allBinIndexes()
Secondary indexes for this object.
|
Map<IntIndex,Set<Integer>> |
allIntIndexes()
Deprecated.
|
Map<IntIndex,Set<Long>> |
allIntIndexesV2()
Secondary indexes for this object.
|
Set<String> |
getBinIndex(String name)
Get a copy of the values for the given bin index
|
String |
getBucket()
The name of this objects bucket
|
String |
getContentType()
The content-type of this object's value.
|
Set<Integer> |
getIntIndex(String name)
Deprecated.
|
Set<Long> |
getIntIndexV2(String name)
Get a copy of the values for the given int_ index
|
String |
getKey()
The object's key.
|
Date |
getLastModified()
The last modified date as held by Riak.
|
List<RiakLink> |
getLinks()
A List of
RiakLinks from this object. |
Map<String,String> |
getMeta()
NOTE: a copy is returned.
|
String |
getUsermeta(String key)
Get the user meta data item for that key.
|
byte[] |
getValue()
The value.
|
String |
getValueAsString()
Convenience method.
|
VClock |
getVClock()
This objects Vector Clock.
|
String |
getVClockAsString()
String copy of this object's vector clock.
|
String |
getVtag()
If this object has a version tag (if it is one of a set of siblings)
|
boolean |
hasLink(RiakLink riakLink)
Does this object have that link?
|
boolean |
hasLinks()
Does this object link to any others?
|
boolean |
hasUsermeta()
Does this object have any user meta data?
|
boolean |
hasUsermeta(String key)
Does this object have a meta data item for that key?
|
boolean |
isDeleted()
Check to see if this object is a tombstone (deleted)
Note: The request has to have been made specifying tombstones
(deleted vclocks) are to be returned.
|
Iterator<RiakLink> |
iterator()
an
UnmodifiableIterator view on the RiakLinks |
int |
numLinks()
How many
RiakLinks does this object have. |
IRiakObject |
removeBinIndex(String index)
Remove a
BinIndex from this RiakObject. |
IRiakObject |
removeIntIndex(String index)
Remove a
IntIndex from this RiakObject. |
IRiakObject |
removeLink(RiakLink link)
Remove a
RiakLink from this RiakObject. |
IRiakObject |
removeUsermeta(String key)
Remove that item of user meta data.
|
void |
setContentType(String contentType)
Set the content-type of this object's payload.
|
void |
setValue(byte[] value)
Note: Copies the value.
|
void |
setValue(String value)
Convenience method that will result in value being turned into a byte[]
array using charset utf-8 and also will result in charset=utf-8 being
appended to the content-type for this object
|
Iterable<Map.Entry<String,String>> |
userMetaEntries()
return an unmodifiable view of the user meta entries.
|
public static String DEFAULT_CONTENT_TYPE
public DefaultRiakObject(String bucket, String key, VClock vclock, String vtag, Date lastModified, String contentType, byte[] value, Collection<RiakLink> links, Map<String,String> userMeta, RiakIndexes indexes, boolean isDeleted)
RiakObjectBuilder to create instances.bucket - the bucket the object is stored inkey - the key it is stored undervclock - the vclock, if availablevtag - the version tag, if relevantlastModified - the last modified date from Riak (if relevant)contentType - the content-type of the valuevalue - a byte[] of the data payload to store in Riak. Note: this is cloned on construction of this instance.links - the List of RiakLinks from this object. Note: this is copied.userMeta - the Map of user meta data to store/stored with this object. Note: this is copied.indexes - the RiakIndexes for this object. These will be copied to a new RiakIndexespublic String getBucket()
IRiakObjectgetBucket in interface IRiakObjectpublic VClock getVClock()
IRiakObjectgetVClock in interface IRiakObjectVClock for this object.public String getKey()
IRiakObjectgetKey in interface IRiakObjectpublic String getVtag()
IRiakObjectgetVtag in interface IRiakObjectpublic Date getLastModified()
IRiakObjectgetLastModified in interface IRiakObjectpublic String getContentType()
IRiakObjectgetContentType in interface IRiakObjectDEFAULT_CONTENT_TYPEpublic Map<String,String> getMeta()
getMeta in interface IRiakObjectMap of meta data for this object.IRiakObject.getMeta()public byte[] getValue()
IRiakObjectgetValue in interface IRiakObjectIRiakObject.getValue()public void setValue(byte[] value)
setValue in interface IRiakObjecta - byte[] to store in Riak.public void setValue(String value)
IRiakObjectsetValue in interface IRiakObjectvalue - the String valuepublic void setContentType(String contentType)
IRiakObjectsetContentType in interface IRiakObjectcontentType - the content-type of this object's value (EG
text/plain;charset=utf-8)public Iterator<RiakLink> iterator()
UnmodifiableIterator view on the RiakLinkspublic IRiakObject addLink(RiakLink link)
IRiakObjectaddLink in interface IRiakObjectlink - a RiakLink to add.public IRiakObject removeLink(RiakLink link)
IRiakObjectRiakLink from this RiakObject.removeLink in interface IRiakObjectlink - the RiakLink to removepublic boolean hasLinks()
IRiakObjecthasLinks in interface IRiakObjectpublic int numLinks()
IRiakObjectRiakLinks does this object have.numLinks in interface IRiakObjectpublic List<RiakLink> getLinks()
IRiakObjectRiakLinks from this object. See also Link Walking on the basho
site.getLinks in interface IRiakObjectRiakLink,
LinkWalkpublic boolean hasLink(RiakLink riakLink)
IRiakObjecthasLink in interface IRiakObjectriakLink - a RiakLinkRiakLink, false otherwise.public IRiakObject addUsermeta(String key, String value)
IRiakObjectaddUsermeta in interface IRiakObjectpublic boolean hasUsermeta()
IRiakObjecthasUsermeta in interface IRiakObjectpublic boolean hasUsermeta(String key)
IRiakObjecthasUsermeta in interface IRiakObjectpublic String getUsermeta(String key)
IRiakObjectgetUsermeta in interface IRiakObjectkey - the name of the user meta data itempublic IRiakObject removeUsermeta(String key)
IRiakObjectremoveUsermeta in interface IRiakObjectkey - the key of the item to removepublic Iterable<Map.Entry<String,String>> userMetaEntries()
userMetaEntries in interface IRiakObjectMap.Entrypublic String getVClockAsString()
IRiakObjectgetVClockAsString in interface IRiakObjectpublic String getValueAsString()
IRiakObjectgetValueAsString in interface IRiakObjectpublic Map<BinIndex,Set<String>> allBinIndexes()
IRiakObjectallBinIndexes in interface IRiakObjectpublic Set<String> getBinIndex(String name)
IRiakObjectgetBinIndex in interface IRiakObjectname - the index name@Deprecated public Map<IntIndex,Set<Integer>> allIntIndexes()
allIntIndexes in interface IRiakObjectIRiakObject.allIntIndexesV2()public Map<IntIndex,Set<Long>> allIntIndexesV2()
IRiakObjectallIntIndexesV2 in interface IRiakObject@Deprecated public Set<Integer> getIntIndex(String name)
getIntIndex in interface IRiakObjectIRiakObject.getIntIndexV2(java.lang.String)public Set<Long> getIntIndexV2(String name)
IRiakObjectgetIntIndexV2 in interface IRiakObjectname - the index namepublic IRiakObject addIndex(String index, String value)
IRiakObjectaddIndex in interface IRiakObjectindex - index namevalue - index valuepublic IRiakObject addIndex(String index, long value)
IRiakObjectaddIndex in interface IRiakObjectindex - index namevalue - index valuepublic IRiakObject removeBinIndex(String index)
IRiakObjectBinIndex from this RiakObject.removeBinIndex in interface IRiakObjectindex - the name of the bin index to removepublic IRiakObject removeIntIndex(String index)
IRiakObjectIntIndex from this RiakObject.removeIntIndex in interface IRiakObjectindex - the name of the int index to removepublic boolean isDeleted()
IRiakObjectisDeleted in interface IRiakObjectcom.basho.riak.client.operations.FetchObject#returnDeletedVClock(boolean),
com.basho.riak.client.operations.StoreObject#returnDeletedVClock(boolean)Copyright © 2014. All Rights Reserved.