org.jafer.query
Class JaferQuery

java.lang.Object
  extended by org.jafer.query.JaferQuery
All Implemented Interfaces:
QueryConverter

public class JaferQuery
extends java.lang.Object
implements QueryConverter


Field Summary
protected  org.w3c.dom.Node queryRoot
          Stores a reference to the root of the jafer query
 
Constructor Summary
protected JaferQuery()
          Protected empty constructor to allow test utilities to create query without performing normalisation
  JaferQuery(org.w3c.dom.Node query)
          Constructor that forbids a NOT clause at the start of the query to avoid conversion errors when translating to a query language that does not support UNARY not clauses.
  JaferQuery(org.w3c.dom.Node query, boolean allowTopLevelNot)
          Constructor that optionally allows a NOT clause at the start of the query
 
Method Summary
 org.w3c.dom.Node getQuery()
          Get the constructed query object
 java.lang.String getXML()
          This method returns a string representation of the XML for the current query
private  void initialise(org.w3c.dom.Node query, boolean allowTopLevelNot)
          Initialises the JaferQuery by normalising the query and optionally allowing a NOT clause at the start of the query.
 CQLQuery toCQLQuery()
          This method converts the current Query representation into a CQLQuery object
 JaferQuery toJaferQuery()
          This method converts the current Query representation into a JaferQuery object
 RPNQuery toRPNQuery()
          This method converts the current Query representation into a RPNQuery object
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

queryRoot

protected org.w3c.dom.Node queryRoot
Stores a reference to the root of the jafer query

Constructor Detail

JaferQuery

protected JaferQuery()
Protected empty constructor to allow test utilities to create query without performing normalisation


JaferQuery

public JaferQuery(org.w3c.dom.Node query)
           throws QueryException
Constructor that forbids a NOT clause at the start of the query to avoid conversion errors when translating to a query language that does not support UNARY not clauses.

Parameters:
query - A root node element in the format of a JaferQuery
Throws:
QueryException

JaferQuery

public JaferQuery(org.w3c.dom.Node query,
                  boolean allowTopLevelNot)
           throws QueryException
Constructor that optionally allows a NOT clause at the start of the query

Parameters:
query - A root node element in the format of a JaferQuery
allowTopLevelNot - If true the JaferQuery is allowed to be created when the normalisation process completes with a NOT at the top level.
Throws:
QueryException
Method Detail

initialise

private void initialise(org.w3c.dom.Node query,
                        boolean allowTopLevelNot)
                 throws QueryException
Initialises the JaferQuery by normalising the query and optionally allowing a NOT clause at the start of the query. If NOT is allowed then this means that if its translated to a query that does not support unary NOTs then it will either fail conversion or an extra entry of all records will be added

Parameters:
query - A root node element in the format of a JaferQuery
allowTopLevelNot - If true the JaferQuery is allowed to be created when the normalisation process completes with a NOT at the top level.
Throws:
QueryException

getQuery

public org.w3c.dom.Node getQuery()
Get the constructed query object

Returns:
the root node of the jafer query

toCQLQuery

public CQLQuery toCQLQuery()
                    throws QueryException
This method converts the current Query representation into a CQLQuery object

Specified by:
toCQLQuery in interface QueryConverter
Returns:
A new CQLQuery
Throws:
QueryException

toJaferQuery

public JaferQuery toJaferQuery()
This method converts the current Query representation into a JaferQuery object

Specified by:
toJaferQuery in interface QueryConverter
Returns:
A new JaferQuery

toRPNQuery

public RPNQuery toRPNQuery()
                    throws QueryException
This method converts the current Query representation into a RPNQuery object

Specified by:
toRPNQuery in interface QueryConverter
Returns:
A new RPNQuery
Throws:
QueryException

getXML

public java.lang.String getXML()
                        throws QueryException
This method returns a string representation of the XML for the current query

Specified by:
getXML in interface QueryConverter
Returns:
The query in XML
Throws:
JaferException
QueryException