The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

So, in this example the logic that determines the commission rate is hardcoded. However, I want to take this logic out of the hardcoded code and allow the user to add, modify and delete these criteria using boolean and comparison operators against fields in the db (again, just like Excel conditional formatting)

Note I'm using the setting of a variable as an example. Instead, I could be calling another procedure based on the criteria?

Also, please note that the above example is very simplistic. The calculations in real life will involve a much more complex formula that uses most of the boolean/comparison operators with nested statements. There will almost always be an "else" case if no condition is met. Finally, this will be applied to each row is a fairly large recordset.

Designing the GUI for this isn't a problem, but I'm unsure:
1. Where to store the user's conditions (in a db table, in an XML, etc...)?
2. How to set the commRate variable if the boolean/comparison operators and indeed the very structure of the boolean statement (i.e nested statement) isn't hardcoded

I'm stumped how to achieve this if I'm not actually using the boolean/comparison operators in my actual code, but I know it is possible. I know you can use a binary tree data structure to work with math formulae but I'm unsure if I'm on the right track.