org.jafer.interfaces
Interface QueryBuilder

All Known Implementing Classes:
QueryBuilder

public interface QueryBuilder

Interface for implementing QueryBuilder utility class. Allows the building of XML based queries

All methods use a default search profile if one has been set in ZClient.

Some getNode() methods allow the default search profile to be altered for that query.

(The value of the term supplied to each method cannot be null or an empty String).

Author:
: Antony Corfield; Matthew Dovey; Colin Tatham

Method Summary
 org.w3c.dom.Node and(org.w3c.dom.Node leftNode, org.w3c.dom.Node rightNode)
          Produces an AND node from 2 nodes, which can be query nodes, or AND, OR or NOT nodes.
 org.w3c.dom.Node getNode(int[][] attTypesValues, java.lang.String term)
          Creates a basic query node incorporating the attributes and term supplied.
 org.w3c.dom.Node getNode(int[] attributes, java.lang.String term)
          Creates a basic query node incorporating the attributes and term supplied.
 org.w3c.dom.Node getNode(int useAttribute, java.lang.String term)
          Creates a basic query node incorporating the attribute and term supplied.
 org.w3c.dom.Node getNode(java.lang.String useAttribute, java.lang.String term)
          Creates a basic query node incorporating the attribute and term supplied.
 org.w3c.dom.Node not(org.w3c.dom.Node inputNode)
          Produces a NOT node from a query node, or an AND or OR node.
 org.w3c.dom.Node or(org.w3c.dom.Node leftNode, org.w3c.dom.Node rightNode)
          Produces an OR node from 2 nodes, which can be query nodes, or AND, OR or NOT nodes.
 

Method Detail

getNode

public org.w3c.dom.Node getNode(java.lang.String useAttribute,
                                java.lang.String term)
                         throws QueryException
Creates a basic query node incorporating the attribute and term supplied.

Attribute supplied must be a Use attribute.

Attribute value is checked against lookup table in org.jafer.util.Bib1Attributes.

Parameters:
useAttribute - represents the Use attribute to be used in the query, e.g. "title".
term - the term to be used in the query.
Returns:
a query node, -- returned via getNode(int[] attributes, String term)
Throws:
org.jafer.zclient.QueryException - if useAttribute parameter is not found in lookup table.
QueryException

getNode

public org.w3c.dom.Node getNode(int useAttribute,
                                java.lang.String term)
                         throws QueryException
Creates a basic query node incorporating the attribute and term supplied.

Attribute supplied can only be a Use attribute.

useAttribute parameter is checked against lookup table in org.jafer.util.Bib1Attributes.java.

Parameters:
useAttribute - represents the Use attribute to be used in the query.
term - the term to be used in the query.
Returns:
a query node, -- returned via getNode(int[] attributes, String term)
Throws:
org.jafer.zclient.QueryException - if useAttribute parameter is not within the ranges in the look-up table.
QueryException

getNode

public org.w3c.dom.Node getNode(int[] attributes,
                                java.lang.String term)
                         throws QueryException
Creates a basic query node incorporating the attributes and term supplied.

The int[] parameter values are used in order for:

{Use, Relation, Position, Structure, Truncation, Completeness}

e.g. { 4, 3, 3, 2, 100, 1 }

A smaller sized array can be used, in which case the values given will be interpreted in order, following the pattern above.

If a default search profile has been set, it will be altered for this query: any values given in the parameter will replace corresponding default values.

(A parameter value of 0 will result in the corresponding attribute type to be excluded from the query.)

Parameters:
attributes - represents the attribute values to be used in the query.
term - the term to be used in the query.
Returns:
a query node, -- returned via private method buildConstraintModelNode(int[] attributes, String term)
Throws:
org.jafer.zclient.QueryException - if attributes array size is smaller than 1, or larger than 6. Also if the first attributes element is 0, or term is an empty String or null.
QueryException

getNode

public org.w3c.dom.Node getNode(int[][] attTypesValues,
                                java.lang.String term)
                         throws QueryException
Creates a basic query node incorporating the attributes and term supplied.

The int[][] parameter holds the attribute type and corresponding value.

e.g. {{1,1003}, {2,3}, {4,2}} would set:

Use = 1003, Relation = 3 and Structure = 2.

If a default search profile has been set, the parameter values supplied will override the corresponding default values, for this query.

(A value of 0 will cause that attribute type to be ignored for this query, even if a default search profile has been set.)

Parameters:
attTypesValues - represents the attribute types and their corresponding values to be used in the query.
term - the term to be used in the query.
Returns:
a query node, -- returned via private method buildConstraintModelNode(int[] attributes, String term)
Throws:
org.jafer.zclient.QueryException - if attTypesValues array size is smaller than 1, or larger than 6. Also if the first attributes element is 0, or not supplied. Also if term is an empty String or null.
QueryException

and

public org.w3c.dom.Node and(org.w3c.dom.Node leftNode,
                            org.w3c.dom.Node rightNode)
                     throws QueryException
Produces an AND node from 2 nodes, which can be query nodes, or AND, OR or NOT nodes.

Parameters:
leftNode - a query, AND, OR or NOT node.
rightNode - a query, AND, OR or NOT node.
Returns:
an AND node.
QueryException

or

public org.w3c.dom.Node or(org.w3c.dom.Node leftNode,
                           org.w3c.dom.Node rightNode)
                    throws QueryException
Produces an OR node from 2 nodes, which can be query nodes, or AND, OR or NOT nodes.

Parameters:
leftNode - a query, AND, OR or NOT node.
rightNode - a query, AND, OR or NOT node.
Returns:
an OR node.
QueryException

not

public org.w3c.dom.Node not(org.w3c.dom.Node inputNode)
                     throws QueryException
Produces a NOT node from a query node, or an AND or OR node.

Parameters:
inputNode - a query, AND or OR node.
Returns:
a NOT node.
QueryException