ModeShape Distribution 3.0.0.Beta4

org.infinispan.schematic.document
Interface EditableArray

All Superinterfaces:
Array, Collection<Object>, Document, EditableDocument, Iterable<Object>, List<Object>, Serializable
All Known Implementing Classes:
ArrayEditor, ObservableArrayEditor

public interface EditableArray
extends EditableDocument, Array


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
 
Method Summary
 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.
 EditableDocument addValueIfAbsent(Object value)
          Add the supplied value to this array if and only if there is not already an equivalent value in the array.
 EditableArray getArray(String name)
          Get the existing array value in this array for the given index.
 EditableDocument getDocument(String name)
          Get the existing document value in this array for the given index.
 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 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.
 
Methods inherited from interface org.infinispan.schematic.document.EditableDocument
getOrCreateArray, getOrCreateDocument, putAll, putAll, remove, removeAll, setArray, unwrap
 
Methods inherited from interface org.infinispan.schematic.document.Array
clone, getEntries
 
Methods inherited from interface org.infinispan.schematic.document.Document
containsAll, containsField, fields, get, getBinary, getBoolean, getBoolean, getCode, getCodeWithScope, getDouble, getDouble, getInteger, getInteger, getLong, getLong, getMaxKey, getMinKey, getNumber, getNumber, getObjectId, getPattern, getString, getString, getSymbol, getType, getUuid, getUuid, isEmpty, isNull, isNullOrMissing, keySet, size, toMap, with, with, withVariablesReplaced, withVariablesReplacedWithSystemProperties
 
Methods inherited from interface java.util.List
add, add, addAll, addAll, clear, contains, containsAll, equals, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, retainAll, set, size, subList, toArray, toArray
 

Method Detail

set

EditableArray set(String name,
                  Object value)
Set the value for the field with the given name to the supplied value.

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

setValue

EditableArray setValue(int index,
                       Object value)
Set the value for the field with the given name to the supplied value.

Parameters:
index - The index in the array
value - the new value
Returns:
This array, to allow for chaining methods

addValue

EditableArray addValue(int index,
                       Object value)
Insert the value for the field with the given name to the supplied value.

Parameters:
index - The index in the array
value - the new value
Returns:
This array, to allow for chaining methods

addValue

EditableArray addValue(Object value)
Add the supplied value to this array.

Parameters:
value - the new value
Returns:
This array, to allow for chaining methods

addValueIfAbsent

EditableDocument addValueIfAbsent(Object value)
Add the supplied value to this array if and only if there is not already an equivalent value in the array.

Parameters:
value - the value
Returns:
This array, to allow for chaining methods

setBoolean

EditableArray setBoolean(String name,
                         boolean value)
Set the value for the field at the given index to the supplied boolean value.

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

EditableArray setNumber(String name,
                        int value)
Set the value for the field at the given index to the supplied integer value.

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

EditableArray setNumber(String name,
                        long value)
Set the value for the field at the given index to the supplied long value.

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

EditableArray setNumber(String name,
                        float value)
Set the value for the field at the given index to the supplied float value.

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

EditableArray setNumber(String name,
                        double value)
Set the value for the field at the given index to the supplied double value.

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

EditableArray setString(String name,
                        String value)
Set the value for the field at the given index to the supplied string value.

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

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. 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 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:
setString(String, String)

setDocument

EditableDocument setDocument(String name)
Set the value for the field at the given index to be a new, empty Document.

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

EditableDocument setDocument(String name,
                             Document document)
Set the value for the field at the given index to be the supplied Document.

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.

getDocument

EditableDocument getDocument(String name)
Get the existing document value in this array for the given index.

Specified by:
getDocument in interface Document
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

setArray

EditableArray setArray(String name)
Set the value for the field at the given index to be a new, empty array.

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

EditableArray setArray(String name,
                       Array array)
Set the value for the field at the given index to be the supplied array.

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.

getArray

EditableArray getArray(String name)
Get the existing array value in this array for the given index.

Specified by:
getArray in interface Document
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

setDate

EditableArray setDate(String name,
                      Date value)
