-1

Is there a Java library I can use to convert conditions into actual code instead of using a lot of case statement for all the cominations?

Eg: "GT value1 LT value2" and it should return true/false based on the input values I give.

Franz Kafka
  • 10,623
  • 20
  • 93
  • 149
sharma sharma
  • 87
  • 3
  • 8

2 Answers2

2

I guess you need to look at ANTLR framework.

ANTLR website

Just for the headsup:

ANTLR: Is there a simple example?

Community
  • 1
  • 1
Himanshu Bhardwaj
  • 4,038
  • 3
  • 17
  • 36
0

This isn't a trivial task, what you're asking for is a scripting language interpreter for Java.

You could look at OGNL or the JSR api. These both require fairly extensive knowledge of syntax; so depending on what you want to do may not fill the brief.

However, without some structured syntax you are relying wholly on the structure of the English language - you are getting into the realms of NLP.

You could just use a scripting language like Groovy if all you are looking for is a way to change behaviour at runtime.

Boris the Spider
  • 59,842
  • 6
  • 106
  • 166
  • It doesn't have to be GTE or LTE. I can use '>=' in place of that. That is a much smaller switch block than trying to write cases for all combinations of GTE, LTE, LT, GT etc – sharma sharma Apr 10 '13 at 20:41