Class AssignFieldPathUpdate
java.lang.Object
com.yahoo.document.fieldpathupdate.FieldPathUpdate
com.yahoo.document.fieldpathupdate.AssignFieldPathUpdate
- Author:
- Thomas Gundersen
-
Nested Class Summary
Nested classes/interfaces inherited from class com.yahoo.document.fieldpathupdate.FieldPathUpdate
FieldPathUpdate.Type
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
static final int
static final int
-
Constructor Summary
ConstructorDescriptionAssignFieldPathUpdate
(DocumentType type, DocumentUpdateReader reader) Creates an assign update from a serialized object.AssignFieldPathUpdate
(DocumentType type, String fieldPath) AssignFieldPathUpdate
(DocumentType type, String fieldPath, FieldValue newValue) AssignFieldPathUpdate
(DocumentType type, String fieldPath, String whereClause, FieldValue newValue) Creates an assignment update that overwrites the old value with the given new value.AssignFieldPathUpdate
(DocumentType type, String fieldPath, String whereClause, String expression) Creates an assign statement based on a mathematical expression. -
Method Summary
Modifier and TypeMethodDescriptionboolean
boolean
boolean
int
hashCode()
boolean
void
void
setCreateMissingPath
(boolean createMissingPath) If set to true, and any part of the field path specified does not exist (except for array indexes), we create the path as necessary.void
setExpression
(String value) Turns this assignment into a mathematical expression assignment.void
setNewValue
(FieldValue value) Turns this assignment into a literal one.void
setRemoveIfZero
(boolean removeIfZero) If set to true, and the new value assigned evaluates to a numeric value of 0, removes the value instead of setting it.toString()
Methods inherited from class com.yahoo.document.fieldpathupdate.FieldPathUpdate
applyTo, create, getDocumentType, getFieldPath, getOriginalFieldPath, getOriginalWhereClause, getUpdateType, getWhereClause, setFieldPath, setWhereClause
-
Field Details
-
ARITHMETIC_EXPRESSION
public static final int ARITHMETIC_EXPRESSION- See Also:
-
REMOVE_IF_ZERO
public static final int REMOVE_IF_ZERO- See Also:
-
CREATE_MISSING_PATH
public static final int CREATE_MISSING_PATH- See Also:
-
-
Constructor Details
-
AssignFieldPathUpdate
public AssignFieldPathUpdate(DocumentType type, String fieldPath, String whereClause, FieldValue newValue) Creates an assignment update that overwrites the old value with the given new value.- Parameters:
type
- The document type the assignment works on.fieldPath
- The field path of the field to be overwritten.whereClause
- A document selection string that selects documents and variables to be updated.newValue
- The new value of the assignment.
-
AssignFieldPathUpdate
-
AssignFieldPathUpdate
public AssignFieldPathUpdate(DocumentType type, String fieldPath, String whereClause, String expression) Creates an assign statement based on a mathematical expression.- Parameters:
type
- The document type the assignment works on.fieldPath
- The field path of the field to be overwritten.whereClause
- A document selection string that selects documents and variables to be updated.expression
- The mathematical expression to apply. Use $value to signify the previous value of the field.
-
AssignFieldPathUpdate
Creates an assign update from a serialized object.- Parameters:
type
- The document type the assignment will work on.reader
- A reader that can deserialize something into this object.
-
AssignFieldPathUpdate
-
-
Method Details
-
setNewValue
Turns this assignment into a literal one.- Parameters:
value
- The new value to assign to the document.
-
getNewValue
- Returns:
- Returns the value to assign, or null if this is a mathematical expression.
-
setExpression
Turns this assignment into a mathematical expression assignment.- Parameters:
value
- The expression to use for assignment.
-
getExpression
- Returns:
- Returns the arithmetic expression to assign, or null if this is not a mathematical expression.
-
setRemoveIfZero
public void setRemoveIfZero(boolean removeIfZero) If set to true, and the new value assigned evaluates to a numeric value of 0, removes the value instead of setting it. Default is false. -
setCreateMissingPath
public void setCreateMissingPath(boolean createMissingPath) If set to true, and any part of the field path specified does not exist (except for array indexes), we create the path as necessary. Default is true. -
isArithmetic
public boolean isArithmetic()- Returns:
- Returns true if this assignment is an arithmetic operation.
-
serialize
- Overrides:
serialize
in classFieldPathUpdate
-
equals
- Overrides:
equals
in classFieldPathUpdate
-
hashCode
public int hashCode()- Overrides:
hashCode
in classFieldPathUpdate
-
toString
- Overrides:
toString
in classFieldPathUpdate
-
getCreateMissingPath
public boolean getCreateMissingPath() -
getRemoveIfZero
public boolean getRemoveIfZero() -
getFieldValue
-