com.stackmob.sdk.api
Class StackMobOptions

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

public class StackMobOptions
extends Object

Stores the various options that can be passed into a request. Calls can be chained for ease of use

 StackMobOptions.https(true).withSelectedFields(Arrays.asList("name", "age").withDepthOf(2)
 
 
Be careful not to call the static methods, which create new options, from non-static context. Java allows this for no good reason with a warning. The object methods are all prefixed with "with". The following code would not do what you want:
 // This is wrong! You'll only get the depthOf in the resulting options
 StackMobOptions.https(true).selectedFields(Arrays.asList("name", "age").depthOf(2)
 
 


Constructor Summary
StackMobOptions()
           
 
Method Summary
static StackMobOptions depthOf(int depth)
          set the expand depth of objects being returned.
 int getExpandDepth()
          get the expand depth as set by withDepthOf(Integer)
 List<Map.Entry<String,String>> getHeaders()
          The headers specified in these options.
 List<String> getSelection()
          get the list of selected fields as specified by selectedFields(java.util.List) or withSelectedFields(java.util.List), or null if none specified (meaning all fields are selected).
static StackMobOptions header(String name, String value)
          add a single header to a request
static StackMobOptions headers(List<Map.Entry<String,String>> headers)
          add a list of headers to a request
static StackMobOptions headers(Map<String,String> headerMap)
          add a set of headers to a request
static StackMobOptions https(boolean https)
          Force a method to be either http or https, overriding any defaults
 boolean isHTTPS()
          whether or not to use https
static StackMobOptions none()
          empty options that do nothing
static StackMobOptions selectedFields(List<String> fields)
          restricts the fields returned by a request.
 StackMobOptions suggestHTTPS(boolean https)
          Force a method to be either http or https, overriding any defaults, unless https has already been set
 StackMobOptions withDepthOf(Integer i)
          set the expand depth of objects being returned.
 StackMobOptions withHeader(String name, String value)
          add a single header to a request
 StackMobOptions withHeaders(List<Map.Entry<String,String>> headers)
          add a list of headers to a request
 StackMobOptions withHeaders(Map<String,String> headerMap)
          add a set of headers to a request
 StackMobOptions withHTTPS(boolean https)
          Force a method to be either http or https, overriding any defaults or previous settings
 StackMobOptions withSelectedFields(List<String> fields)
          restricts the fields returned by a request.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StackMobOptions

public StackMobOptions()
Method Detail

none

public static StackMobOptions none()
empty options that do nothing

Returns:
options with nothing set.

https

public static StackMobOptions https(boolean https)
Force a method to be either http or https, overriding any defaults

Parameters:
https - if true, use https, otherwise http
Returns:
the new options with https set

header

public static StackMobOptions header(String name,
                                     String value)
add a single header to a request

Parameters:
name - the header name
value - the value of the header
Returns:
options with the new header set

headers

public static StackMobOptions headers(Map<String,String> headerMap)
add a set of headers to a request

Parameters:
headerMap - the headers to add
Returns:
options with the new headers set

headers

public static StackMobOptions headers(List<Map.Entry<String,String>> headers)
add a list of headers to a request

Parameters:
headers - the headers to add
Returns:
options with the new headers set

selectedFields

public static StackMobOptions selectedFields(List<String> fields)
restricts the fields returned by a request. This is only supported on get request, login, and getLoggedInUser

Parameters:
fields - the fields to return
Returns:
the new query that resulted from adding this operation

depthOf

public static StackMobOptions depthOf(int depth)
set the expand depth of objects being returned. Objects with relationships will have their related objects returned as child objects

Parameters:
depth - the expand depth, maximum is 3
Returns:
the new query that resulted from adding this operation

withHTTPS

public StackMobOptions withHTTPS(boolean https)
Force a method to be either http or https, overriding any defaults or previous settings

Parameters:
https - if true, use https, otherwise http
Returns:
the new options with https set

suggestHTTPS

public StackMobOptions suggestHTTPS(boolean https)
Force a method to be either http or https, overriding any defaults, unless https has already been set

Parameters:
https - if true, use https, otherwise http
Returns:
the new options with https set

withHeader

public StackMobOptions withHeader(String name,
                                  String value)
add a single header to a request

Parameters:
name - the header name
value - the value of the header
Returns:
options with the new header set

withHeaders

public StackMobOptions withHeaders(Map<String,String> headerMap)
add a set of headers to a request

Parameters:
headerMap - the headers to add
Returns:
options with the new headers set

withHeaders

public StackMobOptions withHeaders(List<Map.Entry<String,String>> headers)
add a list of headers to a request

Parameters:
headers - the headers to add
Returns:
options with the new headers set

withSelectedFields

public StackMobOptions withSelectedFields(List<String> fields)
restricts the fields returned by a request. This is only supported on get request, login, and getLoggedInUser

Parameters:
fields - the fields to return
Returns:
the new query that resulted from adding this operation

withDepthOf

public StackMobOptions withDepthOf(Integer i)
set the expand depth of objects being returned. Objects with relationships will have their related objects returned as child objects

Parameters:
i - the expand depth, maximum is 3
Returns:
the new query that resulted from adding this operation

isHTTPS

public boolean isHTTPS()
whether or not to use https

Returns:
https

getHeaders

public List<Map.Entry<String,String>> getHeaders()
The headers specified in these options.

Returns:
the headers

getExpandDepth

public int getExpandDepth()
get the expand depth as set by withDepthOf(Integer)

Returns:
the expand depth

getSelection

public List<String> getSelection()
get the list of selected fields as specified by selectedFields(java.util.List) or withSelectedFields(java.util.List), or null if none specified (meaning all fields are selected).

Returns:
the selected fields


Copyright © 2013 StackMob. All Rights Reserved.