@Override public boolean update(JsonDoc doc, FieldTreeNode contextMd, Path contextPath) { boolean ret = false; if (numAny > 0) { KeyValueCursor<Path, JsonNode> cursor = doc.getAllNodes(memento.expr.getField()); boolean b = cursor.hasNext(); while (b) { cursor.next(); Path currentKey = cursor.getCurrentKey(); JsonNode currentValue = cursor.getCurrentValue(); UpdateInfo updateInfoInstance = generateProcessedInfo(memento.context, memento.expr, currentKey, this.updateInfo.updater); if (update(doc, contextPath, updateInfoInstance)) { ret = true; } b = cursor.hasNext(); } return ret; } else { ret = update(doc, contextPath, this.updateInfo); return ret; } }
/** * Creates an updater object based on the given update expression * * @param factory Node factory * @param context Metadata for the context node * @param expr The update expression. */ public static Updater getInstance(JsonNodeFactory factory, FieldTreeNode context, UpdateExpression expr) { Updater ret = null; if (expr instanceof UpdateExpressionList) { ret = new UpdateExpressionListEvaluator(factory, context, (UpdateExpressionList) expr); } else if (expr instanceof SetExpression) { ret = new SetExpressionEvaluator(factory, context, (SetExpression) expr); } else if (expr instanceof UnsetExpression) { ret = new UnsetExpressionEvaluator(factory, context, (UnsetExpression) expr); } else if (expr instanceof ForEachExpression) { ret = new ForEachExpressionEvaluator(factory, context, (ForEachExpression) expr); } else if (expr instanceof ArrayAddExpression) { ret = new ArrayAddExpressionEvaluator(factory, context, (ArrayAddExpression) expr); } return ret; } }
public ForEachExpressionEvaluator(JsonNodeFactory factory, FieldTreeNode context, ForEachExpression expr) { this.memento = new Memento(factory, context, expr); this.factory = factory; this.numAny = expr.getField().nAnys(); // Resolve the field, make sure it is an array this.updateInfo = generateProcessedInfo(context, expr, null, null); }
/** * Creates an updater object based on the given update expression * * @param factory Node factory * @param context Metadata for the context node * @param expr The update expression. */ public static Updater getInstance(JsonNodeFactory factory, FieldTreeNode context, UpdateExpression expr) { Updater ret = null; if (expr instanceof UpdateExpressionList) { ret = new UpdateExpressionListEvaluator(factory, context, (UpdateExpressionList) expr); } else if (expr instanceof SetExpression) { ret = new SetExpressionEvaluator(factory, context, (SetExpression) expr); } else if (expr instanceof UnsetExpression) { ret = new UnsetExpressionEvaluator(factory, context, (UnsetExpression) expr); } else if (expr instanceof ForEachExpression) { ret = new ForEachExpressionEvaluator(factory, context, (ForEachExpression) expr); } else if (expr instanceof ArrayAddExpression) { ret = new ArrayAddExpressionEvaluator(factory, context, (ArrayAddExpression) expr); } return ret; } }
public ForEachExpressionEvaluator(JsonNodeFactory factory, FieldTreeNode context, ForEachExpression expr) { this.memento = new Memento(factory, context, expr); this.factory = factory; this.numAny = expr.getField().nAnys(); // Resolve the field, make sure it is an array this.updateInfo = generateProcessedInfo(context, expr, null, null); }
/** * Creates an updater object based on the given update expression * * @param factory Node factory * @param context Metadata for the context node * @param expr The update expression. */ public static Updater getInstance(JsonNodeFactory factory, FieldTreeNode context, UpdateExpression expr) { Updater ret = null; if (expr instanceof UpdateExpressionList) { ret = new UpdateExpressionListEvaluator(factory, context, (UpdateExpressionList) expr); } else if (expr instanceof SetExpression) { ret = new SetExpressionEvaluator(factory, context, (SetExpression) expr); } else if (expr instanceof UnsetExpression) { ret = new UnsetExpressionEvaluator(factory, context, (UnsetExpression) expr); } else if (expr instanceof ForEachExpression) { ret = new ForEachExpressionEvaluator(factory, context, (ForEachExpression) expr); } else if (expr instanceof ArrayAddExpression) { ret = new ArrayAddExpressionEvaluator(factory, context, (ArrayAddExpression) expr); } return ret; } }
@Override public boolean update(JsonDoc doc, FieldTreeNode contextMd, Path contextPath) { boolean ret = false; if (numAny > 0) { KeyValueCursor<Path, JsonNode> cursor = doc.getAllNodes(memento.expr.getField()); boolean b = cursor.hasNext(); while (b) { cursor.next(); Path currentKey = cursor.getCurrentKey(); JsonNode currentValue = cursor.getCurrentValue(); UpdateInfo updateInfoInstance = generateProcessedInfo(memento.context, memento.expr, currentKey, this.updateInfo.updater); if (update(doc, contextPath, updateInfoInstance)) { ret = true; } b = cursor.hasNext(); } return ret; } else { ret = update(doc, contextPath, this.updateInfo); return ret; } }