Spring Data Couchbase

org.springframework.data.couchbase.core.mapping
Class CouchbaseList

java.lang.Object
  extended by org.springframework.data.couchbase.core.mapping.CouchbaseList
All Implemented Interfaces:
CouchbaseStorable

public class CouchbaseList
extends Object
implements CouchbaseStorable

A CouchbaseList is an abstract list that represents an array stored in a (most of the times JSON) document.

This CouchbaseList is part of the potentially nested structure inside one or more CouchbaseDocuments. It can also contain them recursively, depending on how the document is modeled.


Constructor Summary
CouchbaseList()
          Create a new (empty) list.
CouchbaseList(List<Object> initialPayload)
          Create a new list with a given payload on construction.
 
Method Summary
 boolean containsValue(Object value)
          Returns true if it contains the given value.
 List<Object> export()
          Returns the current payload, including all recursive elements.
 Object get(int index)
          Return the stored element at the given index.
 boolean isEmpty()
          Checks if the underlying payload is empty or not.
 CouchbaseList put(Object value)
          Add content to the underlying list.
 int size()
          Returns the size of the attributes in this document (not nested).
 int size(boolean recursive)
          Retruns the size of the attributes in this and recursive documents.
 String toString()
          A string reprensation of the payload.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CouchbaseList

public CouchbaseList()
Create a new (empty) list.


CouchbaseList

public CouchbaseList(List<Object> initialPayload)
Create a new list with a given payload on construction.

Parameters:
initialPayload - the initial data to store.
Method Detail

put

public final CouchbaseList put(Object value)
Add content to the underlying list.

Parameters:
value - the value to be added.
Returns:
the CouchbaseList object for chaining purposes.

get

public final Object get(int index)
Return the stored element at the given index.

Parameters:
index - the index where the document is located.
Returns:
the found object (or null if nothing found).

size

public final int size()
Returns the size of the attributes in this document (not nested).

Returns:
the size of the attributes in this document (not nested).

size

public final int size(boolean recursive)
Retruns the size of the attributes in this and recursive documents.

Parameters:
recursive - wheter nested attributes should be taken into account.
Returns:
the size of the attributes in this and recursive documents.

export

public final List<Object> export()
Returns the current payload, including all recursive elements. It either returns the raw results or makes sure that the recusrive elements are also exported properly.

Returns:

containsValue

public final boolean containsValue(Object value)
Returns true if it contains the given value.

Parameters:
value - the value to check for.
Returns:
true if it contains the specified value.

isEmpty

public final boolean isEmpty()
Checks if the underlying payload is empty or not.

Returns:
whether the underlying payload is empty or not.

toString

public String toString()
A string reprensation of the payload.

Overrides:
toString in class Object
Returns:
the underlying payload as a string representation for easier debugging.

Spring Data Couchbase

Copyright © 2011-2014–2014 Pivotal Software, Inc.. All rights reserved.