title: Parsing "SQL like" query strings
body: <p>For the web services interface of our product we are defining sql like query strings. They don't follow the exact sql syntax. It works like this. The strings are present in the xml requests. My application is parsing the string and creating Java object based on the content. Those java objects are used to query the DB. Here are few examples of the query strings:</p>
  
  <pre><code> objectType==device &amp;&amp; deviceType==mobile &amp;&amp; returnType==full
   objectType==device &amp;&amp; deviceType==computer &amp;&amp; deviceState==connected &amp;&amp; returnType==basic
   objectType==networkEntity &amp;&amp; namePattern==*.nw &amp;&amp; networkEntityType==SGSN
  </code></pre>
  
  <p>The keys (objectType for example) and the values (device/networkEntity) are generally enumerated. So the expectation from the parsing mechanism are:</p>
  
  <ol>
  <li>If any unknown element(key/value) is there in the query String, it should fail.</li>
  <li>The elements (key/value) should appear in a defined sequence (This is just to simplify the parsing logic)</li>
  <li>In future, in addition to "==" and "&amp;&amp;", other operations may also get introduced.</li>
  <li>There can be different combinations of the key/values resulting in large number of unique query strings.</li>
  </ol>
  
  <p>Right now I am using a combination of String.split and Scanner to parse the String. But, I am finding that code is becoming complex and harder to debug. Till now, I have not introduced any major validations. With that I am expecting the code to become even more complex and "ugly". </p>
  
  <p>[Question] Is there any library which can help me in parsing such strings. Any other suggestions/thoughts will also be appreciated. </p>