Package org.bson
Class BsonArray
- java.lang.Object
-
- org.bson.BsonValue
-
- org.bson.BsonArray
-
- All Implemented Interfaces:
java.lang.Cloneable,java.lang.Iterable<BsonValue>,java.util.Collection<BsonValue>,java.util.List<BsonValue>
- Direct Known Subclasses:
RawBsonArray
public class BsonArray extends BsonValue implements java.util.List<BsonValue>, java.lang.Cloneable
A type-safe representation of the BSON array type.- Since:
- 3.0
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(int index, BsonValue element)booleanadd(BsonValue bsonValue)booleanaddAll(int index, java.util.Collection<? extends BsonValue> c)booleanaddAll(java.util.Collection<? extends BsonValue> c)voidclear()BsonArrayclone()booleancontains(java.lang.Object o)booleancontainsAll(java.util.Collection<?> c)booleanequals(java.lang.Object o)BsonValueget(int index)BsonTypegetBsonType()Gets the BSON type of this value.java.util.List<BsonValue>getValues()Gets the values in this array as a list ofBsonValueobjects.inthashCode()intindexOf(java.lang.Object o)booleanisEmpty()java.util.Iterator<BsonValue>iterator()intlastIndexOf(java.lang.Object o)java.util.ListIterator<BsonValue>listIterator()java.util.ListIterator<BsonValue>listIterator(int index)static BsonArrayparse(java.lang.String json)Parses a string in MongoDB Extended JSON format to aBsonArrayBsonValueremove(int index)booleanremove(java.lang.Object o)booleanremoveAll(java.util.Collection<?> c)booleanretainAll(java.util.Collection<?> c)BsonValueset(int index, BsonValue element)intsize()java.util.List<BsonValue>subList(int fromIndex, int toIndex)java.lang.Object[]toArray()<T> T[]toArray(T[] a)java.lang.StringtoString()-
Methods inherited from class org.bson.BsonValue
asArray, asBinary, asBoolean, asDateTime, asDBPointer, asDecimal128, asDocument, asDouble, asInt32, asInt64, asJavaScript, asJavaScriptWithScope, asNumber, asObjectId, asRegularExpression, asString, asSymbol, asTimestamp, isArray, isBinary, isBoolean, isDateTime, isDBPointer, isDecimal128, isDocument, isDouble, isInt32, isInt64, isJavaScript, isJavaScriptWithScope, isNull, isNumber, isObjectId, isRegularExpression, isString, isSymbol, isTimestamp
-
-
-
-
Constructor Detail
-
BsonArray
public BsonArray(java.util.List<? extends BsonValue> values)
Construct an instance with the given list of values.- Parameters:
values- the list of values, none of whose members may be null.
-
BsonArray
public BsonArray()
Construct an empty BsonArray
-
-
Method Detail
-
parse
public static BsonArray parse(java.lang.String json)
Parses a string in MongoDB Extended JSON format to aBsonArray- Parameters:
json- the JSON string- Returns:
- a corresponding
BsonArrayobject - Since:
- 3.4
- See Also:
JsonReader
-
getValues
public java.util.List<BsonValue> getValues()
Gets the values in this array as a list ofBsonValueobjects.- Returns:
- the values in this array.
-
getBsonType
public BsonType getBsonType()
Description copied from class:BsonValueGets the BSON type of this value.- Specified by:
getBsonTypein classBsonValue- Returns:
- the BSON type, which may not be null (but may be BSONType.NULL)
-
size
public int size()
-
isEmpty
public boolean isEmpty()
-
contains
public boolean contains(java.lang.Object o)
-
iterator
public java.util.Iterator<BsonValue> iterator()
-
toArray
public java.lang.Object[] toArray()
-
toArray
public <T> T[] toArray(T[] a)
-
add
public boolean add(BsonValue bsonValue)
-
remove
public boolean remove(java.lang.Object o)
-
containsAll
public boolean containsAll(java.util.Collection<?> c)
-
addAll
public boolean addAll(java.util.Collection<? extends BsonValue> c)
-
addAll
public boolean addAll(int index, java.util.Collection<? extends BsonValue> c)- Specified by:
addAllin interfacejava.util.List<BsonValue>
-
removeAll
public boolean removeAll(java.util.Collection<?> c)
-
retainAll
public boolean retainAll(java.util.Collection<?> c)
-
clear
public void clear()
-
set
public BsonValue set(int index, BsonValue element)
- Specified by:
setin interfacejava.util.List<BsonValue>
-
add
public void add(int index, BsonValue element)- Specified by:
addin interfacejava.util.List<BsonValue>
-
remove
public BsonValue remove(int index)
- Specified by:
removein interfacejava.util.List<BsonValue>
-
indexOf
public int indexOf(java.lang.Object o)
- Specified by:
indexOfin interfacejava.util.List<BsonValue>
-
lastIndexOf
public int lastIndexOf(java.lang.Object o)
- Specified by:
lastIndexOfin interfacejava.util.List<BsonValue>
-
listIterator
public java.util.ListIterator<BsonValue> listIterator()
- Specified by:
listIteratorin interfacejava.util.List<BsonValue>
-
listIterator
public java.util.ListIterator<BsonValue> listIterator(int index)
- Specified by:
listIteratorin interfacejava.util.List<BsonValue>
-
subList
public java.util.List<BsonValue> subList(int fromIndex, int toIndex)
- Specified by:
subListin interfacejava.util.List<BsonValue>
-
equals
public boolean equals(java.lang.Object o)
-
hashCode
public int hashCode()
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
clone
public BsonArray clone()
-
-