Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.slide.search.basic
Class NotNormalizer

    java.lang.Object
      org.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` 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` 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 BadQueryException

  Returns the transformed query where all `<not>` elements has been removed.

  Parameters:
    `expressionElement` - the (root) Element of the query to transform.
  Returns:
    the transformed query where all `<not>` elements has been removed.
  Throws:
    `BadQueryException` - if transformin the query failed (see `BAD_NOT_EXPRESSION_EXCEPTION_MESSAGE`).

### getProcessedElement

    protected org.jdom.Element getProcessedElement(org.jdom.Element expressionElement,
                                                   boolean negate)
                                            throws BadQueryException

  Returns the appropriate replacement for the given `expressionElement`. If `negate` is true, the Element has to be negated.

  Parameters:
    `expressionElement` - the Element for which to return the appropriate replacement.
    `negate` - if `negate` is true, the given Element has to be negated.
  Returns:
    the appropriate replacement for the given `expressionElement`.
  Throws:
    `BadQueryException` - if the Element could not be processed.

### getNegatedQueryElement

    protected org.jdom.Element getNegatedQueryElement(org.jdom.Element expressionElement)
                                               throws BadQueryException

  Returns the negation of the given `expressionElement`.

  Parameters:
    `expressionElement` - the Element to return the appropriate negation for.
  Returns:
    the negation of the given `expressionElement`.
  Throws:
    `BadQueryException` - if the Element could not be processed.

### getNegatedUnknownQueryElement

    protected org.jdom.Element getNegatedUnknownQueryElement(org.jdom.Element expressionElement)
                                                      throws BadQueryException

  Returns the negation of the given `expressionElement`, which is neither in `DAV:` nor `http://jakarta.apache.org/slide/` namespace.

  Parameters:
    `expressionElement` - the Element to return the appropriate negation for.
  Returns:
    the negation of the given `expressionElement`.
  Throws:
    `BadQueryException` - if the Element could not be processed.

### getNegatedDAVQueryElement

    protected org.jdom.Element getNegatedDAVQueryElement(org.jdom.Element expressionElement)
                                                  throws BadQueryException

  Returns the negation of the given `expressionElement`, which is in the `DAV:` namespace.

  Parameters:
    `expressionElement` - the Element to return the appropriate negation for.
  Returns:
    the negation of the given `expressionElement`.
  Throws:
    `BadQueryException` - if the Element could not be processed.

### getNegatedSlideQueryElement

    protected org.jdom.Element getNegatedSlideQueryElement(org.jdom.Element expressionElement)
                                                    throws BadQueryException

  Returns the negation of the given `expressionElement`, which is in the `http://jakarta.apache.org/slide/` namespace.

  Parameters:
    `expressionElement` - the Element to return the appropriate negation for.
  Returns:
    the negation of the given `expressionElement`.
  Throws:
    `BadQueryException` - if the Element could not be processed.

### 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.

  Parameters:
    `source` - the Element from which to copy the value and attributes.
    `newName` - the name to use for the Element to create.
    `newNamespace` - the Namespace to use for the Element to create.
  Returns:
    the created Element.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD