public interface Element extends Serializable, ElementAssignable
Modifier and Type | Method and Description |
---|---|
void |
accept(Visitor visitor)
Accepts the visitor and calls the appropriate method on the visitor based
on the element type.
|
<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.
|
ElementType |
getType()
Returns the type for the BSON type.
|
Object |
getValueAsObject()
Returns the value for BSON element as a Java
Object type. |
String |
getValueAsString()
Returns the value for BSON element as a Java
String . |
<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(String...) method instead. Will be
removed after the 1.1.0 release. |
Element |
withName(String name)
Creates a new element with the same type and value as this element but
with the specified name.
|
asElement
void accept(Visitor visitor)
visitor
- The visitor for the element.<E extends Element> List<E> find(Class<E> clazz, String... nameRegexs)
E
- The type of element to match.clazz
- The class of elements to match.nameRegexs
- The path of regular expressions.List<Element> find(String... nameRegexs)
nameRegexs
- The path of regular expressions.<E extends Element> E findFirst(Class<E> clazz, String... nameRegexs)
E
- The type of element to match.clazz
- The class of element to match.nameRegexs
- The path of regular expressions.Element findFirst(String... nameRegexs)
nameRegexs
- The path of regular expressions.String getName()
ElementType getType()
Object 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
.
Object
type.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')".
String
.@Deprecated <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.E
- The type of element to match.clazz
- The class of elements to match.nameRegexs
- The path of regular expressions.@Deprecated List<Element> queryPath(String... nameRegexs)
find(String...)
method instead. Will be
removed after the 1.1.0 release.nameRegexs
- The path of regular expressions.Element withName(String name)
name
- The new name for the element.Copyright © 2011-2013 Allanbank Consulting, Inc.. All Rights Reserved.