public interface ArrayBuilder extends Builder
Modifier and Type | Method and Description |
---|---|
ArrayBuilder |
add(boolean value)
Adds a boolean element.
|
ArrayBuilder |
add(byte[] data)
Adds a binary element using sub-type zero (the default).
|
ArrayBuilder |
add(byte subType,
byte[] data)
Adds a binary element.
|
ArrayBuilder |
add(Date timestamp)
Adds a timestamp element.
|
ArrayBuilder |
add(DocumentAssignable document)
Adds a pre-constructed document to the array.
|
ArrayBuilder |
add(DocumentElement document)
Adds a pre-constructed
DocumentElement to the array. |
ArrayBuilder |
add(double value)
Adds a double element.
|
ArrayBuilder |
add(ElementAssignable element)
Adds a pre-built element to the document.
|
ArrayBuilder |
add(int value)
Adds a integer (32-bit signed) element.
|
ArrayBuilder |
add(long value)
Adds a long (64-bit signed) element.
|
ArrayBuilder |
add(Object value)
Adds the value to the array after trying to coerce the value into the
best possible element type.
|
ArrayBuilder |
add(ObjectId id)
Adds an ObjectId element.
|
ArrayBuilder |
add(Pattern pattern)
Adds an ObjectId element.
|
ArrayBuilder |
add(String value)
Adds a string element.
|
ArrayBuilder |
add(String databaseName,
String collectionName,
ObjectId id)
Deprecated.
See BSON specification.
|
ArrayBuilder |
add(UUID uuid)
Adds a (sub-type 4)
UUID binary element. |
ArrayBuilder |
addBinary(byte[] data)
Adds a binary element using sub-type zero (the default).
|
ArrayBuilder |
addBinary(byte subType,
byte[] data)
Adds a binary element.
|
ArrayBuilder |
addBoolean(boolean value)
Adds a boolean element.
|
ArrayBuilder |
addDBPointer(String databaseName,
String collectionName,
ObjectId id)
Deprecated.
See BSON specification.
|
ArrayBuilder |
addDocument(DocumentAssignable document)
Adds a pre-constructed document to the array.
|
ArrayBuilder |
addDouble(double value)
Adds a double element.
|
ArrayBuilder |
addInteger(int value)
Adds a integer (32-bit signed) element.
|
ArrayBuilder |
addJavaScript(String code)
Adds a JavaScript element.
|
ArrayBuilder |
addJavaScript(String code,
DocumentAssignable scope)
Adds a JavaScript with Scope element.
|
ArrayBuilder |
addLegacyUuid(UUID uuid)
Adds a legacy (sub-type 3)
UUID binary element. |
ArrayBuilder |
addLong(long value)
Adds a long (64-bit signed) element.
|
ArrayBuilder |
addMaxKey()
Adds a minimum key value element.
|
ArrayBuilder |
addMinKey()
Adds a minimum key value element.
|
ArrayBuilder |
addMongoTimestamp(long value)
Adds a MongoDB Timestamp element.
|
ArrayBuilder |
addNull()
Adds a
null valued element. |
ArrayBuilder |
addObjectId(ObjectId id)
Adds an ObjectId element.
|
ArrayBuilder |
addRegularExpression(Pattern pattern)
Adds a regular expression element.
|
ArrayBuilder |
addRegularExpression(String pattern,
String options)
Adds a regular expression element.
|
ArrayBuilder |
addString(String value)
Adds a string element.
|
ArrayBuilder |
addSymbol(String symbol)
Adds a symbol element.
|
ArrayBuilder |
addTimestamp(long timestamp)
Adds a timestamp element.
|
ArrayBuilder |
addUuid(UUID uuid)
Adds a (sub-type 4)
UUID binary element. |
Element[] |
build()
Returns the array of
Element s being constructed. |
DocumentBuilder |
push()
Pushes a context for constructing a sub-document.
|
ArrayBuilder |
pushArray()
Pushes a context for constructing a sub-array.
|
ArrayBuilder |
reset()
Resets the builder back to an empty state.
|
ArrayBuilder add(boolean value)
This is a equivalent to addBoolean(boolean)
but less verbose.
value
- The boolean value.ArrayBuilder
for method chaining.ArrayBuilder add(byte subType, byte[] data) throws IllegalArgumentException
This is a equivalent to addBinary(byte, byte[])
but less
verbose.
subType
- The sub-type for the binary data.data
- The binary value.ArrayBuilder
for method chaining.IllegalArgumentException
- If data
is null
.ArrayBuilder add(byte[] data)
This is a equivalent to addBinary(byte[])
but will insert a
NullElement
if the data
is null
instead of
throwing an IllegalArgumentException
.
data
- The binary value.ArrayBuilder
for method chaining.ArrayBuilder add(Date timestamp)
This is a equivalent to addTimeStamp(timestamp.getTime())
but will insert a NullElement
if the timestamp
is null
instead of throwing an
IllegalArgumentException
.
timestamp
- The number of milliseconds since the Unix epoch.ArrayBuilder
for method chaining.ArrayBuilder add(DocumentAssignable document)
This is a equivalent to addDocument(DocumentAssignable)
but will
insert a NullElement
if the document
is null
instead of throwing an IllegalArgumentException
.
document
- The document to add to the array.ArrayBuilder
for method chaining.ArrayBuilder add(DocumentElement document)
DocumentElement
to the array.
This is a equivalent to addDocument(DocumentAssignable)
but will
insert a NullElement
if the document
is null
instead of throwing an IllegalArgumentException
.
Added to resolve ambiguity between the DocumentElement
being both
a DocumentAssignable
and an ElementAssignable
.
document
- The document to add to the array.ArrayBuilder
for method chaining.ArrayBuilder add(double value)
This is a equivalent to addDouble(double)
but less verbose.
value
- The double value.ArrayBuilder
for method chaining.ArrayBuilder add(ElementAssignable element) throws IllegalArgumentException
element
- The element to add.ArrayBuilder
for method chaining.IllegalArgumentException
- If element
is null
.ArrayBuilder add(int value)
This is a equivalent to addInteger(int)
but less verbose.
value
- The integer value.ArrayBuilder
for method chaining.ArrayBuilder add(long value)
This is a equivalent to addLong(long)
but less verbose.
value
- The long value.ArrayBuilder
for method chaining.ArrayBuilder add(Object value) throws IllegalArgumentException
IllegalArgumentException
is thrown.
This method does type inspection which can be slow. It is generally much faster to use the type specific methods of this interface.
value
- The Object value to coerce into an element.ArrayBuilder
for method chaining.IllegalArgumentException
- If the value
cannot be coerced into an element type.ArrayBuilder add(ObjectId id)
This is a equivalent to addObjectId(ObjectId)
but will insert a
NullElement
if the id
is null
instead of
throwing an IllegalArgumentException
.
id
- The ObjectId to add.ArrayBuilder
for method chaining.ArrayBuilder add(Pattern pattern)
This is a equivalent to addRegularExpression(Pattern)
but will
insert a NullElement
if the pattern
is null
instead of throwing an IllegalArgumentException
.
pattern
- The pattern for the regular expression.ArrayBuilder
for method chaining.ArrayBuilder add(String value)
This is a equivalent to addString(String)
but will insert a
NullElement
if the value
is null
instead of
throwing an IllegalArgumentException
.
value
- The string value.ArrayBuilder
for method chaining.@Deprecated ArrayBuilder add(String databaseName, String collectionName, ObjectId id) throws IllegalArgumentException
This is a equivalent to addDBPointer(String, String, ObjectId)
but less verbose.
databaseName
- The name of the database containing the document.collectionName
- The name of the collection containing the document.id
- The id for the document.ArrayBuilder
for method chaining.IllegalArgumentException
- If databaseName
, collectionName
, or
id
is null
.ArrayBuilder add(UUID uuid)
UUID
binary element.
This is a equivalent to addUuid(UUID)
but will insert a
NullElement
if the uuid
is null
instead of
throwing an IllegalArgumentException
.
uuid
- The UUID
to add.ArrayBuilder
for method chaining.ArrayBuilder addBinary(byte subType, byte[] data) throws IllegalArgumentException
subType
- The sub-type for the binary data.data
- The binary value.ArrayBuilder
for method chaining.IllegalArgumentException
- If data
is null
.ArrayBuilder addBinary(byte[] data) throws IllegalArgumentException
This method throws an IllegalArgumentException
if the
data
is null
. If you would prefer a
NullElement
be inserted in the document use the
add(byte[])
method instead.
data
- The binary value.ArrayBuilder
for method chaining.IllegalArgumentException
- If data
is null
.ArrayBuilder addBoolean(boolean value)
value
- The boolean value.ArrayBuilder
for method chaining.@Deprecated ArrayBuilder addDBPointer(String databaseName, String collectionName, ObjectId id) throws IllegalArgumentException
databaseName
- The name of the database containing the document.collectionName
- The name of the collection containing the document.id
- The id for the document.ArrayBuilder
for method chaining.IllegalArgumentException
- If databaseName
, collectionName
, or
id
is null
.ArrayBuilder addDocument(DocumentAssignable document) throws IllegalArgumentException
This method throws an IllegalArgumentException
if the
document
is null
. If you would prefer a
NullElement
be inserted in the document use the
add(DocumentAssignable)
method instead.
document
- The document to add to the array.ArrayBuilder
for method chaining.IllegalArgumentException
- If document
is null
.ArrayBuilder addDouble(double value)
value
- The double value.ArrayBuilder
for method chaining.ArrayBuilder addInteger(int value)
value
- The integer value.ArrayBuilder
for method chaining.ArrayBuilder addJavaScript(String code) throws IllegalArgumentException
code
- The java script code.ArrayBuilder
for method chaining.IllegalArgumentException
- If code
is null
.ArrayBuilder addJavaScript(String code, DocumentAssignable scope) throws IllegalArgumentException
code
- The java script code.scope
- The scope for the JacaScript code.ArrayBuilder
for method chaining.IllegalArgumentException
- If code
or scope
is null
.ArrayBuilder addLegacyUuid(UUID uuid) throws IllegalArgumentException
UUID
binary element.
This method throws an IllegalArgumentException
if the
uuid
is null
.
uuid
- The UUID
to add.ArrayBuilder
for method chaining.IllegalArgumentException
- If the uuid
is null
.ArrayBuilder addLong(long value)
value
- The long value.ArrayBuilder
for method chaining.ArrayBuilder addMaxKey()
ArrayBuilder
for method chaining.ArrayBuilder addMinKey()
ArrayBuilder
for method chaining.ArrayBuilder addMongoTimestamp(long value)
value
- The mongoDB timstamp value.ArrayBuilder
for method chaining.ArrayBuilder addNull()
null
valued element.ArrayBuilder
for method chaining.ArrayBuilder addObjectId(ObjectId id) throws IllegalArgumentException
This method throws an IllegalArgumentException
if the id
is null
. If you would prefer a NullElement
be
inserted in the document use the add(ObjectId)
method instead.
id
- The ObjectId to add.ArrayBuilder
for method chaining.IllegalArgumentException
- If id
is null
.ArrayBuilder addRegularExpression(Pattern pattern) throws IllegalArgumentException
This method throws an IllegalArgumentException
if the
pattern
is null
. If you would prefer a
NullElement
be inserted in the document use the
add(Pattern)
method instead.
pattern
- The pattern for the regular expression.ArrayBuilder
for method chaining.IllegalArgumentException
- If pattern
is null
.ArrayBuilder addRegularExpression(String pattern, String options) throws IllegalArgumentException
pattern
- The pattern for the regular expression.options
- The regular expression options. See the BSON specification for
details. These may be null
.ArrayBuilder
for method chaining.IllegalArgumentException
- If pattern
is null
. The options may be
null
.ArrayBuilder addString(String value) throws IllegalArgumentException
This method throws an IllegalArgumentException
if the
value
is null
. If you would prefer a
NullElement
be inserted in the document use the
add(String)
method instead.
value
- The string value.ArrayBuilder
for method chaining.IllegalArgumentException
- If value
is null
.ArrayBuilder addSymbol(String symbol) throws IllegalArgumentException
symbol
- The symbol value.ArrayBuilder
for method chaining.IllegalArgumentException
- If symbol
is null
.ArrayBuilder addTimestamp(long timestamp)
timestamp
- The number of milliseconds since the Unix epoch.ArrayBuilder
for method chaining.ArrayBuilder addUuid(UUID uuid) throws IllegalArgumentException
UUID
binary element.
This method throws an IllegalArgumentException
if the
uuid
is null
. If you would prefer a
NullElement
be inserted in the array use the add(UUID)
method instead.
uuid
- The UUID
to add.ArrayBuilder
for method chaining.IllegalArgumentException
- If the uuid
is null
.Element[] build()
Element
s being constructed.Element
.DocumentBuilder push()
ArrayBuilder
for method chaining.ArrayBuilder pushArray()
ArrayBuilder
for method chaining.ArrayBuilder reset()
Overridden to return an ArrayBuilder
instance.
Copyright © 2011–2014 Allanbank Consulting, Inc.. All rights reserved.