Set the value for the field at the given index to the supplied date value.

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

EditableArray setDate(String name,
                      String isoDate)
                      throws ParseException
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 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

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. 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 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:
setDate(String, Date)

setObjectId

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. 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 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:
setObjectId(String, byte[]), setObjectId(String, int, int, int, int)

setObjectId

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. 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 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:
setObjectId(String, String), setObjectId(String, int, int, int, int)

setObjectId

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. 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 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:
setObjectId(String, String), setObjectId(String, byte[])

setRegularExpression

EditableArray setRegularExpression(String name,
                                   String pattern)
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 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:
setRegularExpression(String, String, int)

setRegularExpression

EditableArray setRegularExpression(String name,
                                   String pattern,
                                   int flags)
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 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:
setRegularExpression(String, String)

setNull

EditableArray setNull(String name)
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 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

EditableArray setBinary(String name,
                        byte type,
                        byte[] data)
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 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

EditableArray setUuid(String name,
                      UUID uuid)
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 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

EditableDocument setCode(String name,
                         String code,
                         boolean includeScope)
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 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:
setCode(String, String, Document)

setCode

EditableDocument setCode(String name,
                         String code,
                         Document scope)
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 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:
setCode(String, String, boolean)

setBoolean

EditableArray setBoolean(int index,
                         boolean value)
Set the value for the field at the given index to the supplied boolean value.

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

EditableArray setNumber(int index,
                        int value)
Set the value for the field at the given index to the supplied integer value.

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

EditableArray setNumber(int index,
                        long value)
Set the value for the field at the given index to the supplied long value.

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

EditableArray setNumber(int index,
                        float value)
Set the value for the field at the given index to the supplied float value.

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

EditableArray setNumber(int index,
                        double value)
Set the value for the field at the given index to the supplied double value.

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

EditableArray setString(int index,
                        String value)
Set the value for the field at the given index to the supplied string value.

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

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. 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.

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:
setString(int, String)

setDocument

EditableDocument setDocument(int index)
Set the value for the field at the given index to be a new, empty Document.

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

EditableDocument setDocument(int index,
                             Document document)
Set the value for the field at the given index to be the supplied Document.

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

EditableArray setArray(int index)
Set the value for the field at the given index to be a new, empty array.

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

EditableArray setArray(int index,
                       Array array)
Set the value for the field at the given index to be the supplied array.

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

EditableArray setDate(int index,
                      Date value)
Set the value for the field at the given index to the supplied date value.

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

EditableArray setDate(int index,
                      String isoDate)
                      throws ParseException
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:

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

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. Note that Date values are recommended for most purposes, as they are better suited to most applications' representations of time instants.

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:
setDate(int, Date)

setObjectId

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. 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" }
 

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:
setObjectId(int, byte[]), setObjectId(int, int, int, int, int)

setObjectId

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. 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" }
 

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:
setObjectId(int, String), setObjectId(int, int, int, int, int)

setObjectId

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. 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" }
 

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:
setObjectId(int, String), setObjectId(int, byte[])

setRegularExpression

EditableArray setRegularExpression(int index,
                                   String pattern)
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.

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:
setRegularExpression(int, String, int)

setRegularExpression

EditableArray setRegularExpression(int index,
                                   String pattern,
                                   int flags)
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.

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:
setRegularExpression(int, String)

setNull

EditableArray setNull(int index)
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.

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

EditableArray setBinary(int index,
                        byte type,
                        byte[] data)
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.

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

EditableArray setUuid(int index,
                      UUID uuid)
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.

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

EditableDocument setCode(int index,
                         String code,
                         boolean includeScope)
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.

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:
setCode(int, String, Document)

setCode

EditableDocument setCode(int index,
                         String code,
                         Document scope)
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.

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:
setCode(int, String, boolean)

addBoolean

EditableArray addBoolean(int index,
                         boolean value)
Insert the value for the field at the given index to the supplied boolean value.

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

EditableArray addNumber(int index,
                        int value)
Insert the value for the field at the given index to the supplied integer value.

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

EditableArray addNumber(int index,
                        long value)
