public void read(AssignFieldPathUpdate update) { try { for (int i = 0; i < reader.getAttributeCount(); i++) { if (reader.getAttributeName(i).toString().equals("removeifzero")) { update.setRemoveIfZero(Boolean.parseBoolean(reader.getAttributeValue(i))); } else if (reader.getAttributeName(i).toString().equals("createmissingpath")) { update.setCreateMissingPath(Boolean.parseBoolean(reader.getAttributeValue(i))); } } DataType dt = update.getFieldPath().getResultingDataType(); if (dt instanceof NumericDataType) { update.setExpression(reader.getElementText()); } else { FieldValue fv = dt.createFieldValue(); fv.deserialize(resolveField(update), this); update.setNewValue(fv); } } catch (XMLStreamException e) { throw newException(e); } }
public static void applyUpdate(FieldPathUpdate update, Document doc) { if (update instanceof AddFieldPathUpdate) { update.applyTo(doc); } else if (update instanceof AssignFieldPathUpdate) { AssignFieldPathUpdate assign = (AssignFieldPathUpdate)update; boolean createMissingPath = assign.getCreateMissingPath(); boolean removeIfZero = assign.getRemoveIfZero(); assign.setCreateMissingPath(true); assign.setRemoveIfZero(false); assign.applyTo(doc); assign.setCreateMissingPath(createMissingPath); assign.setRemoveIfZero(removeIfZero); } else if (update instanceof RemoveFieldPathUpdate) { doc.iterateNested(update.getFieldPath(), 0, new MyHandler()); } }
public void read(AssignFieldPathUpdate update) { byte flags = getByte(null); update.setRemoveIfZero((flags & AssignFieldPathUpdate.REMOVE_IF_ZERO) != 0); update.setCreateMissingPath((flags & AssignFieldPathUpdate.CREATE_MISSING_PATH) != 0); if ((flags & AssignFieldPathUpdate.ARITHMETIC_EXPRESSION) != 0) { update.setExpression(getString(null)); } else { DataType dt = update.getFieldPath().getResultingDataType(); FieldValue fv = dt.createFieldValue(); fv.deserialize(this); update.setNewValue(fv); } }
public void read(AssignFieldPathUpdate update) { byte flags = getByte(null); update.setRemoveIfZero((flags & AssignFieldPathUpdate.REMOVE_IF_ZERO) != 0); update.setCreateMissingPath((flags & AssignFieldPathUpdate.CREATE_MISSING_PATH) != 0); if ((flags & AssignFieldPathUpdate.ARITHMETIC_EXPRESSION) != 0) { update.setExpression(getString(null)); } else { DataType dt = update.getFieldPath().getResultingDataType(); FieldValue fv = dt.createFieldValue(); fv.deserialize(this); update.setNewValue(fv); } }