Esri Geoportal Server
1.0

com.esri.gpt.framework.sql
Class ExpressionBinder

java.lang.Object
  extended by com.esri.gpt.framework.sql.ExpressionBinder
Direct Known Subclasses:
HttpExpressionBinder

public class ExpressionBinder
extends Object

Aids in the process of binding variables to SQL expressions.


Constructor Summary
ExpressionBinder()
          Default constructor.
 
Method Summary
 void addBinding(String field, String binding, boolean forceUpper, boolean forceLike)
          Adds a bound field filter to the expression.
 void addBinding(String field, String operator, Object binding)
          Adds a bound field filter to the expression.
 void addBindings(String field, String[] bindings, boolean forceUpper, boolean forceLike)
          Adds a collection of bound field filters to the expression.
 void addBindings(String field, String operator, Object[] bindings)
          Adds a collection of bound field filters to the expression.
 void addClause(String expression, Object[] bindings)
          Adds a sub-clause expression.
 int applyBindings(PreparedStatement statement, int startIndex)
          Binds variables to a JDBC prepared statement.
 List<Object> getBindings()
          Gets a list of objects bound to the expression.
 String getExpression(boolean includeWhereKeyword)
          Gets the SQL where clause expression.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExpressionBinder

public ExpressionBinder()
Default constructor.

Method Detail

addBinding

public void addBinding(String field,
                       String operator,
                       Object binding)
Adds a bound field filter to the expression.

Parameters:
field - the field name
operator - the operator examples: =, !=, >, >=, <, <=, LIKE, ...
binding - the variable to bind

addBinding

public void addBinding(String field,
                       String binding,
                       boolean forceUpper,
                       boolean forceLike)
Adds a bound field filter to the expression.
This method is useful for VARCHAR type fields.

Parameters:
field - the field name
binding - the variable to bind
forceUpper - force an upper case comparison
forceLike - for a LIKE operator

addBindings

public void addBindings(String field,
                        String operator,
                        Object[] bindings)
Adds a collection of bound field filters to the expression.
The collection is connected by logical "OR" operators.

Parameters:
field - the field name
operator - the operator examples: =, !=, >, >=, <, <=, LIKE, ...
bindings - the array of variables to bind

addBindings

public void addBindings(String field,
                        String[] bindings,
                        boolean forceUpper,
                        boolean forceLike)
Adds a collection of bound field filters to the expression.
The collection is connected by a logical "OR" operators.
This method is useful for VARCHAR type fields.

Parameters:
field - the field name
bindings - the array of variables to bind
forceUpper - force an upper case comparison
forceLike - for a LIKE operator

addClause

public void addClause(String expression,
                      Object[] bindings)
Adds a sub-clause expression.
If the sub-clause expression is unbound, pass null for the bindings argument.

Parameters:
expression - the sub-clause expression
bindings - the array of variables bound to the clause

applyBindings

public int applyBindings(PreparedStatement statement,
                         int startIndex)
                  throws SQLException
Binds variables to a JDBC prepared statement.

Parameters:
statement - the prepared statement
startIndex - the starting index for bound statement variables
Returns:
the next index to use for bound statement variables
Throws:
SQLException - if an exception occurs while binding

getBindings

public List<Object> getBindings()
Gets a list of objects bound to the expression.

Returns:
the bound objects

getExpression

public String getExpression(boolean includeWhereKeyword)
Gets the SQL where clause expression.

Parameters:
includeWhereKeyword - if true, prefix with "WHERE" if the expression is not empty
Returns:
the SQL where clause

Esri Geoportal Server
1.0

Copyright 2011 Environmental Systems Research Institute. All rights reserved. Use is subject to license terms.