com.basho.riak.client
Interface IRiakObject

All Superinterfaces:
Iterable<RiakLink>
All Known Implementing Classes:
DefaultRiakObject

public interface IRiakObject
extends Iterable<RiakLink>

Represents the data and meta data stored in Riak at a bucket/key.

Although you can store your own Java Beans in Riak, this interface represents the core data type that is passed between the low and high level APIs and that all POJOs are converted to and from when stored or fetched.

Extends Iterable to provide a simple way to iterate over the collection of RiakLinks.

NOTE: The name will be changing soon. The initial Java client release laid claim to the best name real estate. This class will be named RiakObject in subsequent releases.

Author:
russell

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 string)
          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 string)
          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()
          User meta data can be added to any Riak object.
 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?
 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)
          Set this IRiakObject's 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()
          An iterable view on the user meta entries.
 
Methods inherited from interface java.lang.Iterable
iterator
 

Method Detail

getBucket

String getBucket()
The name of this objects bucket

Returns:
the bucket name.

getValue

byte[] getValue()
The value.

Returns:
byte[] of this object value.

getValueAsString

String getValueAsString()
Convenience method. Will use the content-type to figure out the charset.

Returns:
the byte[] coerced to a String using the object's content-type

getVClock

VClock getVClock()
This objects Vector Clock. See the basho wiki for more on vector clocks

Returns:
the VClock for this object.

getVClockAsString

String getVClockAsString()
String copy of this object's vector clock.

Returns:
A String of this objects Vector Clock

getKey

String getKey()
The object's key.

Returns:
The objects key.

getVtag

String getVtag()
If this object has a version tag (if it is one of a set of siblings)

Returns:
the vtag, if present.

getLastModified

Date getLastModified()
The last modified date as held by Riak.

Returns:
the last modified date as returned from Riak.

getContentType

String getContentType()
The content-type of this object's value.

Returns:
the Objects Content-Type. If you don't set this it defaults to DefaultRiakObject.DEFAULT_CONTENT_TYPE

getLinks

List<RiakLink> getLinks()
A List of RiakLinks from this object. See also Link Walking on the basho site.

Returns:
The List of RiakLinks from this object
See Also:
RiakLink, LinkWalk

hasLinks

boolean hasLinks()
Does this object link to any others?

Returns:
true if this object has any links, false otherwise.

numLinks

int numLinks()
How many RiakLinks does this object have.

Returns:
the number of links from this object.

hasLink

boolean hasLink(RiakLink riakLink)
Does this object have that link?

Parameters:
riakLink - a RiakLink
Returns:
true if this object's link collection contains the passed RiakLink, false otherwise.

getMeta

Map<String,String> getMeta()
User meta data can be added to any Riak object. They are a String key/value pairs that are stored with the IRiakObject riak. See basho wiki for more details.

Returns:
the Map of meta data for this object.

hasUsermeta

boolean hasUsermeta()
Does this object have any user meta data?

Returns:
if this IRiakObject has any user meta data items.

hasUsermeta

boolean hasUsermeta(String key)
Does this object have a meta data item for that key?

Parameters:
key -
Returns:
true if this IRiakObject's user meta data contains the supplied key

getUsermeta

String getUsermeta(String key)
Get the user meta data item for that key.

Parameters:
key - the name of the user meta data item
Returns:
a String of the user meta data item or null if no item present for the supplied key

userMetaEntries

Iterable<Map.Entry<String,String>> userMetaEntries()
An iterable view on the user meta entries.

Returns:
an iterable view of the set of user meta data.
See Also:
Map.Entry

allBinIndexes

Map<BinIndex,Set<String>> allBinIndexes()
Secondary indexes for this object. See basho wiki for more details. TODO update doc link when 2i hits the wiki

Returns:
a copy of the string indexes for this object.

getBinIndex

Set<String> getBinIndex(String string)
Get a copy of the values for the given bin index

Parameters:
string - the index name
Returns:
a Set of value

allIntIndexes

Map<IntIndex,Set<Integer>> allIntIndexes()
Secondary indexes for this object. See basho wiki for more details. TODO update doc link when 2i hits the wiki

Returns:
a copy of the int indexes for this object

getIntIndex

Set<Integer> getIntIndex(String string)
Get a copy of the values for the given bin index

Parameters:
string - the index name
Returns:
a Set of value

setValue

void setValue(byte[] value)
Set this IRiakObject's value.

Parameters:
value - the byte[] to set.

setValue

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

Parameters:
value - the String value

setContentType

void setContentType(String contentType)
Set the content-type of this object's payload.

Parameters:
contentType - the content-type of this object's value (EG text/plain;charset=utf-8)

addLink

IRiakObject addLink(RiakLink link)
Add link to this RiakObject's links.

Parameters:
link - a RiakLink to add.
Returns:
this RiakObject.

removeLink

IRiakObject removeLink(RiakLink link)
Remove a RiakLink from this RiakObject.

Parameters:
link - the RiakLink to remove
Returns:
this RiakObject

addUsermeta

IRiakObject addUsermeta(String key,
                        String value)
Adds the key, value to the collection of user meta data for this object.

Parameters:
key -
value -
Returns:
this RiakObject.

removeUsermeta

IRiakObject removeUsermeta(String key)
Remove that item of user meta data.

Parameters:
key - the key of the item to remove

addIndex

IRiakObject addIndex(String index,
                     String value)
Add a String index to this objects indexes.

Parameters:
index - index name
value - index value
Returns:
this RiakObject.

addIndex

IRiakObject addIndex(String index,
                     int value)
Add an int index to this objects indexes.

Parameters:
index - index name
value - index value
Returns:
this RiakObject.

removeBinIndex

IRiakObject removeBinIndex(String index)
Remove a BinIndex from this RiakObject.

Parameters:
index - the name of the bin index to remove
Returns:
this RiakObject

removeIntIndex

IRiakObject removeIntIndex(String index)
Remove a IntIndex from this RiakObject.

Parameters:
index - the name of the int index to remove
Returns:
this RiakObject


Copyright © 2012. All Rights Reserved.