public class ArrayElement extends AbstractElement
| Modifier and Type | Field and Description | 
|---|---|
static ElementType | 
TYPE
The BSON type for an array. 
 | 
ELEMENT_TYPE| Constructor and Description | 
|---|
ArrayElement(String name,
            Element... entries)
Constructs a new  
ArrayElement. | 
ArrayElement(String name,
            List<Element> entries)
Constructs a new  
ArrayElement. | 
| Modifier and Type | Method and Description | 
|---|---|
void | 
accept(Visitor visitor)
Accepts the visitor and calls the
  
Visitor.visitArray(String, List) method. | 
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. 
 | 
<E extends Element>  | 
findFirst(Class<E> clazz,
         String... nameRegexs)
Returns the first element matching the path of regular expressions. 
 | 
List<Element> | 
getEntries()
Returns the entries in the array. 
 | 
ElementType | 
getType()
Returns the type for the BSON type. 
 | 
Element[] | 
getValueAsObject()
Returns the value for BSON element as a Java  
Object type. | 
int | 
hashCode()
Computes a reasonable hash code. 
 | 
static String | 
nameFor(int index)
Similar to the caching of Integer object values for a range we cache the
 index names for an array's first 256 positions. 
 | 
ArrayElement | 
withName(String name)
Creates a new element with the same type and value as this element but
 with the specified name. 
 | 
asElement, find, findFirst, getName, getValueAsString, nullSafeEquals, queryPath, queryPath, toStringpublic static final ElementType TYPE
public ArrayElement(String name, Element... entries) throws IllegalArgumentException
ArrayElement.name - The name for the BSON array.entries - The entries in the array.IllegalArgumentException - If the name is null.public ArrayElement(String name, List<Element> entries) throws IllegalArgumentException
ArrayElement.name - The name for the BSON array.entries - The entries in the array.IllegalArgumentException - If the name is null.public static final String nameFor(int index)
index - The index for the array element.public void accept(Visitor visitor)
Visitor.visitArray(String, List) method.visitor - The visitor for the element.Element.accept(Visitor)public boolean equals(Object object)
equals in class AbstractElementobject - The object to compare to.Object.equals(java.lang.Object)public <E extends Element> List<E> find(Class<E> clazz, String... nameRegexs)
Returns a singleton list if the nameRegexs is empty and this element's type is assignable to E. An empty list otherwise.
Searches this sub-elements for matching elements on the path and are of the right type.
find in interface Elementfind in class AbstractElementE - The type of element to match.clazz - The class of elements to match.nameRegexs - The path of regular expressions.Element.queryPath(java.lang.Class<E>, java.lang.String...)public <E extends Element> E findFirst(Class<E> clazz, String... nameRegexs)
 Returns a this if the nameRegexs is empty and this element's type
 is assignable to E. An empty list otherwise.
 
Searches this sub-elements for matching elements on the path and are of the right type.
findFirst in interface ElementfindFirst in class AbstractElementE - 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 List<Element> getEntries()
public ElementType getType()
public Element[] getValueAsObject()
Object type.
 
 Automatic conversion from the Object-ified value to an element is
 provided via the DocumentBuilder.add(String, Object) method. Not
 all element types will be successfully converted to the same element
 duing a Element-->Object value-->Element conversion. This cases are noted
 in the appropriate sub-type's JavaDoc.
 
 Sub-types will also overload this method with the appropriate type
 returned. e.g., The
 StringElement.getValueAsObject()
 method signature returns a String.
 
Returns an Element[].
Object type.public int hashCode()
hashCode in class AbstractElementpublic ArrayElement withName(String name)
 Returns a new ArrayElement.
 
name - The new name for the element.Copyright © 2011-2013 Allanbank Consulting, Inc.. All Rights Reserved.