DBQueryBuilder
Builder for database queries (highscore, etc.). Always created via Flock.createDBQueryBuilder(String primary_key)
.
Sorting is applied to all keys either ASC or DESC (default), in the order you add the attributes.
All methods return the class, so it's possible to chain commands:
DBQueryBuilder q = Flock.createDBQueryBuilder()
.setPrimaryAttributeNumber("points")
.addAttributeNumber("wins")
.addAttributeNumber("losses", DBQueryBuilder.ORDER_ASC);
.setFormat(DBQueryBuilder.FORMAT_HTML)
mWebView.loadUrl(q.toQueryURI());
JSON response includes non-ascii usernames encoded in unicode
- See Also:
FlockEngine.createDBQueryBuilder()
Summary
Field Summary | |
---|---|
static int |
FORMAT_HTML
|
static int |
FORMAT_JSON
|
static int |
ORDER_ASC
|
static int |
ORDER_DESC
|
Method Summary | |
---|---|
DBQueryBuilder |
addAttributeNumber(java.lang.String attribute_key)
For found items, also include this attribute (number) in the results. |
DBQueryBuilder |
addAttributeNumber(java.lang.String attribute_key,
int order)
For found items, also include this attribute (number) in the results, |
DBQueryBuilder |
addAttributeString(java.lang.String attribute_key)
For found items, also include this attribute (string) in the results Default: ORDER_DESC |
DBQueryBuilder |
addAttributeString(java.lang.String attribute_key,
int order)
For found items, also include this attribute (string) in the results |
DBQueryBuilder |
setCapitalizedTitles(boolean is_capitalized)
If you want to show capitalized html table headers, use 'setCapitalizedTitles(true)' |
DBQueryBuilder |
setFormat(int format_flag)
Set the response-format to either HTML or JSON. |
DBQueryBuilder |
setLimit(int max_return_items)
Limit the number of returned items (default: 100) |
DBQueryBuilder |
setMatchValue(long value)
All results will match this exact numeric value for the primary search-key |
DBQueryBuilder |
setMatchValue(java.lang.String value)
All results will match this exact string-value for the primary search-key (will not match with numbers). |
DBQueryBuilder |
setMaxValue(long max_value)
All results will have at most this numeric value for the primary search-key |
DBQueryBuilder |
setMinValue(long min_value)
All results will have at least this numeric value for the primary search-key |
DBQueryBuilder |
setPrimaryAttributeNumber(java.lang.String key)
Set a numeric primary key, by default ordered by ORDER_DESC |
DBQueryBuilder |
setPrimaryAttributeNumber(java.lang.String key,
int order)
Set a numeric primary key with a sort option (ORDER_ASC or ORDER_DESC) |
DBQueryBuilder |
setPrimaryAttributeString(java.lang.String key)
Set a primary string key |
DBQueryBuilder |
setPrimaryAttributeString(java.lang.String key,
int order)
Set a primary string key with a sort option (ORDER_ASC or ORDER_DESC) |
DBQueryBuilder |
setStylesheet(java.lang.String stylesheet_url)
Add a custom stylesheet to the header. |
DBQueryBuilder |
setUsernameAlias(java.lang.String alias)
Instead of displaying "username" in the html table header, you can use any alias you wish. |
java.lang.String |
toQueryURI()
Return the built query as URI, which can be set to the WebView etc. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Details
Field Detail |
---|
ORDER_ASC
public static final int ORDER_ASC
- See Also:
- Constant Field Values
ORDER_DESC
public static final int ORDER_DESC
- See Also:
- Constant Field Values
FORMAT_JSON
public static final int FORMAT_JSON
- See Also:
- Constant Field Values
FORMAT_HTML
public static final int FORMAT_HTML
- See Also:
- Constant Field Values
Method Detail |
---|
setPrimaryAttributeNumber
public DBQueryBuilder setPrimaryAttributeNumber(java.lang.String key)
- Set a numeric primary key, by default ordered by ORDER_DESC
- Parameters:
key
-
setPrimaryAttributeNumber
public DBQueryBuilder setPrimaryAttributeNumber(java.lang.String key, int order)
- Set a numeric primary key with a sort option (ORDER_ASC or ORDER_DESC)
- Parameters:
key
-
setPrimaryAttributeString
public DBQueryBuilder setPrimaryAttributeString(java.lang.String key)
- Set a primary string key
- Parameters:
key
-
setPrimaryAttributeString
public DBQueryBuilder setPrimaryAttributeString(java.lang.String key, int order)
- Set a primary string key with a sort option (ORDER_ASC or ORDER_DESC)
- Parameters:
key
-
setUsernameAlias
public DBQueryBuilder setUsernameAlias(java.lang.String alias)
- Instead of displaying "username" in the html table header, you can use any alias you wish.
- Parameters:
alias
-- Returns:
setCapitalizedTitles
public DBQueryBuilder setCapitalizedTitles(boolean is_capitalized)
- If you want to show capitalized html table headers, use 'setCapitalizedTitles(true)'
- Parameters:
is_capitalized
-- Returns:
setMatchValue
public DBQueryBuilder setMatchValue(long value)
- All results will match this exact numeric value for the primary search-key
- Parameters:
value
-- Returns:
setMatchValue
public DBQueryBuilder setMatchValue(java.lang.String value)
- All results will match this exact string-value for the primary search-key (will not match with numbers).
- Parameters:
value
-- Returns:
setMinValue
public DBQueryBuilder setMinValue(long min_value)
- All results will have at least this numeric value for the primary search-key
- Parameters:
min_value
-- Returns:
setMaxValue
public DBQueryBuilder setMaxValue(long max_value)
- All results will have at most this numeric value for the primary search-key
- Parameters:
max_value
-- Returns:
setLimit
public DBQueryBuilder setLimit(int max_return_items)
- Limit the number of returned items (default: 100)
- Parameters:
max_return_items
-- Returns:
setFormat
public DBQueryBuilder setFormat(int format_flag)
- Set the response-format to either HTML or JSON.
- Parameters:
format_flag
- DBQueryBuilder.FORMAT_JSON or DBQueryBuilder.FORMAT_HTML- Returns:
setStylesheet
public DBQueryBuilder setStylesheet(java.lang.String stylesheet_url)
- Add a custom stylesheet to the header. URL must end with ".css".
- Parameters:
stylesheet_url
-- Returns:
addAttributeNumber
public DBQueryBuilder addAttributeNumber(java.lang.String attribute_key)
- For found items, also include this attribute (number) in the results.
Default: ORDER_DESC
- Parameters:
attribute_key
-
addAttributeNumber
public DBQueryBuilder addAttributeNumber(java.lang.String attribute_key, int order)
- For found items, also include this attribute (number) in the results,
- Parameters:
attribute_key
-order
- specifies the sort-order (ORDER_ASC or ORDER_DESC (default))
addAttributeString
public DBQueryBuilder addAttributeString(java.lang.String attribute_key)
- For found items, also include this attribute (string) in the results
Default: ORDER_DESC
- Parameters:
attribute_key
-
addAttributeString
public DBQueryBuilder addAttributeString(java.lang.String attribute_key, int order)
- For found items, also include this attribute (string) in the results
- Parameters:
attribute_key
-order
- specifies the sort-order (ORDER_ASC or ORDER_DESC (default))
toQueryURI
public java.lang.String toQueryURI()
- Return the built query as URI, which can be set to the WebView etc.
- Returns:
- URI which includes the currently built request