How to programmatically construct textual query

Posted by stibi on Programmers See other posts from Programmers or by stibi
Published on 2012-11-28T18:23:14Z Indexed on 2012/11/28 23:14 UTC
Read the original article Hit count: 263

Filed under:
|

Here is a query language, more specifically, it's JQL, you can use it in Jira, to search for issues, it's something like SQL, but quite simpler.

My case is that, I need to construct such queries programmatically, in my application. Something like:

JQLMachine jqlMachine = new JQLMachine()
jqlMachine.setStatuses("Open", "In Progress")
jqlMachine.setReporter("foouser", "baruser")
jqlMachine.setDateRange(...)
jqlMachine.getQuery() --> String with corresponding JQL query is returned

You get my point I hope. I can imagine the code for this, but it's not nice, using my current knowledge how I'd do that.

That's why I'm asking. What you'd advice to use to create such thing. I believe some patterns for creating something like this already exist and there is already best practices, how to do that in good way.

© Programmers or respective owner

Related posts about syntax

Related posts about query