Package org.bson

Class 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
    • 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 a BsonArray
        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 of BsonValue 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 class BsonValue
        Returns:
        the BSON type, which may not be null (but may be BSONType.NULL)
      • size

        public int size()
        Specified by:
        size in interface java.util.Collection<BsonValue>
        Specified by:
        size in interface java.util.List<BsonValue>
      • isEmpty

        public boolean isEmpty()
        Specified by:
        isEmpty in interface java.util.Collection<BsonValue>
        Specified by:
        isEmpty in interface java.util.List<BsonValue>
      • contains

        public boolean contains​(java.lang.Object o)
        Specified by:
        contains in interface java.util.Collection<BsonValue>
        Specified by:
        contains in interface java.util.List<BsonValue>
      • iterator

        public java.util.Iterator<BsonValue> iterator()
        Specified by:
        iterator in interface java.util.Collection<BsonValue>
        Specified by:
        iterator in interface java.lang.Iterable<BsonValue>
        Specified by:
        iterator in interface java.util.List<BsonValue>
      • toArray

        public java.lang.Object[] toArray()
        Specified by:
        toArray in interface java.util.Collection<BsonValue>
        Specified by:
        toArray in interface java.util.List<BsonValue>
      • toArray

        public <T> T[] toArray​(T[] a)
        Specified by:
        toArray in interface java.util.Collection<BsonValue>
        Specified by:
        toArray in interface java.util.List<BsonValue>
      • add

        public boolean add​(BsonValue bsonValue)
        Specified by:
        add in interface java.util.Collection<BsonValue>
        Specified by:
        add in interface java.util.List<BsonValue>
      • remove

        public boolean remove​(java.lang.Object o)
        Specified by:
        remove in interface java.util.Collection<BsonValue>
        Specified by:
        remove in interface java.util.List<BsonValue>
      • containsAll

        public boolean containsAll​(java.util.Collection<?> c)
        Specified by:
        containsAll in interface java.util.Collection<BsonValue>
        Specified by:
        containsAll in interface java.util.List<BsonValue>
      • addAll

        public boolean addAll​(java.util.Collection<? extends BsonValue> c)
        Specified by:
        addAll in interface java.util.Collection<BsonValue>
        Specified by:
        addAll in interface java.util.List<BsonValue>
      • addAll

        public boolean addAll​(int index,
                              java.util.Collection<? extends BsonValue> c)
        Specified by:
        addAll in interface java.util.List<BsonValue>
      • removeAll

        public boolean removeAll​(java.util.Collection<?> c)
        Specified by:
        removeAll in interface java.util.Collection<BsonValue>
        Specified by:
        removeAll in interface java.util.List<BsonValue>
      • retainAll

        public boolean retainAll​(java.util.Collection<?> c)
        Specified by:
        retainAll in interface java.util.Collection<BsonValue>
        Specified by:
        retainAll in interface java.util.List<BsonValue>
      • clear

        public void clear()
        Specified by:
        clear in interface java.util.Collection<BsonValue>
        Specified by:
        clear in interface java.util.List<BsonValue>
      • get

        public BsonValue get​(int index)
        Specified by:
        get in interface java.util.List<BsonValue>
      • add

        public void add​(int index,
                        BsonValue element)
        Specified by:
        add in interface java.util.List<BsonValue>
      • remove

        public BsonValue remove​(int index)
        Specified by:
        remove in interface java.util.List<BsonValue>
      • indexOf

        public int indexOf​(java.lang.Object o)
        Specified by:
        indexOf in interface java.util.List<BsonValue>
      • lastIndexOf

        public int lastIndexOf​(java.lang.Object o)
        Specified by:
        lastIndexOf in interface java.util.List<BsonValue>
      • listIterator

        public java.util.ListIterator<BsonValue> listIterator()
        Specified by:
        listIterator in interface java.util.List<BsonValue>
      • listIterator

        public java.util.ListIterator<BsonValue> listIterator​(int index)
        Specified by:
        listIterator in interface java.util.List<BsonValue>
      • subList

        public java.util.List<BsonValue> subList​(int fromIndex,
                                                 int toIndex)
        Specified by:
        subList in interface java.util.List<BsonValue>
      • equals

        public boolean equals​(java.lang.Object o)
        Specified by:
        equals in interface java.util.Collection<BsonValue>
        Specified by:
        equals in interface java.util.List<BsonValue>
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Specified by:
        hashCode in interface java.util.Collection<BsonValue>
        Specified by:
        hashCode in interface java.util.List<BsonValue>
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object