Insert the value for the field at the given index to the supplied long value.

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

EditableArray addNumber(int index,
                        float value)
Insert the value for the field at the given index to the supplied float value.

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

EditableArray addNumber(int index,
                        double value)
Insert the value for the field at the given index to the supplied double value.

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

EditableArray addString(int index,
                        String value)
Insert the value for the field at the given index to the supplied string value.

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

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. 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.

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:
setString(int, String)

addDocument

EditableDocument addDocument(int index)
Insert the value for the field at the given index to be a new, empty Document.

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

EditableDocument addDocument(int index,
                             Document document)
Insert the value for the field at the given index to be the supplied Document.

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

EditableArray addArray(int index)
Insert the value for the field at the given index to be a new, empty array.

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

EditableArray addArray(int index,
                       Array array)
Insert the value for the field at the given index to be the supplied array.

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

EditableArray addDate(int index,
                      Date value)
Insert the value for the field at the given index to the supplied date value.

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

EditableArray addDate(int index,
                      String isoDate)
                      throws ParseException
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:

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

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. Note that Date values are recommended for most purposes, as they are better suited to most applications' representations of time instants.

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:
setDate(int, Date)

addObjectId

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. 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" }
 

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:
setObjectId(int, byte[]), setObjectId(int, int, int, int, int)

addObjectId

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. 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" }
 

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:
setObjectId(int, String), setObjectId(int, int, int, int, int)

addObjectId

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. 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" }
 

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:
setObjectId(int, String), setObjectId(int, byte[])

addRegularExpression

EditableArray addRegularExpression(int index,
                                   String pattern)
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.

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:
setRegularExpression(int, String, int)

addRegularExpression

EditableArray addRegularExpression(int index,
                                   String pattern,
                                   int flags)
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.

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:
setRegularExpression(int, String)

addNull

EditableArray addNull(int index)
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.

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

EditableArray addBinary(int index,
                        byte type,
                        byte[] data)
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.

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

EditableArray addUuid(int index,
                      UUID uuid)
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.

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

EditableDocument addCode(int index,
                         String code,
                         boolean includeScope)
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.

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:
setCode(int, String, Document)

addCode

EditableDocument addCode(int index,
                         String code,
                         Document scope)
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.

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:
setCode(int, String, boolean)

addBoolean

EditableArray addBoolean(boolean value)
Adds the supplied boolean value to this array.

Parameters:
value - the new value for the field
Returns:
This document, to allow for chaining methods

addNumber

EditableArray addNumber(int value)
Adds the supplied integer value to this array.

Parameters:
value - the new value for the field
Returns:
This document, to allow for chaining methods

addNumber

EditableArray addNumber(long value)
Adds the supplied long value to this array.

Parameters:
value - the new value for the field
Returns:
This document, to allow for chaining methods

addNumber

EditableArray addNumber(float value)
Adds the supplied float value to this array.

Parameters:
value - the new value for the field
Returns:
This document, to allow for chaining methods

addNumber

EditableArray addNumber(double value)
Adds the supplied double value to this array.

Parameters:
value - the new value for the field
Returns:
This document, to allow for chaining methods

addString

EditableArray addString(String value)
Adds the supplied string value to this array.

Parameters:
value - the new value for the field
Returns:
This document, to allow for chaining methods

addSymbol

EditableArray addSymbol(String value)
Adds to this array a Symbol with the supplied string.

Parameters:
value - the new value for the field
Returns:
This document, to allow for chaining methods
See Also:
addString(String)

addDocument

EditableDocument addDocument()
Adds to this array a new empty document.

Returns:
The editable document that was just created; never null

addDocument

EditableDocument addDocument(Document document)
Adds to this array the supplied document.

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

EditableArray addArray()
Adds to this array a new empty array.

Returns:
The editable array that was just created; never null

addArray

EditableArray addArray(Array array)
Adds to this array the supplied array.

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

EditableArray addDate(Date value)
Adds to this array the supplied date.

Parameters:
value - the new value for the field
Returns:
This document, to allow for chaining methods

addDate

