org.datanucleus.store.rdbms.sql.expression
Class SQLExpressionFactory

java.lang.Object
  extended by org.datanucleus.store.rdbms.sql.expression.SQLExpressionFactory

public class SQLExpressionFactory
extends java.lang.Object

Factory for creating SQL expressions/literals. These are typically called when we are building up an SQL statement and we want to impose conditions using the fields of a class, and values for the field.


Field Summary
protected static org.datanucleus.util.Localiser LOCALISER
          Localiser for messages
 
Constructor Summary
SQLExpressionFactory(RDBMSManager storeMgr)
          Constructor for an SQLExpressionFactory.
 
Method Summary
 org.datanucleus.store.mapped.mapping.JavaTypeMapping getMappingForType(java.lang.Class cls, boolean useCached)
          Accessor for a mapping to use in a query expression.
 SQLExpression invokeMethod(SQLStatement stmt, java.lang.String className, java.lang.String methodName, SQLExpression expr, java.util.List args)
          Accessor for the result of a method call on the supplied expression with the supplied args.
 SQLExpression invokeOperation(java.lang.String name, SQLExpression expr, SQLExpression expr2)
          Accessor for the result of an operation call on the supplied expression with the supplied args.
 SQLExpression newExpression(SQLStatement stmt, SQLTable sqlTbl, org.datanucleus.store.mapped.mapping.JavaTypeMapping mapping)
          Factory for an expression representing a mapping on a table.
 SQLExpression newLiteral(SQLStatement stmt, org.datanucleus.store.mapped.mapping.JavaTypeMapping mapping, java.lang.Object value)
          Factory for a literal representing a value.
 SQLExpression newLiteralParameter(SQLStatement stmt, org.datanucleus.store.mapped.mapping.JavaTypeMapping mapping, java.lang.Object value)
          Factory for a literal as an input parameter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOCALISER

protected static final org.datanucleus.util.Localiser LOCALISER
Localiser for messages

Constructor Detail

SQLExpressionFactory

public SQLExpressionFactory(RDBMSManager storeMgr)
Constructor for an SQLExpressionFactory. Loads up the defined SQL expressions [extension-point "org.datanucleus.store.rdbms.sql_expression"] and caches them. Also loads up the defined SQL methods [extension-point: "org.datanucleus.store.rdbms.sql_method"] and caches them. Also loads up the defined SQL operations [extension-point: "org.datanucleus.store.rdbms.sql_operation"] and caches them.

Parameters:
storeMgr - RDBMS Manager
Method Detail

newExpression

public SQLExpression newExpression(SQLStatement stmt,
                                   SQLTable sqlTbl,
                                   org.datanucleus.store.mapped.mapping.JavaTypeMapping mapping)
Factory for an expression representing a mapping on a table.

Parameters:
stmt - The statement
sqlTbl - The table
mapping - The mapping
Returns:
The expression

newLiteral

public SQLExpression newLiteral(SQLStatement stmt,
                                org.datanucleus.store.mapped.mapping.JavaTypeMapping mapping,
                                java.lang.Object value)
Factory for a literal representing a value. To create a NullLiteral pass in a null mapping.

Parameters:
stmt - The statement
mapping - The mapping
value - The value
Returns:
The literal

newLiteralParameter

public SQLExpression newLiteralParameter(SQLStatement stmt,
                                         org.datanucleus.store.mapped.mapping.JavaTypeMapping mapping,
                                         java.lang.Object value)
Factory for a literal as an input parameter. If the mapping (type of parameter) is not known at this point then put in null and it will return a ParameterLiteral.

Parameters:
stmt - The statement
mapping - The mapping
value - Value of the literal (if known)
Returns:
The literal

invokeMethod

public SQLExpression invokeMethod(SQLStatement stmt,
                                  java.lang.String className,
                                  java.lang.String methodName,
                                  SQLExpression expr,
                                  java.util.List args)
Accessor for the result of a method call on the supplied expression with the supplied args. Throws a NucleusException is the method is not supported.

Parameters:
stmt - SQLStatement that this relates to
className - Class we are invoking the method on
methodName - Name of the method
expr - The expression we invoke the method on
args - Any arguments to the method call
Returns:
The result

invokeOperation

public SQLExpression invokeOperation(java.lang.String name,
                                     SQLExpression expr,
                                     SQLExpression expr2)
Accessor for the result of an operation call on the supplied expression with the supplied args. Throws a NucleusException is the method is not supported.

Parameters:
name - Operation to be invoked
expr - The first expression to perform the operation on
expr2 - The second expression to perform the operation on
Returns:
The result

getMappingForType

public org.datanucleus.store.mapped.mapping.JavaTypeMapping getMappingForType(java.lang.Class cls,
                                                                              boolean useCached)
Accessor for a mapping to use in a query expression.

Parameters:
cls - The class that the mapping should represent.
useCached - Whether to use any cached mapping (if available)
Returns:
The mapping


Copyright © 2009. All Rights Reserved.