I have two arraylists of type String, one of Operands and one of Operators
ArrayList<String> operands = new ArrayList<String>();
ArrayList<String> operators = new ArrayList<String>();
They are filled like so
operands = { "\"symbol\": \"CHKP%\"", "\"price\": {$gt: 23.72\" };
operators = { "and"};
Ideally I would convert this to a single ArrayList that is filled like so
ArrayList<String> polishNotation = { "and",
"\"symbol\": \"CHKP%\"",
"\"price\": {$gt: 23.72\" };
It would be easy to hardcode Polish Notation for three elements, but I have varying numbers of operators and operands (up to four operands and three operators). This code is to be used to convert SQL select statements to MongoDB.find() statements. Any pointers on how to implement the ArrayList merge in Polish Notation(prefix polish notation) would be much appreciated.
[Edit 2] Below is an example of an SQL statement with 3 operators ("like", "and", "<") and three operands ('FLIR%', "price", "price") and it's MongoDB equivalent. I think using Polish Notation can help me convert SQL's order of the query into a Mongo-ordered query
in SQL
SELECT * FROM STOCK WHERE symbol like 'FLIR%' and price > 24.04 and price < 24.39;
in MongoDB
db.STOCK.find({
"symbol": "FLIR%",
"price": {
"$gt": 24.04,
"$lt": 24.39
}
}