SequoiaDB
 All Classes Namespaces Functions Variables Pages
Public Member Functions | List of all members
org.bson.types.BasicBSONList Class Reference
Inheritance diagram for org.bson.types.BasicBSONList:

Public Member Functions

Object put (String key, Object v)
 
Object put (int key, Object v)
 
void putAll (Map m)
 
void putAll (BSONObject o)
 
Object get (String key)
 
Object removeField (String key)
 
boolean containsKey (String key)
 
boolean containsField (String key)
 
Set< String > keySet ()
 
Map toMap ()
 
Object asList ()
 

Detailed Description

Utility class to allow array DBObjects to be created.

Note: MongoDB will also create arrays from java.util.Lists.

DBObject obj = new BasicBSONList();
obj.put("0", value1);
obj.put("4", value2);
obj.put(2, value3);

This simulates the array [ value1, null, value3, null, value2 ] by creating the DBObject { "0" : value1, "1" : null, "2" : value3, "3" : null, "4" : value2 }

BasicBSONList only supports numeric keys. Passing strings that cannot be converted to ints will cause an IllegalArgumentException.

BasicBSONList list = new BasicBSONList();
list.put("1", "bar"); // ok
list.put("1E1", "bar"); // throws exception

Member Function Documentation

boolean org.bson.types.BasicBSONList.containsKey ( String  key)
inline
Object org.bson.types.BasicBSONList.get ( String  key)
inline

Gets a value at an index. For interface compatibility. Must be passed a String that is parsable to an int.

Parameters
keythe index
Returns
the value, if found, or null
Exceptions
IllegalArgumentExceptionif key cannot be parsed into an int
Object org.bson.types.BasicBSONList.put ( String  key,
Object  v 
)
inline

Puts a value at an index. For interface compatibility. Must be passed a String that is parsable to an int.

Parameters
keythe index at which to insert the value
vthe value to insert
Returns
the value
Exceptions
IllegalArgumentExceptionif key cannot be parsed into an int
Object org.bson.types.BasicBSONList.put ( int  key,
Object  v 
)
inline

Puts a value at an index. This will fill any unset indexes less than index with null.

Parameters
keythe index at which to insert the value
vthe value to insert
Returns
the value

The documentation for this class was generated from the following file: