public class JavaScriptWithScopeElement extends JavaScriptElement
| Modifier and Type | Field and Description |
|---|---|
static ElementType |
TYPE
The BSON type for a string.
|
ELEMENT_TYPE| Constructor and Description |
|---|
JavaScriptWithScopeElement(String name,
String javaScript,
Document scope)
Constructs a new
JavaScriptWithScopeElement. |
JavaScriptWithScopeElement(String name,
String javaScript,
Document scope,
long size)
Constructs a new
JavaScriptWithScopeElement. |
| Modifier and Type | Method and Description |
|---|---|
void |
accept(Visitor visitor)
Accepts the visitor and calls the
Visitor.visitJavaScript(String,String,Document) method. |
int |
compareTo(Element otherElement) |
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.
|
Document |
getScope()
Returns the BSON JavaScript scope.
|
ElementType |
getType()
Returns the type for the BSON type.
|
Document |
getValueAsObject()
Returns the value for BSON element as a Java
Object type. |
int |
hashCode()
Computes a reasonable hash code.
|
JavaScriptWithScopeElement |
withName(String name)
Creates a new element with the same type and value as this element but
with the specified name.
|
getJavaScriptasElement, find, find, findFirst, findFirst, getName, getValueAsString, nullSafeEquals, size, toStringpublic static final ElementType TYPE
public JavaScriptWithScopeElement(String name, String javaScript, Document scope)
JavaScriptWithScopeElement.name - The name for the BSON string.javaScript - The BSON JavaScript value.scope - The scope for the JavaScriptIllegalArgumentException - If the name, javaScript, or scope is
null.public JavaScriptWithScopeElement(String name, String javaScript, Document scope, long size)
JavaScriptWithScopeElement.name - The name for the BSON string.javaScript - The BSON JavaScript value.scope - The scope for the JavaScriptsize - The size of the element when encoded in bytes. If not known
then use the
JavaScriptWithScopeElement(String, String, Document)
constructor instead.IllegalArgumentException - If the name, javaScript, or scope is
null.public void accept(Visitor visitor)
Visitor.visitJavaScript(String,String,Document) method.accept in interface Elementaccept in class JavaScriptElementvisitor - The visitor for the element.Element.accept(Visitor)public int compareTo(Element otherElement)
Overridden to compare the elements based on the tuple (name, type, value).
Overridden to compare the elements based on the tuple (name, type). Derived classes are responsible for the value portion of the full comparison.
Overridden to compare the Java Script (as text) if the base class comparison is equals.
Overridden to compare the Java Script (as text) if the base class comparison is equals.
compareTo in interface ElementcompareTo in interface Comparable<Element>compareTo in class JavaScriptElementpublic boolean equals(Object object)
equals in class JavaScriptElementobject - The object to compare to.Object.equals(java.lang.Object)public Document getScope()
public ElementType getType()
getType in interface ElementgetType in class JavaScriptElementpublic Document 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 the result of JavaScriptElement.getJavaScript().
Implementation Note: The return type cannot be a String here as
JavaScriptWithScopeElement returns a Document.
Returns a document representing the code and scope similar to the strict JSON encoding.
Note: This value will not be recreated is a Object-->Element conversion. A more generic sub-document is created instead.
getValueAsObject in interface ElementgetValueAsObject in class JavaScriptElementObject type.public int hashCode()
hashCode in class JavaScriptElementpublic JavaScriptWithScopeElement withName(String name)
Returns a new JavaScriptElement.
Returns a new JavaScriptElement.
withName in interface ElementwithName in class JavaScriptElementname - The new name for the element.Copyright © 2011–2014 Allanbank Consulting, Inc.. All rights reserved.