EditableArray addDate(String isoDate)
                      throws ParseException
Adds to this array a Date with the supplied ISO-8601 string.

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:
addDate(Date)

addTimestamp

EditableArray addTimestamp(int timeInSeconds,
                           int increment)
Adds to this array a Timestamp with the supplied time in seconds and increment value.

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:
addDate(Date)

addObjectId

EditableArray addObjectId(String hex)
Adds to this array an ObjectId with the supplied hexadecimal string.

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

addObjectId

EditableArray addObjectId(byte[] bytes)
Adds to this array an ObjectId with the supplied 12-byte value.

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

addObjectId

EditableArray addObjectId(int time,
                          int machine,
                          int process,
                          int inc)
Adds to this array an ObjectId with the supplied time, machine, process, and increment.

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:
addObjectId(String), addObjectId(byte[])

addRegularExpression

EditableArray addRegularExpression(String pattern)
Adds to this array a regular expression with the supplied pattern string.

Parameters:
pattern - the regular expression pattern string
Returns:
This document, to allow for chaining methods

addRegularExpression

EditableArray addRegularExpression(String pattern,
                                   int flags)
Adds to this array a regular expression with the supplied pattern string and option flags.

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

EditableArray addNull()
Adds to this array a Null value.

Returns:
This document, to allow for chaining methods
See Also:
Document.isNull(String), Document.isNullOrMissing(String)

addBinary

EditableArray addBinary(byte type,
                        byte[] data)
Adds to this array a Binary value with the supplied type and content.

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

EditableArray addUuid(UUID uuid)
Adds to this array the supplied UUID.

Parameters:
uuid - the UUID value
Returns:
This document, to allow for chaining methods

addCode

EditableDocument addCode(String code,
                         boolean includeScope)
Adds to this array a Code with the supplied JavaScript code.

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:
addCode(String, Document)

addCode

EditableDocument addCode(String code,
                         Document scope)
Adds to this array a CodeWithScope with the supplied JavaScript code and scope.

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:
addCode(String, boolean)

addBooleanIfAbsent

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.

Parameters:
value - the new value for the field
Returns:
This document, to allow for chaining methods

addNumberIfAbsent

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.

Parameters:
value - the new value for the field
Returns:
This document, to allow for chaining methods

addNumberIfAbsent

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.

Parameters:
value - the new value for the field
Returns:
This document, to allow for chaining methods

addNumberIfAbsent

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.

Parameters:
value - the new value for the field
Returns:
This document, to allow for chaining methods

addNumberIfAbsent

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.

Parameters:
value - the new value for the field
Returns:
This document, to allow for chaining methods

addStringIfAbsent

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.

Parameters:
value - the new value for the field
Returns:
This document, to allow for chaining methods

addSymbolIfAbsent

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.

Parameters:
value - the new value for the field
Returns:
This document, to allow for chaining methods
See Also:
addString(String)

addDocumentIfAbsent

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.

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

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.

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

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.

Parameters:
value - the new value for the field
Returns:
This document, to allow for chaining methods

addDateIfAbsent

EditableArray addDateIfAbsent(String isoDate)
                              throws ParseException
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.

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:
addDate(Date)

addTimestampIfAbsent

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.

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:
addDate(Date)

addObjectIdIfAbsent

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.

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

addObjectIdIfAbsent

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.

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

addObjectIdIfAbsent

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.

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:
addObjectId(String), addObjectId(byte[])

addRegularExpressionIfAbsent

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.

Parameters:
pattern - the regular expression pattern string
Returns:
This document, to allow for chaining methods

addRegularExpressionIfAbsent

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.

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

EditableArray addNullIfAbsent()
Adds to this array a Null value, if and only if there is not already a null value in the array.

Returns:
This document, to allow for chaining methods
See Also:
Document.isNull(String), Document.isNullOrMissing(String)

addBinaryIfAbsent

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.

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

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.

Parameters:
uuid - the UUID value
Returns:
This document, to allow for chaining methods

addCodeIfAbsent

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.

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:
addCode(String, boolean)

ModeShape Distribution 3.0.0.Beta4

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