|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.stackmob.sdk.api.StackMobQuery
public class StackMobQuery
A class that builds queries for data access methods like those in StackMob. Example usage:
StackMobQuery query = new StackMobQuery("user")
.fieldIsGreaterThan("age", 20)
.fieldIsLessThanOrEqualTo("age", 40)
.fieldIsIn("friend", Arrays.asList("joe", "bob", "alice");
//Of if you have multiple constraints on the same field and you want to type less
StackMobQuery query = new StackMobQuery("user")
.field(new StackMobQueryField("age").isGreaterThan(20).isLessThanOrEqualTo(40))
.field(new StackMobQueryField("friend").isIn(Arrays.asList("joe", "bob", "alice")));
A few helpful notes about this object:
field(StackMobQueryField) method helps you build up part of your query on a specific field
| Nested Class Summary | |
|---|---|
static class |
StackMobQuery.Ordering
Represents ascending or descending order |
| Constructor Summary | |
|---|---|
StackMobQuery()
creates an empty query. |
|
StackMobQuery(String objectName)
create a query on a specific object |
|
| Method Summary | |
|---|---|
StackMobQuery |
add(StackMobQuery other)
copy the constraints in a give query to this one |
StackMobQuery |
and(StackMobQuery clauses)
Add a new condition that is the logical OR of a set of clauses. |
StackMobQuery |
field(StackMobQueryField field)
Begin adding constraints to a field via a StackMobQueryField |
StackMobQuery |
fieldIsEqualTo(String field,
int val)
add an "=" to your query. |
StackMobQuery |
fieldIsEqualTo(String field,
String val)
add an "=" to your query. |
StackMobQuery |
fieldIsGreaterThan(String field,
int val)
same as fieldIsLessThan(String, String), except applies ">" instead of "<" |
StackMobQuery |
fieldIsGreaterThan(String field,
String val)
same as fieldIsLessThan(String, String), except applies ">" instead of "<" |
StackMobQuery |
fieldIsGreaterThanOrEqualTo(String field,
int val)
same as fieldIsLessThan(String, String), except applies ">=" instead of "<" |
StackMobQuery |
fieldIsGreaterThanOrEqualTo(String field,
String val)
same as fieldIsLessThan(String, String), except applies ">=" instead of "<" |
StackMobQuery |
fieldIsIn(String field,
List<String> values)
add an "IN" to your query. |
StackMobQuery |
fieldIsLessThan(String field,
int val)
same as fieldIsLessThan(String, String), except works with Strings |
StackMobQuery |
fieldIsLessThan(String field,
String val)
same as fieldIsLessThan(String, String), except works with Strings |
StackMobQuery |
fieldIsLessThanOrEqualTo(String field,
int val)
same as fieldIsLessThan(String, String), except applies "<=" instead of "<" |
StackMobQuery |
fieldIslessThanOrEqualTo(String field,
String val)
same as fieldIsLessThan(String, String), except applies "<=" instead of "<" |
StackMobQuery |
fieldIsNear(String field,
StackMobGeoPoint point)
add a "NEAR" to your query for the given StackMobGeoPoint field. |
StackMobQuery |
fieldIsNearWithinKm(String field,
StackMobGeoPoint point,
Double maxDistanceKm)
add a "NEAR" to your query for the given StackMobGeoPoint field. |
StackMobQuery |
fieldIsNearWithinMi(String field,
StackMobGeoPoint point,
Double maxDistanceMi)
add a "NEAR" to your query for the given StackMobGeoPoint field. |
StackMobQuery |
fieldIsNotEqual(String field,
String val)
add a "NE" to your query. |
StackMobQuery |
fieldIsNotNull(String field)
add a "NULL" to your query. |
StackMobQuery |
fieldIsNull(String field)
add a "NULL" to your query. |
StackMobQuery |
fieldIsOrderedBy(String field,
StackMobQuery.Ordering ordering)
add an "ORDER BY" to your query |
StackMobQuery |
fieldIsWithinBox(String field,
StackMobGeoPoint lowerLeft,
StackMobGeoPoint upperRight)
add a "WITHIN" to your query for the given StackMobGeoPoint field. |
StackMobQuery |
fieldIsWithinRadiusInKm(String field,
StackMobGeoPoint point,
Double radiusInKm)
add a "WITHIN" to your query for the given StackMobGeoPoint field. |
StackMobQuery |
fieldIsWithinRadiusInMi(String field,
StackMobGeoPoint point,
Double radiusInMi)
add a "WITHIN" to your query for the given StackMobGeoPoint field. |
List<Map.Entry<String,String>> |
getArguments()
get the arguments generated by this query |
Map<String,String> |
getHeaders()
get the headers generated by this query |
String |
getObjectName()
get the schema being queried against |
StackMobQuery |
isInRange(Integer start)
same thing as isInRange(Integer, Integer), except does not specify an end to the range. |
StackMobQuery |
isInRange(Integer start,
Integer end)
this method lets you add a "LIMIT" and "SKIP" to your query at once. |
static StackMobQuery |
objects(String objectName)
create a query on a specific object |
StackMobQuery |
or(StackMobQuery clauses)
Add a new condition that is the logical OR of a set of clauses. |
void |
setObjectName(String objectName)
set the schema being queried against |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public StackMobQuery()
StackMobQuery(String) should be used in almost all cases. Only use
this if you then later call setObjectName(String)
public StackMobQuery(String objectName)
objectName - the schema you're querying against| Method Detail |
|---|
public static StackMobQuery objects(String objectName)
objectName - the schema you're querying against
public void setObjectName(String objectName)
objectName - the schemapublic String getObjectName()
public Map<String,String> getHeaders()
public List<Map.Entry<String,String>> getArguments()
public StackMobQuery add(StackMobQuery other)
other - the query to copy
public StackMobQuery or(StackMobQuery clauses)
clauses - a sub-query. Each constraint added to it is combined into an OR statement.
public StackMobQuery and(StackMobQuery clauses)
clauses - a sub-query. Each constraint added to it is combined into an AND statement.
public StackMobQuery field(StackMobQueryField field)
StackMobQueryField
field - the name of the field
public StackMobQuery fieldIsNear(String field,
StackMobGeoPoint point)
field - the StackMobGeoPoint field whose value to testpoint - the lon/lat location to center the search
public StackMobQuery fieldIsNearWithinMi(String field,
StackMobGeoPoint point,
Double maxDistanceMi)
field - the StackMobGeoPoint field whose value to testpoint - the lon/lat location to center the searchmaxDistanceMi - the maximum distance in miles a matched field can be from point.
public StackMobQuery fieldIsNearWithinKm(String field,
StackMobGeoPoint point,
Double maxDistanceKm)
field - the StackMobGeoPoint field whose value to testpoint - the lon/lat location to center the searchmaxDistanceKm - the maximum distance in kilometers a matched field can be from point.
public StackMobQuery fieldIsWithinRadiusInMi(String field,
StackMobGeoPoint point,
Double radiusInMi)
field - the StackMobGeoPoint field whose value to testpoint - the lon/lat location to center the searchradiusInMi - the maximum distance in miles a matched field can be from point.
public StackMobQuery fieldIsWithinRadiusInKm(String field,
StackMobGeoPoint point,
Double radiusInKm)
field - the StackMobGeoPoint field whose value to testpoint - the lon/lat location to center the searchradiusInKm - the maximum distance in kilometers a matched field can be from point.
public StackMobQuery fieldIsWithinBox(String field,
StackMobGeoPoint lowerLeft,
StackMobGeoPoint upperRight)
field - the StackMobGeoPoint field whose value to testlowerLeft - the lon/lat location of the lower left corner of the bounding boxupperRight - the lon/lat location of the upper right corner of the bounding box
public StackMobQuery fieldIsIn(String field,
List<String> values)
field - the field whose value to testvalues - the values against which to match
public StackMobQuery fieldIsNotEqual(String field,
String val)
field - the field whose value to testval - the value against which to match
public StackMobQuery fieldIsNull(String field)
field - the field whose value to test
public StackMobQuery fieldIsNotNull(String field)
field - the field whose value to test
public StackMobQuery fieldIsLessThan(String field,
String val)
fieldIsLessThan(String, String), except works with Strings
field - the field whose value to testval - the value against which to test
public StackMobQuery fieldIsLessThan(String field,
int val)
fieldIsLessThan(String, String), except works with Strings
field - the field whose value to testval - the value against which to test
public StackMobQuery fieldIslessThanOrEqualTo(String field,
String val)
fieldIsLessThan(String, String), except applies "<=" instead of "<"
field - the field whose value to testval - the value against which to test
public StackMobQuery fieldIsLessThanOrEqualTo(String field,
int val)
fieldIsLessThan(String, String), except applies "<=" instead of "<"
field - the field whose value to testval - the value against which to test
public StackMobQuery fieldIsGreaterThan(String field,
String val)
fieldIsLessThan(String, String), except applies ">" instead of "<"
field - the field whose value to testval - the value against which to test
public StackMobQuery fieldIsGreaterThan(String field,
int val)
fieldIsLessThan(String, String), except applies ">" instead of "<"
field - the field whose value to testval - the value against which to test
public StackMobQuery fieldIsGreaterThanOrEqualTo(String field,
String val)
fieldIsLessThan(String, String), except applies ">=" instead of "<"
field - the field whose value to testval - the value against which to test
public StackMobQuery fieldIsGreaterThanOrEqualTo(String field,
int val)
fieldIsLessThan(String, String), except applies ">=" instead of "<"
field - the field whose value to testval - the value against which to test
public StackMobQuery fieldIsEqualTo(String field,
String val)
field - the field whose value to testval - the value against which to test
public StackMobQuery fieldIsEqualTo(String field,
int val)
field - the field whose value to testval - the value against which to test
public StackMobQuery fieldIsOrderedBy(String field,
StackMobQuery.Ordering ordering)
field - the field to order byordering - the ordering of that field
public StackMobQuery isInRange(Integer start,
Integer end)
start - the starting object number (inclusive)end - the ending object number (inclusive)
public StackMobQuery isInRange(Integer start)
isInRange(Integer, Integer), except does not specify an end to the range.
instead, gets all objects from a starting point (including)
start - the starting object number
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||