org.apache.openjpa.jdbc.kernel.exps
Class Variable

java.lang.Object
  extended by org.apache.openjpa.jdbc.kernel.exps.AbstractVal
      extended by org.apache.openjpa.jdbc.kernel.exps.Variable
All Implemented Interfaces:
Serializable, Val, Value

 class Variable
extends AbstractVal

A variable in a filter. Typically, the initialize(org.apache.openjpa.jdbc.sql.Select, org.apache.openjpa.jdbc.kernel.exps.ExpContext, int) and #getJoins methods of this value are not called. They are only called if the variable is bound but otherwise unused in the filter, in which case we must at least make the joins to the variable because the act of binding a variable should at least guarantee that an instance representing the variable could exist (i.e. the binding collection is not empty).

Author:
Abe White

Field Summary
 
Fields inherited from class org.apache.openjpa.jdbc.kernel.exps.AbstractVal
FALSE, TRUE
 
Fields inherited from interface org.apache.openjpa.jdbc.kernel.exps.Val
ABS_VAL, ARGS_VAL, CMP_EQUAL, COALESCE_VAL, CONCAT_VAL, FORCE_OUTER, GENERALCASE_VAL, INDEXOF_VAL, JOIN_REL, LENGTH_VAL, LOCATE_VAL, LOWER_VAL, MATH_VAL, NULL_CMP, NULLIF_VAL, SIMPLECASE_VAL, SQRT_VAL, SUBSTRING_VAL, TRIM_VAL, UPPER_VAL, VAL, WHENCONDITION_VAL, WHENSCALAR_VAL
 
Constructor Summary
Variable(String name, Class type)
          Constructor.
 
Method Summary
 void acceptVisit(ExpressionVisitor visitor)
          Accept a visit from a tree visitor.
 void appendIsEmpty(Select sel, ExpContext ctx, ExpState state, SQLBuffer buf)
          Append the SQL testing whether this value is empty to the given buffer.
 void appendIsNotEmpty(Select sel, ExpContext ctx, ExpState state, SQLBuffer buf)
          Append the SQL testing whether this value is not empty to the given buffer.
 void appendIsNotNull(Select sel, ExpContext ctx, ExpState state, SQLBuffer buf)
          Append the SQL testing whether this value is not null to the given buffer.
 void appendIsNull(Select sel, ExpContext ctx, ExpState state, SQLBuffer buf)
          Append the SQL testing whether this value is null to the given buffer.
 void appendSize(Select sel, ExpContext ctx, ExpState state, SQLBuffer buf)
          Append the SQL checking the size of this value.
 void appendTo(Select sel, ExpContext ctx, ExpState state, SQLBuffer sql, int index)
          Append the indexth SQL element to the given buffer.
 void calculateValue(Select sel, ExpContext ctx, ExpState state, Val other, ExpState otherState)
          Calculate and cache the SQL for this value.
 ClassMetaData getMetaData()
          Return any associated persistent type.
 String getName()
          Return the variable name.
 Path getPath()
           
 PCPath getPCPath()
          Return the path this variable is aliased to.
 Class getType()
          Return the expected type for this value, or Object if the type is unknown.
 void groupBy(Select sel, ExpContext ctx, ExpState state)
          Group by this value.
 ExpState initialize(Select sel, ExpContext ctx, int flags)
          Initialize the value.
 boolean isBound()
          Return true if the variable is bound.
 boolean isVariable()
          Return true if this value is a variable.
 int length(Select sel, ExpContext ctx, ExpState state)
          Return the number of SQL elements in this value.
 Object load(ExpContext ctx, ExpState state, Result res)
          Load the data for this value.
 void orderBy(Select sel, ExpContext ctx, ExpState state, boolean asc)
          Order by this value.
 void select(Select sel, ExpContext ctx, ExpState state, boolean pks)
          Select the data for this value.
 void selectColumns(Select sel, ExpContext ctx, ExpState state, boolean pks)
          Select just the columns for this value.
 void setImplicitType(Class type)
          Set the implicit type of the value, based on how it is used in the filter.
 void setMetaData(ClassMetaData meta)
          Associate a persistent type with this value.
 void setPCPath(PCPath path)
          Set the path this variable is aliased to.
 
Methods inherited from class org.apache.openjpa.jdbc.kernel.exps.AbstractVal
appendIndex, appendType, getAlias, getId, getSelectAs, isAggregate, isXPath, setAlias, toDataStoreValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Variable

public Variable(String name,
                Class type)
Constructor. Supply variable name and type.

Method Detail

getName

public String getName()
Return the variable name.

Specified by:
getName in interface Value
Overrides:
getName in class AbstractVal

isBound

