org.apache.slide.search.basic
Class BasicExpressionCompiler

java.lang.Object
  extended byorg.apache.slide.search.basic.BasicExpressionCompiler
All Implemented Interfaces:
IBasicExpressionCompiler

public class BasicExpressionCompiler
extends java.lang.Object
implements IBasicExpressionCompiler

The implementation of the IBasicExpressionCompiler interface.

Version:
$Revision: 1.4.2.1 $
Author:
Ralf Stuckert

Field Summary
protected  boolean alreadyTriedToInstantiate
          Inidicates if it has already been tried to instantiate the storeSpecificExpressionFactory.
protected  IBasicExpressionFactory defaultExpressionFactory
          The default IBasicExpressionFactory to use.
protected  PropertyProvider propertyProvider
          The PropertyProvider to use (if set).
protected  IBasicQuery query
          The IBasicQuery that provides some general information about the query.
protected  IBasicExpressionFactory storeSpecificExpressionFactory
          The store specific IBasicExpressionFactory to use (if one exists).
 
Constructor Summary
BasicExpressionCompiler(IBasicQuery query, PropertyProvider propertyProvider)
          Creates the BasicExpressionCompiler.
BasicExpressionCompiler(IBasicQuery query, PropertyProvider propertyProvider, IBasicExpressionFactory defaultExpressionFactory)
          Creates the BasicExpressionCompiler.
 
Method Summary
 IBasicExpression compile(org.jdom.Element expressionElement)
          Compiles an IBasicExpression (-tree) from the given expressionElement.
(package private)  IBasicExpression createExpression(org.jdom.Element expressionElement)
          Creates a (non-merge) expression (compare...) for the given Element.
(package private)  IBasicExpression createMergeExpression(java.lang.String name, java.lang.String namespace, java.util.List expressionsToMerge)
          Creates a MergeExpression for the given element (AND, OR).
 IBasicExpressionFactory getDefaultExpressionFactory()
          Returns the default expression factory to use.
 IBasicExpressionFactory getStoreSpecificExpressionFactory()
          Returns the store specific expression factory to use.
static boolean isMergeExpression(org.jdom.Element expressionElement)
          Returns true if the given expressionElement describes a merge expression.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

query

protected IBasicQuery query
The IBasicQuery that provides some general information about the query.


propertyProvider

protected PropertyProvider propertyProvider
The PropertyProvider to use (if set).


defaultExpressionFactory

protected IBasicExpressionFactory defaultExpressionFactory
The default IBasicExpressionFactory to use.


storeSpecificExpressionFactory

protected IBasicExpressionFactory storeSpecificExpressionFactory
The store specific IBasicExpressionFactory to use (if one exists).


alreadyTriedToInstantiate

protected boolean alreadyTriedToInstantiate
Inidicates if it has already been tried to instantiate the storeSpecificExpressionFactory.

Constructor Detail

BasicExpressionCompiler

public BasicExpressionCompiler(IBasicQuery query,
                               PropertyProvider propertyProvider)
                        throws BadQueryException
Creates the BasicExpressionCompiler.

Parameters:
query - the IBasicQuery.
propertyProvider - the PropertyProvider to use (may be null).

BasicExpressionCompiler

public BasicExpressionCompiler(IBasicQuery query,
                               PropertyProvider propertyProvider,
                               IBasicExpressionFactory defaultExpressionFactory)
                        throws BadQueryException
Creates the BasicExpressionCompiler.

Parameters:
query - the IBasicQuery.
propertyProvider - the PropertyProvider to use (may be null).
defaultExpressionFactory - the default IBasicExpressionFactory to use.
Method Detail

compile

public IBasicExpression compile(org.jdom.Element expressionElement)
                         throws BadQueryException
Compiles an IBasicExpression (-tree) from the given expressionElement.

Specified by:
compile in interface IBasicExpressionCompiler
Parameters:
expressionElement - the (root) expression Element to compile into an IBasicExpression.
Returns:
the compiled IBasicExpression.
Throws:
BadQueryException - if compiling the expression failed.

createMergeExpression

IBasicExpression createMergeExpression(java.lang.String name,
                                       java.lang.String namespace,
                                       java.util.List expressionsToMerge)
                                 throws BadQueryException
Creates a MergeExpression for the given element (AND, OR). The given children are the expressions to merge.

Parameters:
name - the name of the Element describing the merge expression.
namespace - the namespace of the Element describing the merge expression.
expressionsToMerge - the expressions to merge.
Returns:
an IBasicExpression
Throws:
BadQueryException

createExpression

IBasicExpression createExpression(org.jdom.Element expressionElement)
                            throws BadQueryException
Creates a (non-merge) expression (compare...) for the given Element.

Parameters:
expressionElement - an Element describing the expression.
Returns:
an IBasicExpression
Throws:
BadQueryException

getDefaultExpressionFactory

public IBasicExpressionFactory getDefaultExpressionFactory()
                                                    throws BadQueryException
Returns the default expression factory to use. If it does not exist yet, a BasicExpressionFactory will be created and initialized.

Returns:
the default expression factory to use.
Throws:
BadQueryException

getStoreSpecificExpressionFactory

public IBasicExpressionFactory getStoreSpecificExpressionFactory()
                                                          throws BadQueryException
Returns the store specific expression factory to use.

Returns:
the store specific expression factory to use.
Throws:
BadQueryException

isMergeExpression

public static boolean isMergeExpression(org.jdom.Element expressionElement)
Returns true if the given expressionElement describes a merge expression.

Parameters:
expressionElement - the Element that describes the expression.
Returns:
true if the given expressionElement describes a merge expression.