org.outerj.daisy.query.model
Interface ValueExpr

All Superinterfaces:
Expression
All Known Subinterfaces:
Function
All Known Implementing Classes:
AbsFunction, AbstractBinaryMathFunction, AbstractCaseFunction, AbstractFunction, AbstractUnaryMathFunction, AddFunction, CeilingFunction, ConcatFunction, ContextDocFunction, CurrentDateFunction, CurrentDateTimeFunction, DateComponentFunction, DayOfMonthFunction, DayOfWeekFunction, DayOfYearFunction, DivideFunction, FloorFunction, Identifier, LeftFunction, LengthFunction, Literal, LowerCaseFunction, ModFunction, MonthFunction, MultiplyFunction, RandomFunction, RelativeDateFunction, RelativeDateTimeFunction, RightFunction, RoundFunction, SubstractFunction, SubstringFunction, UpperCaseFunction, UserIdFunction, WeekFunction, YearFunction

public interface ValueExpr
extends Expression

An expression which evaluates to some value.


Method Summary
 int bindPreConditions(java.sql.PreparedStatement stmt, int bindPos)
           
 int bindValueExpr(java.sql.PreparedStatement stmt, int bindPos, QValueType valueType, org.outerj.daisy.repository.query.EvaluationContext evaluationContext)
           
 boolean canTestAppliesTo()
           
 java.lang.Object evaluate(QValueType valueType, org.outerj.daisy.repository.Document document, org.outerj.daisy.repository.Version version, org.outerj.daisy.repository.query.EvaluationContext evaluationContext)
          Evaluates this expression for the given document and/or version.
 java.lang.Object evaluate(QValueType valueType, org.outerj.daisy.repository.query.EvaluationContext evaluationContext)
          Evaluates the expression without access to document information.
 void generateSqlValueExpr(java.lang.StringBuffer sql, SqlGenerationContext context)
          Generates the SQL for this expression.
 java.lang.String getExpression()
          Get a textual representation of this expression, i.e.
 java.lang.Object getOutputValue(org.outerj.daisy.repository.Document document, org.outerj.daisy.repository.Version version, org.outerj.daisy.repository.query.EvaluationContext evaluationContext)
          Returns the output value of this identifier for the given document and version.
 QValueType getOutputValueType()
          Identifies the type of data returned from the getOutputValue(org.outerj.daisy.repository.Document, org.outerj.daisy.repository.Version, EvaluationContext) method.
 java.lang.String getSqlPreConditions(SqlGenerationContext context)
          Generates any SQL conditions needed outside of the main value expression (which is generated using generateSqlValueExpr(StringBuffer, SqlGenerationContext)).
 java.lang.String getTitle(java.util.Locale locale)
           
 QValueType getValueType()
          Returns the ValueType of this expression, or null if undetermined.
 AclConditionViolation isAclAllowed()
          Returns non-null if this ValueExpr is not fitted for use in ACL document selection expressions.
 boolean isMultiValue()
           
 boolean isOutputOnly()
          Returns true for ValueExpr's which cannot be searched on (i.e.
 boolean isSymbolicIdentifier()
          Returns true if this ValueExpr represents a symbolic identifier.
 void prepare(QueryContext context)
          A method that should be called before any of the others.
 java.lang.Object translateSymbolic(ValueExpr valueExpr, org.outerj.daisy.repository.query.EvaluationContext evaluationContext)
          See isSymbolicIdentifier().
 
Methods inherited from interface org.outerj.daisy.query.model.Expression
getColumn, getLine, getLocation, setLocation
 

Method Detail

prepare

void prepare(QueryContext context)
             throws org.outerj.daisy.repository.query.QueryException
A method that should be called before any of the others.

Throws:
org.outerj.daisy.repository.query.QueryException

evaluate

java.lang.Object evaluate(QValueType valueType,
                          org.outerj.daisy.repository.query.EvaluationContext evaluationContext)
                          throws org.outerj.daisy.repository.query.QueryException
Evaluates the expression without access to document information. This will only work for expressions that do not need access to information from the document (thus typically without identifiers), otherwise this will throw an exception.

Parameters:
valueType - Indicates the type of object to return. This parameter only matters when
Throws:
org.outerj.daisy.repository.query.QueryException

evaluate

