我有一个系统,在这个系统中我查询REST/Atom服务器上的文档。查询受到gdata的启发,看起来像:
http://server/base/feeds/documents?bq=[type in {'news'}]
我必须解析“bq”参数,以知道在不进行实际查询的情况下返回哪种类型的文档。例如,
bq=[type = 'news'] -> return ["news"]
bq=[type in {'news'}] -> return ["news"]
bq=[type in {'news', 'article'}] -> return ["news", "article"]
bq=[type = 'news']|[type = 'article'] -> return ["news", "article"]
bq=[type = 'news']|[title = 'My Title'] -> return ["news"]
基本上,查询语言是可以与或(“”)或和(没有分隔符)组合的谓词列表。每个谓词都是对字段的约束。约束可以是=、<、>、<=、>=、In等…任何有意义的地方都可能有空间。
我在regexp、stringtokenizer、streamtokenizer等之间有点迷失…我被Java 1.4所困扰,所以没有解析器…
谁能给我指明正确的方向?
谢谢!