org.jafer.query.converter
Class JaferQueryConverter

java.lang.Object
  extended by org.jafer.query.converter.Converter
      extended by org.jafer.query.converter.JaferQueryConverter

public class JaferQueryConverter
extends Converter


Field Summary
private static QueryBuilder builder
          Stores a reference to the query builder
 
Constructor Summary
JaferQueryConverter()
           
 
Method Summary
static org.w3c.dom.Node normaliseJaferQuery(org.w3c.dom.Node jaferQueryNode)
          normalises the jafer query node to apply demorgans laws and clear up any double ngatives in the query
protected static org.w3c.dom.Node processAndNode(org.w3c.dom.Node node)
          Apply demorgans laws to the AND node
protected static org.w3c.dom.Node processNode(org.w3c.dom.Node node)
          This method applies the demorgan laws to convert the query to a normalised fashion.
protected static org.w3c.dom.Node processNotNode(org.w3c.dom.Node node)
          Apply demorgans laws to the NOT node and remove any double negatives
protected static org.w3c.dom.Node processOrNode(org.w3c.dom.Node node)
          Apply demorgans laws to the OR node
 
Methods inherited from class org.jafer.query.converter.Converter
findNotChild, getFirstChild, getNodeValue, getSecondChild, selectNode, selectNodeList
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

builder

private static QueryBuilder builder
Stores a reference to the query builder

Constructor Detail

JaferQueryConverter

public JaferQueryConverter()
Method Detail

normaliseJaferQuery

public static org.w3c.dom.Node normaliseJaferQuery(org.w3c.dom.Node jaferQueryNode)
                                            throws QueryException
normalises the jafer query node to apply demorgans laws and clear up any double ngatives in the query

Parameters:
jaferQueryNode - The query to process
Returns:
The normailised query
Throws:
QueryException

processNode

protected static org.w3c.dom.Node processNode(org.w3c.dom.Node node)
                                       throws QueryException
This method applies the demorgan laws to convert the query to a normalised fashion. It parses the whole tree converting:
  • not(g) or not(p) into not(g and p)
  • not(g) and not(p) into not(g or p)
  • and removes any double negatives not(not(g))

  • Parameters:
    node - The node to convert
    Returns:
    The resulting new node
    Throws:
    QueryException

    processOrNode

    protected static org.w3c.dom.Node processOrNode(org.w3c.dom.Node node)
                                             throws QueryException
    Apply demorgans laws to the OR node

    Parameters:
    node - The node to process
    Returns:
    The updated resulting node
    Throws:
    QueryException

    processAndNode

    protected static org.w3c.dom.Node processAndNode(org.w3c.dom.Node node)
                                              throws QueryException
    Apply demorgans laws to the AND node

    Parameters:
    node - The node to process
    Returns:
    The updated resulting node
    Throws:
    QueryException

    processNotNode

    protected static org.w3c.dom.Node processNotNode(org.w3c.dom.Node node)
                                              throws QueryException
    Apply demorgans laws to the NOT node and remove any double negatives

    Parameters:
    node - The node to process
    Returns:
    The updated resulting node
    Throws:
    QueryException