Package com.parse
Class ParseConfig
- java.lang.Object
-
- com.parse.ParseConfig
-
public class ParseConfig extends java.lang.Object
TheParseConfig
is a local representation of configuration data that can be set from the Parse dashboard.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ParseConfig
get()
Fetches a new configuration object from the server.java.lang.Object
get(java.lang.String key)
Access a value.java.lang.Object
get(java.lang.String key, java.lang.Object defaultValue)
Access a value, returning a default value if the key doesn't exist.boolean
getBoolean(java.lang.String key)
Access aboolean
value.boolean
getBoolean(java.lang.String key, boolean defaultValue)
Access aboolean
value, returning a default value if it doesn't exist.static ParseConfig
getCurrentConfig()
Retrieves the most recently-fetched configuration object, either from memory or disk if necessary.java.util.Date
getDate(java.lang.String key)
Access aDate
value.java.util.Date
getDate(java.lang.String key, java.util.Date defaultValue)
Access aDate
value, returning a default value if it doesn't exist.double
getDouble(java.lang.String key)
Access adouble
value.double
getDouble(java.lang.String key, double defaultValue)
Access adouble
value, returning a default value if it doesn't exist.static <any>
getInBackground()
Fetches a new configuration object from the server in a background thread.static void
getInBackground(ConfigCallback callback)
Fetches a new configuration object from the server in a background thread.int
getInt(java.lang.String key)
Access anint
value.int
getInt(java.lang.String key, int defaultValue)
Access anint
value, returning a default value if it doesn't exist.JSONArray
getJSONArray(java.lang.String key)
Access aJSONArray
value.JSONArray
getJSONArray(java.lang.String key, JSONArray defaultValue)
Access aJSONArray
value, returning a default value if it doesn't exist.JSONObject
getJSONObject(java.lang.String key)
Access aJSONObject
value.JSONObject
getJSONObject(java.lang.String key, JSONObject defaultValue)
Access aJSONObject
value, returning a default value if it doesn't exist.<T> java.util.List<T>
getList(java.lang.String key)
Access aList
value.<T> java.util.List<T>
getList(java.lang.String key, java.util.List<T> defaultValue)
Access aList
value, returning a default value if it doesn't exist.long
getLong(java.lang.String key)
Access along
value.long
getLong(java.lang.String key, long defaultValue)
Access along
value, returning a default value if it doesn't exist.<V> java.util.Map<java.lang.String,V>
getMap(java.lang.String key)
Access aMap
value.<V> java.util.Map<java.lang.String,V>
getMap(java.lang.String key, java.util.Map<java.lang.String,V> defaultValue)
Access aMap
value, returning a default value if it doesn't exist.java.lang.Number
getNumber(java.lang.String key)
Access a numerical value.java.lang.Number
getNumber(java.lang.String key, java.lang.Number defaultValue)
Access a numerical value, returning a default value if it doesn't exist.ParseFile
getParseFile(java.lang.String key)
Access aParseFile
value.ParseFile
getParseFile(java.lang.String key, ParseFile defaultValue)
Access aParseFile
value, returning a default value if it doesn't exist.ParseGeoPoint
getParseGeoPoint(java.lang.String key)
Access aParseGeoPoint
value.ParseGeoPoint
getParseGeoPoint(java.lang.String key, ParseGeoPoint defaultValue)
Access aParseGeoPoint
value, returning a default value if it doesn't exist.java.lang.String
getString(java.lang.String key)
Access aString
value.java.lang.String
getString(java.lang.String key, java.lang.String defaultValue)
Access aString
value, returning a default value if it doesn't exist.java.lang.String
toString()
-
-
-
Method Detail
-
getCurrentConfig
public static ParseConfig getCurrentConfig()
Retrieves the most recently-fetched configuration object, either from memory or disk if necessary.- Returns:
- The most recently-fetched
ParseConfig
if it exists, else an emptyParseConfig
-
get
public static ParseConfig get() throws ParseException
Fetches a new configuration object from the server.- Returns:
- The
ParseConfig
that was fetched. - Throws:
ParseException
- Throws an exception if the server is inaccessible.
-
getInBackground
public static void getInBackground(ConfigCallback callback)
Fetches a new configuration object from the server in a background thread. This is preferable to usingget()
, unless your code is already running from a background thread.- Parameters:
callback
- callback.done(config, e) is called when the fetch completes.
-
getInBackground
public static <any> getInBackground()
Fetches a new configuration object from the server in a background thread. This is preferable to usingget()
, unless your code is already running from a background thread.- Returns:
- A Task that is resolved when the fetch completes.
-
get
public java.lang.Object get(java.lang.String key)
Access a value. In most cases it is more convenient to use a helper function such asgetString(java.lang.String)
orgetInt(java.lang.String)
.- Parameters:
key
- The key to access the value for.- Returns:
- Returns
null
if there is no such key.
-
get
public java.lang.Object get(java.lang.String key, java.lang.Object defaultValue)
Access a value, returning a default value if the key doesn't exist. In most cases it is more convenient to use a helper function such asgetString(java.lang.String)
orgetInt(java.lang.String)
.- Parameters:
key
- The key to access the value for.defaultValue
- The value to return if the key is not present in the configuration object.- Returns:
- The default value if there is no such key.
-
getBoolean
public boolean getBoolean(java.lang.String key)
Access aboolean
value.- Parameters:
key
- The key to access the value for.- Returns:
- Returns false if there is no such key or if it is not a
boolean
.
-
getBoolean
public boolean getBoolean(java.lang.String key, boolean defaultValue)
Access aboolean
value, returning a default value if it doesn't exist.- Parameters:
key
- The key to access the value for.defaultValue
- The value to return if the key is not present or has the wrong type.- Returns:
- The default value if there is no such key or if it is not a
boolean
.
-
getDate
public java.util.Date getDate(java.lang.String key)
Access aDate
value.- Parameters:
key
- The key to access the value for.- Returns:
- Returns
null
if there is no such key or if it is not aDate
.
-
getDate
public java.util.Date getDate(java.lang.String key, java.util.Date defaultValue)
Access aDate
value, returning a default value if it doesn't exist.- Parameters:
key
- The key to access the value for.defaultValue
- The value to return if the key is not present or has the wrong type.- Returns:
- The default value if there is no such key or if it is not a
Date
.
-
getDouble
public double getDouble(java.lang.String key)
Access adouble
value.- Parameters:
key
- The key to access the value for.- Returns:
- Returns 0 if there is no such key or if it is not a number.
-
getDouble
public double getDouble(java.lang.String key, double defaultValue)
Access adouble
value, returning a default value if it doesn't exist.- Parameters:
key
- The key to access the value for.defaultValue
- The value to return if the key is not present or has the wrong type.- Returns:
- The default value if there is no such key or if it is not a number.
-
getInt
public int getInt(java.lang.String key)
Access anint
value.- Parameters:
key
- The key to access the value for.- Returns:
- Returns 0 if there is no such key or if it is not a number.
-
getInt
public int getInt(java.lang.String key, int defaultValue)
Access anint
value, returning a default value if it doesn't exist.- Parameters:
key
- The key to access the value for.defaultValue
- The value to return if the key is not present or has the wrong type.- Returns:
- The default value if there is no such key or if it is not a number.
-
getJSONArray
public JSONArray getJSONArray(java.lang.String key)
Access aJSONArray
value.- Parameters:
key
- The key to access the value for.- Returns:
- Returns
null
if there is no such key or if it is not aJSONArray
.
-
getJSONArray
public JSONArray getJSONArray(java.lang.String key, JSONArray defaultValue)
Access aJSONArray
value, returning a default value if it doesn't exist.- Parameters:
key
- The key to access the value for.defaultValue
- The value to return if the key is not present or has the wrong type.- Returns:
- The default value if there is no such key or if it is not a
JSONArray
.
-
getJSONObject
public JSONObject getJSONObject(java.lang.String key)
Access aJSONObject
value.- Parameters:
key
- The key to access the value for.- Returns:
- Returns
null
if there is no such key or if it is not aJSONObject
.
-
getJSONObject
public JSONObject getJSONObject(java.lang.String key, JSONObject defaultValue)
Access aJSONObject
value, returning a default value if it doesn't exist.- Parameters:
key
- The key to access the value for.defaultValue
- The value to return if the key is not present or has the wrong type.- Returns:
- The default value if there is no such key or if it is not a
JSONObject
.
-
getList
public <T> java.util.List<T> getList(java.lang.String key)
Access aList
value.- Parameters:
key
- The key to access the value for.- Returns:
- Returns
null
if there is no such key or if it cannot be converted to aList
.
-
getList
public <T> java.util.List<T> getList(java.lang.String key, java.util.List<T> defaultValue)
Access aList
value, returning a default value if it doesn't exist.- Parameters:
key
- The key to access the value for.defaultValue
- The value to return if the key is not present or has the wrong type.- Returns:
- The default value if there is no such key or if it cannot be converted to a
List
.
-
getLong
public long getLong(java.lang.String key)
Access along
value.- Parameters:
key
- The key to access the value for.- Returns:
- Returns 0 if there is no such key or if it is not a number.
-
getLong
public long getLong(java.lang.String key, long defaultValue)
Access along
value, returning a default value if it doesn't exist.- Parameters:
key
- The key to access the value for.defaultValue
- The value to return if the key is not present or has the wrong type.- Returns:
- The default value if there is no such key or if it is not a number.
-
getMap
public <V> java.util.Map<java.lang.String,V> getMap(java.lang.String key)
Access aMap
value.- Parameters:
key
- The key to access the value for.- Returns:
null
if there is no such key or if it cannot be converted to aMap
.
-
getMap
public <V> java.util.Map<java.lang.String,V> getMap(java.lang.String key, java.util.Map<java.lang.String,V> defaultValue)
Access aMap
value, returning a default value if it doesn't exist.- Parameters:
key
- The key to access the value for.defaultValue
- The value to return if the key is not present or has the wrong type.- Returns:
- The default value if there is no such key or if it cannot be converted to a
Map
.
-
getNumber
public java.lang.Number getNumber(java.lang.String key)
Access a numerical value.- Parameters:
key
- The key to access the value for.- Returns:
- Returns
null
if there is no such key or if it is not aNumber
.
-
getNumber
public java.lang.Number getNumber(java.lang.String key, java.lang.Number defaultValue)
Access a numerical value, returning a default value if it doesn't exist.- Parameters:
key
- The key to access the value for.defaultValue
- The value to return if the key is not present or has the wrong type.- Returns:
- The default value if there is no such key or if it is not a
Number
.
-
getParseFile
public ParseFile getParseFile(java.lang.String key)
Access aParseFile
value. This function will not perform a network request. Unless theParseFile
has been downloaded (e.g. by callingParseFile.getData()
),ParseFile.isDataAvailable()
will return false.- Parameters:
key
- The key to access the value for.- Returns:
null
if there is no such key or if it is not aParseFile
.
-
getParseFile
public ParseFile getParseFile(java.lang.String key, ParseFile defaultValue)
Access aParseFile
value, returning a default value if it doesn't exist. This function will not perform a network request. Unless theParseFile
has been downloaded (e.g. by callingParseFile.getData()
),ParseFile.isDataAvailable()
will return false.- Parameters:
key
- The key to access the value for.defaultValue
- The value to return if the key is not present or has the wrong type.- Returns:
- The default value if there is no such key or if it is not a
ParseFile
.
-
getParseGeoPoint
public ParseGeoPoint getParseGeoPoint(java.lang.String key)
Access aParseGeoPoint
value.- Parameters:
key
- The key to access the value for- Returns:
null
if there is no such key or if it is not aParseGeoPoint
.
-
getParseGeoPoint
public ParseGeoPoint getParseGeoPoint(java.lang.String key, ParseGeoPoint defaultValue)
Access aParseGeoPoint
value, returning a default value if it doesn't exist.- Parameters:
key
- The key to access the value fordefaultValue
- The value to return if the key is not present or has the wrong type.- Returns:
- The default value if there is no such key or if it is not a
ParseGeoPoint
.
-
getString
public java.lang.String getString(java.lang.String key)
Access aString
value.- Parameters:
key
- The key to access the value for.- Returns:
- Returns
null
if there is no such key or if it is not aString
.
-
getString
public java.lang.String getString(java.lang.String key, java.lang.String defaultValue)
Access aString
value, returning a default value if it doesn't exist.- Parameters:
key
- The key to access the value for.defaultValue
- The value to return if the key is not present or has the wrong type.- Returns:
- The default value if there is no such key or if it is not a
String
.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-