Class SQLEmbed
- java.lang.Object
-
- org.apache.openjpa.jdbc.kernel.exps.SQLEmbed
-
- All Implemented Interfaces:
java.io.Serializable,JDBCFilterListener,FilterListener
- Direct Known Subclasses:
SQLExpression,SQLValue
public class SQLEmbed extends java.lang.Object implements JDBCFilterListener
Simple listener which embeds its SQL argument into the query. Listens onsql. Example:
"price < sql(\"(SELECT AVG (PRICE) FROM PRODUCT_TABLE)\")"- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringTAG
-
Constructor Summary
Constructors Constructor Description SQLEmbed()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidappendTo(SQLBuffer buf, FilterValue target, FilterValue[] args, ClassMapping type, JDBCStore store)Append the SQL for this expression or value.java.lang.Objectevaluate(java.lang.Object target, java.lang.Class targetClass, java.lang.Object[] args, java.lang.Class[] argClasses, java.lang.Object candidate, StoreContext ctx)Evaluate the given expression.booleanexpectsArguments()Return true if this extension expects arguments to act on.booleanexpectsTarget()Return true if this extension expects a target to act on.java.lang.StringgetTag()Return the tag that this extension listens for.java.lang.ClassgetType(java.lang.Class targetClass, java.lang.Class[] argClasses)Return the expected type of the result of this listener.
-
-
-
Method Detail
-
getTag
public java.lang.String getTag()
Description copied from interface:FilterListenerReturn the tag that this extension listens for.- Specified by:
getTagin interfaceFilterListener
-
expectsArguments
public boolean expectsArguments()
Description copied from interface:FilterListenerReturn true if this extension expects arguments to act on. Some extensions may not need arguments; for example, an extension to switch a string to upper case might be of the form:field.ext:toUpperCase ().- Specified by:
expectsArgumentsin interfaceFilterListener
-
expectsTarget
public boolean expectsTarget()
Description copied from interface:FilterListenerReturn true if this extension expects a target to act on. Some extensions act on a field or object value; others stand alone.field.ext:toUpperCase ()acts on the targetfieldbut has no arguments, while another possible form,ext:toUpperCase (field)has no target but does have an argument.- Specified by:
expectsTargetin interfaceFilterListener
-
evaluate
public java.lang.Object evaluate(java.lang.Object target, java.lang.Class targetClass, java.lang.Object[] args, java.lang.Class[] argClasses, java.lang.Object candidate, StoreContext ctx)Description copied from interface:FilterListenerEvaluate the given expression. This method is used when evaluating in-memory expressions. The method used when evaluating data store expressions will change depending on the data store in use.- Specified by:
evaluatein interfaceFilterListener- Parameters:
target- the target object / field value to act on; will be null if this extension does not expect a targettargetClass- the expected class of the target; given in case the target evaluates to null and typing is neededargs- the values of the arguments given in the filter; will be null if this extension does not expect an argumentargClasses- the expected classes of the arguments; given in case an argument evaluates to null and typing is neededcandidate- the candidate object being evaluatedctx- the persistence context- Returns:
- the value of the extension for this candidate; if
this extension is an expression, this method should
return
Boolean.TRUEorBoolean.FALSE
-
appendTo
public void appendTo(SQLBuffer buf, FilterValue target, FilterValue[] args, ClassMapping type, JDBCStore store)
Description copied from interface:JDBCFilterListenerAppend the SQL for this expression or value.- Specified by:
appendToin interfaceJDBCFilterListener- Parameters:
buf- the SQL buffer to append totarget- the target to act on, or null if the listener doesn't expect a targetargs- the values of the arguments given in the filter, or null if this listener doesn't expect argumentstype- the class mapping for the query's candidate classstore- the store that owns the query
-
getType
public java.lang.Class getType(java.lang.Class targetClass, java.lang.Class[] argClasses)Description copied from interface:FilterListenerReturn the expected type of the result of this listener.- Specified by:
getTypein interfaceFilterListener- Parameters:
targetClass- the expected class of the target, or null if no targetargClasses- the expected classes of the arguments, or null if no arguments
-
-