ModeShape Distribution 3.0.0.Beta4

org.infinispan.schematic.internal.document
Class ArrayEditor

java.lang.Object
  extended by org.infinispan.schematic.internal.document.ArrayEditor
All Implemented Interfaces:
Serializable, Iterable<Object>, Collection<Object>, List<Object>, Array, Document, EditableArray, EditableDocument
Direct Known Subclasses:
ObservableArrayEditor

public class ArrayEditor
extends Object
implements EditableArray

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.infinispan.schematic.document.Array
Array.Entry
 
Nested classes/interfaces inherited from interface org.infinispan.schematic.document.Document
Document.Field, Document.ValueTransformer
 
Constructor Summary
ArrayEditor(MutableArray array, DocumentValueFactory factory)
           
 
Method Summary
 void add(int index, Object element)
           
 boolean add(Object e)
           
 boolean addAll(Collection<? extends Object> c)
           
 boolean addAll(int index, Collection<? extends Object> c)
           
 EditableArray addArray()
          Adds to this array a new empty array.
 EditableArray addArray(Array array)
          Adds to this array the supplied array.
 EditableArray addArray(int index)
          Insert the value for the field at the given index to be a new, empty array.
 EditableArray addArray(int index, Array array)
          Insert the value for the field at the given index to be the supplied array.
 EditableArray addArrayIfAbsent(Array array)
          Adds to this array the supplied array, if and only if an equivalent value doesn't already exist in the array.
 EditableArray addBinary(byte type, byte[] data)
          Adds to this array a Binary value with the supplied type and content.
 EditableArray addBinary(int index, byte type, byte[] data)
          Insert the value for the field at the given index to be a binary value.
 EditableArray addBinaryIfAbsent(byte type, byte[] data)
          Adds to this array a Binary value with the supplied type and content, if and only if an equivalent value doesn't already exist in the array.
 EditableArray addBoolean(boolean value)
          Adds the supplied boolean value to this array.
 EditableArray addBoolean(int index, boolean value)
          Insert the value for the field at the given index to the supplied boolean value.
 EditableArray addBooleanIfAbsent(boolean value)
          Adds the supplied boolean value to this array, if and only if an equivalent value doesn't already exist in the array.
 EditableDocument addCode(int index, String code, boolean includeScope)
          Insert the value for the field at the given index to be a Code or CodeWithScope.
 EditableDocument addCode(int index, String code, Document scope)
          Insert the value for the field at the given index to be a Code or CodeWithScope.
 EditableDocument addCode(String code, boolean includeScope)
          Adds to this array a Code with the supplied JavaScript code.
 EditableDocument addCode(String code, Document scope)
          Adds to this array a CodeWithScope with the supplied JavaScript code and scope.
 EditableDocument addCodeIfAbsent(String code, Document scope)
          Adds to this array a CodeWithScope with the supplied JavaScript code and scope, if and only if an equivalent value doesn't already exist in the array.
 EditableArray addDate(Date value)
          Adds to this array the supplied date.
 EditableArray addDate(int index, Date value)
          Insert the value for the field at the given index to the supplied date value.
 EditableArray addDate(int index, String isoDate)
          Insert the value for the field at the given index to the date value parsed from the ISO-8601 date representation.
 EditableArray addDate(String isoDate)
          Adds to this array a Date with the supplied ISO-8601 string.
 EditableArray addDateIfAbsent(Date value)
          Adds to this array the supplied date, if and only if an equivalent value doesn't already exist in the array.
 EditableArray addDateIfAbsent(String isoDate)
          Adds to this array a Date with the supplied ISO-8601 string, if and only if an equivalent value doesn't already exist in the array.
 EditableDocument addDocument()
          Adds to this array a new empty document.
 EditableDocument addDocument(Document document)
          Adds to this array the supplied document.
 EditableDocument addDocument(int index)
          Insert the value for the field at the given index to be a new, empty Document.
 EditableDocument addDocument(int index, Document document)
          Insert the value for the field at the given index to be the supplied Document.
 EditableDocument addDocumentIfAbsent(Document document)
          Adds to this array the supplied document, if and only if an equivalent value doesn't already exist in the array.
 EditableArray addNull()
          Adds to this array a Null value.
 EditableArray addNull(int index)
          Insert the value for the field at the given index to be a null value.
 EditableArray addNullIfAbsent()
          Adds to this array a Null value, if and only if there is not already a null value in the array.
 EditableArray addNumber(double value)
          Adds the supplied double value to this array.
 EditableArray addNumber(float value)
          Adds the supplied float value to this array.
 EditableArray addNumber(int value)
          Adds the supplied integer value to this array.
 EditableArray addNumber(int index, double value)
          Insert the value for the field at the given index to the supplied double value.
 EditableArray addNumber(int index, float value)
          Insert the value for the field at the given index to the supplied float value.
 EditableArray addNumber(int index, int value)
          Insert the value for the field at the given index to the supplied integer value.
 EditableArray addNumber(int index, long value)
          Insert the value for the field at the given index to the supplied long value.
 EditableArray addNumber(long value)
          Adds the supplied long value to this array.
 EditableArray addNumberIfAbsent(double value)
          Adds the supplied double value to this array, if and only if an equivalent value doesn't already exist in the array.
 EditableArray addNumberIfAbsent(float value)
          Adds the supplied float value to this array, if and only if an equivalent value doesn't already exist in the array.
 EditableArray addNumberIfAbsent(int value)
          Adds the supplied integer value to this array, if and only if an equivalent value doesn't already exist in the array.
 EditableArray addNumberIfAbsent(long value)
          Adds the supplied long value to this array, if and only if an equivalent value doesn't already exist in the array.
 EditableArray addObjectId(byte[] bytes)
          Adds to this array an ObjectId with the supplied 12-byte value.
 EditableArray addObjectId(int index, byte[] bytes)
          Insert the value for the field at the given index to an ObjectId created from the supplied 12-byte binary value.
 EditableArray addObjectId(int time, int machine, int process, int inc)
          Adds to this array an ObjectId with the supplied time, machine, process, and increment.
 EditableArray addObjectId(int index, int time, int machine, int process, int inc)
          Insert the value for the field at the given index to an ObjectId created from the supplied hexadecimal binary value.
 EditableArray addObjectId(int index, String hex)
          Insert the value for the field at the given index to an ObjectId created from the supplied hexadecimal binary value.
 EditableArray addObjectId(String hex)
          Adds to this array an ObjectId with the supplied hexadecimal string.
 EditableArray addObjectIdIfAbsent(byte[] bytes)
          Adds to this array an ObjectId with the supplied 12-byte value, if and only if an equivalent value doesn't already exist in the array.
 EditableArray addObjectIdIfAbsent(int time, int machine, int process, int inc)
          Adds to this array an ObjectId with the supplied time, machine, process, and increment, if and only if an equivalent value doesn't already exist in the array.
 EditableArray addObjectIdIfAbsent(String hex)
          Adds to this array an ObjectId with the supplied hexadecimal string, if and only if an equivalent value doesn't already exist in the array.
 EditableArray addRegularExpression(int index, String pattern)
          Insert the value for the field at the given index to the supplied regular expression.
 EditableArray addRegularExpression(int index, String pattern, int flags)
          Insert the value for the field at the given index to the supplied regular expression.
 EditableArray addRegularExpression(String pattern)
          Adds to this array a regular expression with the supplied pattern string.
 EditableArray addRegularExpression(String pattern, int flags)
          Adds to this array a regular expression with the supplied pattern string and option flags.
 EditableArray addRegularExpressionIfAbsent(String pattern)
          Adds to this array a regular expression with the supplied pattern string, if and only if an equivalent value doesn't already exist in the array.
 EditableArray addRegularExpressionIfAbsent(String pattern, int flags)
          Adds to this array a regular expression with the supplied pattern string and option flags, if and only if an equivalent value doesn't already exist in the array.
 EditableArray addString(int index, String value)
          Insert the value for the field at the given index to the supplied string value.
 EditableArray addString(String value)
          Adds the supplied string value to this array.
 EditableArray addStringIfAbsent(String value)
          Adds the supplied string value to this array, if and only if an equivalent value doesn't already exist in the array.
 EditableArray addSymbol(int index, String value)
          Insert the value for the field at the given index to a Symbol created from the supplied string value.
 EditableArray addSymbol(String value)
          Adds to this array a Symbol with the supplied string.
 EditableArray addSymbolIfAbsent(String value)
          Adds to this array a Symbol with the supplied string, if and only if an equivalent value doesn't already exist in the array.
 EditableArray addTimestamp(int timeInSeconds, int increment)
          Adds to this array a Timestamp with the supplied time in seconds and increment value.
 EditableArray addTimestamp(int index, int timeInSeconds, int increment)
          Insert the value for the field at the given index to a Timestamp with the supplied time in seconds and increment.
 EditableArray addTimestampIfAbsent(int timeInSeconds, int increment)
          Adds to this array a Timestamp with the supplied time in seconds and increment value, if and only if an equivalent value doesn't already exist in the array.
 EditableArray addUuid(int index, UUID uuid)
          Insert the value for the field at the given index to be a UUID.
 EditableArray addUuid(UUID uuid)
          Adds to this array the supplied UUID.
 EditableArray addUuidIfAbsent(UUID uuid)
          Adds to this array the supplied UUID, if and only if an equivalent value doesn't already exist in the array.
 EditableArray addValue(int index, Object value)
          Insert the value for the field with the given name to the supplied value.
 EditableArray addValue(Object value)
          Add the supplied value to this array.
 EditableArray addValueIfAbsent(Object value)
          Add the supplied value to this array if and only if there is not already an equivalent value in the array.
 MutableArray asMutableArray()
          Return the array that was edited.
 void clear()
           
 ArrayEditor clone()
          Obtain a clone of this document.
 boolean contains(Object o)
           
 boolean containsAll(Collection<?> c)
           
 boolean containsAll(Document document)
          Checks if this object contains all of the fields in the supplied document.
 boolean containsField(String name)
          Checks if this object contains a field with the given name.
protected  EditableArray createEditableArray(MutableArray array, int index, DocumentValueFactory factory)
           
protected  EditableDocument createEditableDocument(MutableDocument document, int index, DocumentValueFactory factory)
           
protected  EditableArray createEditableSublist(MutableArray array, DocumentValueFactory factory)
           
protected  boolean doAddAll(Collection<? extends Object> c)
           
protected  boolean doAddAll(int index, Collection<? extends Object> c)
           
protected  void doAddValue(int index, Object value)
           
protected  int doAddValue(Object value)
           
protected  boolean doAddValueIfAbsent(Object value)
           
protected  void doClear()
           
protected  List<Array.Entry> doRemoveAll(Collection<?> c)
           
protected  Object doRemoveValue(int index)
           
protected  boolean doRemoveValue(Object value)
           
protected  List<Array.Entry> doRetainAll(Collection<?> c)
           
protected  Object doSetValue(int index, Object value)
           
protected  Object doSetValue(String name, Object value)
           
protected  EditableDocument editable(Document doc, int index)
           
protected  EditableArray editable(List<?> array, int index)
           
 Iterable<Document.Field> fields()
          Obtain an iterator over the Document.Fields in this object.
 Object get(int index)
           
 Object get(String name)
          Gets the value in this document for the given field name.
 EditableArray getArray(String name)
          Get the existing array value in this array for the given index.
 Binary getBinary(String name)
          Get the Binary value in this document for the given field name.
 Boolean getBoolean(String name)
          Get the boolean value in this document for the given field name.
 boolean getBoolean(String name, boolean defaultValue)
          Get the boolean value in this document for the given field name.
 Code getCode(String name)
          Get the Code value in this document for the given field name.
 CodeWithScope getCodeWithScope(String name)
          Get the CodeWithScope value in this document for the given field name.
 EditableDocument getDocument(String name)
          Get the existing document value in this array for the given index.
 Double getDouble(String name)
          Get the double value in this document for the given field name.
 double getDouble(String name, double defaultValue)
          Get the double value in this document for the given field name.
 Iterable<Array.Entry> getEntries()
          Get the entries in this array.
 Integer getInteger(String name)
          Get the integer value in this document for the given field name.
 int getInteger(String name, int defaultValue)
          Get the integer value in this document for the given field name.
 Long getLong(String name)
          Get the integer value in this document for the given field name.
 long getLong(String name, long defaultValue)
          Get the long value in this document for the given field name.
 MaxKey getMaxKey(String name)
          Get the MaxKey value in this document for the given field name.
 MinKey getMinKey(String name)
          Get the MinKey value in this document for the given field name.
 Number getNumber(String name)
          Get the number value in this document for the given field name.
 Number getNumber(String name, Number defaultValue)
          Get the number value in this document for the given field name.
 ObjectId getObjectId(String name)
          Get the ObjectId value in this document for the given field name.
 EditableArray getOrCreateArray(String name)
          Get the existing array value in this document for the given field name, or create a new array if there is no existing array at this field.
 EditableDocument getOrCreateDocument(String name)
          Get the existing document value in this document for the given field name, or create a new document if there is no existing document at this field.
 Pattern getPattern(String name)
          Get the Pattern value in this document for the given field name.
 String getString(String name)
          Get the string value in this document for the given field name.
 String getString(String name, String defaultValue)
          Get the string value in this document for the given field name.
 Symbol getSymbol(String name)
          Get the Symbol value in this document for the given field name.
 int getType(String name)
          Get the Bson.Type constant that describes the type of value for the given field name.
 UUID getUuid(String name)
          Get the UUID value in this document for the given field name.
 UUID getUuid(String name, UUID defaultValue)
          Get the UUID value in this document for the given field name.
