com.google.api.ads.dfp.axis.utils.v201206
Class StatementBuilder

java.lang.Object
  extended by com.google.api.ads.dfp.axis.utils.v201206.StatementBuilder
All Implemented Interfaces:
QueryBuilderInterface<Value>

public final class StatementBuilder
extends Object
implements QueryBuilderInterface<Value>

StatementBuilder allows for statements to be constructed in parts.

Typical usage is:

 StatementBuilder statementBuilder = new StatementBuilder()
     .where("lastModifiedDateTime > :yesterday AND type = :type")
     .orderBy("name DESC")
     .limit(200)
     .offset(20)
     .withBindVariableValue("yesterday",
         DateTimes.fromDate(new org.joda.time.DateTime().minusDays(1).toDate()))
     .withBindVariableValue("type", "Type")

 Statement statement = statementBuilder.toStatement();
 //...
 statementBuilder.increaseOffsetBy(20);
 statement = statementBuilder.toStatement();
 

Author:
Adam Rogal

Field Summary
static int SUGGESTED_PAGE_LIMIT
           
 
Constructor Summary
StatementBuilder()
          Constructs a statement builder.
 
Method Summary
 String buildQuery()
           
 StatementBuilder from(String table)
           
 Map<String,Value> getBindVariableMap()
           
 Integer getOffset()
           
 StatementBuilder increaseOffsetBy(Integer amount)
           
 StatementBuilder limit(Integer count)
           
 StatementBuilder offset(Integer count)
           
 StatementBuilder orderBy(String orderBy)
           
 StatementBuilder removeLimitAndOffset()
           
 StatementBuilder select(String columns)
           
 Statement toStatement()
          Gets the Statement representing the state of this statement builder.
 StatementBuilder where(String conditions)
           
 StatementBuilder withBindVariableValue(String key, Object value)
          Adds a bind variable value to the statement.
 StatementBuilder withBindVariableValue(String key, Value value)
          Adds a bind variable value to the statement.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SUGGESTED_PAGE_LIMIT

public static final int SUGGESTED_PAGE_LIMIT
See Also:
Constant Field Values
Constructor Detail

StatementBuilder

public StatementBuilder()
Constructs a statement builder.

Method Detail

withBindVariableValue

public StatementBuilder withBindVariableValue(String key,
                                              Object value)
Adds a bind variable value to the statement. The value will converted according to Pql.createValue(Object). If the value is of type Value, no conversion will be done.

Parameters:
key - the value key
value - the bind variable value
Returns:
a reference to this object

withBindVariableValue

public StatementBuilder withBindVariableValue(String key,
                                              Value value)
Adds a bind variable value to the statement.

Specified by:
withBindVariableValue in interface QueryBuilderInterface<Value>
Parameters:
key - the value key
value - the bind variable value
Returns:
a reference to this object

toStatement

public Statement toStatement()
Gets the Statement representing the state of this statement builder.

Returns:
the Statement

select

public StatementBuilder select(String columns)
Specified by:
select in interface QueryBuilderInterface<Value>

from

public StatementBuilder from(String table)
Specified by:
from in interface QueryBuilderInterface<Value>

where

public StatementBuilder where(String conditions)
Specified by:
where in interface QueryBuilderInterface<Value>

limit

public StatementBuilder limit(Integer count)
Specified by:
limit in interface QueryBuilderInterface<Value>

offset

public StatementBuilder offset(Integer count)
Specified by:
offset in interface QueryBuilderInterface<Value>

increaseOffsetBy

public StatementBuilder increaseOffsetBy(Integer amount)
Specified by:
increaseOffsetBy in interface QueryBuilderInterface<Value>

getOffset

public Integer getOffset()
Specified by:
getOffset in interface QueryBuilderInterface<Value>

removeLimitAndOffset

public StatementBuilder removeLimitAndOffset()
Specified by:
removeLimitAndOffset in interface QueryBuilderInterface<Value>

orderBy

public StatementBuilder orderBy(String orderBy)
Specified by:
orderBy in interface QueryBuilderInterface<Value>

getBindVariableMap

public Map<String,Value> getBindVariableMap()
Specified by:
getBindVariableMap in interface QueryBuilderInterface<Value>

buildQuery

public String buildQuery()
Specified by:
buildQuery in interface QueryBuilderInterface<Value>


Copyright © 2012. All Rights Reserved.