}
return newQuery;
}
static void replaceStrings(Node node, Node parent, Scriptable parameters) {
if (node.getType() == Token.CALL) {
Node caller = node.getFirstChild();
}
if (node.getType() == Token.NAME && ("$obj".equals(node.getString()) || "$obj".equals(node.getString()))) {
node.setType(Token.THIS);
}
if (node.getType() == Token.GETPROP && node.getFirstChild().getType() == Token.NAME &&
"args".equals(node.getFirstChild().getString()) && node.getLastChild().getType() == Token.STRING &&
node.getLastChild().getString().startsWith("param")) {
Object value = parameters.get(node.getLastChild().getString(),parameters);
if (value instanceof String) {
parent.replaceChild(node,Node.newString((String) value));
}
else if (value instanceof Number) {
parent.replaceChild(node,Node.newNumber(((Number) value).doubleValue()));
}
else if (value instanceof Persistable) {
node.setType(Token.EQ);
while(node.getFirstChild() != null)
node.removeChild(node.getFirstChild());
node.addChildToFront(new Node(Token.DOT,new Node(Token.THIS),new Node(Token.NAME)));
node.addChildToFront(new Node(Token.STRING));
node.getFirstChild().getLastChild().setString("id");
node.getLastChild().setString(((Persistable)value).getId().subObjectId);
}
//TODO: Do the rest of these
}