|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.z3950.zing.cql.CQLGenerator
public class CQLGenerator
A generator that produces random CQL queries.
Why is that useful? Mainly to produce test-cases for CQL parsers (including the CQLParser class in this package): you can generate a random search tree, render it to XCQL and remember the result. Then decompile the tree to CQL, feed the generated CQL to the parser of your choice, and check that the XCQL it comes up with is the same what you got from your initial rendering.
This code is based on the same grammar as the CQLParser class in this distribution - there is a generate_x() method for each grammar element X.
Constructor Summary | |
---|---|
CQLGenerator(java.util.Properties params)
Creates a new CQL generator with the specified parameters. |
Method Summary | |
---|---|
CQLNode |
generate()
Generates a single random CQL query. |
static void |
main(java.lang.String[] args)
A simple test-harness for the generator. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public CQLGenerator(java.util.Properties params)
params
- A Properties table containing configuration
parameters for the queries to be generated by this generator.
Recognised parameters are:
Method Detail |
---|
public CQLNode generate() throws MissingParameterException
Uses the parameters that were associated with the generator when it was created. You are free to create as many random queries as you wish from a single generator; each of them will use the same parameters.
MissingParameterException
public static void main(java.lang.String[] args) throws java.lang.Exception
It generates a single random query using the parameters specified in a nominated properties file, plus any additional name value pairs provided on the command-line, and decompiles it into CQL which is written to standard output.
For example, java org.z3950.zing.cql.CQLGenerator etc/generate.properties seed 18398, where the file generate.properties contains:
complexQuery=0.4 complexClause=0.4 equalsRelation=0.5 numericRelation=0.7 proxOp=0.0yields:
((dc.author = "<xml.element>") or (bath.title = cat)) and (dc.subject >= "the complete dinosaur")
configFile
- The name of a properties file from which to read the
configuration parameters (see above).name
- The name of a configuration parameter.value
- The value to assign to the configuration parameter named in
the immediately preceding command-line argument.
java.lang.Exception
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |