|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.z3950.zing.cql.CQLParser
public class CQLParser
Compiles CQL strings into parse trees of CQLNode subtypes.
| Field Summary | |
|---|---|
boolean |
allowKeywordTerms
|
static int |
V1POINT1
|
static int |
V1POINT1SORT
|
static int |
V1POINT2
|
| Constructor Summary | |
|---|---|
CQLParser()
The new parser implements CQL 1.2 |
|
CQLParser(int compat)
The new parser implements a dialect of CQL specified by the compat argument: V1POINT1 - CQL version 1.1 V1POINT2 - CQL version 1.2 V1POINT1SORT - CQL version 1.1 but including sortby as specified for CQL 1.2. |
|
CQLParser(int compat,
boolean allowKeywordTerms)
Official CQL grammar allows registered keywords like 'and/or/not/sortby/prox' to be used unquoted in terms. |
|
| Method Summary | |
|---|---|
static void |
main(String[] args)
Simple test-harness for the CQLParser class. |
CQLNode |
parse(String cql)
Compiles a CQL query. |
boolean |
registerCustomRelation(String relation)
Registers custom relation in this parser. |
boolean |
unregisterCustomRelation(String relation)
Unregisters previously registered custom relation in this instance of the parser. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int V1POINT1
public static final int V1POINT2
public static final int V1POINT1SORT
public final boolean allowKeywordTerms
| Constructor Detail |
|---|
public CQLParser(int compat)
public CQLParser(int compat,
boolean allowKeywordTerms)
compat - CQL version compatibilityallowKeywordTerms - when false registered keywords are disallowed in unquoted termspublic CQLParser()
| Method Detail |
|---|
public boolean registerCustomRelation(String relation)
relation -
public boolean unregisterCustomRelation(String relation)
relation -
public CQLNode parse(String cql)
throws CQLParseException,
IOException
The resulting parse tree may be further processed by hand (see the individual node-types' documentation for details on the data structure) or, more often, simply rendered out in the desired form using one of the back-ends. toCQL() returns a decompiled CQL query equivalent to the one that was compiled in the first place; toXCQL() returns an XML snippet representing the query; and toPQF() returns the query rendered in Index Data's Prefix Query Format.
cql - The query
CQLParseException
IOExceptionpublic static void main(String[] args)
Reads a CQL query either from its command-line argument, if there is one, or standard input otherwise. So these two invocations are equivalent:
CQLParser 'au=(Kerninghan or Ritchie) and ti=Unix' echo au=(Kerninghan or Ritchie) and ti=Unix | CQLParserThe test-harness parses the supplied query and renders is as XCQL, so that both of the invocations above produce the following output:
<triple>
<boolean>
<value>and</value>
</boolean>
<triple>
<boolean>
<value>or</value>
</boolean>
<searchClause>
<index>au</index>
<relation>
<value>=</value>
</relation>
<term>Kerninghan</term>
</searchClause>
<searchClause>
<index>au</index>
<relation>
<value>=</value>
</relation>
<term>Ritchie</term>
</searchClause>
</triple>
<searchClause>
<index>ti</index>
<relation>
<value>=</value>
</relation>
<term>Unix</term>
</searchClause>
</triple>
-1 - CQL version 1.1 (default version 1.2)-d - Debug mode: extra output written to stderr.-c - Causes the output to be written in CQL rather than XCQL - that
is, a query equivalent to that which was input, is output. In
effect, the test harness acts as a query canonicaliser.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||