org.openanzo.sqlscribe
Class VariableMatch

java.lang.Object
  extended by org.openanzo.sqlscribe.Match
      extended by org.openanzo.sqlscribe.VariableMatch
All Implemented Interfaces:
Constraint

public class VariableMatch
extends Match
implements Constraint

Extension of a value constraint in SQL that takes advantage of JDBC prepared statement variable bindings. For example: "SELECT id WHERE type = ?" is a prepared statement with a variable binding. See the SqlQuery builder class for details on how to bind to these variables when executing a query.

Author:
Joe Betz

Constructor Summary
VariableMatch(Column lhs, java.lang.String operator, java.lang.String varName)
          Create a new VariableMatch
 
Method Summary
 java.lang.String getConstraint(java.util.List<java.lang.String> unboundVariables)
          Get the SQL text for this constraint, using any variables from the provided list
 java.lang.String getVariableName()
          Get the variable name for this match
 void writeConstraint(java.lang.StringBuffer buf, java.util.List<java.lang.String> unboundVariables)
          Write the SQL text for this constraint to the provided buffer, using any variables from the provided list
 
Methods inherited from class org.openanzo.sqlscribe.Match
equals, equals, getLhs, getOperator, greater, greater, in, isNotNull, isNull, less, less, listTables, varEquals, varGreater, varGreaterEquals, varLess, varLessEquals
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.openanzo.sqlscribe.Constraint
listTables
 

Constructor Detail

VariableMatch

public VariableMatch(Column lhs,
                     java.lang.String operator,
                     java.lang.String varName)
Create a new VariableMatch

Parameters:
lhs - column to match
operator - type of match operation to use
varName - name of variable
Method Detail

getVariableName

public java.lang.String getVariableName()
Get the variable name for this match

Returns:
the variable name for this match

getConstraint

public java.lang.String getConstraint(java.util.List<java.lang.String> unboundVariables)
Description copied from interface: Constraint
Get the SQL text for this constraint, using any variables from the provided list

Specified by:
getConstraint in interface Constraint
Parameters:
unboundVariables - set of variables that can be used within constraints
Returns:
the SQL text for this constraint, using any variables from the provided list

writeConstraint

public void writeConstraint(java.lang.StringBuffer buf,
                            java.util.List<java.lang.String> unboundVariables)
Description copied from interface: Constraint
Write the SQL text for this constraint to the provided buffer, using any variables from the provided list

Specified by:
writeConstraint in interface Constraint
Parameters:
buf - StringBuffer to which the SQL text for this constraint is appended
unboundVariables - set of variables that can be used within constraints


Copyright © 2007 Cambridge Semantics Inc.. All Rights Reserved.