public abstract class AbstractDocument 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 |
|---|
AbstractDocument()
Creates a new AbstractDocument.
|
| 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.
|
protected abstract Map<String,Element> |
getElementMap()
Returns the mapping from the names of elements to the element.
|
abstract List<Element> |
getElements()
Returns the array of elements that create this document.
|
int |
hashCode()
Computes a reasonable hash code.
|
Iterator<Element> |
iterator()
Returns an iterator over the documents elements.
|
String |
toString()
String form of the object.
|
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.find(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.find(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.findFirst(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.findFirst(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 abstract List<Element> getElements()
getElements in interface Documentpublic int hashCode()
public Iterator<Element> iterator()
iterator in interface Iterable<Element>Iterable.iterator()public String toString()
toString in class ObjectObject.toString()Copyright © 2011–2014 Allanbank Consulting, Inc.. All rights reserved.