- // Test harness.
- //
- // e.g. echo '(au=Kerninghan or au=Ritchie) and ti=Unix' |
- // java org.z3950.zing.cql.CQLParser
- // yields:
- // <triple>
- // <boolean>and</boolean>
- // <triple>
- // <boolean>or</boolean>
- // <searchClause>
- // <index>au<index>
- // <relation>=<relation>
- // <term>Kerninghan<term>
- // </searchClause>
- // <searchClause>
- // <index>au<index>
- // <relation>=<relation>
- // <term>Ritchie<term>
- // </searchClause>
- // </triple>
- // <searchClause>
- // <index>ti<index>
- // <relation>=<relation>
- // <term>Unix<term>
- // </searchClause>
- // </triple>
- //
+ /**
+ * Simple test-harness for the CQLParser class.
+ * <P>
+ * Reads a CQL query either from its command-line argument, if
+ * there is one, or standard input otherwise. So these two
+ * invocations are equivalent:
+ * <PRE>
+ * CQLParser 'au=(Kerninghan or Ritchie) and ti=Unix'
+ * echo au=(Kerninghan or Ritchie) and ti=Unix | CQLParser
+ * </PRE>
+ * The test-harness parses the supplied query and renders is as
+ * XCQL, so that both of the invocations above produce the
+ * following output:
+ * <PRE>
+ * <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>
+ * </PRE>
+ * <P>
+ * @param -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.
+ * @return
+ * The input query, either as XCQL [default] or CQL [if the
+ * <TT>-c</TT> option is supplied].
+ */