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 void
add(int index, BsonValue element)
boolean
add(BsonValue bsonValue)
boolean
addAll(int index, java.util.Collection<? extends BsonValue> c)
boolean
addAll(java.util.Collection<? extends BsonValue> c)
void
clear()
BsonArray
clone()
boolean
contains(java.lang.Object o)
boolean
containsAll(java.util.Collection<?> c)
boolean
equals(java.lang.Object o)
BsonValue
get(int index)
BsonType
getBsonType()
Gets the BSON type of this value.java.util.List<BsonValue>
getValues()
Gets the values in this array as a list ofBsonValue
objects.int
hashCode()
int
indexOf(java.lang.Object o)
boolean
isEmpty()
java.util.Iterator<BsonValue>
iterator()
int
lastIndexOf(java.lang.Object o)
java.util.ListIterator<BsonValue>
listIterator()
java.util.ListIterator<BsonValue>
listIterator(int index)
static BsonArray
parse(java.lang.String json)
Parses a string in MongoDB Extended JSON format to aBsonArray
BsonValue
remove(int index)
boolean
remove(java.lang.Object o)
boolean
removeAll(java.util.Collection<?> c)
boolean
retainAll(java.util.Collection<?> c)
BsonValue
set(int index, BsonValue element)
int
size()
java.util.List<BsonValue>
subList(int fromIndex, int toIndex)
java.lang.Object[]
toArray()
<T> T[]
toArray(T[] a)
java.lang.String
toString()
-
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
BsonArray
object - Since:
- 3.4
- See Also:
JsonReader
-
getValues
public java.util.List<BsonValue> getValues()
Gets the values in this array as a list ofBsonValue
objects.- Returns:
- the values in this array.
-
getBsonType
public BsonType getBsonType()
Description copied from class:BsonValue
Gets the BSON type of this value.- Specified by:
getBsonType
in 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:
addAll
in 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:
set
in interfacejava.util.List<BsonValue>
-
add
public void add(int index, BsonValue element)
- Specified by:
add
in interfacejava.util.List<BsonValue>
-
remove
public BsonValue remove(int index)
- Specified by:
remove
in interfacejava.util.List<BsonValue>
-
indexOf
public int indexOf(java.lang.Object o)
- Specified by:
indexOf
in interfacejava.util.List<BsonValue>
-
lastIndexOf
public int lastIndexOf(java.lang.Object o)
- Specified by:
lastIndexOf
in interfacejava.util.List<BsonValue>
-
listIterator
public java.util.ListIterator<BsonValue> listIterator()
- Specified by:
listIterator
in interfacejava.util.List<BsonValue>
-
listIterator
public java.util.ListIterator<BsonValue> listIterator(int index)
- Specified by:
listIterator
in interfacejava.util.List<BsonValue>
-
subList
public java.util.List<BsonValue> subList(int fromIndex, int toIndex)
- Specified by:
subList
in interfacejava.util.List<BsonValue>
-
equals
public boolean equals(java.lang.Object o)
-
hashCode
public int hashCode()
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
clone
public BsonArray clone()
-
-