protected  int indexFrom(String name)
           
 int indexOf(Object o)
           
 boolean isEmpty()
          Return whether this document contains no fields and is therefore empty.
 boolean isNull(String name)
          Determine whether this object has a pair with the given the name and the value is null.
 boolean isNullOrMissing(String name)
          Determine whether this object has a pair with the given the name and the value is null, or if this object has no field with the given name.
 Iterator<Object> iterator()
           
 Set<String> keySet()
          Returns this object's fields' names
 int lastIndexOf(Object o)
           
 ListIterator<Object> listIterator()
           
 ListIterator<Object> listIterator(int index)
           
 Object put(String name, Object value)
           
 void putAll(Document object)
          Sets on this object all name/value pairs from the supplied object.
 void putAll(Map<? extends String,? extends Object> map)
          Sets on this object all key/value pairs from the supplied map.
 Object remove(int index)
           
 boolean remove(Object o)
           
 Object remove(String name)
          Remove the field with the supplied name, and return the value.
 void removeAll()
          Remove all fields from this document.
 boolean removeAll(Collection<?> c)
           
 boolean retainAll(Collection<?> c)
           
 Object set(int index, Object element)
           
 EditableArray set(String name, Object value)
          Set the value for the field with the given name to the supplied value.
 EditableArray setArray(int index)
          Set the value for the field at the given index to be a new, empty array.
 EditableArray setArray(int index, Array array)
          Set the value for the field at the given index to be the supplied array.
 EditableArray setArray(String name)
          Set the value for the field at the given index to be a new, empty array.
 EditableArray setArray(String name, Array array)
          Set the value for the field at the given index to be the supplied array.
 EditableArray setArray(String name, Object... values)
          Set the value for the field with the given name to be the supplied array.
 EditableArray setBinary(int index, byte type, byte[] data)
          Set the value for the field at the given index to be a binary value.
 EditableArray setBinary(String name, byte type, byte[] data)
          Set the value for the field at the given index to be a binary value.
 EditableArray setBoolean(int index, boolean value)
          Set the value for the field at the given index to the supplied boolean value.
 EditableArray setBoolean(String name, boolean value)
          Set the value for the field at the given index to the supplied boolean value.
 EditableDocument setCode(int index, String code, boolean includeScope)
          Set the value for the field at the given index to be a Code or CodeWithScope.
 EditableDocument setCode(int index, String code, Document scope)
          Set the value for the field at the given index to be a Code or CodeWithScope.
 EditableDocument setCode(String name, String code, boolean includeScope)
          Set the value for the field at the given index to be a Code or CodeWithScope.
 EditableDocument setCode(String name, String code, Document scope)
          Set the value for the field at the given index to be a Code or CodeWithScope.
 EditableArray setDate(int index, Date value)
          Set the value for the field at the given index to the supplied date value.
 EditableArray setDate(int index, String isoDate)
          Set the value for the field at the given index to the date value parsed from the ISO-8601 date representation.
 EditableArray setDate(String name, Date value)
          Set the value for the field at the given index to the supplied date value.
 EditableArray setDate(String name, String isoDate)
          Set the value for the field at the given index to the date value parsed from the ISO-8601 date representation.
 EditableDocument setDocument(int index)
          Set the value for the field at the given index to be a new, empty Document.
 EditableDocument setDocument(int index, Document document)
          Set the value for the field at the given index to be the supplied Document.
 EditableDocument setDocument(String name)
          Set the value for the field at the given index to be a new, empty Document.
 EditableDocument setDocument(String name, Document document)
          Set the value for the field at the given index to be the supplied Document.
 EditableArray setNull(int index)
          Set the value for the field at the given index to be a null value.
 EditableArray setNull(String name)
          Set the value for the field at the given index to be a null value.
 EditableArray setNumber(int index, double value)
          Set the value for the field at the given index to the supplied double value.
 EditableArray setNumber(int index, float value)
          Set the value for the field at the given index to the supplied float value.
 EditableArray setNumber(int index, int value)
          Set the value for the field at the given index to the supplied integer value.
 EditableArray setNumber(int index, long value)
          Set the value for the field at the given index to the supplied long value.
 EditableArray setNumber(String name, double value)
          Set the value for the field at the given index to the supplied double value.
 EditableArray setNumber(String name, float value)
          Set the value for the field at the given index to the supplied float value.
 EditableArray setNumber(String name, int value)
          Set the value for the field at the given index to the supplied integer value.
 EditableArray setNumber(String name, long value)
          Set the value for the field at the given index to the supplied long value.
 EditableArray setObjectId(int index, byte[] bytes)
          Set the value for the field at the given index to an ObjectId created from the supplied 12-byte binary value.
 EditableArray setObjectId(int index, int time, int machine, int process, int inc)
          Set the value for the field at the given index to an ObjectId created from the supplied hexadecimal binary value.
 EditableArray setObjectId(int index, String hex)
          Set the value for the field at the given index to an ObjectId created from the supplied hexadecimal binary value.
 EditableArray setObjectId(String name, byte[] bytes)
          Set the value for the field at the given index to an ObjectId created from the supplied 12-byte binary value.
 EditableArray setObjectId(String name, int time, int machine, int process, int inc)
          Set the value for the field at the given index to an ObjectId created from the supplied hexadecimal binary value.
 EditableArray setObjectId(String name, String hex)
          Set the value for the field at the given index to an ObjectId created from the supplied hexadecimal binary value.
 EditableArray setRegularExpression(int index, String pattern)
          Set the value for the field at the given index to the supplied regular expression.
 EditableArray setRegularExpression(int index, String pattern, int flags)
          Set the value for the field at the given index to the supplied regular expression.
 EditableArray setRegularExpression(String name, String pattern)
          Set the value for the field at the given index to the supplied regular expression.
 EditableArray setRegularExpression(String name, String pattern, int flags)
          Set the value for the field at the given index to the supplied regular expression.
 EditableArray setString(int index, String value)
          Set the value for the field at the given index to the supplied string value.
 EditableArray setString(String name, String value)
          Set the value for the field at the given index to the supplied string value.
 EditableArray setSymbol(int index, String value)
          Set the value for the field at the given index to a Symbol created from the supplied string value.
 EditableArray setSymbol(String name, String value)
          Set the value for the field at the given index to a Symbol created from the supplied string value.
 EditableArray setTimestamp(int index, int timeInSeconds, int increment)
          Set the value for the field at the given index to a Timestamp with the supplied time in seconds and increment.
 EditableArray setTimestamp(String name, int timeInSeconds, int increment)
          Set the value for the field at the given index to a Timestamp with the supplied time in seconds and increment.
 EditableArray setUuid(int index, UUID uuid)
          Set the value for the field at the given index to be a UUID.
 EditableArray setUuid(String name, UUID uuid)
          Set the value for the field at the given index to be a UUID.
 EditableArray setValue(int index, Object value)
          Set the value for the field with the given name to the supplied value.
protected  EditableArray setValue(String name, Object value)
           
 int size()
          Return the number of name-value pairs in this object.
 List<Object> subList(int fromIndex, int toIndex)
           
 Object[] toArray()
           
<T> T[]
toArray(T[] a)
           
 Map<String,? extends Object> toMap()
          Returns a map representing this BSONObject.
 String toString()
           
 Array unwrap()
          Unwrap this editor to obtain the potentially wrapped document.
static Array unwrap(Array array)
           
static Document unwrap(Document document)
           
static Object unwrap(Object value)
           
 ArrayEditor with(Document.ValueTransformer transformer)
          Obtain a clone of this document, but with the field values transformed using the supplied Document.ValueTransformer.
 ArrayEditor with(Map<String,Object> changedFields)
          Obtain a clone of this document, but with the supplied fields replaced.
 Document withVariablesReplaced(Properties properties)
          Obtain a clone of this document, but with all variables in string field values replaced with the referenced values from the supplied properties.
 Document withVariablesReplacedWithSystemProperties()
          Obtain a clone of this document, but with all variables in string field values replaced with the referenced values from the System properties.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
equals, hashCode
 

Constructor Detail

ArrayEditor

public ArrayEditor(MutableArray array,
                   DocumentValueFactory factory)
Method Detail

clone

public ArrayEditor clone()
Description copied from interface: Document
Obtain a clone of this document.

Specified by:
clone in interface Array
Specified by:
clone in interface Document
Overrides:
clone in class Object
Returns:
the clone of this document; never null

with

public ArrayEditor with(Map<String,Object> changedFields)
Description copied from interface: Document
Obtain a clone of this document, but with the supplied fields replaced.

Specified by:
with in interface Document
Parameters:
changedFields - the fields that should be changed; may be null
Returns:
the clone of this document with the change fields, or this document if there are no changes

with

public ArrayEditor with(Document.ValueTransformer transformer)
Description copied from interface: Document
Obtain a clone of this document, but with the field values transformed using the supplied Document.ValueTransformer.

Specified by:
with in interface Document
Parameters:
transformer - the transformer that should be used to transform each field value; may not be null
Returns:
the clone of this document with transformed fields, or this document if the transformer changed none of the values

withVariablesReplaced

public Document withVariablesReplaced(Properties properties)
Description copied from interface: Document
Obtain a clone of this document, but with all variables in string field values replaced with the referenced values from the supplied properties.

