com.google.api.ads.dfp.lib.utils
Interface QueryBuilderInterface<V>

Type Parameters:
V - the type of the API Value
All Known Implementing Classes:
QueryBuilder

public interface QueryBuilderInterface<V>

QueryBuilderInterface allows for queries to be constructed in parts.

Author:
Adam Rogal

Method Summary
 String buildQuery()
          Builds the query from the clauses.
 QueryBuilderInterface<V> from(String table)
          Sets the statement FROM clause in the form of "table".
 Map<String,V> getBindVariableMap()
          Gets an unmodifiable key-value map.
 Integer getOffset()
          Gets the current offset.
 QueryBuilderInterface<V> increaseOffsetBy(Integer amount)
          Increases the offset by the amount.
 QueryBuilderInterface<V> limit(Integer count)
          Sets the statement LIMIT clause in the form of

"LIMIT <count>"

e.g.
 QueryBuilderInterface<V> offset(Integer count)
          Sets the statement OFFSET clause in the form of

"OFFSET <count>"

e.g.
 QueryBuilderInterface<V> orderBy(String orderBy)
          Sets the statement ORDER BY clause in the form of

"ORDER BY <property> [ASC | DESC]"

e.g.
 QueryBuilderInterface<V> removeLimitAndOffset()
          Removes the limit and offset from the query.
 QueryBuilderInterface<V> select(String columns)
          Sets the statement SELECT clause in the form of "a,b" or "*".
 QueryBuilderInterface<V> where(String conditions)
          Sets the statement WHERE clause in the form of

"WHERE <condition> {[AND | OR] <condition> ...}"

e.g.
 QueryBuilderInterface<V> withBindVariableValue(String key, V value)
          Puts a key-value into the bind variables.
 

Method Detail

select

QueryBuilderInterface<V> select(String columns)
Sets the statement SELECT clause in the form of "a,b" or "*". Only necessary for statements being sent to the PublisherQueryLanguageService. The "SELECT " keyword will be ignored.

Parameters:
columns - the statement select clause without "SELECT"
Returns:
a reference to this object

from

QueryBuilderInterface<V> from(String table)
Sets the statement FROM clause in the form of "table". Only necessary for statements being sent to the PublisherQueryLanguageService. The "FROM " keyword will be ignored.

Parameters:
table - the statement from clause without "FROM"
Returns:
a reference to this object

where

QueryBuilderInterface<V> where(String conditions)
Sets the statement WHERE clause in the form of

"WHERE <condition> {[AND | OR] <condition> ...}"

e.g. "a = b OR b = c". The "WHERE " keyword will be ignored.

Parameters:
conditions - the statement query without "WHERE"
Returns:
a reference to this object

limit

QueryBuilderInterface<V> limit(Integer count)
Sets the statement LIMIT clause in the form of

"LIMIT <count>"

e.g. 1000.

Parameters:
count - the statement limit
Returns:
a reference to this object

offset

QueryBuilderInterface<V> offset(Integer count)
Sets the statement OFFSET clause in the form of

"OFFSET <count>"

e.g. 200.

Parameters:
count - the statement offset
Returns:
a reference to this object

increaseOffsetBy

QueryBuilderInterface<V> increaseOffsetBy(Integer amount)
Increases the offset by the amount.

Parameters:
amount - the amount to increase the offset
Returns:
a reference to this object

getOffset

Integer getOffset()
Gets the current offset.

Returns:
the current offset

removeLimitAndOffset

QueryBuilderInterface<V> removeLimitAndOffset()
Removes the limit and offset from the query.

Returns:
a reference to this object

orderBy

QueryBuilderInterface<V> orderBy(String orderBy)
Sets the statement ORDER BY clause in the form of

"ORDER BY <property> [ASC | DESC]"

e.g. "type ASC, lastModifiedDateTime DESC". The "ORDER BY " keyword will be ignored.

Parameters:
orderBy - the statement order by without "ORDER BY"
Returns:
a reference to this object

withBindVariableValue

QueryBuilderInterface<V> withBindVariableValue(String key,
                                               V value)
Puts a key-value into the bind variables.


getBindVariableMap

Map<String,V> getBindVariableMap()
Gets an unmodifiable key-value map.


buildQuery

String buildQuery()
Builds the query from the clauses.

Returns:
the constructed query


Copyright © 2012. All Rights Reserved.