org.outerj.daisy.query.model
Class Literal

java.lang.Object
  extended by org.outerj.daisy.query.model.Literal
All Implemented Interfaces:
Expression, ValueExpr

public final class Literal
extends java.lang.Object
implements ValueExpr


Constructor Summary
Literal(java.lang.String value, java.lang.String originalToken)
           
 
Method Summary
static int bindLiteral(java.sql.PreparedStatement stmt, int bindPos, QValueType valueType, java.lang.Object value)
          Utility method for use by other classes.
 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)
           
 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.
 int getColumn()
           
 java.lang.String getExpression()
          Get a textual representation of this expression, i.e.
 int getLine()
           
 java.lang.String getLocation()
           
 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 ValueExpr.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 ValueExpr.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.
 void setLocation(int line, int column)
           
 java.lang.Object translateSymbolic(ValueExpr valueExpr, org.outerj.daisy.repository.query.EvaluationContext evaluationContext)
          See ValueExpr.isSymbolicIdentifier().
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Literal

public Literal(java.lang.String value,
               java.lang.String originalToken)
Method Detail

setLocation

public void setLocation(int line,
                        int column)
Specified by:
setLocation in interface Expression

getLocation

public java.lang.String getLocation()
Specified by:
getLocation in interface Expression

getLine

public int getLine()
Specified by:
getLine in interface Expression

getColumn

public int getColumn()
Specified by:
getColumn in interface Expression

evaluate

public java.lang.Object evaluate(QValueType valueType,
                                 org.outerj.daisy.repository.query.EvaluationContext evaluationContext)
                          throws org.outerj.daisy.repository.query.QueryException
Description copied from interface: ValueExpr
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.

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

evaluate

public java.lang.Object evaluate(QValueType valueType)
                          throws org.outerj.daisy.repository.query.QueryException
Throws:
org.outerj.daisy.repository.query.QueryException

evaluate

public 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
Description copied from interface: ValueExpr
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.

Specified by:
evaluate in interface ValueExpr
Throws:
org.outerj.daisy.repository.query.QueryException

isMultiValue

public boolean isMultiValue()
Specified by:
isMultiValue in interface ValueExpr

prepare

public void prepare(QueryContext context)
Description copied from interface: ValueExpr
A method that should be called before any of the others.

Specified by:
prepare in interface ValueExpr

isOutputOnly

public boolean isOutputOnly()
Description copied from interface: ValueExpr
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.

Specified by:
isOutputOnly in interface ValueExpr

isAclAllowed

public AclConditionViolation isAclAllowed()
Description copied from interface: ValueExpr
Returns non-null if this ValueExpr is not fitted for use in ACL document selection expressions.

Specified by:
isAclAllowed in interface ValueExpr

getSqlPreConditions

public java.lang.String getSqlPreConditions(SqlGenerationContext context)
Description copied from interface: ValueExpr
Generates any SQL conditions needed outside of the main value expression (which is generated using ValueExpr.generateSqlValueExpr(StringBuffer, SqlGenerationContext)).

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

Specified by:
getSqlPreConditions in interface ValueExpr
Returns:
null if not applicable

generateSqlValueExpr

public void generateSqlValueExpr(java.lang.StringBuffer sql,
                                 SqlGenerationContext context)
Description copied from interface: ValueExpr
Generates the SQL for this expression.

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

Specified by:
generateSqlValueExpr in interface ValueExpr

bindPreConditions

public int bindPreConditions(java.sql.PreparedStatement stmt,
                             int bindPos)
Specified by:
bindPreConditions in interface ValueExpr

bindValueExpr

public 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
Specified by:
bindValueExpr in interface ValueExpr
Throws:
java.sql.SQLException
org.outerj.daisy.repository.query.QueryException

bindLiteral

public static int bindLiteral(java.sql.PreparedStatement stmt,
                              int bindPos,
                              QValueType valueType,
                              java.lang.Object value)
                       throws java.sql.SQLException
Utility method for use by other classes.

Throws:
java.sql.SQLException

getValueType

public QValueType getValueType()
Description copied from interface: ValueExpr
Returns the ValueType of this expression, or null if undetermined.

Specified by:
getValueType in interface ValueExpr

isSymbolicIdentifier

public boolean isSymbolicIdentifier()
Description copied from interface: ValueExpr
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 ValueExpr.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.

Specified by:
isSymbolicIdentifier in interface ValueExpr

translateSymbolic

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

Specified by:
translateSymbolic in interface ValueExpr
Throws:
org.outerj.daisy.repository.query.QueryException

getTitle

public java.lang.String getTitle(java.util.Locale locale)
Specified by:
getTitle in interface ValueExpr

getExpression

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

Specified by:
getExpression in interface ValueExpr

getOutputValueType

public QValueType getOutputValueType()
Description copied from interface: ValueExpr
Identifies the type of data returned from the ValueExpr.getOutputValue(org.outerj.daisy.repository.Document, org.outerj.daisy.repository.Version, EvaluationContext) method.

Specified by:
getOutputValueType in interface ValueExpr

getOutputValue

public java.lang.Object getOutputValue(org.outerj.daisy.repository.Document document,
                                       org.outerj.daisy.repository.Version version,
                                       org.outerj.daisy.repository.query.EvaluationContext evaluationContext)
Description copied from interface: ValueExpr
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 ValueExpr.evaluate(QValueType, org.outerj.daisy.repository.Document, org.outerj.daisy.repository.Version, EvaluationContext). The version is allowed to be null.

Specified by:
getOutputValue in interface ValueExpr

canTestAppliesTo

public boolean canTestAppliesTo()
Specified by:
canTestAppliesTo in interface ValueExpr


Copyright © -2012 . All Rights Reserved.