Variables may appear anywhere within a string value, and multiple variables can be used within the same value. Variables take the form:

    variable := '${' variableNames [ ':' defaultValue ] '}'
    
    variableNames := variableName [ ',' variableNames ]
    
    variableName := /* any characters except ',' and ':' and '}'
    
    defaultValue := /* any characters except
 
Note that variableName is the name used to look up the Properties property.

Notice that the syntax supports multiple variables. The logic will process the variables from let to right, until an existing System property is found. And at that point, it will stop and will not attempt to find values for the other variables.

Specified by:
withVariablesReplaced in interface Document
Parameters:
properties - the properties keyed by variable name
Returns:
the clone of this document with variables in fields string values replaced with values from the properties object, or this document if no variables were found
See Also:
Document.withVariablesReplacedWithSystemProperties(), Document.with(ValueTransformer), SchemaLibrary.convertValues(Document, String)

withVariablesReplacedWithSystemProperties

public Document withVariablesReplacedWithSystemProperties()
Description copied from interface: Document
Obtain a clone of this document, but with all variables in string field values replaced with the referenced values from the System properties.

Variables may appear anywhere within a string value, and multiple variables can be used within the same value. Variables take the form:

    variable := '${' variableNames [ ':' defaultValue ] '}'
    
    variableNames := variableName [ ',' variableNames ]
    
    variableName := /* any characters except ',' and ':' and '}'
    
    defaultValue := /* any characters except
 
Note that variableName is the name used to look up a System property via System.getProperty(String).

Notice that the syntax supports multiple variables. The logic will process the variables from let to right, until an existing System property is found. And at that point, it will stop and will not attempt to find values for the other variables.

Because only string values can contain variables, the resulting values are left as strings. This may not be valid according to the document's JSON Schema, so see SchemaLibrary.convertValues(Document, String) to convert the string values after variable substitution into the expected non-string types.

Specified by:
withVariablesReplacedWithSystemProperties in interface Document
Returns:
the clone of this document with variables in fields string values replaced with values from the System properties, or this document if no variables were found
See Also:
Document.withVariablesReplaced(Properties), Document.with(ValueTransformer), SchemaLibrary.convertValues(Document, String)

unwrap

public Array unwrap()
Description copied from interface: EditableDocument
Unwrap this editor to obtain the potentially wrapped document.

Specified by:
unwrap in interface EditableDocument
Returns:
the wrapped document, or this object; never null

asMutableArray

public MutableArray asMutableArray()
Return the array that was edited.

Returns:
the edited array; never null

get

public Object get(String name)
Description copied from interface: Document
Gets the value in this document for the given field name.

Specified by:
get in interface Document
Parameters:
name - The name of the pair
Returns:
The field value, if found, or null otherwise

getBoolean

public Boolean getBoolean(String name)
Description copied from interface: Document
Get the boolean value in this document for the given field name.

Specified by:
getBoolean in interface Document
Parameters:
name - The name of the pair
Returns:
The boolean field value, if found, or null if there is no such pair or if the value is not a boolean

getBoolean

public boolean getBoolean(String name,
                          boolean defaultValue)
Description copied from interface: Document
Get the boolean value in this document for the given field name.

Specified by:
getBoolean in interface Document
Parameters:
name - The name of the pair
defaultValue - the default value to return if there is no such pair or if the value is not a boolean
Returns:
The boolean field value if found, or defaultValue if there is no such pair or if the value is not a boolean

put

public Object put(String name,
                  Object value)

putAll

public void putAll(Document object)
Description copied from interface: EditableDocument
Sets on this object all name/value pairs from the supplied object. If the supplied object is null, this method does nothing.

Specified by:
putAll in interface EditableDocument
Parameters:
object - the object containing the name/value pairs to be set on this object

putAll

public void putAll(Map<? extends String,? extends Object> map)
Description copied from interface: EditableDocument
Sets on this object all key/value pairs from the supplied map. If the supplied map is null, this method does nothing.

Specified by:
putAll in interface EditableDocument
Parameters:
map - the map containing the name/value pairs to be set on this object

remove

public Object remove(String name)
Description copied from interface: EditableDocument
Remove the field with the supplied name, and return the value.

Specified by:
remove in interface EditableDocument
Parameters:
name - The name of the field
Returns:
the value that was removed, or null if there was no such value

getInteger

public Integer getInteger(String name)
Description copied from interface: Document
Get the integer value in this document for the given field name.

Specified by:
getInteger in interface Document
Parameters:
name - The name of the pair
Returns:
The integer field value, if found, or null if there is no such pair or if the value is not an integer

getInteger

public int getInteger(String name,
                      int defaultValue)
Description copied from interface: Document
Get the integer value in this document for the given field name.

Specified by:
getInteger in interface Document
Parameters:
name - The name of the pair
defaultValue - the default value to return if there is no such pair or if the value is not a integer
Returns:
The integer field value if found, or defaultValue if there is no such pair or if the value is not a integer

getLong

public Long getLong(String name)
Description copied from interface: Document
Get the integer value in this document for the given field name.

Specified by:
getLong in interface Document
Parameters:
name - The name of the pair
Returns:
The long field value, if found, or null if there is no such pair or if the value is not a long value

getLong

public long getLong(String name,
                    long defaultValue)
Description copied from interface: Document
Get the long value in this document for the given field name.

Specified by:
getLong in interface Document
Parameters:
name - The name of the pair
defaultValue - the default value to return if there is no such pair or if the value is not a long value
Returns:
The long field value if found, or defaultValue if there is no such pair or if the value is not a long value

getDouble

public Double getDouble(String name)
Description copied from interface: Document
Get the double value in this document for the given field name.

Specified by:
getDouble in interface Document
Parameters:
name - The name of the pair
Returns:
The double field value, if found, or null if there is no such pair or if the value is not a double

getDouble

public double getDouble(String name,
                        double defaultValue)
Description copied from interface: Document
Get the double value in this document for the given field name.

Specified by:
getDouble in interface Document
Parameters:
name - The name of the pair
defaultValue - the default value to return if there is no such pair or if the value is not a double
Returns:
The double field value if found, or defaultValue if there is no such pair or if the value is not a double

getNumber

public Number getNumber(String name)
Description copied from interface: Document
Get the number value in this document for the given field name.

Specified by:
getNumber in interface Document
Parameters:
name - The name of the pair
Returns:
The double field value, if found, or null if there is no such pair or if the value is not a number

getNumber

public Number getNumber(String name,
                        Number defaultValue)
Description copied from interface: Document
Get the number value in this document for the given field name.

Specified by:
getNumber in interface Document
Parameters:
name - The name of the pair
defaultValue - the default value to return if there is no such pair or if the value is not a number
Returns:
The number field value if found, or defaultValue if there is no such pair or if the value is not a number

getString

public String getString(String name)
Description copied from interface: Document
Get the string value in this document for the given field name. This method will return the string even if the actual value is a Symbol.

Specified by:
getString in interface Document
Parameters:
name - The name of the pair
Returns:
The string field value, if found, or null if there is no such pair or if the value is not a string

getString

public String getString(String name,
                        String defaultValue)
Description copied from interface: Document
Get the string value in this document for the given field name. This method will return the string even if the actual value is a Symbol.

Specified by:
getString in interface Document
Parameters:
name - The name of the pair
defaultValue - the default value to return if there is no such pair or if the value is not a string
Returns:
The string field value if found, or defaultValue if there is no such pair or if the value is not a string

getArray

public EditableArray getArray(String name)
Description copied from interface: EditableArray
Get the existing array value in this array for the given index.

Specified by:
getArray in interface Document
Specified by:
getArray in interface EditableArray
Specified by:
getArray in interface EditableDocument
Parameters:
name - The name of the field, which is the string representation of the index in the array
Returns:
The editable array field value, if found, or null if there is no such pair or if the value is not an array

getOrCreateArray

public EditableArray getOrCreateArray(String name)
Description copied from interface: EditableDocument
Get the existing array value in this document for the given field name, or create a new array if there is no existing array at this field.

Specified by:
getOrCreateArray in interface EditableDocument
Parameters:
name - The name of the pair
Returns:
The editable array field value; never null

getDocument

public EditableDocument getDocument(String name)
Description copied from interface: EditableArray
Get the existing document value in this array for the given index.

Specified by:
getDocument in interface Document
Specified by:
getDocument in interface EditableArray
Specified by:
getDocument in interface EditableDocument
Parameters:
name - The name of the field, which is the string representation of the index in the array
Returns:
The editable document field value, if found, or null if there is no such pair or if the value is not a document

getOrCreateDocument

public EditableDocument getOrCreateDocument(String name)
Description copied from interface: EditableDocument
Get the existing document value in this document for the given field name, or create a new document if there is no existing document at this field.

Specified by:
getOrCreateDocument in interface EditableDocument
Parameters:
name - The name of the pair
Returns:
The editable document field value; never null

isNull

public boolean isNull(String name)
Description copied from interface: Document
Determine whether this object has a pair with the given the name and the value is null. This is equivalent to calling:
 this.get(name) instanceof Null;
 

Specified by:
isNull in interface Document
Parameters:
name - The name of the pair
Returns:
true if the field has been set to a Null value, or false otherwise
See Also:
Document.isNullOrMissing(String)

isNullOrMissing

public boolean isNullOrMissing(String name)
Description copied from interface: Document
Determine whether this object has a pair with the given the name and the value is null, or if this object has no field with the given name. This is equivalent to calling:
 Null.matches(this.get(name));
 

Specified by:
isNullOrMissing in interface Document
Parameters:
name - The name of the pair
Returns:
true if the field value for the name is null or if there is no such field.
See Also:
Document.isNull(String)

getMaxKey

public MaxKey getMaxKey(String name)
Description copied from interface: Document
Get the MaxKey value in this document for the given field name.

Specified by:
getMaxKey in interface Document
Parameters:
name - The name of the pair
Returns:
The MaxKey field value, if found, or null if there is no such pair or if the value is not a MaxKey

getMinKey

public MinKey getMinKey(String name)
Description copied from interface: Document
Get the MinKey value in this document for the given field name.

Specified by:
getMinKey in interface Document
Parameters:
name - The name of the pair
Returns:
The MinKey field value, if found, or null if there is no such pair or if the value is not a MinKey

getCode

public Code getCode(String name)
Description copied from interface: Document
Get the Code value in this document for the given field name.

Specified by:
getCode in interface Document
Parameters:
name - The name of the pair
Returns:
The Code field value, if found, or null if there is no such pair or if the value is not a Code

getCodeWithScope

public CodeWithScope getCodeWithScope(String name)
Description copied from interface: Document
Get the CodeWithScope value in this document for the given field name.

Specified by:
getCodeWithScope in interface Document
Parameters:
name - The name of the pair
Returns:
The CodeWithScope field value, if found, or null if there is no such pair or if the value is not a CodeWithScope

getObjectId

public ObjectId getObjectId(String name)
Description copied from interface: Document
Get the ObjectId value in this document for the given field name.

Specified by:
getObjectId in interface Document
Parameters:
name - The name of the pair
Returns:
The ObjectId field value, if found, or null if there is no such pair or if the value is not a ObjectId

getBinary

public Binary getBinary(String name)
Description copied from interface: Document
Get the Binary value in this document for the given field name.

Specified by:
getBinary in interface Document
Parameters:
name - The name of the pair
Returns:
The Binary field value, if found, or null if there is no such pair or if the value is not a Binary

getSymbol

public Symbol getSymbol(String name)
Description copied from interface: Document
Get the Symbol value in this document for the given field name.

Specified by:
getSymbol in interface Document
Parameters:
name - The name of the pair
Returns:
The Symbol field value, if found, or null if there is no such pair or if the value is not a Symbol

getPattern

public Pattern getPattern(String name)
Description copied from interface: Document
Get the Pattern value in this document for the given field name.

Specified by:
getPattern in interface Document
Parameters:
name - The name of the pair
Returns:
The Pattern field value, if found, or null if there is no such pair or if the value is not a Pattern

getUuid

public UUID getUuid(String name)
Description copied from interface: Document
Get the UUID value in this document for the given field name.

Specified by:
getUuid in interface Document
Parameters:
name - The name of the pair
Returns:
The UUID field value, if found, or null if there is no such pair or if the value is not a UUID

getUuid

public UUID getUuid(String name,
                    UUID defaultValue)
Description copied from interface: Document
Get the UUID value in this document for the given field name.

Specified by:
getUuid in interface Document
Parameters:
name - The name of the pair
defaultValue - the default value to return if there is no such pair or if the value is not a string
Returns:
The UUID field value if found, or defaultValue if there is no such pair or if the value is not a UUID (or a string that is convertable from a UUID)

getType

public int getType(String name)
Description copied from interface: Document
Get the Bson.Type constant that describes the type of value for the given field name.

Specified by:
getType in interface Document
Parameters:
name - The name of the pair
Returns:
the Bson.Type constant describing the value, or -1 if there is no field with the supplied name

toMap

public Map<String,? extends Object> toMap()
Description copied from interface: Document
Returns a map representing this BSONObject.

Specified by:
toMap in interface Document
Returns:
the map

fields

public Iterable<Document.Field> fields()
Description copied from interface: Document
Obtain an iterator over the Document.Fields in this object.

Specified by:
fields in interface Document
Returns:
a field iterator; never null

containsField

public boolean containsField(String name)
Description copied from interface: Document
Checks if this object contains a field with the given name.

Specified by:
containsField in interface Document
Parameters:
name - The name of the pair for which to check
Returns:
true if this document contains a field with the supplied name, or false otherwise

containsAll

public boolean containsAll(Document document)
Description copied from interface: Document
Checks if this object contains all of the fields in the supplied document.

Specified by:
containsAll in interface Document
Parameters:
document - The document with the fields that should be in this document
Returns:
true if this document contains all of the fields in the supplied document, or false otherwise

keySet

public Set<String> keySet()
Description copied from interface: Document
Returns this object's fields' names

Specified by:
keySet in interface Document
Returns:
The names of the fields in this object

size

public int size()
Description copied from interface: Document
Return the number of name-value pairs in this object.

Specified by:
size in interface Collection<Object>
Specified by:
size in interface List<Object>
Specified by:
size in interface Document
Returns:
the number of name-value pairs; never negative

removeAll

public void removeAll()
Description copied from interface: EditableDocument
Remove all fields from this document.

Specified by:
removeAll in interface EditableDocument

setBoolean

public EditableArray setBoolean(String name,
                                boolean value)
Description copied from interface: EditableArray
Set the value for the field at the given index to the supplied boolean value.

Specified by:
setBoolean in interface EditableArray
Specified by:
setBoolean in interface EditableDocument
Parameters:
name - The name of the field, which is the string representation of the index in the array
value - the new value for the field
Returns:
This array, to allow for chaining methods

setNumber

public EditableArray setNumber(String name,
                               int value)
Description copied from interface: EditableArray
Set the value for the field at the given index to the supplied integer value.

Specified by:
setNumber in interface EditableArray
Specified by:
setNumber in interface EditableDocument
Parameters:
name - The name of the field, which is the string representation of the index in the array
value - the new value for the field
Returns:
This document, to allow for chaining methods

setNumber

public EditableArray setNumber(String name,
                               long value)
Description copied from interface: EditableArray
Set the value for the field at the given index to the supplied long value.

Specified by:
setNumber in interface EditableArray
Specified by:
setNumber in interface EditableDocument
Parameters:
name - The name of the field, which is the string representation of the index in the array
value - the new value for the field
Returns:
This document, to allow for chaining methods

setNumber

public EditableArray setNumber(String name,
                               float value)
Description copied from interface: EditableArray
Set the value for the field at the given index to the supplied float value.

Specified by:
setNumber in interface EditableArray
Specified by:
setNumber in interface EditableDocument
Parameters:
name - The name of the field, which is the string representation of the index in the array
value - the new value for the field
Returns:
This document, to allow for chaining methods

setNumber

public EditableArray setNumber(String name,
                               double value)
Description copied from interface: EditableArray
Set the value for the field at the given index to the supplied double value.

Specified by:
setNumber in interface EditableArray
Specified by:
setNumber in interface EditableDocument
Parameters:
name - The name of the field, which is the string representation of the index in the array
value - the new value for the field
Returns:
This document, to allow for chaining methods

setString

public EditableArray setString(String name,
                               String value)
Description copied from interface: EditableArray
Set the value for the field at the given index to the supplied string value.

Specified by:
setString in interface EditableArray
Specified by:
setString in interface EditableDocument
Parameters:
name - The name of the field, which is the string representation of the index in the array
value - the new value for the field
Returns:
This document, to allow for chaining methods

setSymbol

public EditableArray setSymbol(String name,
                               String value)
Description copied from interface: EditableArray
Set the value for the field at the given index to a Symbol created from the supplied string value. Symbols are defined in the BSON specification as being similar to a string but which exists for those languages that have a specific symbol type. Symbols are serialized to JSON as a normal string.

Specified by:
setSymbol in interface EditableArray
Specified by:
setSymbol in interface EditableDocument
Parameters:
name - The name of the field, which is the string representation of the index in the array
value - the new value for the field
Returns:
This document, to allow for chaining methods
See Also:
EditableArray.setString(String, String)

setDocument

public EditableDocument setDocument(String name)
Description copied from interface: EditableArray
Set the value for the field at the given index to be a new, empty Document.

Specified by:
setDocument in interface EditableArray
Specified by:
setDocument in interface EditableDocument
Parameters:
name - The name of the field, which is the string representation of the index in the array
Returns:
The editable document that was just created; never null

setDocument

public EditableDocument setDocument(String name,
                                    Document document)
Description copied from interface: EditableArray
Set the value for the field at the given index to be the supplied Document.

Specified by:
setDocument in interface EditableArray
Specified by:
setDocument in interface EditableDocument
Parameters:
name - The name of the field, which is the string representation of the index in the array
document - the document
Returns:
The editable document that was just set as the value for the named field; never null and may or may not be the same instance as the supplied document.

setArray

public EditableArray setArray(String name)
Description copied from interface: EditableArray
Set the value for the field at the given index to be a new, empty array.

Specified by:
setArray in interface EditableArray
Specified by:
setArray in interface EditableDocument
Parameters:
name - The name of the field, which is the string representation of the index in the array
Returns:
The editable array that was just created; never null

setArray

public EditableArray setArray(String name,
                              Array array)
Description copied from interface: EditableArray
Set the value for the field at the given index to be the supplied array.

Specified by:
setArray in interface EditableArray
Specified by:
setArray in interface EditableDocument
Parameters:
name - The name of the field, which is the string representation of the index in the array
array - the array
Returns:
The editable array that was just set as the value for the named field; never null and may or may not be the same instance as the supplied array.

setArray

public EditableArray setArray(String name,
                              Object... values)
Description copied from interface: EditableDocument
Set the value for the field with the given name to be the supplied array.

Specified by:
setArray in interface EditableDocument
Parameters:
name - The name of the field
values - the (valid) values for the array
Returns:
The editable array that was just set as the value for the named field; never null and may or may not be the same instance as the supplied array.

setDate

public EditableArray setDate(String name,
                             Date value)
Description copied from interface: EditableArray
Set the value for the field at the given index to the supplied date value.

Specified by:
setDate in interface EditableArray
Specified by:
setDate in interface EditableDocument
Parameters:
name - The name of the field, which is the string representation of the index in the array
value - the new value for the field
Returns:
This document, to allow for chaining methods

setDate

public EditableArray setDate(String name,
                             String isoDate)
                      throws ParseException
Description copied from interface: EditableArray
Set the value for the field at the given index to the date value parsed from the ISO-8601 date representation. Specifically, the date string must match one of these patterns:

Specified by:
setDate in interface EditableArray
Specified by:
setDate in interface EditableDocument
Parameters:
name - The name of the field, which is the string representation of the index in the array
isoDate - the new value for the field
Returns:
This document, to allow for chaining methods
Throws:
ParseException - if the supplied value could not be parsed into a valid date

setTimestamp

public EditableArray setTimestamp(String name,
                                  int timeInSeconds,
                                  int increment)
Description copied from interface: EditableArray
Set the value for the field at the given index to a Timestamp with the supplied time in seconds and increment. Note that Date values are recommended for most purposes, as they are better suited to most applications' representations of time instants.

Specified by:
setTimestamp in interface EditableArray
Specified by:
setTimestamp in interface EditableDocument
Parameters:
name - The name of the field, which is the string representation of the index in the array
timeInSeconds - the time in seconds for the new Timestamp
increment - the time increment for the new Timestamp
Returns:
This document, to allow for chaining methods
See Also:
EditableArray.setDate(String, Date)

setObjectId

public EditableArray setObjectId(String name,
                                 String hex)
Description copied from interface: EditableArray
Set the value for the field at the given index to an ObjectId created from the supplied hexadecimal binary value. Object IDs are defined by the BSON specification as 12-byte binary values designed to have a reasonably high probability of being unique when allocated. Since there is no explicit way to represent these in a JSON document, each ObjectId value is serialized in a JSON document as a nested document of the form:
 { "$oid" : "12bytesOfIdInBase16" }
 
When nested documents of this form are read by this library's JSON reader, nested documents of this form will be converted to an ObjectId value.

For example, an ObjectId with time value of "1310745823", machine value of "1", process value of "2", and increment value of "3" would be written as

 { "$oid" : "4e2064df0000010002000003" }
 

Specified by:
setObjectId in interface EditableArray
Specified by:
setObjectId in interface EditableDocument
Parameters:
name - The name of the field, which is the string representation of the index in the array
hex - the hexadecimal binary value for the ObjectId
Returns:
This document, to allow for chaining methods
See Also:
EditableArray.setObjectId(String, byte[]), EditableArray.setObjectId(String, int, int, int, int)

setObjectId

public EditableArray setObjectId(String name,
                                 byte[] bytes)
Description copied from interface: EditableArray
Set the value for the field at the given index to an ObjectId created from the supplied 12-byte binary value. Object IDs are defined by the BSON specification as 12-byte binary values designed to have a reasonably high probability of being unique when allocated. Since there is no explicit way to represent these in a JSON document, each ObjectId value is serialized in a JSON document as a nested document of the form:
 { "$oid" : "12bytesOfIdInBase16" }
 
When nested documents of this form are read by this library's JSON reader, nested documents of this form will be converted to an ObjectId value.

For example, an ObjectId with time value of "1310745823", machine value of "1", process value of "2", and increment value of "3" would be written as

 { "$oid" : "4e2064df0000010002000003" }
 

Specified by:
setObjectId in interface EditableArray
Specified by:
setObjectId in interface EditableDocument
Parameters:
name - The name of the field, which is the string representation of the index in the array
bytes - the 12-byte value for the ObjectId
Returns:
This document, to allow for chaining methods
See Also:
EditableArray.setObjectId(String, String), EditableArray.setObjectId(String, int, int, int, int)

setObjectId

public EditableArray setObjectId(String name,
                                 int time,
                                 int machine,
                                 int process,
                                 int inc)
Description copied from interface: EditableArray
Set the value for the field at the given index to an ObjectId created from the supplied hexadecimal binary value. Object IDs are defined by the BSON specification as 12-byte binary values designed to have a reasonably high probability of being unique when allocated. Since there is no explicit way to represent these in a JSON document, each ObjectId value is serialized in a JSON document as a nested document of the form:
 { "$oid" : "12bytesOfIdInBase16" }
 
When nested documents of this form are read by this library's JSON reader, nested documents of this form will be converted to an ObjectId value.

For example, an ObjectId with time value of "1310745823", machine value of "1", process value of "2", and increment value of "3" would be written as

 { "$oid" : "4e2064df0000010002000003" }
 

Specified by:
setObjectId in interface EditableArray
Specified by:
setObjectId in interface EditableDocument
Parameters:
name - The name of the field, which is the string representation of the index in the array
time - the Unix-style timestamp, which is a signed integer representing the number of seconds before or after January 1st 1970 (UTC)
machine - the first three bytes of the (md5) hash of the machine host name, or of the mac/network address, or the virtual machine id
process - the 2 bytes of the process id (or thread id) of the process generating the object id
inc - an ever incrementing value, or a random number if a counter can't be used in the language/runtime
Returns:
This document, to allow for chaining methods
See Also:
EditableArray.setObjectId(String, String), EditableArray.setObjectId(String, byte[])

setRegularExpression

public EditableArray setRegularExpression(String name,
                                          String pattern)
Description copied from interface: EditableArray
Set the value for the field at the given index to the supplied regular expression. Regular expression values are represented in memory using Pattern instances, and are stored natively in BSON as regular expressions. However, when serialized to JSON, regular expressions are written as nested documents of the form:
 { "$regex" : "pattern" }
 
where "pattern" is the regular expression pattern.

When nested documents of this form are read by this library's JSON reader, nested documents of this form will be converted to a regular expression value.

Specified by:
setRegularExpression in interface EditableArray
Specified by:
setRegularExpression in interface EditableDocument
Parameters:
name - The name of the field, which is the string representation of the index in the array
pattern - the regular expression pattern string
Returns:
This document, to allow for chaining methods
See Also:
EditableArray.setRegularExpression(String, String, int)

setRegularExpression

public EditableArray setRegularExpression(String name,
                                          String pattern,
                                          int flags)
Description copied from interface: EditableArray
Set the value for the field at the given index to the supplied regular expression. Regular expression values are represented in memory using Pattern instances, and are stored natively in BSON as regular expressions. However, when serialized to JSON, regular expressions are written as nested documents of the form:
 { "$regex" : "pattern", "$options" : "flags" }
 
where "pattern" is the regular expression pattern, and "flags" is a string representation of the regular expression options.

When nested documents of this form are read by this library's JSON reader, nested documents of this form will be converted to a regular expression value.

Specified by:
setRegularExpression in interface EditableArray
Specified by:
setRegularExpression in interface EditableDocument
Parameters:
name - The name of the field, which is the string representation of the index in the array
pattern - the regular expression pattern string
flags - the bitwise-anded Pattern options: Pattern.CANON_EQ, Pattern.CASE_INSENSITIVE, Pattern.CASE_INSENSITIVE, Pattern.COMMENTS, Pattern.DOTALL, Pattern.LITERAL, Pattern.MULTILINE, Pattern.UNICODE_CASE, and Pattern.UNIX_LINES
Returns:
This document, to allow for chaining methods
See Also:
EditableArray.setRegularExpression(String, String)

setNull

public EditableArray setNull(String name)
Description copied from interface: EditableArray
Set the value for the field at the given index to be a null value. Both JSON and BSON formats support null values, and Null is used for the value in the in-memory representation. The Document.isNull(String) methods can be used to determine if a field has been set to null, or Document.isNullOrMissing(String) if the field has not be set or if it has been set to null.

Specified by:
setNull in interface EditableArray
Specified by:
setNull in interface EditableDocument
Parameters:
name - The name of the field, which is the string representation of the index in the array
Returns:
This document, to allow for chaining methods
See Also:
Document.isNull(String), Document.isNullOrMissing(String)

setBinary

public EditableArray setBinary(String name,
                               byte type,
                               byte[] data)
Description copied from interface: EditableArray
Set the value for the field at the given index to be a binary value. JSON does not formally support binary values, and so such values will be encoded using a nested document of the form:
 { "$type" : typeAsInt, "$base64" : "bytesInBase64" }
 
where "typeAsInt" is the integer representation of the BSON type, and "bytesInBase64" is the Base64 encoding of the actual Binary bytes.

When nested documents of this form are read by this library's JSON reader, nested documents of this form will be converted to Binary value.

Specified by:
setBinary in interface EditableArray
Specified by:
setBinary in interface EditableDocument
Parameters:
name - The name of the field, which is the string representation of the index in the array
type - one of the BSON type constants denoting the type of the Binary value
data - the bytes for the Binary value
Returns:
This document, to allow for chaining methods

setUuid

public EditableArray setUuid(String name,
                             UUID uuid)
Description copied from interface: EditableArray
Set the value for the field at the given index to be a UUID. JSON does not formally support binary values, and so such values will be encoded using a nested document of the form:
 { "$uuid" : "string-form-of-uuid" }
 
where "string-form-of-uuid" is the UUID's string representation

When nested documents of this form are read by this library's JSON reader, nested documents of this form will be converted to UUID value.

Specified by:
setUuid in interface EditableArray
Specified by:
setUuid in interface EditableDocument
Parameters:
name - The name of the field, which is the string representation of the index in the array
uuid - the UUID value
Returns:
This document, to allow for chaining methods

setCode

public EditableDocument setCode(String name,
                                String code,
                                boolean includeScope)
Description copied from interface: EditableArray
Set the value for the field at the given index to be a Code or CodeWithScope. JSON does not formally support such values, and so when written to JSON they will be encoded using a nested document of the form:
 { "$code" : "code" }
 
or, if there is a scope document
 { "$code" : "code", "$scope" : scope document }
 
where "code" is the Code's JavaScript code and scopeDocument is the nested document representing the scope in which the JavaScript code should be evaluated.

When nested documents of this form are read by this library's JSON reader, nested documents of this form will be converted to Code or CodeWithScope value.

Note that when includeScope is true, the returned EditableArray can be used to populate the scope document.

Specified by:
setCode in interface EditableArray
Specified by:
setCode in interface EditableDocument
Parameters:
name - The name of the field, which is the string representation of the index in the array
code - the code
includeScope - true if the code should include a scope (and if this method should return an EditableArray for this scope document), or false otherwise
Returns:
if includeScope is true, then the EditableDocument for the scope; otherwise, this array to allow for chaining methods
See Also:
EditableArray.setCode(String, String, Document)

setCode

public EditableDocument setCode(String name,
                                String code,
                                Document scope)
Description copied from interface: EditableArray
Set the value for the field at the given index to be a Code or CodeWithScope. JSON does not formally support such values, and so when written to JSON they will be encoded using a nested document of the form:
 { "$code" : "code" }
 
or, if there is a scope document
 { "$code" : "code", "$scope" : scope document }
 
where "code" is the Code's JavaScript code and scopeDocument is the nested document representing the scope in which the JavaScript code should be evaluated.

When nested documents of this form are read by this library's JSON reader, nested documents of this form will be converted to Code or CodeWithScope value.

Specified by:
setCode in interface EditableArray
Specified by:
setCode in interface EditableDocument
Parameters:
name - The name of the field, which is the string representation of the index in the array
code - the code
scope - the scope in which the JavaScript code should be evaulated, or null if there is no scope
Returns:
the EditableDocument for the scope
See Also:
EditableArray.setCode(String, String, boolean)

setValue

protected EditableArray setValue(String name,
                                 Object value)

setValue

public EditableArray setValue(int index,
                              Object value)
Description copied from interface: EditableArray
Set the value for the field with the given name to the supplied value.

Specified by:
setValue in interface EditableArray
Parameters:
index - The index in the array
value - the new value
Returns:
This array, to allow for chaining methods

addValue

public EditableArray addValue(Object value)
Description copied from interface: EditableArray
Add the supplied value to this array.

Specified by:
addValue in interface EditableArray
Parameters:
value - the new value
Returns:
This array, to allow for chaining methods

addValueIfAbsent

public EditableArray addValueIfAbsent(Object value)
Description copied from interface: EditableArray
Add the supplied value to this array if and only if there is not already an equivalent value in the array.

Specified by:
addValueIfAbsent in interface EditableArray
Parameters:
value - the value
Returns:
This array, to allow for chaining methods

addValue

public EditableArray addValue(int index,
                              Object value)
Description copied from interface: EditableArray
Insert the value for the field with the given name to the supplied value.

Specified by:
addValue in interface EditableArray
Parameters:
index - The index in the array
value - the new value
Returns:
This array, to allow for chaining methods

indexFrom

protected final int indexFrom(String name)

doSetValue

protected Object doSetValue(String name,
                            Object value)

doSetValue

protected Object doSetValue(int index,
                            Object value)

doAddValue

protected int doAddValue(Object value)

doAddValue

protected void doAddValue(int index,
                          Object value)

doAddValueIfAbsent

protected boolean doAddValueIfAbsent(Object value)

doRemoveValue

protected boolean doRemoveValue(Object value)

doRemoveValue

protected Object doRemoveValue(int index)

doAddAll

protected boolean doAddAll(Collection<? extends Object> c)

doAddAll

protected boolean doAddAll(int index,
                           Collection<? extends Object> c)

doRemoveAll

protected List<Array.Entry> doRemoveAll(Collection<?> c)

doRetainAll

protected List<Array.Entry> doRetainAll(Collection<?> c)

doClear

protected void doClear()

editable

protected EditableDocument editable(Document doc,
                                    int index)

editable

protected EditableArray editable(List<?> array,
                                 int index)

createEditableDocument

protected EditableDocument createEditableDocument(MutableDocument document,
                                                  int index,
                                                  DocumentValueFactory factory)

createEditableArray

protected EditableArray createEditableArray(MutableArray array,
                                            int index,
                                            DocumentValueFactory factory)

createEditableSublist

protected EditableArray createEditableSublist(MutableArray array,
                                              DocumentValueFactory factory)

unwrap

public static Array unwrap(Array array)

unwrap

public static Document unwrap(Document document)

unwrap

public static Object unwrap(Object value)

isEmpty

public boolean isEmpty()
Description copied from interface: Document
Return whether this document contains no fields and is therefore empty.

Specified by:
isEmpty in interface Collection<Object>
Specified by:
isEmpty in interface List<Object>
Specified by:
isEmpty in interface Document
Returns:
true if there are no fields in this document, or false if there is at least one.

contains

public boolean contains(Object o)
Specified by:
contains in interface Collection<Object>
Specified by:
contains in interface List<Object>

iterator

public Iterator<Object> iterator()
Specified by:
iterator in interface Iterable<Object>
Specified by:
iterator in interface Collection<Object>
Specified by:
iterator in interface List<Object>

toArray

public Object[] toArray()
Specified by:
toArray in interface Collection<Object>
Specified by:
toArray in interface List<Object>

toArray

public <T> T[] toArray(T[] a)
Specified by:
toArray in interface Collection<Object>
Specified by:
toArray in interface List<Object>

add

public boolean add(Object e)
Specified by:
add in interface Collection<Object>
Specified by:
add in interface List<Object>

remove

public boolean remove(Object o)
Specified by:
remove in interface Collection<Object>
Specified by:
remove in interface List<Object>

containsAll

public boolean containsAll(Collection<?> c)
Specified by:
containsAll in interface Collection<Object>
Specified by:
containsAll in interface List<Object>

addAll

public boolean addAll(Collection<? extends Object> c)
Specified by:
addAll in interface Collection<Object>
Specified by:
addAll in interface List<Object>

addAll

public boolean addAll(int index,
                      Collection<? extends Object> c)
Specified by:
addAll in interface List<Object>

removeAll

public boolean removeAll(Collection<?> c)
Specified by:
removeAll in interface Collection<Object>
Specified by:
removeAll in interface List<Object>

retainAll

public boolean retainAll(Collection<?> c)
Specified by:
retainAll in interface Collection<Object>
Specified by:
retainAll in interface List<Object>

clear

public void clear()
Specified by:
clear in interface Collection<Object>
Specified by:
clear in interface List<Object>

get

public Object get(int index)
Specified by:
get in interface List<Object>

set

public Object set(int index,
                  Object element)
Specified by:
set in interface List<Object>

add

public void add(int index,
                Object element)
Specified by:
add in interface List<Object>

remove

public Object remove(int index)
Specified by:
remove in interface List<Object>

indexOf

public int indexOf(Object o)
Specified by:
indexOf in interface List<Object>

lastIndexOf

public int lastIndexOf(Object o)
Specified by:
lastIndexOf in interface List<Object>

getEntries

public Iterable<Array.Entry> getEntries()
Description copied from interface: Array
Get the entries in this array.

Specified by:
getEntries in interface Array
Returns:
an iterable containing the array's entries; never null

listIterator

public ListIterator<Object> listIterator()
Specified by:
listIterator in interface List<Object>

listIterator

public ListIterator<Object> listIterator(int index)
Specified by:
listIterator in interface List<Object>

subList

public List<Object> subList(int fromIndex,
                            int toIndex)
Specified by:
subList in interface List<Object>

set

public EditableArray set(String name,
                         Object value)
Description copied from interface: EditableArray
Set the value for the field with the given name to the supplied value.

Specified by:
set in interface EditableArray
Specified by:
set in interface EditableDocument
Parameters:
name - The name of the field
value - the new value for the field
Returns:
This document, to allow for chaining methods

setBoolean

public EditableArray setBoolean(int index,
                                boolean value)
Description copied from interface: EditableArray
Set the value for the field at the given index to the supplied boolean value.

Specified by:
setBoolean in interface EditableArray
Parameters:
index - The index in the array at which the value is to be set
value - the new value for the field
Returns:
This document, to allow for chaining methods

setNumber

public EditableArray setNumber(int index,
                               int value)
Description copied from interface: EditableArray
Set the value for the field at the given index to the supplied integer value.

Specified by:
setNumber in interface EditableArray
Parameters:
index - The index in the array at which the value is to be set
value - the new value for the field
Returns:
This document, to allow for chaining methods

setNumber

public EditableArray setNumber(int index,
                               long value)
Description copied from interface: EditableArray
Set the value for the field at the given index to the supplied long value.

Specified by:
setNumber in interface EditableArray
Parameters:
index - The index in the array at which the value is to be set
value - the new value for the field
Returns:
This document, to allow for chaining methods

setNumber

public EditableArray setNumber(int index,
                               float value)
Description copied from interface: EditableArray
Set the value for the field at the given index to the supplied float value.

Specified by:
setNumber in interface EditableArray
Parameters:
index - The index in the array at which the value is to be set
value - the new value for the field
Returns:
This document, to allow for chaining methods

setNumber

public EditableArray setNumber(int index,
                               double value)
Description copied from interface: EditableArray
Set the value for the field at the given index to the supplied double value.

Specified by:
setNumber in interface EditableArray
Parameters:
index - The index in the array at which the value is to be set
value - the new value for the field
Returns:
This document, to allow for chaining methods

setString

public EditableArray setString(int index,
                               String value)
Description copied from interface: EditableArray
Set the value for the field at the given index to the supplied string value.

Specified by:
setString in interface EditableArray
Parameters:
index - The index in the array at which the value is to be set
value - the new value for the field
Returns:
This document, to allow for chaining methods

setSymbol

public EditableArray setSymbol(int index,
                               String value)
Description copied from interface: EditableArray
Set the value for the field at the given index to a Symbol created from the supplied string value. Symbols are defined in the BSON specification as being similar to a string but which exists for those languages that have a specific symbol type. Symbols are serialized to JSON as a normal string.

Specified by:
setSymbol in interface EditableArray
Parameters:
index - The index in the array at which the value is to be set
value - the new value for the field
Returns:
This document, to allow for chaining methods
See Also:
EditableArray.setString(int, String)

setDocument

public EditableDocument setDocument(int index)
Description copied from interface: EditableArray
Set the value for the field at the given index to be a new, empty Document.

Specified by:
setDocument in interface EditableArray
Parameters:
index - The index in the array at which the value is to be set
Returns:
The editable document that was just created; never null

setDocument

public EditableDocument setDocument(int index,
                                    Document document)
Description copied from interface: EditableArray
Set the value for the field at the given index to be the supplied Document.

Specified by:
setDocument in interface EditableArray
Parameters:
index - The index in the array at which the value is to be set
document - the document
Returns:
The editable document that was just set as the value at the supplied index in this array; never null and may or may not be the same instance as the supplied document.

setArray

public EditableArray setArray(int index)
Description copied from interface: EditableArray
Set the value for the field at the given index to be a new, empty array.

Specified by:
setArray in interface EditableArray
Parameters:
index - The index in the array at which the value is to be set
Returns:
The editable array that was just created; never null

setArray

public EditableArray setArray(int index,
                              Array array)
Description copied from interface: EditableArray
Set the value for the field at the given index to be the supplied array.

Specified by:
setArray in interface EditableArray
Parameters:
index - The index in the array at which the value is to be set
array - the array
Returns:
The editable array that was just set as the value at the supplied index in this array; never null and may or may not be the same instance as the supplied array.

setDate

public EditableArray setDate(int index,
                             Date value)
Description copied from interface: EditableArray
Set the value for the field at the given index to the supplied date value.

Specified by:
setDate in interface EditableArray
Parameters:
index - The index in the array at which the value is to be set
value - the new value for the field
Returns:
This document, to allow for chaining methods

setDate

public EditableArray setDate(int index,
                             String isoDate)
                      throws ParseException
Description copied from interface: EditableArray
Set the value for the field at the given index to the date value parsed from the ISO-8601 date representation. Specifically, the date string must match one of these patterns:

Specified by:
setDate in interface EditableArray
Parameters:
index - The index in the array at which the value is to be set
isoDate - the new value for the field
Returns:
This document, to allow for chaining methods
Throws:
ParseException - if the supplied value could not be parsed into a valid date

setTimestamp

public EditableArray setTimestamp(int index,
                                  int timeInSeconds,
                                  int increment)
Description copied from interface: EditableArray
Set the value for the field at the given index to a Timestamp with the supplied time in seconds and increment. Note that Date values are recommended for most purposes, as they are better suited to most applications' representations of time instants.

Specified by:
setTimestamp in interface EditableArray
Parameters:
index - The index in the array at which the value is to be set
timeInSeconds - the time in seconds for the new Timestamp
increment - the time increment for the new Timestamp
Returns:
This document, to allow for chaining methods
See Also:
EditableArray.setDate(int, Date)

setObjectId

public EditableArray setObjectId(int index,
                                 String hex)
Description copied from interface: EditableArray
Set the value for the field at the given index to an ObjectId created from the supplied hexadecimal binary value. Object IDs are defined by the BSON specification as 12-byte binary values designed to have a reasonably high probability of being unique when allocated. Since there is no explicit way to represent these in a JSON document, each ObjectId value is serialized in a JSON document as a nested document of the form:
 { "$oid" : "12bytesOfIdInBase16" }
 
When nested documents of this form are read by this library's JSON reader, nested documents of this form will be converted to an ObjectId value.

For example, an ObjectId with time value of "1310745823", machine value of "1", process value of "2", and increment value of "3" would be written as

 { "$oid" : "4e2064df0000010002000003" }
 

Specified by:
setObjectId in interface EditableArray
Parameters:
index - The index in the array at which the value is to be set
hex - the hexadecimal binary value for the ObjectId
Returns:
This document, to allow for chaining methods
See Also:
EditableArray.setObjectId(int, byte[]), EditableArray.setObjectId(int, int, int, int, int)

setObjectId

public EditableArray setObjectId(int index,
                                 byte[] bytes)
Description copied from interface: EditableArray
Set the value for the field at the given index to an ObjectId created from the supplied 12-byte binary value. Object IDs are defined by the BSON specification as 12-byte binary values designed to have a reasonably high probability of being unique when allocated. Since there is no explicit way to represent these in a JSON document, each ObjectId value is serialized in a JSON document as a nested document of the form:
 { "$oid" : "12bytesOfIdInBase16" }
 
When nested documents of this form are read by this library's JSON reader, nested documents of this form will be converted to an ObjectId value.

For example, an ObjectId with time value of "1310745823", machine value of "1", process value of "2", and increment value of "3" would be written as

 { "$oid" : "4e2064df0000010002000003" }
 

Specified by:
setObjectId in interface EditableArray
Parameters:
index - The index in the array at which the value is to be set
bytes - the 12-byte value for the ObjectId
Returns:
This document, to allow for chaining methods
See Also:
EditableArray.setObjectId(int, String), EditableArray.setObjectId(int, int, int, int, int)

setObjectId

public EditableArray setObjectId(int index,
                                 int time,
                                 int machine,
                                 int process,
                                 int inc)
Description copied from interface: EditableArray
Set the value for the field at the given index to an ObjectId created from the supplied hexadecimal binary value. Object IDs are defined by the BSON specification as 12-byte binary values designed to have a reasonably high probability of being unique when allocated. Since there is no explicit way to represent these in a JSON document, each ObjectId value is serialized in a JSON document as a nested document of the form:
 { "$oid" : "12bytesOfIdInBase16" }
 
When nested documents of this form are read by this library's JSON reader, nested documents of this form will be converted to an ObjectId value.

For example, an ObjectId with time value of "1310745823", machine value of "1", process value of "2", and increment value of "3" would be written as

 { "$oid" : "4e2064df0000010002000003" }
 

Specified by:
setObjectId in interface EditableArray
Parameters:
index - The index in the array at which the value is to be set
time - the Unix-style timestamp, which is a signed integer representing the number of seconds before or after January 1st 1970 (UTC)
machine - the first three bytes of the (md5) hash of the machine host name, or of the mac/network address, or the virtual machine id
process - the 2 bytes of the process id (or thread id) of the process generating the object id
inc - an ever incrementing value, or a random number if a counter can't be used in the language/runtime
Returns:
This document, to allow for chaining methods
See Also:
EditableArray.setObjectId(int, String), EditableArray.setObjectId(int, byte[])

setRegularExpression

public EditableArray setRegularExpression(int index,
                                          String pattern)
Description copied from interface: EditableArray
Set the value for the field at the given index to the supplied regular expression. Regular expression values are represented in memory using Pattern instances, and are stored natively in BSON as regular expressions. However, when serialized to JSON, regular expressions are written as nested documents of the form:
 { "$regex" : "pattern" }
 
where "pattern" is the regular expression pattern.

When nested documents of this form are read by this library's JSON reader, nested documents of this form will be converted to a regular expression value.

Specified by:
setRegularExpression in interface EditableArray
Parameters:
index - The index in the array at which the value is to be set
pattern - the regular expression pattern string
Returns:
This document, to allow for chaining methods
See Also:
EditableArray.setRegularExpression(int, String, int)

setRegularExpression

public EditableArray setRegularExpression(int index,
                                          String pattern,
                                          int flags)
Description copied from interface: EditableArray
Set the value for the field at the given index to the supplied regular expression. Regular expression values are represented in memory using Pattern instances, and are stored natively in BSON as regular expressions. However, when serialized to JSON, regular expressions are written as nested documents of the form:
 { "$regex" : "pattern", "$options" : "flags" }
 
where "pattern" is the regular expression pattern, and "flags" is a string representation of the regular expression options.

When nested documents of this form are read by this library's JSON reader, nested documents of this form will be converted to a regular expression value.

Specified by:
setRegularExpression in interface EditableArray
Parameters:
index - The index in the array at which the value is to be set
pattern - the regular expression pattern string
flags - the bitwise-anded Pattern options: Pattern.CANON_EQ, Pattern.CASE_INSENSITIVE, Pattern.CASE_INSENSITIVE, Pattern.COMMENTS, Pattern.DOTALL, Pattern.LITERAL, Pattern.MULTILINE, Pattern.UNICODE_CASE, and Pattern.UNIX_LINES
Returns:
This document, to allow for chaining methods
See Also:
EditableArray.setRegularExpression(int, String)

setNull

public EditableArray setNull(int index)
Description copied from interface: EditableArray
Set the value for the field at the given index to be a null value. Both JSON and BSON formats support null values, and Null is used for the value in the in-memory representation. The Document.isNull(String) methods can be used to determine if a field has been set to null, or Document.isNullOrMissing(String) if the field has not be set or if it has been set to null.

Specified by:
setNull in interface EditableArray
Parameters:
index - The index in the array at which the value is to be set
Returns:
This document, to allow for chaining methods
See Also:
Document.isNull(String), Document.isNullOrMissing(String)

setBinary

public EditableArray setBinary(int index,
                               byte type,
                               byte[] data)
Description copied from interface: EditableArray
Set the value for the field at the given index to be a binary value. JSON does not formally support binary values, and so such values will be encoded using a nested document of the form:
 { "$type" : typeAsInt, "$base64" : "bytesInBase64" }
 
where "typeAsInt" is the integer representation of the BSON type, and "bytesInBase64" is the Base64 encoding of the actual Binary bytes.

When nested documents of this form are read by this library's JSON reader, nested documents of this form will be converted to Binary value.

Specified by:
setBinary in interface EditableArray
Parameters:
index - The index in the array at which the value is to be set
type - one of the BSON type constants denoting the type of the Binary value
data - the bytes for the Binary value
Returns:
This document, to allow for chaining methods

setUuid

public EditableArray setUuid(int index,
                             UUID uuid)
Description copied from interface: EditableArray
Set the value for the field at the given index to be a UUID. JSON does not formally support binary values, and so such values will be encoded using a nested document of the form:
 { "$uuid" : "string-form-of-uuid" }
 
where "string-form-of-uuid" is the UUID's string representation

When nested documents of this form are read by this library's JSON reader, nested documents of this form will be converted to UUID value.

Specified by:
setUuid in interface EditableArray
Parameters:
index - The index in the array at which the value is to be set
uuid - the UUID value
Returns:
This document, to allow for chaining methods

setCode

public EditableDocument setCode(int index,
                                String code,
                                boolean includeScope)
Description copied from interface: EditableArray
Set the value for the field at the given index to be a Code or CodeWithScope. JSON does not formally support such values, and so when written to JSON they will be encoded using a nested document of the form:
 { "$code" : "code" }
 
or, if there is a scope document
 { "$code" : "code", "$scope" : scope document }
 
where "code" is the Code's JavaScript code and scopeDocument is the nested document representing the scope in which the JavaScript code should be evaluated.

When nested documents of this form are read by this library's JSON reader, nested documents of this form will be converted to Code or CodeWithScope value.

Note that when includeScope is true, the returned EditableArray can be used to populate the scope document.

Specified by:
setCode in interface EditableArray
Parameters:
index - The index in the array at which the value is to be set
code - the code
includeScope - true if the code should include a scope (and if this method should return an EditableArray for this scope document), or false otherwise
Returns:
if includeScope is true, then the EditableDocument for the scope; otherwise, this array to allow for chaining methods
See Also:
EditableArray.setCode(int, String, Document)

setCode

public EditableDocument setCode(int index,
                                String code,
                                Document scope)
Description copied from interface: EditableArray
Set the value for the field at the given index to be a Code or CodeWithScope. JSON does not formally support such values, and so when written to JSON they will be encoded using a nested document of the form:
 { "$code" : "code" }
 
or, if there is a scope document
 { "$code" : "code", "$scope" : scope document }
 
where "code" is the Code's JavaScript code and scopeDocument is the nested document representing the scope in which the JavaScript code should be evaluated.

When nested documents of this form are read by this library's JSON reader, nested documents of this form will be converted to Code or CodeWithScope value.

Specified by:
setCode in interface EditableArray
Parameters:
index - The index in the array at which the value is to be set
code - the code
scope - the scope in which the JavaScript code should be evaulated, or null if there is no scope
Returns:
the EditableDocument for the scope; or this array if the scope is null
See Also:
EditableArray.setCode(int, String, boolean)

addBoolean

public EditableArray addBoolean(int index,
                                boolean value)
Description copied from interface: EditableArray
Insert the value for the field at the given index to the supplied boolean value.

Specified by:
addBoolean in interface EditableArray
Parameters:
index - The index in the array at which the value is to be set
value - the new value for the field
Returns:
This document, to allow for chaining methods

addNumber

public EditableArray addNumber(int index,
                               int value)
Description copied from interface: EditableArray
Insert the value for the field at the given index to the supplied integer value.

Specified by:
addNumber in interface EditableArray
Parameters:
index - The index in the array at which the value is to be set
value - the new value for the field
Returns:
This document, to allow for chaining methods

addNumber

public EditableArray addNumber(int index,
                               long value)
Description copied from interface: EditableArray
Insert the value for the field at the given index to the supplied long value.

Specified by:
addNumber in interface EditableArray
Parameters:
index - The index in the array at which the value is to be set
value - the new value for the field
Returns:
This document, to allow for chaining methods

addNumber

public EditableArray addNumber(int index,
                               float value)
Description copied from interface: EditableArray
Insert the value for the field at the given index to the supplied float value.

Specified by:
addNumber in interface EditableArray
Parameters:
index - The index in the array at which the value is to be set
value - the new value for the field
Returns:
This document, to allow for chaining methods

addNumber

public EditableArray addNumber(int index,
                               double value)
Description copied from interface: EditableArray
Insert the value for the field at the given index to the supplied double value.

Specified by:
addNumber in interface EditableArray
Parameters:
index - The index in the array at which the value is to be set
value - the new value for the field
Returns:
This document, to allow for chaining methods

addString

public EditableArray addString(int index,
                               String value)
Description copied from interface: EditableArray
Insert the value for the field at the given index to the supplied string value.

Specified by:
addString in interface EditableArray
Parameters:
index - The index in the array at which the value is to be set
value - the new value for the field
Returns:
This document, to allow for chaining methods

addSymbol

public EditableArray addSymbol(int index,
                               String value)
Description copied from interface: EditableArray
Insert the value for the field at the given index to a Symbol created from the supplied string value. Symbols are defined in the BSON specification as being similar to a string but which exists for those languages that have a specific symbol type. Symbols are serialized to JSON as a normal string.

Specified by:
addSymbol in interface EditableArray
Parameters:
index - The index in the array at which the value is to be set
value - the new value for the field
Returns:
This document, to allow for chaining methods
See Also:
EditableArray.setString(int, String)

addDocument

public EditableDocument addDocument(int index)
Description copied from interface: EditableArray
Insert the value for the field at the given index to be a new, empty Document.

Specified by:
addDocument in interface EditableArray
Parameters:
index - The index in the array at which the value is to be set
Returns:
The editable document that was just created; never null

addDocument

public EditableDocument addDocument(int index,
                                    Document document)
Description copied from interface: EditableArray
Insert the value for the field at the given index to be the supplied Document.

Specified by:
addDocument in interface EditableArray
Parameters:
index - The index in the array at which the value is to be set
document - the document
Returns:
The editable document that was just set as the value at the supplied index in this array; never null and may or may not be the same instance as the supplied document.

addArray

public EditableArray addArray(int index)
Description copied from interface: EditableArray
Insert the value for the field at the given index to be a new, empty array.

Specified by:
addArray in interface EditableArray
Parameters:
index - The index in the array at which the value is to be set
Returns:
The editable array that was just created; never null

addArray

public EditableArray addArray(int index,
                              Array array)
Description copied from interface: EditableArray
Insert the value for the field at the given index to be the supplied array.

Specified by:
addArray in interface EditableArray
Parameters:
index - The index in the array at which the value is to be set
array - the array
Returns:
The editable array that was just set as the value at the supplied index in this array; never null and may or may not be the same instance as the supplied array.

addDate

public EditableArray addDate(int index,
                             Date value)
Description copied from interface: EditableArray
Insert the value for the field at the given index to the supplied date value.

Specified by:
addDate in interface EditableArray
Parameters:
index - The index in the array at which the value is to be set
value - the new value for the field
Returns:
This document, to allow for chaining methods

addDate

public EditableArray addDate(int index,
                             String isoDate)
                      throws ParseException
Description copied from interface: EditableArray
Insert the value for the field at the given index to the date value parsed from the ISO-8601 date representation. Specifically, the date string must match one of these patterns:

Specified by:
addDate in interface EditableArray
Parameters:
index - The index in the array at which the value is to be set
isoDate - the new value for the field
Returns:
This document, to allow for chaining methods
Throws:
ParseException - if the supplied value could not be parsed into a valid date

addTimestamp

public EditableArray addTimestamp(int index,
                                  int timeInSeconds,
                                  int increment)
Description copied from interface: EditableArray
Insert the value for the field at the given index to a Timestamp with the supplied time in seconds and increment. Note that Date values are recommended for most purposes, as they are better suited to most applications' representations of time instants.

Specified by:
addTimestamp in interface EditableArray
Parameters:
index - The index in the array at which the value is to be set
timeInSeconds - the time in seconds for the new Timestamp
increment - the time increment for the new Timestamp
Returns:
This document, to allow for chaining methods
See Also:
EditableArray.setDate(int, Date)

addObjectId

public EditableArray addObjectId(int index,
                                 String hex)
Description copied from interface: EditableArray
Insert the value for the field at the given index to an ObjectId created from the supplied hexadecimal binary value. Object IDs are defined by the BSON specification as 12-byte binary values designed to have a reasonably high probability of being unique when allocated. Since there is no explicit way to represent these in a JSON document, each ObjectId value is serialized in a JSON document as a nested document of the form:
 { "$oid" : "12bytesOfIdInBase16" }
 
When nested documents of this form are read by this library's JSON reader, nested documents of this form will be converted to an ObjectId value.

For example, an ObjectId with time value of "1310745823", machine value of "1", process value of "2", and increment value of "3" would be written as

 { "$oid" : "4e2064df0000010002000003" }
 

Specified by:
addObjectId in interface EditableArray
Parameters:
index - The index in the array at which the value is to be set
hex - the hexadecimal binary value for the ObjectId
Returns:
This document, to allow for chaining methods
See Also:
EditableArray.setObjectId(int, byte[]), EditableArray.setObjectId(int, int, int, int, int)

addObjectId

public EditableArray addObjectId(int index,
                                 byte[] bytes)
Description copied from interface: EditableArray
Insert the value for the field at the given index to an ObjectId created from the supplied 12-byte binary value. Object IDs are defined by the BSON specification as 12-byte binary values designed to have a reasonably high probability of being unique when allocated. Since there is no explicit way to represent these in a JSON document, each ObjectId value is serialized in a JSON document as a nested document of the form:
 { "$oid" : "12bytesOfIdInBase16" }
 
When nested documents of this form are read by this library's JSON reader, nested documents of this form will be converted to an ObjectId value.

For example, an ObjectId with time value of "1310745823", machine value of "1", process value of "2", and increment value of "3" would be written as

 { "$oid" : "4e2064df0000010002000003" }
 

Specified by:
addObjectId in interface EditableArray
Parameters:
index - The index in the array at which the value is to be set
bytes - the 12-byte value for the ObjectId
Returns:
This document, to allow for chaining methods
See Also:
EditableArray.setObjectId(int, String), EditableArray.setObjectId(int, int, int, int, int)

addObjectId

public EditableArray addObjectId(int index,
                                 int time,
                                 int machine,
                                 int process,
                                 int inc)
Description copied from interface: EditableArray
Insert the value for the field at the given index to an ObjectId created from the supplied hexadecimal binary value. Object IDs are defined by the BSON specification as 12-byte binary values designed to have a reasonably high probability of being unique when allocated. Since there is no explicit way to represent these in a JSON document, each ObjectId value is serialized in a JSON document as a nested document of the form:
 { "$oid" : "12bytesOfIdInBase16" }
 
When nested documents of this form are read by this library's JSON reader, nested documents of this form will be converted to an ObjectId value.

For example, an ObjectId with time value of "1310745823", machine value of "1", process value of "2", and increment value of "3" would be written as

 { "$oid" : "4e2064df0000010002000003" }
 

Specified by:
addObjectId in interface EditableArray
Parameters:
index - The index in the array at which the value is to be set
time - the Unix-style timestamp, which is a signed integer representing the number of seconds before or after January 1st 1970 (UTC)
machine - the first three bytes of the (md5) hash of the machine host name, or of the mac/network address, or the virtual machine id
process - the 2 bytes of the process id (or thread id) of the process generating the object id
inc - an ever incrementing value, or a random number if a counter can't be used in the language/runtime
Returns:
This document, to allow for chaining methods
See Also:
EditableArray.setObjectId(int, String), EditableArray.setObjectId(int, byte[])

addRegularExpression

public EditableArray addRegularExpression(int index,
                                          String pattern)
Description copied from interface: EditableArray
Insert the value for the field at the given index to the supplied regular expression. Regular expression values are represented in memory using Pattern instances, and are stored natively in BSON as regular expressions. However, when serialized to JSON, regular expressions are written as nested documents of the form:
 { "$regex" : "pattern" }
 
where "pattern" is the regular expression pattern.

When nested documents of this form are read by this library's JSON reader, nested documents of this form will be converted to a regular expression value.

Specified by:
addRegularExpression in interface EditableArray
Parameters:
index - The index in the array at which the value is to be set
pattern - the regular expression pattern string
Returns:
This document, to allow for chaining methods
See Also:
EditableArray.setRegularExpression(int, String, int)

addRegularExpression

public EditableArray addRegularExpression(int index,
                                          String pattern,
                                          int flags)
Description copied from interface: EditableArray
Insert the value for the field at the given index to the supplied regular expression. Regular expression values are represented in memory using Pattern instances, and are stored natively in BSON as regular expressions. However, when serialized to JSON, regular expressions are written as nested documents of the form:
 { "$regex" : "pattern", "$options" : "flags" }
 
where "pattern" is the regular expression pattern, and "flags" is a string representation of the regular expression options.

When nested documents of this form are read by this library's JSON reader, nested documents of this form will be converted to a regular expression value.

Specified by:
addRegularExpression in interface EditableArray
Parameters:
index - The index in the array at which the value is to be set
pattern - the regular expression pattern string
flags - the bitwise-anded Pattern options: Pattern.CANON_EQ, Pattern.CASE_INSENSITIVE, Pattern.CASE_INSENSITIVE, Pattern.COMMENTS, Pattern.DOTALL, Pattern.LITERAL, Pattern.MULTILINE, Pattern.UNICODE_CASE, and Pattern.UNIX_LINES
Returns:
This document, to allow for chaining methods
See Also:
EditableArray.setRegularExpression(int, String)

addNull

public EditableArray addNull(int index)
Description copied from interface: EditableArray
Insert the value for the field at the given index to be a null value. Both JSON and BSON formats support null values, and Null is used for the value in the in-memory representation. The Document.isNull(String) methods can be used to determine if a field has been set to null, or Document.isNullOrMissing(String) if the field has not be set or if it has been set to null.

Specified by:
addNull in interface EditableArray
Parameters:
index - The index in the array at which the value is to be set
Returns:
This document, to allow for chaining methods
See Also:
Document.isNull(String), Document.isNullOrMissing(String)

addBinary

public EditableArray addBinary(int index,
                               byte type,
                               byte[] data)
Description copied from interface: EditableArray
Insert the value for the field at the given index to be a binary value. JSON does not formally support binary values, and so such values will be encoded using a nested document of the form:
 { "$type" : typeAsInt, "$base64" : "bytesInBase64" }
 
where "typeAsInt" is the integer representation of the BSON type, and "bytesInBase64" is the Base64 encoding of the actual Binary bytes.

When nested documents of this form are read by this library's JSON reader, nested documents of this form will be converted to Binary value.

Specified by:
addBinary in interface EditableArray
Parameters:
index - The index in the array at which the value is to be set
type - one of the BSON type constants denoting the type of the Binary value
data - the bytes for the Binary value
Returns:
This document, to allow for chaining methods

addUuid

public EditableArray addUuid(int index,
                             UUID uuid)
Description copied from interface: EditableArray
Insert the value for the field at the given index to be a UUID. JSON does not formally support binary values, and so such values will be encoded using a nested document of the form:
 { "$uuid" : "string-form-of-uuid" }
 
where "string-form-of-uuid" is the UUID's string representation

When nested documents of this form are read by this library's JSON reader, nested documents of this form will be converted to UUID value.

Specified by:
addUuid in interface EditableArray
Parameters:
index - The index in the array at which the value is to be set
uuid - the UUID value
Returns:
This document, to allow for chaining methods

addCode

public EditableDocument addCode(int index,
                                String code,
                                boolean includeScope)
Description copied from interface: EditableArray
Insert the value for the field at the given index to be a Code or CodeWithScope. JSON does not formally support such values, and so when written to JSON they will be encoded using a nested document of the form:
 { "$code" : "code" }
 
or, if there is a scope document
 { "$code" : "code", "$scope" : scope document }
 
where "code" is the Code's JavaScript code and scopeDocument is the nested document representing the scope in which the JavaScript code should be evaluated.

When nested documents of this form are read by this library's JSON reader, nested documents of this form will be converted to Code or CodeWithScope value.

Note that when includeScope is true, the returned EditableArray can be used to populate the scope document.

Specified by:
addCode in interface EditableArray
Parameters:
index - The index in the array at which the value is to be set
code - the code
includeScope - true if the code should include a scope (and if this method should return an EditableArray for this scope document), or false otherwise
Returns:
if includeScope is true, then the EditableDocument for the scope; otherwise, this array to allow for chaining methods
See Also:
EditableArray.setCode(int, String, Document)

addCode

public EditableDocument addCode(int index,
                                String code,
                                Document scope)
Description copied from interface: EditableArray
Insert the value for the field at the given index to be a Code or CodeWithScope. JSON does not formally support such values, and so when written to JSON they will be encoded using a nested document of the form:
 { "$code" : "code" }
 
or, if there is a scope document
 { "$code" : "code", "$scope" : scope document }
 
where "code" is the Code's JavaScript code and scopeDocument is the nested document representing the scope in which the JavaScript code should be evaluated.

When nested documents of this form are read by this library's JSON reader, nested documents of this form will be converted to Code or CodeWithScope value.

Specified by:
addCode in interface EditableArray
Parameters:
index - The index in the array at which the value is to be set
code - the code
scope - the scope in which the JavaScript code should be evaulated, or null if there is no scope
Returns:
the EditableDocument for the scope; or this array if the scope is null
See Also:
EditableArray.setCode(int, String, boolean)

addBoolean

public EditableArray addBoolean(boolean value)
Description copied from interface: EditableArray
Adds the supplied boolean value to this array.

Specified by:
addBoolean in interface EditableArray
Parameters:
value - the new value for the field
Returns:
This document, to allow for chaining methods

addNumber

public EditableArray addNumber(int value)
Description copied from interface: EditableArray
Adds the supplied integer value to this array.

Specified by:
addNumber in interface EditableArray
Parameters:
value - the new value for the field
Returns:
This document, to allow for chaining methods

addNumber

public EditableArray addNumber(long value)
Description copied from interface: EditableArray
Adds the supplied long value to this array.

Specified by:
addNumber in interface EditableArray
Parameters:
value - the new value for the field
Returns:
This document, to allow for chaining methods

addNumber

public EditableArray addNumber(float value)
Description copied from interface: EditableArray
Adds the supplied float value to this array.

Specified by:
addNumber in interface EditableArray
Parameters:
value - the new value for the field
Returns:
This document, to allow for chaining methods

addNumber

public EditableArray addNumber(double value)
Description copied from interface: EditableArray
Adds the supplied double value to this array.

Specified by:
addNumber in interface EditableArray
Parameters:
value - the new value for the field
Returns:
This document, to allow for chaining methods

addString

public EditableArray addString(String value)
Description copied from interface: EditableArray
Adds the supplied string value to this array.

Specified by:
addString in interface EditableArray
Parameters:
value - the new value for the field
Returns:
This document, to allow for chaining methods

addSymbol

public EditableArray addSymbol(String value)
Description copied from interface: EditableArray
Adds to this array a Symbol with the supplied string.

Specified by:
addSymbol in interface EditableArray
Parameters:
value - the new value for the field
Returns:
This document, to allow for chaining methods
See Also:
EditableArray.addString(String)

addDocument

public EditableDocument addDocument()
Description copied from interface: EditableArray
Adds to this array a new empty document.

Specified by:
addDocument in interface EditableArray
Returns:
The editable document that was just created; never null

addDocument

public EditableDocument addDocument(Document document)
Description copied from interface: EditableArray
Adds to this array the supplied document.

Specified by:
addDocument in interface EditableArray
Parameters:
document - the document
Returns:
The editable document that was just added to this array; never null and may or may not be the same instance as the supplied document.

addArray

public EditableArray addArray()
Description copied from interface: EditableArray
Adds to this array a new empty array.

Specified by:
addArray in interface EditableArray
Returns:
The editable array that was just created; never null

addArray

public EditableArray addArray(Array array)
Description copied from interface: EditableArray
Adds to this array the supplied array.

Specified by:
addArray in interface EditableArray
Parameters:
array - the array
Returns:
The editable array that was just added to this array; never null and may or may not be the same instance as the supplied array.

addDate

public EditableArray addDate(Date value)
Description copied from interface: EditableArray
Adds to this array the supplied date.

Specified by:
addDate in interface EditableArray
Parameters:
value - the new value for the field
Returns:
This document, to allow for chaining methods

addDate

public EditableArray addDate(String isoDate)
                      throws ParseException
Description copied from interface: EditableArray
Adds to this array a Date with the supplied ISO-8601 string.

Specified by:
addDate in interface EditableArray
Parameters:
isoDate - the new value for the field
Returns:
This document, to allow for chaining methods
Throws:
ParseException - if the supplied value could not be parsed into a valid date
See Also:
EditableArray.addDate(Date)

addTimestamp

public EditableArray addTimestamp(int timeInSeconds,
                                  int increment)
Description copied from interface: EditableArray
Adds to this array a Timestamp with the supplied time in seconds and increment value.

Specified by:
addTimestamp in interface EditableArray
Parameters:
timeInSeconds - the time in seconds for the new Timestamp
increment - the time increment for the new Timestamp
Returns:
This document, to allow for chaining methods
See Also:
EditableArray.addDate(Date)

addObjectId

public EditableArray addObjectId(String hex)
Description copied from interface: EditableArray
Adds to this array an ObjectId with the supplied hexadecimal string.

Specified by:
addObjectId in interface EditableArray
Parameters:
hex - the hexadecimal binary value for the ObjectId
Returns:
This document, to allow for chaining methods
See Also:
EditableArray.addObjectId(byte[]), EditableArray.addObjectId(int, int, int, int)

addObjectId

public EditableArray addObjectId(byte[] bytes)
Description copied from interface: EditableArray
Adds to this array an ObjectId with the supplied 12-byte value.

Specified by:
addObjectId in interface EditableArray
Parameters:
bytes - the 12-byte value for the ObjectId
Returns:
This document, to allow for chaining methods
See Also:
EditableArray.addObjectId(String), EditableArray.addObjectId(int, int, int, int)

addObjectId

public EditableArray addObjectId(int time,
                                 int machine,
                                 int process,
                                 int inc)
Description copied from interface: EditableArray
Adds to this array an ObjectId with the supplied time, machine, process, and increment.

Specified by:
addObjectId in interface EditableArray
Parameters:
time - the Unix-style timestamp, which is a signed integer representing the number of seconds before or after January 1st 1970 (UTC)
machine - the first three bytes of the (md5) hash of the machine host name, or of the mac/network address, or the virtual machine id
process - the 2 bytes of the process id (or thread id) of the process generating the object id
inc - an ever incrementing value, or a random number if a counter can't be used in the language/runtime
Returns:
This document, to allow for chaining methods
See Also:
EditableArray.addObjectId(String), EditableArray.addObjectId(byte[])

addRegularExpression

public EditableArray addRegularExpression(String pattern)
Description copied from interface: EditableArray
Adds to this array a regular expression with the supplied pattern string.

Specified by:
addRegularExpression in interface EditableArray
Parameters:
pattern - the regular expression pattern string
Returns:
This document, to allow for chaining methods

addRegularExpression

public EditableArray addRegularExpression(String pattern,
                                          int flags)
Description copied from interface: EditableArray
Adds to this array a regular expression with the supplied pattern string and option flags.

Specified by:
addRegularExpression in interface EditableArray
Parameters:
pattern - the regular expression pattern string
flags - the bitwise-anded Pattern options: Pattern.CANON_EQ, Pattern.CASE_INSENSITIVE, Pattern.CASE_INSENSITIVE, Pattern.COMMENTS, Pattern.DOTALL, Pattern.LITERAL, Pattern.MULTILINE, Pattern.UNICODE_CASE, and Pattern.UNIX_LINES
Returns:
This document, to allow for chaining methods

addNull

public EditableArray addNull()
Description copied from interface: EditableArray
Adds to this array a Null value.

Specified by:
addNull in interface EditableArray
Returns:
This document, to allow for chaining methods
See Also:
Document.isNull(String), Document.isNullOrMissing(String)

addBinary

public EditableArray addBinary(byte type,
                               byte[] data)
Description copied from interface: EditableArray
Adds to this array a Binary value with the supplied type and content.

Specified by:
addBinary in interface EditableArray
Parameters:
type - one of the BSON type constants denoting the type of the Binary value
data - the bytes for the Binary value
Returns:
This document, to allow for chaining methods

addUuid

public EditableArray addUuid(UUID uuid)
Description copied from interface: EditableArray
Adds to this array the supplied UUID.

Specified by:
addUuid in interface EditableArray
Parameters:
uuid - the UUID value
Returns:
This document, to allow for chaining methods

addCode

public EditableDocument addCode(String code,
                                boolean includeScope)
Description copied from interface: EditableArray
Adds to this array a Code with the supplied JavaScript code.

Specified by:
addCode in interface EditableArray
Parameters:
code - the code
includeScope - true if the code should include a scope (and if this method should return an EditableArray for this scope document), or false otherwise
Returns:
if includeScope is true, then the EditableArray for the scope; otherwise, this document to allow for chaining methods
See Also:
EditableArray.addCode(String, Document)

addCode

public EditableDocument addCode(String code,
                                Document scope)
Description copied from interface: EditableArray
Adds to this array a CodeWithScope with the supplied JavaScript code and scope.

Specified by:
addCode in interface EditableArray
Parameters:
code - the code
scope - the scope in which the JavaScript code should be evaulated, or null if there is no scope
Returns:
the EditableDocument for the scope, or null if the scope reference is null
See Also:
EditableArray.addCode(String, boolean)

addBooleanIfAbsent

public EditableArray addBooleanIfAbsent(boolean value)
Description copied from interface: EditableArray
Adds the supplied boolean value to this array, if and only if an equivalent value doesn't already exist in the array.

Specified by:
addBooleanIfAbsent in interface EditableArray
Parameters:
value - the new value for the field
Returns:
This document, to allow for chaining methods

addNumberIfAbsent

public EditableArray addNumberIfAbsent(int value)
Description copied from interface: EditableArray
Adds the supplied integer value to this array, if and only if an equivalent value doesn't already exist in the array.

Specified by:
addNumberIfAbsent in interface EditableArray
Parameters:
value - the new value for the field
Returns:
This document, to allow for chaining methods

addNumberIfAbsent

public EditableArray addNumberIfAbsent(long value)
Description copied from interface: EditableArray
Adds the supplied long value to this array, if and only if an equivalent value doesn't already exist in the array.

Specified by:
addNumberIfAbsent in interface EditableArray
Parameters:
value - the new value for the field
Returns:
This document, to allow for chaining methods

addNumberIfAbsent

public EditableArray addNumberIfAbsent(float value)
Description copied from interface: EditableArray
Adds the supplied float value to this array, if and only if an equivalent value doesn't already exist in the array.

Specified by:
addNumberIfAbsent in interface EditableArray
Parameters:
value - the new value for the field
Returns:
This document, to allow for chaining methods

addNumberIfAbsent

public EditableArray addNumberIfAbsent(double value)
Description copied from interface: EditableArray
Adds the supplied double value to this array, if and only if an equivalent value doesn't already exist in the array.

Specified by:
addNumberIfAbsent in interface EditableArray
Parameters:
value - the new value for the field
Returns:
This document, to allow for chaining methods

addStringIfAbsent

public EditableArray addStringIfAbsent(String value)
Description copied from interface: EditableArray
Adds the supplied string value to this array, if and only if an equivalent value doesn't already exist in the array.

Specified by:
addStringIfAbsent in interface EditableArray
Parameters:
value - the new value for the field
Returns:
This document, to allow for chaining methods

addSymbolIfAbsent

public EditableArray addSymbolIfAbsent(String value)
Description copied from interface: EditableArray
Adds to this array a Symbol with the supplied string, if and only if an equivalent value doesn't already exist in the array.

Specified by:
addSymbolIfAbsent in interface EditableArray
Parameters:
value - the new value for the field
Returns:
This document, to allow for chaining methods
See Also:
EditableArray.addString(String)

addDocumentIfAbsent

public EditableDocument addDocumentIfAbsent(Document document)
Description copied from interface: EditableArray
Adds to this array the supplied document, if and only if an equivalent value doesn't already exist in the array.

Specified by:
addDocumentIfAbsent in interface EditableArray
Parameters:
document - the document
Returns:
The editable document that was just added to this array; never null and may or may not be the same instance as the supplied document.

addArrayIfAbsent

public EditableArray addArrayIfAbsent(Array array)
Description copied from interface: EditableArray
Adds to this array the supplied array, if and only if an equivalent value doesn't already exist in the array.

Specified by:
addArrayIfAbsent in interface EditableArray
Parameters:
array - the array
Returns:
The editable array that was just added to this array; never null and may or may not be the same instance as the supplied array.

addDateIfAbsent

public EditableArray addDateIfAbsent(Date value)
Description copied from interface: EditableArray
Adds to this array the supplied date, if and only if an equivalent value doesn't already exist in the array.

Specified by:
addDateIfAbsent in interface EditableArray
Parameters:
value - the new value for the field
Returns:
This document, to allow for chaining methods

addDateIfAbsent

public EditableArray addDateIfAbsent(String isoDate)
                              throws ParseException
Description copied from interface: EditableArray
Adds to this array a Date with the supplied ISO-8601 string, if and only if an equivalent value doesn't already exist in the array.

Specified by:
addDateIfAbsent in interface EditableArray
Parameters:
isoDate - the new value for the field
Returns:
This document, to allow for chaining methods
Throws:
ParseException - if the supplied value could not be parsed into a valid date
See Also:
EditableArray.addDate(Date)

addTimestampIfAbsent

public EditableArray addTimestampIfAbsent(int timeInSeconds,
                                          int increment)
Description copied from interface: EditableArray
Adds to this array a Timestamp with the supplied time in seconds and increment value, if and only if an equivalent value doesn't already exist in the array.

Specified by:
addTimestampIfAbsent in interface EditableArray
Parameters:
timeInSeconds - the time in seconds for the new Timestamp
increment - the time increment for the new Timestamp
Returns:
This document, to allow for chaining methods
See Also:
EditableArray.addDate(Date)

addObjectIdIfAbsent

public EditableArray addObjectIdIfAbsent(String hex)
Description copied from interface: EditableArray
Adds to this array an ObjectId with the supplied hexadecimal string, if and only if an equivalent value doesn't already exist in the array.

Specified by:
addObjectIdIfAbsent in interface EditableArray
Parameters:
hex - the hexadecimal binary value for the ObjectId
Returns:
This document, to allow for chaining methods
See Also:
EditableArray.addObjectId(byte[]), EditableArray.addObjectId(int, int, int, int)

addObjectIdIfAbsent

public EditableArray addObjectIdIfAbsent(byte[] bytes)
Description copied from interface: EditableArray
Adds to this array an ObjectId with the supplied 12-byte value, if and only if an equivalent value doesn't already exist in the array.

Specified by:
addObjectIdIfAbsent in interface EditableArray
Parameters:
bytes - the 12-byte value for the ObjectId
Returns:
This document, to allow for chaining methods
See Also:
EditableArray.addObjectId(String), EditableArray.addObjectId(int, int, int, int)

addObjectIdIfAbsent

public EditableArray addObjectIdIfAbsent(int time,
                                         int machine,
                                         int process,
                                         int inc)
Description copied from interface: EditableArray
Adds to this array an ObjectId with the supplied time, machine, process, and increment, if and only if an equivalent value doesn't already exist in the array.

Specified by:
addObjectIdIfAbsent in interface EditableArray
Parameters:
time - the Unix-style timestamp, which is a signed integer representing the number of seconds before or after January 1st 1970 (UTC)
machine - the first three bytes of the (md5) hash of the machine host name, or of the mac/network address, or the virtual machine id
process - the 2 bytes of the process id (or thread id) of the process generating the object id
inc - an ever incrementing value, or a random number if a counter can't be used in the language/runtime
Returns:
This document, to allow for chaining methods
See Also:
EditableArray.addObjectId(String), EditableArray.addObjectId(byte[])

addRegularExpressionIfAbsent

public EditableArray addRegularExpressionIfAbsent(String pattern)
Description copied from interface: EditableArray
Adds to this array a regular expression with the supplied pattern string, if and only if an equivalent value doesn't already exist in the array.

Specified by:
addRegularExpressionIfAbsent in interface EditableArray
Parameters:
pattern - the regular expression pattern string
Returns:
This document, to allow for chaining methods

addRegularExpressionIfAbsent

public EditableArray addRegularExpressionIfAbsent(String pattern,
                                                  int flags)
Description copied from interface: EditableArray
Adds to this array a regular expression with the supplied pattern string and option flags, if and only if an equivalent value doesn't already exist in the array.

Specified by:
addRegularExpressionIfAbsent in interface EditableArray
Parameters:
pattern - the regular expression pattern string
flags - the bitwise-anded Pattern options: Pattern.CANON_EQ, Pattern.CASE_INSENSITIVE, Pattern.CASE_INSENSITIVE, Pattern.COMMENTS, Pattern.DOTALL, Pattern.LITERAL, Pattern.MULTILINE, Pattern.UNICODE_CASE, and Pattern.UNIX_LINES
Returns:
This document, to allow for chaining methods

addNullIfAbsent

public EditableArray addNullIfAbsent()
Description copied from interface: EditableArray
Adds to this array a Null value, if and only if there is not already a null value in the array.

Specified by:
addNullIfAbsent in interface EditableArray
Returns:
This document, to allow for chaining methods
See Also:
Document.isNull(String), Document.isNullOrMissing(String)

addBinaryIfAbsent

public EditableArray addBinaryIfAbsent(byte type,
                                       byte[] data)
Description copied from interface: EditableArray
Adds to this array a Binary value with the supplied type and content, if and only if an equivalent value doesn't already exist in the array.

Specified by:
addBinaryIfAbsent in interface EditableArray
Parameters:
type - one of the BSON type constants denoting the type of the Binary value
data - the bytes for the Binary value
Returns:
This document, to allow for chaining methods

addUuidIfAbsent

public EditableArray addUuidIfAbsent(UUID uuid)
Description copied from interface: EditableArray
Adds to this array the supplied UUID, if and only if an equivalent value doesn't already exist in the array.

Specified by:
addUuidIfAbsent in interface EditableArray
Parameters:
uuid - the UUID value
Returns:
This document, to allow for chaining methods

addCodeIfAbsent

public EditableDocument addCodeIfAbsent(String code,
                                        Document scope)
Description copied from interface: EditableArray
Adds to this array a CodeWithScope with the supplied JavaScript code and scope, if and only if an equivalent value doesn't already exist in the array.

Specified by:
addCodeIfAbsent in interface EditableArray
Parameters:
code - the code
scope - the scope in which the JavaScript code should be evaulated, or null if there is no scope
Returns:
the EditableDocument for the scope, or null if the scope reference is null
See Also:
EditableArray.addCode(String, boolean)

toString

public String toString()
Overrides:
toString in class Object

ModeShape Distribution 3.0.0.Beta4

Copyright © 2008-2012 JBoss, a division of Red Hat. All Rights Reserved.