public class ArrayBuilderImpl extends AbstractBuilder implements ArrayBuilder
AbstractBuilder.BuilderElementASSERTIONS_ENABLED, BUILDER_ELEMENT_CLASS, myElements, mySize| Constructor and Description |
|---|
ArrayBuilderImpl()
Creates a new
ArrayBuilderImpl. |
ArrayBuilderImpl(AbstractBuilder outerBuilder)
Creates a new
ArrayBuilderImpl. |
| 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.
|
ArrayBuilder |
add(UUID uuid)
Adds a (sub-type 4)
UUID binary element. |
ArrayBuilder |
addBinary(byte[] value)
Adds a binary element using sub-type zero (the default).
|
ArrayBuilder |
addBinary(byte subType,
byte[] value)
Adds a binary element.
|
ArrayBuilder |
addBoolean(boolean value)
Adds a boolean element.
|
ArrayBuilder |
addDBPointer(String databaseName,
String collectionName,
ObjectId id)
Deprecated.
|
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
Elements being constructed. |
ArrayElement |
build(String name)
Constructs the final form of the element 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.
|
String |
toString() |
doPush, doPushArray, pop, subElementspublic ArrayBuilderImpl()
ArrayBuilderImpl.public ArrayBuilderImpl(AbstractBuilder outerBuilder)
ArrayBuilderImpl.outerBuilder - The outer builder scope.public ArrayBuilder add(boolean value)
This is a equivalent to ArrayBuilder.addBoolean(boolean) but less verbose.
add in interface ArrayBuildervalue - The boolean value.ArrayBuilder for method chaining.public ArrayBuilder add(byte subType, byte[] data) throws IllegalArgumentException
This is a equivalent to ArrayBuilder.addBinary(byte, byte[]) but less
verbose.
add in interface ArrayBuildersubType - The sub-type for the binary data.data - The binary value.ArrayBuilder for method chaining.IllegalArgumentException - If data is null.public ArrayBuilder add(byte[] data)
This is a equivalent to ArrayBuilder.addBinary(byte[]) but will insert a
NullElement if the data is null instead of
throwing an IllegalArgumentException.
add in interface ArrayBuilderdata - The binary value.ArrayBuilder for method chaining.public 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.
add in interface ArrayBuildertimestamp - The number of milliseconds since the Unix epoch.ArrayBuilder for method chaining.public ArrayBuilder add(DocumentAssignable document)
This is a equivalent to ArrayBuilder.addDocument(DocumentAssignable) but will
insert a NullElement if the document is null
instead of throwing an IllegalArgumentException.
add in interface ArrayBuilderdocument - The document to add to the array.ArrayBuilder for method chaining.public ArrayBuilder add(DocumentElement document)
DocumentElement to the array.
This is a equivalent to ArrayBuilder.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.
add in interface ArrayBuilderdocument - The document to add to the array.ArrayBuilder for method chaining.public ArrayBuilder add(double value)
This is a equivalent to ArrayBuilder.addDouble(double) but less verbose.
add in interface ArrayBuildervalue - The double value.ArrayBuilder for method chaining.public ArrayBuilder add(ElementAssignable element) throws IllegalArgumentException
add in interface ArrayBuilderelement - The element to add.ArrayBuilder for method chaining.IllegalArgumentException - If element is null.public ArrayBuilder add(int value)
This is a equivalent to ArrayBuilder.addInteger(int) but less verbose.
add in interface ArrayBuildervalue - The integer value.ArrayBuilder for method chaining.public ArrayBuilder add(long value)
This is a equivalent to ArrayBuilder.addLong(long) but less verbose.
add in interface ArrayBuildervalue - The long value.ArrayBuilder for method chaining.public 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.
add in interface ArrayBuildervalue - The Object value to coerce into an element.ArrayBuilder for method chaining.IllegalArgumentException - If the value cannot be coerced into an element type.public ArrayBuilder add(ObjectId id)
This is a equivalent to ArrayBuilder.addObjectId(ObjectId) but will insert a
NullElement if the id is null instead of
throwing an IllegalArgumentException.
add in interface ArrayBuilderid - The ObjectId to add.ArrayBuilder for method chaining.public ArrayBuilder add(Pattern pattern)
This is a equivalent to ArrayBuilder.addRegularExpression(Pattern) but will
insert a NullElement if the pattern is null
instead of throwing an IllegalArgumentException.
add in interface ArrayBuilderpattern - The pattern for the regular expression.ArrayBuilder for method chaining.public ArrayBuilder add(String value)
This is a equivalent to ArrayBuilder.addString(String) but will insert a
NullElement if the value is null instead of
throwing an IllegalArgumentException.
add in interface ArrayBuildervalue - The string value.ArrayBuilder for method chaining.@Deprecated public ArrayBuilder add(String databaseName, String collectionName, ObjectId id) throws IllegalArgumentException
This is a equivalent to ArrayBuilder.addDBPointer(String, String, ObjectId)
but less verbose.
add in interface ArrayBuilderdatabaseName - 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.public ArrayBuilder add(UUID uuid) throws IllegalArgumentException
UUID binary element.
This is a equivalent to ArrayBuilder.addUuid(UUID) but will insert a
NullElement if the uuid is null instead of
throwing an IllegalArgumentException.
add in interface ArrayBuilderuuid - The UUID to add.ArrayBuilder for method chaining.IllegalArgumentExceptionpublic ArrayBuilder addBinary(byte subType, byte[] value) throws IllegalArgumentException
addBinary in interface ArrayBuildersubType - The sub-type for the binary data.value - The binary value.ArrayBuilder for method chaining.IllegalArgumentException - If data is null.public ArrayBuilder addBinary(byte[] value) 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
ArrayBuilder.add(byte[]) method instead.
addBinary in interface ArrayBuildervalue - The binary value.ArrayBuilder for method chaining.IllegalArgumentException - If data is null.public ArrayBuilder addBoolean(boolean value)
addBoolean in interface ArrayBuildervalue - The boolean value.ArrayBuilder for method chaining.@Deprecated public ArrayBuilder addDBPointer(String databaseName, String collectionName, ObjectId id) throws IllegalArgumentException
addDBPointer in interface ArrayBuilderdatabaseName - 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.public 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
ArrayBuilder.add(DocumentAssignable) method instead.
addDocument in interface ArrayBuilderdocument - The document to add to the array.ArrayBuilder for method chaining.IllegalArgumentException - If document is null.public ArrayBuilder addDouble(double value)
addDouble in interface ArrayBuildervalue - The double value.ArrayBuilder for method chaining.public ArrayBuilder addInteger(int value)
addInteger in interface ArrayBuildervalue - The integer value.ArrayBuilder for method chaining.public ArrayBuilder addJavaScript(String code) throws IllegalArgumentException
addJavaScript in interface ArrayBuildercode - The java script code.ArrayBuilder for method chaining.IllegalArgumentException - If code is null.public ArrayBuilder addJavaScript(String code, DocumentAssignable scope) throws IllegalArgumentException
addJavaScript in interface ArrayBuildercode - The java script code.scope - The scope for the JacaScript code.ArrayBuilder for method chaining.IllegalArgumentException - If code or scope is null.public ArrayBuilder addLegacyUuid(UUID uuid) throws IllegalArgumentException
UUID binary element.
This method throws an IllegalArgumentException if the
uuid is null.
addLegacyUuid in interface ArrayBuilderuuid - The UUID to add.ArrayBuilder for method chaining.IllegalArgumentException - If the uuid is null.public ArrayBuilder addLong(long value)
addLong in interface ArrayBuildervalue - The long value.ArrayBuilder for method chaining.public ArrayBuilder addMaxKey()
addMaxKey in interface ArrayBuilderArrayBuilder for method chaining.public ArrayBuilder addMinKey()
addMinKey in interface ArrayBuilderArrayBuilder for method chaining.public ArrayBuilder addMongoTimestamp(long value)
addMongoTimestamp in interface ArrayBuildervalue - The mongoDB timstamp value.ArrayBuilder for method chaining.public ArrayBuilder addNull()
null valued element.addNull in interface ArrayBuilderArrayBuilder for method chaining.public 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 ArrayBuilder.add(ObjectId) method instead.
addObjectId in interface ArrayBuilderid - The ObjectId to add.ArrayBuilder for method chaining.IllegalArgumentException - If id is null.public 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
ArrayBuilder.add(Pattern) method instead.
addRegularExpression in interface ArrayBuilderpattern - The pattern for the regular expression.ArrayBuilder for method chaining.IllegalArgumentException - If pattern is null.public ArrayBuilder addRegularExpression(String pattern, String options) throws IllegalArgumentException
addRegularExpression in interface ArrayBuilderpattern - 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.public 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
ArrayBuilder.add(String) method instead.
addString in interface ArrayBuildervalue - The string value.ArrayBuilder for method chaining.IllegalArgumentException - If value is null.public ArrayBuilder addSymbol(String symbol) throws IllegalArgumentException
addSymbol in interface ArrayBuildersymbol - The symbol value.ArrayBuilder for method chaining.IllegalArgumentException - If symbol is null.public ArrayBuilder addTimestamp(long timestamp)
addTimestamp in interface ArrayBuildertimestamp - The number of milliseconds since the Unix epoch.ArrayBuilder for method chaining.public 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 ArrayBuilder.add(UUID)
method instead.
addUuid in interface ArrayBuilderuuid - The UUID to add.ArrayBuilder for method chaining.IllegalArgumentException - If the uuid is null.public Element[] build()
Elements being constructed.
Overridden to return an array of the built elements.
build in interface ArrayBuilderElement.public ArrayElement build(String name)
Overridden to return an ArrayElement.
build in class AbstractBuildername - The name of the element.public DocumentBuilder push()
push in interface ArrayBuilderArrayBuilder for method chaining.public ArrayBuilder pushArray()
pushArray in interface ArrayBuilderArrayBuilder for method chaining.public ArrayBuilder reset()
reset in interface ArrayBuilderreset in interface Builderreset in class AbstractBuilderCopyright © 2011–2014 Allanbank Consulting, Inc.. All rights reserved.