public class RootDocument extends Object implements Document
| Modifier and Type | Field and Description |
|---|---|
protected static Class<Element> |
ELEMENT_TYPE
The base type (interface) for all elements.
|
static List<Element> |
EMPTY_ELEMENTS
The empty list of elements.
|
| Constructor and Description |
|---|
RootDocument(Element... elements)
Constructs a new
RootDocument. |
RootDocument(List<Element> elements)
Constructs a new
RootDocument. |
RootDocument(List<Element> elements,
boolean idPresent)
Constructs a new
RootDocument. |
| Modifier and Type | Method and Description |
|---|---|
void |
accept(Visitor visitor)
Accepts the visitor and calls the
Visitor.visitDocument(java.lang.String, java.util.List<com.allanbank.mongodb.bson.Element>) method. |
Document |
asDocument()
Converts the object into a document.
|
boolean |
contains(String name)
Returns true if the document contains an element with the specified name.
|
boolean |
equals(Object object)
Determines if the passed object is of this same type as this object and
if so that its fields are equal.
|
<E extends Element> |
find(Class<E> clazz,
String... nameRegexs)
Returns the elements matching the path of regular expressions.
|
List<Element> |
find(String... nameRegexs)
Returns the elements matching the path of regular expressions.
|
<E extends Element> |
findFirst(Class<E> clazz,
String... nameRegexs)
Returns the first element matching the path of regular expressions.
|
Element |
findFirst(String... nameRegexs)
Returns the first element matching the path of regular expressions.
|
<E extends Element> |
get(Class<E> clazz,
String name)
Returns the element with the specified name and type or null if no
element with that name and type exists.
|
Element |
get(String name)
Returns the element with the specified name or null if no element with
that name exists.
|
List<Element> |
getElements()
Returns the elements in the document.
|
int |
hashCode()
Computes a reasonable hash code.
|
void |
injectId()
Adds an
ObjectIdElement to the head of the document. |
Iterator<Element> |
iterator()
Returns an iterator over the documents elements.
|
<E extends Element> |
queryPath(Class<E> clazz,
String... nameRegexs)
Deprecated.
Use the
find(Class,String...) method instead. Will
be removed after the 1.1.0 release. |
List<Element> |
queryPath(String... nameRegexs)
Deprecated.
Use the
find(Class,String...) method instead. Will
be removed after the 1.1.0 release. |
String |
toString()
String form of the object.
|
public RootDocument(Element... elements)
RootDocument.elements - The elements for the BSON document.public RootDocument(List<Element> elements)
RootDocument.elements - The elements for the BSON document.public RootDocument(List<Element> elements, boolean idPresent)
RootDocument.elements - The elements for the BSON document.idPresent - If true then there is an _id element in the list of elements.public void accept(Visitor visitor)
Visitor.visitDocument(java.lang.String, java.util.List<com.allanbank.mongodb.bson.Element>) method.accept in interface Documentvisitor - THe visitor for the document.Element.accept(Visitor)public Document asDocument()
Returns this document.
asDocument in interface DocumentAssignablepublic boolean contains(String name)
contains in interface Documentname - The name of the element to locate.Document.contains(String)public boolean equals(Object object)
equals in class Objectobject - The object to compare to.Object.equals(java.lang.Object)public <E extends Element> List<E> find(Class<E> clazz, String... nameRegexs)
Searches this sub-elements for matching elements on the path and are of the right type.
find in interface DocumentE - The type of element to match.clazz - The class of elements to match.nameRegexs - The path of regular expressions.null.Document.queryPath(java.lang.Class<E>, java.lang.String...)public List<Element> find(String... nameRegexs)
Searches this sub-elements for matching elements on the path.
find in interface DocumentnameRegexs - The path of regular expressions.null.Document.queryPath(java.lang.Class<E>, java.lang.String...)public <E extends Element> E findFirst(Class<E> clazz, String... nameRegexs)
Note: It is much faster to use the Document.get(Class,String) method on a
document than to use the Document.findFirst(String...) with a single
nameRegexs.
Searches this sub-elements for matching elements on the path and are of the right type.
findFirst in interface DocumentE - The type of element to match.clazz - The class of element to match.nameRegexs - The path of regular expressions.Document.queryPath(java.lang.Class<E>, java.lang.String...)public Element findFirst(String... nameRegexs)
Note: It is much faster to use the Document.get(String) method on a
document than to use the Document.findFirst(String...) with a single
nameRegexs.
Searches this sub-elements for matching elements on the path and are of the right type.
findFirst in interface DocumentnameRegexs - The path of regular expressions.Document.queryPath(java.lang.Class<E>, java.lang.String...)public <E extends Element> E get(Class<E> clazz, String name)
get in interface DocumentE - The type of element to get.clazz - The class of element to get.name - The name of the element to locate.Document.get(String)public Element get(String name)
get in interface Documentname - The name of the element to locate.Document.get(String)public List<Element> getElements()
getElements in interface Documentpublic int hashCode()
public void injectId()
ObjectIdElement to the head of the document.public Iterator<Element> iterator()
iterator in interface Iterable<Element>Iterable.iterator()@Deprecated public <E extends Element> List<E> queryPath(Class<E> clazz, String... nameRegexs)
find(Class,String...) method instead. Will
be removed after the 1.1.0 release.
To call the replacement method, find(Class, String...).
queryPath in interface DocumentE - The type of element to match.clazz - The class of elements to match.nameRegexs - The path of regular expressions.Document.queryPath(java.lang.Class<E>, java.lang.String...)@Deprecated public List<Element> queryPath(String... nameRegexs)
find(Class,String...) method instead. Will
be removed after the 1.1.0 release.
To call the replacement method, find(String...).
queryPath in interface DocumentnameRegexs - The path of regular expressions.Document.queryPath(java.lang.Class<E>, java.lang.String...)public String toString()
toString in class ObjectObject.toString()Copyright © 2011-2013 Allanbank Consulting, Inc.. All Rights Reserved.