I have a table which contains following columns
dependentColumn : values table1.column2, table1.column3, table3.column4....
condition : values ([table1.column2.LAST3][=ABC][OR][=DEF]),
([table1.column2.ALL][=ABC]),
(([table1.column2][=ABC][OR][table1.column2][!="DEF"])[AND]
([table1.column2][!="DEF"]))
...
values: abc, [table1.column1.LAST3]
Now I need to parse the values contained in condition column and write a code containg the conditions and put the values to the dependentColumns
My concern is making java conditions from the conditions mentioned in the 'condition' column. conditions are stored in a pattern. there can be multiple conditions wh开发者_C百科ith ANDs and ORs. How do I tackel the problem. I Know its possible but I am a bit confused.Can I use Stack Class, tyhough I have not used it before.
If there is a simple way out to the solution please tell me
It's not totally clear what you're trying to do from your question but here's my understanding. It looks like you're trying to encode some values into some db objects described by the "dependentColumn" column of a database table where the values are defined by evaluating a domain-specific language (DSL) encoded in the the "condition" column.
One critical aspect is how complex this DSL is. A simple language could be parsed by regular expressions and evaluated using a stack as you mentioned but from your example it looks like you could have grouped boolean expressions which might require the use of an actual parser generator (e.g. ANTLR).
精彩评论