com.stackmob.sdk.api
Class StackMobQuery

java.lang.Object
  extended by com.stackmob.sdk.api.StackMobQuery

public class StackMobQuery
extends Object

A class that builds queries to execute on the StackMob platform. Example usage: //this code: StackMobQuery query = new StackMobQuery("user").field("age").isGreaterThan(20).isLessThanOrEqualTo(40).field("friend").in(Arrays.asList("joe", "bob", "alice").getQuery(); //is identical to this code: StackMobQuery query = new StackMobQuery("user").fieldIsGreaterThan("user", 20).fieldIsLessThanOrEqualTo("user", 40).fieldIsIn("user", Arrays.asList("joe", "bob", "alice"); A few helpful notes about this object:


Nested Class Summary
static class StackMobQuery.Operator
           
static class StackMobQuery.Ordering
           
 
Constructor Summary
StackMobQuery(String objectName)
           
 
Method Summary
 StackMobQuery expandDepthIs(Integer i)
          set the expand depth of this query.
 StackMobQueryWithField field(String field)
           
 StackMobQuery fieldIsEqualTo(String field, String val)
          add an "=" to your query.
 StackMobQuery fieldIsGreaterThan(String field, String 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, String val)
          same as fieldIsLessThan(String, String), except works with Strings
 StackMobQuery fieldIslessThanOrEqualTo(String field, String val)
          same as fieldIsLessThan(String, String), except applies "<=" instead of "<"
 StackMobQuery fieldIsOrderedBy(String field, StackMobQuery.Ordering ordering)
          add an "ORDER BY" to your query
 Map<String,String> getArguments()
           
 Map<String,String> getHeaders()
           
 String getObjectName()
           
 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)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StackMobQuery

public StackMobQuery(String objectName)
Method Detail

objects

public static StackMobQuery objects(String objectName)

getObjectName

public String getObjectName()

getHeaders

public Map<String,String> getHeaders()

getArguments

public Map<String,String> getArguments()

field

public StackMobQueryWithField field(String field)

fieldIsIn

public StackMobQuery fieldIsIn(String field,
                               List<String> values)
add an "IN" to your query. test whether the given field's value is in the given list of possible values

Parameters:
field - the field whose value to test
values - the values against which to match
Returns:
the new query that resulted from adding this operation

fieldIsLessThan

public StackMobQuery fieldIsLessThan(String field,
                                     String val)
same as fieldIsLessThan(String, String), except works with Strings

Parameters:
field - the field whose value to test
val - the value against which to test
Returns:
the new query that resulted from adding this operation

fieldIslessThanOrEqualTo

public StackMobQuery fieldIslessThanOrEqualTo(String field,
                                              String val)
same as fieldIsLessThan(String, String), except applies "<=" instead of "<"

Parameters:
field - the field whose value to test
val - the value against which to test
Returns:
the new query that resulted from adding this operation

fieldIsGreaterThan

public StackMobQuery fieldIsGreaterThan(String field,
                                        String val)
same as fieldIsLessThan(String, String), except applies ">" instead of "<"

Parameters:
field - the field whose value to test
val - the value against which to test
Returns:
the new query that resulted from adding this operation

fieldIsGreaterThanOrEqualTo

public StackMobQuery fieldIsGreaterThanOrEqualTo(String field,
                                                 String val)
same as fieldIsLessThan(String, String), except applies ">=" instead of "<"

Parameters:
field - the field whose value to test
val - the value against which to test
Returns:
the new query that resulted from adding this operation

fieldIsEqualTo

public StackMobQuery fieldIsEqualTo(String field,
                                    String val)
add an "=" to your query. test whether the given field's value is equal to the given value

Parameters:
field - the field whose value to test
val - the value against which to test
Returns:
the new query that resulted from adding this operation

fieldIsOrderedBy

public StackMobQuery fieldIsOrderedBy(String field,
                                      StackMobQuery.Ordering ordering)
add an "ORDER BY" to your query

Parameters:
field - the field to order by
ordering - the ordering of that field
Returns:
the new query that resulted from adding this operation

expandDepthIs

public StackMobQuery expandDepthIs(Integer i)
set the expand depth of this query. the expand depth instructs the StackMob platform to detect relationships and automatically replace those relationship IDs with the values that they point to.

Parameters:
i - the expand depth. at time of writing, StackMob restricts expand depth to maximum 3
Returns:
the new query that resulted from adding this operation

isInRange

public StackMobQuery isInRange(Integer start,
                               Integer end)
this method lets you add a "LIMIT" and "SKIP" to your query at once. Can be used to implement pagination in your app.

Parameters:
start - the starting object number (inclusive)
end - the ending object number (inclusive)
Returns:
the new query that resulted from adding this operation

isInRange

public StackMobQuery isInRange(Integer start)
same thing as isInRange(Integer, Integer), except does not specify an end to the range. instead, gets all objects from a starting point (including)

Parameters:
start - the starting object number
Returns:
the new query that resulted from adding this operation


Copyright © 2011 StackMob. All Rights Reserved.