Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.apache.slide.search.basic
Class NotNormalizer  view NotNormalizer download NotNormalizer.java

java.lang.Object
  extended byorg.apache.slide.search.basic.NotNormalizer

public class NotNormalizer
extends java.lang.Object

This class recursivly removes all <not> expressions and replaces their successors by appropriate negated expressions. Since an example explains more than a thousand words:

 <D:not>
    <D:or>
       <D:lt>
          <D:prop>
             <D:getcontentlength>
          </D:prop>
          <D:literal>1000</D:literal>
       </D:lt>
       <D:eq>
          <D:prop>
             <D:getcontenttype>
          </D:prop>
          <D:literal>text/xml</D:literal>
       </D:eq>
    </D:or>
 </D:not>
 
will be transformed to
 <D:and>
    <D:not-lt>
       <D:prop>
          <D:getcontentlength>
       </D:prop>
       <D:literal>1000</D:literal>
    </D:not-lt>
    <D:not-eq>
       <D:prop>
          <D:getcontenttype>
       </D:prop>
       <D:literal>text/xml</D:literal>
    </D:not-eq>
 </D:and>
 

Version:
$Revision: 1.6 $

Field Summary
static java.lang.String BAD_NOT_EXPRESSION_EXCEPTION_MESSAGE
          The message of the InvalidQueryException which is thrown by getQueryWithoutNotExpression 55 if a <not> expression has NOT exactly one successor.
 
Constructor Summary
NotNormalizer()
           
 
Method Summary
protected  org.jdom.Element getNamedClone(org.jdom.Element source, java.lang.String newName, org.jdom.Namespace newNamespace)
          Creates a new Element with the given newName in the newNamespace and sets the value (text) and attributes of the given source element.
protected  org.jdom.Element getNegatedDAVQueryElement(org.jdom.Element expressionElement)
          Returns the negation of the given expressionElement, which is in the DAV: namespace.
protected  org.jdom.Element getNegatedQueryElement(org.jdom.Element expressionElement)
          Returns the negation of the given expressionElement.
protected  org.jdom.Element getNegatedSlideQueryElement(org.jdom.Element expressionElement)
          Returns the negation of the given expressionElement, which is in the http://jakarta.apache.org/slide/ namespace.
protected  org.jdom.Element getNegatedUnknownQueryElement(org.jdom.Element expressionElement)
          Returns the negation of the given expressionElement, which is neither in DAV: nor http://jakarta.apache.org/slide/ namespace.
protected  org.jdom.Element getProcessedElement(org.jdom.Element expressionElement, boolean negate)
          Returns the appropriate replacement for the given expressionElement.
 org.jdom.Element getQueryWithoutNotExpression(org.jdom.Element expressionElement)
          Returns the transformed query where all <not> elements has been removed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BAD_NOT_EXPRESSION_EXCEPTION_MESSAGE

public static final java.lang.String BAD_NOT_EXPRESSION_EXCEPTION_MESSAGE
The message of the InvalidQueryException which is thrown by getQueryWithoutNotExpression 55 if a <not> expression has NOT exactly one successor.

See Also:
Constant Field Values
Constructor Detail

NotNormalizer

public NotNormalizer()
Method Detail

getQueryWithoutNotExpression

public org.jdom.Element getQueryWithoutNotExpression(org.jdom.Element expressionElement)
                                              throws org.apache.slide.search.BadQueryException
Returns the transformed query where all <not> elements has been removed.


getProcessedElement

protected org.jdom.Element getProcessedElement(org.jdom.Element expressionElement,
                                               boolean negate)
                                        throws org.apache.slide.search.BadQueryException
Returns the appropriate replacement for the given expressionElement. If negate is true, the Element has to be negated.


getNegatedQueryElement

protected org.jdom.Element getNegatedQueryElement(org.jdom.Element expressionElement)
                                           throws org.apache.slide.search.BadQueryException
Returns the negation of the given expressionElement.


getNegatedUnknownQueryElement

protected org.jdom.Element getNegatedUnknownQueryElement(org.jdom.Element expressionElement)
                                                  throws org.apache.slide.search.BadQueryException
Returns the negation of the given expressionElement, which is neither in DAV: nor http://jakarta.apache.org/slide/ namespace.


getNegatedDAVQueryElement

protected org.jdom.Element getNegatedDAVQueryElement(org.jdom.Element expressionElement)
                                              throws org.apache.slide.search.BadQueryException
Returns the negation of the given expressionElement, which is in the DAV: namespace.


getNegatedSlideQueryElement

protected org.jdom.Element getNegatedSlideQueryElement(org.jdom.Element expressionElement)
                                                throws org.apache.slide.search.BadQueryException
Returns the negation of the given expressionElement, which is in the http://jakarta.apache.org/slide/ namespace.


getNamedClone

protected org.jdom.Element getNamedClone(org.jdom.Element source,
                                         java.lang.String newName,
                                         org.jdom.Namespace newNamespace)
Creates a new Element with the given newName in the newNamespace and sets the value (text) and attributes of the given source element.