com.gentics.api.lib.expressionparser.filtergenerator
Interface DatasourceFilter

All Superinterfaces:
Cloneable, Serializable

public interface DatasourceFilter
extends Serializable, Cloneable

Interface for FilterGenerators. Implementations transform expressions into Datasource-specific filters.


Method Summary
 void addBaseResolvable(String baseName, Resolvable resolvable)
          Add a base resolvable to the resolver with the given baseName
 void addPostProcessor(PostProcessor postProcessor, EvaluableExpression data)
          Add a post processor to this filter
 boolean allowsNullValues(String attributeName)
          Determines if the given attribute may contain null values.
 void doPostProcessing(List<Resolvable> result, ExpressionQueryRequest request)
          Do post processing of the result.
 FilterPart generateConstantFilterPart(String constantString, Object[] params)
          Generate a filterpart for a constant string with optional parameters
 FilterPart generateLiteralFilterPart(Object literal, int expectedValueType)
          Generate a filterpart for a literal.
 FilterPart generateVariableFilterPart(String expressionName, int expectedValueType)
          Generate a filterpart for a variable.
 Class getDatasourceClass()
          Get the datasource class of this datasource filter
 String getExpressionString()
          Get the expression string of this filter
 FilterPart getMainFilterPart()
          Get the main filterpart of this filter.
 PropertyResolver getResolver()
          Get the resolver to resolve object paths
 int getValueType(String attributeName)
          Get the value type of the given attribute
 String getVariableName(String expressionName, int expectedValueType)
          Convert the name of a variable in the expression into the datasource specific name
 boolean hasPostProcessors()
          Check whether the filter contains PostProcessors
 void setCustomResolver(PropertyResolver resolver)
          Set a custom resolver into the filter.
 

Method Detail

getVariableName

String getVariableName(String expressionName,
                       int expectedValueType)
                       throws FilterGeneratorException
Convert the name of a variable in the expression into the datasource specific name

Parameters:
expressionName - name in the expression (something like 'object.path_to_property')
expectedValueType - expected value type
Returns:
datasource specific name of the variable to be used in the filter statement
Throws:
FilterGeneratorException

getDatasourceClass

Class getDatasourceClass()
Get the datasource class of this datasource filter

Returns:
datasource class

getResolver

PropertyResolver getResolver()
Get the resolver to resolve object paths

Returns:
resolver to resolve object paths

setCustomResolver

void setCustomResolver(PropertyResolver resolver)
Set a custom resolver into the filter. When a custom resolver is set, any subsequent call to addBaseResolvable(String, Resolvable) will throw an exception and previously set base resolvables will not be used. When the custom resolver is unset (set to null), the previously set base resolvables will be used.

Parameters:
resolver - resolver to set or null to unset the custom resolver

addBaseResolvable

void addBaseResolvable(String baseName,
                       Resolvable resolvable)
                       throws FilterGeneratorException
Add a base resolvable to the resolver with the given baseName

Parameters:
baseName - base name of the resolvable (must not be "object")
resolvable - resolvable to add
Throws:
FilterGeneratorException - when the resolvable cannot be added

generateConstantFilterPart

FilterPart generateConstantFilterPart(String constantString,
                                      Object[] params)
                                      throws FilterGeneratorException
Generate a filterpart for a constant string with optional parameters

Parameters:
constantString - constant statement part
params - optional parameters, may be empty or null
Returns:
filterpart for a constant statement part
Throws:
FilterGeneratorException

generateVariableFilterPart

FilterPart generateVariableFilterPart(String expressionName,
                                      int expectedValueType)
                                      throws FilterGeneratorException
Generate a filterpart for a variable.

Parameters:
expressionName - name of the expression, should start with "object."
expectedValueType - expected value type
Returns:
filterpart for the variable
Throws:
FilterGeneratorException

generateLiteralFilterPart

FilterPart generateLiteralFilterPart(Object literal,
                                     int expectedValueType)
                                     throws FilterGeneratorException
Generate a filterpart for a literal.

Parameters:
literal - literal value
expectedValueType - expected value type.
Returns:
filterpart for a literal
Throws:
FilterGeneratorException

getMainFilterPart

FilterPart getMainFilterPart()
Get the main filterpart of this filter. This filter part is the entry point for all generated filterparts.

Returns:
main filterpart

getExpressionString

String getExpressionString()
Get the expression string of this filter

Returns:
expression string of this filter

allowsNullValues

boolean allowsNullValues(String attributeName)
                         throws FilterGeneratorException
Determines if the given attribute may contain null values.

Parameters:
attributeName - name of the attribute
Returns:
true if the attribute can contain null values.
Throws:
FilterGeneratorException

getValueType

int getValueType(String attributeName)
                 throws FilterGeneratorException
Get the value type of the given attribute

Parameters:
attributeName - attribute name
Returns:
value type
Throws:
FilterGeneratorException

doPostProcessing

void doPostProcessing(List<Resolvable> result,
                      ExpressionQueryRequest request)
                      throws ExpressionParserException
Do post processing of the result.

Parameters:
result - current result of the filter
request - request
Throws:
ExpressionParserException

hasPostProcessors

boolean hasPostProcessors()
Check whether the filter contains PostProcessors

Returns:
true if the filter contains PostProcessors, false if not

addPostProcessor

void addPostProcessor(PostProcessor postProcessor,
                      EvaluableExpression data)
                      throws ExpressionParserException
Add a post processor to this filter

Parameters:
postProcessor - post processor instance
data - evaluable expression that will be evaluated and the result passed to the post processor in the call PostProcessor#process(List, Object).
Throws:
ExpressionParserException


Copyright © 2013 Gentics Software GmbH. All Rights Reserved.