public class BasicBSONList extends ArrayList<Object> implements BSONObject
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
modCount| 构造器和说明 |
|---|
BasicBSONList() |
| 限定符和类型 | 方法和说明 |
|---|---|
<T> T |
as(Class<T> type)
Returns an instance of the class "type" only for BasicBsonObject
|
<T> T |
as(Class<T> type,
Type eleType)
Returns an instance of the class "type"
only for BasicBsonObject
|
boolean |
containsField(String key)
Checks if this object contains a field with the given name.
|
boolean |
containsKey(String key)
已过时。
|
Object |
get(String key)
Gets a value at an index.
|
Set<String> |
keySet()
Returns this object's fields' names
|
Object |
put(int key,
Object v)
Puts a value at an index.
|
Object |
put(String key,
Object v)
Puts a value at an index.
|
void |
putAll(BSONObject o)
Sets all key/value pairs from an object into this object
|
void |
putAll(Map m)
Sets all key/value pairs from a map into this object
|
Object |
removeField(String key)
Removes a field with a given name from this object.
|
Map |
toMap()
Returns a map representing this BSONObject.
|
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, get, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeRange, retainAll, set, size, subList, toArray, toArray, trimToSizeequals, hashCodecontainsAll, toStringisEmptycontainsAll, equals, hashCodepublic Object put(String key, Object v)
put 在接口中 BSONObjectkey - the index at which to insert the valuev - the value to insertIllegalArgumentException - if key cannot be parsed into an intpublic Object put(int key, Object v)
index with null.key - the index at which to insert the valuev - the value to insertpublic void putAll(Map m)
BSONObjectputAll 在接口中 BSONObjectm - the mappublic void putAll(BSONObject o)
BSONObjectputAll 在接口中 BSONObjecto - the objectpublic Object get(String key)
get 在接口中 BSONObjectkey - the indexIllegalArgumentException - if key cannot be parsed into an intpublic Object removeField(String key)
BSONObjectremoveField 在接口中 BSONObjectkey - The name of the field to remove@Deprecated public boolean containsKey(String key)
BSONObjectcontainsKey 在接口中 BSONObjectpublic boolean containsField(String key)
BSONObjectcontainsField 在接口中 BSONObjectkey - Field name for which to checkpublic Set<String> keySet()
BSONObjectkeySet 在接口中 BSONObjectpublic Map toMap()
BSONObjecttoMap 在接口中 BSONObjectpublic <T> T as(Class<T> type) throws Exception
as 在接口中 BSONObjecttype - Exceptionpublic <T> T as(Class<T> type, Type eleType) throws Exception
BSONObjectas 在接口中 BSONObjectExceptionCopyright © 2015. All Rights Reserved.