public boolean isBound()
Return true if the variable is bound.


getPCPath

public PCPath getPCPath()
Return the path this variable is aliased to.


getPath

public Path getPath()
Specified by:
getPath in interface Value
Overrides:
getPath in class AbstractVal

setPCPath

public void setPCPath(PCPath path)
Set the path this variable is aliased to.


getMetaData

public ClassMetaData getMetaData()
Description copied from interface: Value
Return any associated persistent type.


setMetaData

public void setMetaData(ClassMetaData meta)
Description copied from interface: Value
Associate a persistent type with this value.


isVariable

public boolean isVariable()
Description copied from interface: Value
Return true if this value is a variable.

Specified by:
isVariable in interface Value
Overrides:
isVariable in class AbstractVal

getType

public Class getType()
Description copied from interface: Value
Return the expected type for this value, or Object if the type is unknown.


setImplicitType

public void setImplicitType(Class type)
Description copied from interface: Value
Set the implicit type of the value, based on how it is used in the filter. This method is only called on values who return Object from Value.getType().


initialize

public ExpState initialize(Select sel,
                           ExpContext ctx,
                           int flags)
Description copied from interface: Val
Initialize the value. This method should recursively initialize any sub-values.


select

public void select(Select sel,
                   ExpContext ctx,
                   ExpState state,
                   boolean pks)
Description copied from interface: Val
Select the data for this value.


selectColumns

public void selectColumns(Select sel,
                          ExpContext ctx,
                          ExpState state,
                          boolean pks)
Description copied from interface: Val
Select just the columns for this value.


groupBy

public void groupBy(Select sel,
                    ExpContext ctx,
                    ExpState state)
Description copied from interface: Val
Group by this value.


orderBy

public void orderBy(Select sel,
                    ExpContext ctx,
                    ExpState state,
                    boolean asc)
Description copied from interface: Val
Order by this value.


load

public Object load(ExpContext ctx,
                   ExpState state,
                   Result res)
            throws SQLException
Description copied from interface: Val
Load the data for this value.

Throws:
SQLException

calculateValue

public void calculateValue(Select sel,
                           ExpContext ctx,
                           ExpState state,
                           Val other,
                           ExpState otherState)
Description copied from interface: Val
Calculate and cache the SQL for this value. This method is called before length or any append methods.

other - the value being compared to, or null if not a comparison

length

public int length(Select sel,
                  ExpContext ctx,
                  ExpState state)
Description copied from interface: Val
Return the number of SQL elements in this value.


appendTo

public void appendTo(Select sel,
                     ExpContext ctx,
                     ExpState state,
                     SQLBuffer sql,
                     int index)
Description copied from interface: Val
Append the indexth SQL element to the given buffer.


appendIsEmpty

public void appendIsEmpty(Select sel,
                          ExpContext ctx,
                          ExpState state,
                          SQLBuffer buf)
Description copied from interface: Val
Append the SQL testing whether this value is empty to the given buffer.

Specified by:
appendIsEmpty in interface Val
Overrides:
appendIsEmpty in class AbstractVal

appendIsNotEmpty

public void appendIsNotEmpty(Select sel,
                             ExpContext ctx,
                             ExpState state,
                             SQLBuffer buf)
Description copied from interface: Val
Append the SQL testing whether this value is not empty to the given buffer.

Specified by:
appendIsNotEmpty in interface Val
Overrides:
appendIsNotEmpty in class AbstractVal

appendSize

public void appendSize(Select sel,
                       ExpContext ctx,
                       ExpState state,
                       SQLBuffer buf)
Description copied from interface: Val
Append the SQL checking the size of this value.

Specified by:
appendSize in interface Val
Overrides:
appendSize in class AbstractVal

appendIsNull

public void appendIsNull(Select sel,
                         ExpContext ctx,
                         ExpState state,
                         SQLBuffer buf)
Description copied from interface: Val
Append the SQL testing whether this value is null to the given buffer.

Specified by:
appendIsNull in interface Val
Overrides:
appendIsNull in class AbstractVal

appendIsNotNull

public void appendIsNotNull(Select sel,
                            ExpContext ctx,
                            ExpState state,
                            SQLBuffer buf)
Description copied from interface: Val
Append the SQL testing whether this value is not null to the given buffer.

Specified by:
appendIsNotNull in interface Val
Overrides:
appendIsNotNull in class AbstractVal

acceptVisit

public void acceptVisit(ExpressionVisitor visitor)
Description copied from interface: Value
Accept a visit from a tree visitor.

Specified by:
acceptVisit in interface Value
Overrides:
acceptVisit in class AbstractVal


Copyright © 2006-2011 Apache Software Foundation. All Rights Reserved.