public interface Element extends Serializable, ElementAssignable, Comparable<Element>
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.
|
int |
compareTo(Element otherElement) |
<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 . |
long |
size()
Returns the number of bytes that are used to encode the element.
|
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.int compareTo(Element otherElement)
Overridden to compare the elements based on the tuple (name, type, value).
compareTo
in interface Comparable<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
.long size()
Element withName(String name)
name
- The new name for the element.Copyright © 2011–2014 Allanbank Consulting, Inc.. All rights reserved.