public class BinaryElement extends AbstractElement
Modifier and Type | Field and Description |
---|---|
static byte |
DEFAULT_SUB_TYPE
The sub type used when no sub type is specified.
|
static ElementType |
TYPE
The BSON type for a binary.
|
ELEMENT_TYPE
Constructor and Description |
---|
BinaryElement(String name,
byte[] value)
Constructs a new
BinaryElement . |
BinaryElement(String name,
byte subType,
byte[] value)
Constructs a new
BinaryElement . |
Modifier and Type | Method and Description |
---|---|
void |
accept(Visitor visitor)
Accepts the visitor and calls the
Visitor.visitBinary(java.lang.String, byte, byte[]) 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.
|
byte |
getSubType()
Return the binary sub-type.
|
ElementType |
getType()
Returns the type for the BSON type.
|
byte[] |
getValue()
Returns the BSON binary value.
|
Object |
getValueAsObject()
Returns the value for BSON element as a Java
Object type. |
int |
hashCode()
Computes a reasonable hash code.
|
BinaryElement |
withName(String name)
Creates a new element with the same type and value as this element but
with the specified name.
|
asElement, find, find, findFirst, findFirst, getName, getValueAsString, nullSafeEquals, queryPath, queryPath, toString
public static final byte DEFAULT_SUB_TYPE
public static final ElementType TYPE
public BinaryElement(String name, byte subType, byte[] value)
BinaryElement
.name
- The name for the BSON binary.subType
- The sub-type of the binary data.value
- The BSON binary value.IllegalArgumentException
- If the name
or value
is null
.public BinaryElement(String name, byte[] value)
BinaryElement
. Uses the
DEFAULT_SUB_TYPE
.name
- The name for the BSON binary.value
- The BSON binary value.IllegalArgumentException
- If the name
or value
is null
.public void accept(Visitor visitor)
Visitor.visitBinary(java.lang.String, byte, byte[])
method.visitor
- The visitor for the element.Element.accept(Visitor)
public boolean equals(Object object)
equals
in class AbstractElement
object
- The object to compare to.Object.equals(java.lang.Object)
public byte getSubType()
public ElementType getType()
public byte[] getValue()
public 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
.
Returns a byte[].
Note: This value will not be recreated is a Object-->Element
conversion. The sub type is lost in this conversion to an Object
.
Implementation Note: The return type cannot be a byte[] here as
UuidElement
returns a UUID
.
Object
type.public int hashCode()
hashCode
in class AbstractElement
public BinaryElement withName(String name)
Returns a new BinaryElement
.
name
- The new name for the element.Copyright © 2011-2013 Allanbank Consulting, Inc.. All Rights Reserved.