|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.basho.riak.client.DefaultRiakObject
public class DefaultRiakObject
The default implementation of 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.
| Field Summary | |
|---|---|
static String |
DEFAULT_CONTENT_TYPE
The default content type assigned when persisted in Riak if non is provided. |
| Constructor Summary | |
|---|---|
DefaultRiakObject(String bucket,
String key,
VClock vclock,
String vtag,
Date lastModified,
String contentType,
byte[] value,
Collection<RiakLink> links,
Map<String,String> userMeta,
RiakIndexes indexes)
Large number of arguments due to largely immutable nature. |
|
| Method Summary | |
|---|---|
IRiakObject |
addIndex(String index,
int 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()
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)
Get a copy of the values for the given bin 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? |
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. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static String DEFAULT_CONTENT_TYPE
| Constructor Detail |
|---|
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)
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 RiakIndexes| Method Detail |
|---|
public String getBucket()
IRiakObject
getBucket in interface IRiakObjectpublic VClock getVClock()
IRiakObject
getVClock in interface IRiakObjectVClock for this object.public String getKey()
IRiakObject
getKey in interface IRiakObjectpublic String getVtag()
IRiakObject
getVtag in interface IRiakObjectpublic Date getLastModified()
IRiakObject
getLastModified in interface IRiakObjectpublic String getContentType()
IRiakObject
getContentType in interface IRiakObjectDEFAULT_CONTENT_TYPEpublic Map<String,String> getMeta()
getMeta in interface IRiakObjectMap of meta data for this object.IRiakObject.getMeta()public byte[] getValue()
IRiakObject
getValue in interface IRiakObjectIRiakObject.getValue()public void setValue(byte[] value)
setValue in interface IRiakObjecta - byte[] to store in Riak.public void setValue(String value)
IRiakObject
setValue in interface IRiakObjectvalue - the String valuepublic void setContentType(String contentType)
IRiakObject
setContentType 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 RiakLinks
iterator in interface Iterable<RiakLink>public IRiakObject addLink(RiakLink link)
IRiakObject
addLink in interface IRiakObjectlink - a RiakLink to add.
public IRiakObject removeLink(RiakLink link)
IRiakObjectRiakLink from this RiakObject.
removeLink in interface IRiakObjectlink - the RiakLink to remove
public boolean hasLinks()
IRiakObject
hasLinks 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)
IRiakObject
hasLink in interface IRiakObjectriakLink - a RiakLink
RiakLink, false otherwise.
public IRiakObject addUsermeta(String key,
String value)
IRiakObject
addUsermeta in interface IRiakObjectpublic boolean hasUsermeta()
IRiakObject
hasUsermeta in interface IRiakObjectpublic boolean hasUsermeta(String key)
IRiakObject
hasUsermeta in interface IRiakObjectpublic String getUsermeta(String key)
IRiakObject
getUsermeta in interface IRiakObjectkey - the name of the user meta data item
public IRiakObject removeUsermeta(String key)
IRiakObject
removeUsermeta in interface IRiakObjectkey - the key of the item to removepublic Iterable<Map.Entry<String,String>> userMetaEntries()
userMetaEntries in interface IRiakObjectMap.Entrypublic String getVClockAsString()
IRiakObject
getVClockAsString in interface IRiakObjectpublic String getValueAsString()
IRiakObject
getValueAsString in interface IRiakObjectpublic Map<BinIndex,Set<String>> allBinIndexes()
IRiakObject
allBinIndexes in interface IRiakObjectpublic Set<String> getBinIndex(String name)
IRiakObject
getBinIndex in interface IRiakObjectname - the index name
public Map<IntIndex,Set<Integer>> allIntIndexes()
IRiakObject
allIntIndexes in interface IRiakObjectpublic Set<Integer> getIntIndex(String name)
IRiakObject
getIntIndex in interface IRiakObjectname - the index name
public IRiakObject addIndex(String index,
String value)
IRiakObject
addIndex in interface IRiakObjectindex - index namevalue - index value
public IRiakObject addIndex(String index,
int value)
IRiakObject
addIndex in interface IRiakObjectindex - index namevalue - index value
public IRiakObject removeBinIndex(String index)
IRiakObjectBinIndex from this RiakObject.
removeBinIndex in interface IRiakObjectindex - the name of the bin index to remove
public IRiakObject removeIntIndex(String index)
IRiakObjectIntIndex from this RiakObject.
removeIntIndex in interface IRiakObjectindex - the name of the int index to remove
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||