1-
21package org .z3950 .zing .cql ;
2+
33import java .util .Properties ;
44import java .util .Random ;
55import java .io .InputStream ;
66import java .io .FileInputStream ;
7- import java .io .FileNotFoundException ;
8-
97
108/**
119 * A generator that produces random CQL queries.
1210 * <P>
1311 * Why is that useful? Mainly to produce test-cases for CQL parsers
14- * (including the <TT >CQLParser</TT > class in this package): you can
12+ * (including the <code >CQLParser</code > class in this package): you can
1513 * generate a random search tree, render it to XCQL and remember the
1614 * result. Then decompile the tree to CQL, feed the generated CQL to
1715 * the parser of your choice, and check that the XCQL it comes up with
1816 * is the same what you got from your initial rendering.
1917 * <P>
20- * This code is based on the same grammar as the <TT >CQLParser</TT > class in
21- * this distribution - there is a <TT >generate_<I>x</I>()</TT > method
18+ * This code is based on the same grammar as the <code >CQLParser</code > class in
19+ * this distribution - there is a <code >generate_<I>x</I>()</code > method
2220 * for each grammar element <I>X</I>.
2321 *
2422 * @see <A href="http://zing.z3950.org/cql/index.html"
@@ -31,67 +29,61 @@ public class CQLGenerator {
3129
3230 /**
3331 * Creates a new CQL generator with the specified parameters.
34- * <P>
3532 * @param params
36- * A <TT >Properties</TT > table containing configuration
33+ * A <code >Properties</code > table containing configuration
3734 * parameters for the queries to be generated by this generator.
38- * Recognised parameters are:
3935 * <P>
36+ * Recognised parameters are:
37+ * </P>
4038 * <DL>
41- * <DT><TT >seed</TT ></DT>
39+ * <DT><code >seed</code ></DT>
4240 * <DD>
43- * If specified, this is a <TT >long</TT > used to seed the
41+ * If specified, this is a <code >long</code > used to seed the
4442 * random number generator, so that the CQL generator can be
4543 * run repeatably, giving the same results each time. If it's
4644 * omitted, then no seed is explicitly specified, and the
4745 * results of each run will be different (so long as you don't
4846 * run it more that 2^32 times :-)
49- * <P>
5047 * </DD>
51- * <DT><TT >complexQuery</TT ></DT>
48+ * <DT><code >complexQuery</code ></DT>
5249 * <DD>
5350 * [mandatory] A floating-point number between 0.0 and 1.0,
54- * indicating the probability for each <TT >cql-query</TT > node
51+ * indicating the probability for each <code >cql-query</code > node
5552 * that it will be expanded into a ``complex query''
56- * (<TT>cql-query boolean search-clause</TT>) rather
57- * than a <TT>search-clause</TT>.
58- * <P>
53+ * (<code>cql-query boolean search-clause</code>) rather
54+ * than a <code>search-clause</code>.
5955 * </DD>
60- * <DT><TT >complexClause</TT ></DT>
56+ * <DT><code >complexClause</code ></DT>
6157 * <DD>
6258 * [mandatory] A floating-point number between 0.0 and 1.0,
63- * indicating the probability for each <TT >search-clause</TT >
59+ * indicating the probability for each <code >search-clause</code >
6460 * node that it will be expanded into a full sub-query rather
65- * than an <TT>[ index relation ] term</TT> triplet.
66- * <P>
61+ * than an <code>[ index relation ] term</code> triplet.
6762 * </DD>
68- * <DT><TT >proxOp</TT ></DT>
63+ * <DT><code >proxOp</code ></DT>
6964 * <DD>
7065 * [mandatory] A floating-point number between 0.0 and 1.0,
7166 * indicating the probability that each boolean operator will
7267 * be chosen to be proximity operation; otherwise, the three
73- * simpler boolean operations (<TT>and</TT>, <TT>or</TT> and
74- * <TT>not</TT>) are chosen with equal probability.
75- * <P>
68+ * simpler boolean operations (<code>and</code>, <code>or</code> and
69+ * <code>not</code>) are chosen with equal probability.
7670 * </DD>
77- * <DT><TT >equalsRelation</TT ></DT>
71+ * <DT><code >equalsRelation</code ></DT>
7872 * <DD>
7973 * [mandatory] A floating-point number between 0.0 and 1.0,
8074 * indicating the probability that each relation will be chosen
81- * to be <TT >=</TT > - this is treated as a special case, since
75+ * to be <code >=</code > - this is treated as a special case, since
8276 * it's likely to be by far the most common relation in
8377 * ``real life'' searches.
84- * <P>
8578 * </DD>
86- * <DT><TT >numericRelation</TT ></DT>
87- * <DD>
79+ * <DT><code >numericRelation</code ></DT>
80+ * <DD>q
8881 * [mandatory] A floating-point number between 0.0 and 1.0,
8982 * indicating the probability that a relation, having chosen
90- * not to be <TT>=</TT>, is instead chosen to be one of the six
91- * numeric relations (<TT><</TT>, <TT>></TT>,
92- * <TT><=</TT>, <TT>>=</TT>, <TT><></TT> and
93- * <TT>=</TT>).
94- * <P>
83+ * not to be <code>=</code>, is instead chosen to be one of the six
84+ * numeric relations (<code><</code>, <code>></code>,
85+ * <code><=</code>, <code>>=</code>, <code><></code> and
86+ * <code>=</code>).
9587 * </DD>
9688 * </DL>
9789 */
@@ -116,11 +108,11 @@ private static void debug(String str) {
116108 * when it was created. You are free to create as many random
117109 * queries as you wish from a single generator; each of them will
118110 * use the same parameters.
119- * <P>
111+ * </ P>
120112 * @return
121- * A <TT >CQLNode</TT > that is the root of the generated tree.
122- * That tree may be rendered in XCQL using its <TT >toXCQL()</TT >
123- * method, or decompiled into CQL using its <TT >toCQL</TT >
113+ * A <code >CQLNode</code > that is the root of the generated tree.
114+ * That tree may be rendered in XCQL using its <code >toXCQL()</code >
115+ * method, or decompiled into CQL using its <code >toCQL</code >
124116 * method.
125117 */
126118 public CQLNode generate () throws MissingParameterException {
@@ -264,9 +256,9 @@ boolean maybe(String param) throws MissingParameterException {
264256 * decompiles it into CQL which is written to standard output.
265257 * <P>
266258 * For example,
267- * <TT >java org.z3950.zing.cql.CQLGenerator
268- * etc/generate.properties seed 18398</TT >,
269- * where the file <TT >generate.properties</TT > contains:<PRE>
259+ * <code >java org.z3950.zing.cql.CQLGenerator
260+ * etc/generate.properties seed 18398</code >,
261+ * where the file <code >generate.properties</code > contains:<PRE>
270262 * complexQuery=0.4
271263 * complexClause=0.4
272264 * equalsRelation=0.5
0 commit comments