public class ImmutableDocument extends AbstractDocument
Documents normally returned from the document builders have the ability to be
modified by injecting an _id
field into the document. This document
class does not have that ability.
Most users will not need to use this class except when creating static documents within classes. The intended usage is then to use the builder when constructing the immutable document:
public static final Document QUERY; ... static { DocumentBuilder builder = BuilderFactory.start(); builder.add(...); ... QUERY = new ImmutableDocument(builder); }
ELEMENT_TYPE, EMPTY_ELEMENTS
Constructor and Description |
---|
ImmutableDocument(DocumentAssignable document)
Constructs a new
ImmutableDocument . |
ImmutableDocument(DocumentAssignable document,
long size)
Constructs a new
ImmutableDocument . |
Modifier and Type | Method and Description |
---|---|
protected Map<String,Element> |
getElementMap()
Returns a map from the element names to the elements in the document.
|
List<Element> |
getElements()
Returns the elements in the document.
|
long |
size()
Returns the size of the document when encoded as bytes.
|
public ImmutableDocument(DocumentAssignable document)
ImmutableDocument
.document
- The elements for the BSON document.public ImmutableDocument(DocumentAssignable document, long size)
ImmutableDocument
.document
- The elements for the BSON document.size
- The size of the document when encoded in bytes. If not known
then use the
ImmutableDocument(DocumentAssignable)
constructor instead.public List<Element> getElements()
getElements
in interface Document
getElements
in class AbstractDocument
public long size()
protected Map<String,Element> getElementMap()
getElementMap
in class AbstractDocument
Copyright © 2011–2014 Allanbank Consulting, Inc.. All rights reserved.