java.lang.Object evaluate(QValueType valueType,
                          org.outerj.daisy.repository.Document document,
                          org.outerj.daisy.repository.Version version,
                          org.outerj.daisy.repository.query.EvaluationContext evaluationContext)
                          throws org.outerj.daisy.repository.query.QueryException
Evaluates this expression for the given document and/or version. The version argument can be null, in which case the data will be retrieved from the document object.

Throws:
org.outerj.daisy.repository.query.QueryException

getValueType

QValueType getValueType()
Returns the ValueType of this expression, or null if undetermined.


isSymbolicIdentifier

boolean isSymbolicIdentifier()
Returns true if this ValueExpr represents a symbolic identifier. A symbolic identifier is an identifier that identifies an object by name in the query, but uses an ID to search on the database.

If this method returns true, then translateSymbolic(org.outerj.daisy.query.model.ValueExpr, org.outerj.daisy.repository.query.EvaluationContext) can be called to convert the symbolic value to the test value.


translateSymbolic

java.lang.Object translateSymbolic(ValueExpr valueExpr,
                                   org.outerj.daisy.repository.query.EvaluationContext evaluationContext)
                                   throws org.outerj.daisy.repository.query.QueryException
See isSymbolicIdentifier(). This method should only be called if isSymbolicIdentifier() returns true.

Throws:
org.outerj.daisy.repository.query.QueryException

isMultiValue

boolean isMultiValue()

isOutputOnly

boolean isOutputOnly()
Returns true for ValueExpr's which cannot be searched on (i.e. no SQL can be generated) and which cannot be evaluated. Thus valueExpr's which can be used in the select and order by parts of a query, but not in the where part.


isAclAllowed

AclConditionViolation isAclAllowed()
Returns non-null if this ValueExpr is not fitted for use in ACL document selection expressions.


getSqlPreConditions

java.lang.String getSqlPreConditions(SqlGenerationContext context)
                                     throws org.outerj.daisy.repository.query.QueryException
Generates any SQL conditions needed outside of the main value expression (which is generated using generateSqlValueExpr(StringBuffer, SqlGenerationContext)).

Should throw an exception if this is an output-only ValueExpr.

Returns:
null if not applicable
Throws:
org.outerj.daisy.repository.query.QueryException

generateSqlValueExpr

void generateSqlValueExpr(java.lang.StringBuffer sql,
                          SqlGenerationContext context)
                          throws org.outerj.daisy.repository.query.QueryException
Generates the SQL for this expression.

Should throw an exception if this is an output-only ValueExpr.

Throws:
org.outerj.daisy.repository.query.QueryException

bindPreConditions

int bindPreConditions(java.sql.PreparedStatement stmt,
                      int bindPos)
                      throws java.sql.SQLException,
                             org.outerj.daisy.repository.query.QueryException
Throws:
java.sql.SQLException
org.outerj.daisy.repository.query.QueryException

bindValueExpr

int bindValueExpr(java.sql.PreparedStatement stmt,
                  int bindPos,
                  QValueType valueType,
                  org.outerj.daisy.repository.query.EvaluationContext evaluationContext)
                  throws java.sql.SQLException,
                         org.outerj.daisy.repository.query.QueryException
Throws:
java.sql.SQLException
org.outerj.daisy.repository.query.QueryException

getTitle

java.lang.String getTitle(java.util.Locale locale)

getExpression

java.lang.String getExpression()
Get a textual representation of this expression, i.e. something that could be parsed again and give the same ValueExpr again.


getOutputValueType

QValueType getOutputValueType()
Identifies the type of data returned from the getOutputValue(org.outerj.daisy.repository.Document, org.outerj.daisy.repository.Version, EvaluationContext) method.


getOutputValue

java.lang.Object getOutputValue(org.outerj.daisy.repository.Document document,
                                org.outerj.daisy.repository.Version version,
                                org.outerj.daisy.repository.query.EvaluationContext evaluationContext)
                                throws org.outerj.daisy.repository.query.QueryException
Returns the output value of this identifier for the given document and version. For symbolic identifiers this will be different from the value returned by evaluate(QValueType, org.outerj.daisy.repository.Document, org.outerj.daisy.repository.Version, EvaluationContext). The version is allowed to be null.

Throws:
org.outerj.daisy.repository.query.QueryException

canTestAppliesTo

boolean canTestAppliesTo()


Copyright © -2012 . All Rights Reserved.