public abstract class AbstractElement extends Object implements Element
Modifier and Type | Field and Description |
---|---|
protected static Class<Element> |
ELEMENT_TYPE
The base type (interface) for all elements.
|
Constructor and Description |
---|
AbstractElement(String name)
Constructs a new
AbstractElement . |
Modifier and Type | Method and Description |
---|---|
Element |
asElement()
Converts the object into an
Element . |
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.
|
String |
getName()
Returns the name for the BSON type.
|
String |
getValueAsString()
Returns the value for BSON element as a Java
String . |
int |
hashCode()
Computes a reasonable hash code.
|
protected boolean |
nullSafeEquals(Object rhs,
Object lhs)
Does a null safe equals comparison.
|
<E extends Element> |
queryPath(Class<E> clazz,
String... nameRegexs)
Deprecated.
Use the replacement method,
find(Class, String...) .
Will be removed after the 1.1.0 release. |
List<Element> |
queryPath(String... nameRegexs)
Deprecated.
Use the replacement method,
find(String...) . Will be
removed after the 1.1.0 release. |
String |
toString()
String form of the object.
|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
accept, getType, getValueAsObject, withName
public AbstractElement(String name) throws IllegalArgumentException
AbstractElement
.name
- The name for the BSON type.IllegalArgumentException
- If the name
is null
.public Element asElement()
Element
.
Returns this element.
asElement
in interface ElementAssignable
Element
.public boolean equals(Object object)
equals
in class Object
object
- 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.
find
in interface Element
E
- 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 List<Element> find(String... nameRegexs)
Returns a singleton list if the nameRegexs is empty. An empty list otherwise.
find
in interface Element
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.
findFirst
in interface Element
E
- The type of element to match.clazz
- The class of element to match.nameRegexs
- The path of regular expressions.Element.findFirst(java.lang.Class<E>, java.lang.String...)
public Element findFirst(String... nameRegexs)
Searches this sub-elements for matching elements on the path and are of the right type.
findFirst
in interface Element
nameRegexs
- The path of regular expressions.Document.queryPath(java.lang.Class<E>, java.lang.String...)
public String getName()
public String getValueAsString()
String
. Automatic
conversion from the string value back to an Element is not provided.
Generally the string returned will be the expected value. As an example
for a LongElement with the value 101 the returned string will be "101".
In those cases where there is not canonical form for the value (e.g., a
TimestampElement
the returned
string will match the value when converted to JSON by the
JsonSerializationVisitor
. For a TimestampElement
that is
a string of the form "ISODate('1970-01-01T00:00:00.000+0000')".
Uses the JsonSerializationVisitor
to encode the value. In some
cases it will be more efficient to override this method with a more
straight forward conversion.
getValueAsString
in interface Element
String
.public int hashCode()
@Deprecated public <E extends Element> List<E> queryPath(Class<E> clazz, String... nameRegexs)
find(Class, String...)
.
Will be removed after the 1.1.0 release.
To call the replacement method, find(Class, String...)
.
queryPath
in interface Element
E
- 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(String...)
. Will be
removed after the 1.1.0 release.
To call the replacement method, find(String...)
.
queryPath
in interface Element
nameRegexs
- The path of regular expressions.Document.queryPath(java.lang.Class<E>, java.lang.String...)
public String toString()
toString
in class Object
Object.toString()
Copyright © 2011-2013 Allanbank Consulting, Inc.. All Rights Reserved.