*/
private void readModifiers(CommonTree tree, DaoQuery query, ExecutionContext ctx) {
assertTokenType(tree, MqlParser.UPDATE_OPERATIONS);
// get the modifer
DaoModifier modifier = query.modify();
// go through each operation
for (int i=0; i<tree.getChildCount(); i++) {
CommonTree modiferTree = child(tree, i);
String field = null;
Object value = null;
// add the operation to the query
switch(modiferTree.getType()) {
case MqlParser.INC:
field = child(modiferTree, 0).getText();
value = readVariableLiteral(child(modiferTree, 1), ctx);
assertType(value, modiferTree, Number.class);
modifier.inc(field, Number.class.cast(value));
break;
case MqlParser.SET:
field = child(modiferTree, 0).getText();
value = readVariableLiteral(child(modiferTree, 1), ctx);
modifier.set(field, value);
break;
case MqlParser.UNSET:
field = child(modiferTree, 0).getText();
modifier.unset(field);
break;
case MqlParser.PUSH:
field = child(modiferTree, 0).getText();
value = readVariableLiteral(child(modiferTree, 1), ctx);
modifier.push(field, value);
break;
case MqlParser.PUSH_ALL:
field = child(modiferTree, 0).getText();
value = readVariableLiteral(child(modiferTree, 1), ctx);
assertType(value, modiferTree, Object[].class);
modifier.pushAll(field, Object[].class.cast(value));
break;
case MqlParser.ADD_TO_SET:
field = child(modiferTree, 0).getText();
value = readVariableLiteral(child(modiferTree, 1), ctx);
modifier.addToSet(field, value);
break;
case MqlParser.ADD_TO_SET_EACH:
field = child(modiferTree, 0).getText();
value = readVariableLiteral(child(modiferTree, 1), ctx);
assertType(value, modiferTree, Object[].class);
modifier.addToSetEach(field, Object[].class.cast(value));
break;
case MqlParser.POP:
field = child(modiferTree, 0).getText();
modifier.pop(field);
break;
case MqlParser.SHIFT:
field = child(modiferTree, 0).getText();
modifier.pop(field);
break;
case MqlParser.PULL:
field = child(modiferTree, 0).getText();
value = readVariableLiteral(child(modiferTree, 1), ctx);
modifier.pull(field, value);
break;
case MqlParser.PULL_ALL:
field = child(modiferTree, 0).getText();
value = readVariableLiteral(child(modiferTree, 1), ctx);
assertType(value, modiferTree, Object[].class);
modifier.pullAll(field, Object[].class.cast(value));
break;
case MqlParser.RENAME:
field = child(modiferTree, 0).getText();
value = child(modiferTree, 1).getText();
modifier.rename(field, String.class.cast(value));
break;
case MqlParser.BITWISE:
Tree opTree = modiferTree.getChild(0);
field = child(modiferTree, 1).getText();
value = readVariableLiteral(child(modiferTree, 2), ctx);
assertType(value, modiferTree, Number.class);
if (opTree.getType()==MqlParser.AND) {
modifier.bitwiseAnd(field, Number.class.cast(value));
} else {
modifier.bitwiseOr(field, Number.class.cast(value));
}
break;
default:
throw new MqlException(
"Unknown modifier:" +modiferTree.toString());