case Token.SHEQ:
String property;
Object value;
try {
if(!(expression.getFirstChild().getType() == Token.GETPROP && expression.getFirstChild().getFirstChild().getType() == Token.THIS))
throw new QueryCantBeHandled("Can't handle non-direct property comparisons");
property = expression.getFirstChild().getLastChild().getString();
Node valueNode = expression.getLastChild();
switch(valueNode.getType()){
case Token.STRING:
value = valueNode.getString();
break;
case Token.NUMBER:
value = valueNode.getDouble();
break;
case Token.NULL:
value = null;
break;
case Token.TRUE:
value = true;
break;
case Token.FALSE:
value = false;
break;
case Token.AND:
if(valueNode.getLastChild().getType() == Token.GETPROP && "__ids__".equals(valueNode.getLastChild().getFirstChild().getString())){
value = Identification.idForString(valueNode.getFirstChild().getString());
break;
}
throw new QueryCantBeHandled("unknown value type");
case Token.CALL:
if(valueNode.getFirstChild().getType() == Token.NAME &&
"date".equals(valueNode.getFirstChild().getString())){
value = new Date((long) valueNode.getLastChild().getDouble());
break;
}
default:
throw new QueryCantBeHandled("unknown value type");
}
} catch (RuntimeException e) {
throw new QueryCantBeHandled("not valid structure");
}
IndexTraverser traverser = getDatabase().getTraverserForTable(table, property);
switch(expression.getType()){
case Token.SHNE:
case Token.NE:
case Token.SHEQ:
case Token.EQ:
traverser.minKey = value;
traverser.maxKey = value;
break;
case Token.GE:
traverser.minKey = value;
break;
case Token.GT:
traverser.minReference = JavaScriptDB.MAX_MAX_REFERENCE;
traverser.minKey = value;
break;
case Token.LE:
traverser.maxKey = value;
break;
case Token.LT:
traverser.maxKey = value;
traverser.maxReference = JavaScriptDB.MIN_MIN_REFERENCE;
}
return not ? new NotTraverser(traverser, table) : traverser;
default:
throw new QueryCantBeHandled("Unknown expression");
}
} catch (IOException e) {
throw new RuntimeException(e);
}
}