com.blogspot.applications4android.comicreader.core
Class JsonUtils

java.lang.Object
  extended by com.blogspot.applications4android.comicreader.core.JsonUtils

public class JsonUtils
extends java.lang.Object

Has some handy utility functions viz. for operating on json objects


Method Summary
static JSONObject jsonRoot(java.io.InputStream is)
          Returns root JSON object found in the file
static java.lang.String[] listOfAllComicClasses(JSONArray classes)
          Given the json-array of classes, this will give the list of all comic class names
static java.lang.String[] listOfAllComicClasses(java.lang.String file, AssetManager am, java.lang.String key)
          Returns a list of all comic class names from the JSON array found in the file (stored in android_asset)
static java.lang.String[] listOfAllComicNames(JSONArray classes)
          Given the json-array of classes, this will give the list of all comic names
static java.lang.String[] listOfAllComicNames(java.lang.String file, AssetManager am, java.lang.String key)
          Returns a list of all comic names from the JSON array found in the file (stored in android_asset)
static java.lang.String[] listOfAllComicPrefKeys(JSONArray classes)
          Given the json-array of classes, this will give the list of all comic pref keys
static java.lang.String[] listOfAllComicPrefKeys(java.lang.String file, AssetManager am, java.lang.String key)
          Returns a list of all new comic indices from the JSON array found in the file (stored in android_asset)
static java.util.ArrayList<java.lang.Integer> listOfAllNewComicIndices(JSONArray classes)
          Given the json-array of classes, this will give the list of all new comic indices
static java.util.ArrayList<java.lang.Integer> listOfAllNewComicIndices(java.lang.String file, AssetManager am, java.lang.String key)
          Returns a list of all new comic indices from the JSON array found in the file (stored in android_asset)
static JSONArray listOfComics(java.lang.String file, AssetManager am, java.lang.String key)
          Returns a list of comics from the JSON object found in the file (stored in android_asset)
static JSONObject settingsRoot(java.lang.String file, AssetManager am)
          Returns the root JSON object found in the file (stored in android_asset)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

settingsRoot

public static JSONObject settingsRoot(java.lang.String file,
                                      AssetManager am)
                               throws java.io.IOException,
                                      JSONException
Returns the root JSON object found in the file (stored in android_asset)

Parameters:
file - the file of interest
am - the asset manager which will be used to find the input file
Returns:
the JSON object of interest.
Throws:
java.io.IOException
JSONException

jsonRoot

public static JSONObject jsonRoot(java.io.InputStream is)
                           throws java.io.IOException,
                                  JSONException
Returns root JSON object found in the file

Parameters:
is - input stream from where to read the json-string
Returns:
json-root object
Throws:
java.io.IOException
JSONException

listOfComics

public static JSONArray listOfComics(java.lang.String file,
                                     AssetManager am,
                                     java.lang.String key)
                              throws java.io.IOException,
                                     JSONException
Returns a list of comics from the JSON object found in the file (stored in android_asset)

Parameters:
file - the file of interest
am - the asset manager which will be used to find the input file
key - the key which stores the list of all classes
Returns:
the JSON array of interest
Throws:
JSONException
java.io.IOException

listOfAllComicClasses

public static java.lang.String[] listOfAllComicClasses(JSONArray classes)
                                                throws JSONException
Given the json-array of classes, this will give the list of all comic class names

Parameters:
classes - the json-array.
Returns:
string-array of the class names of the comics
Throws:
JSONException

listOfAllComicClasses

public static java.lang.String[] listOfAllComicClasses(java.lang.String file,
                                                       AssetManager am,
                                                       java.lang.String key)
                                                throws java.io.IOException,
                                                       JSONException
Returns a list of all comic class names from the JSON array found in the file (stored in android_asset)

Parameters:
file - the file of interest
am - the asset manager which will be used to find the input file
key - the key which stores the list of all classes
Returns:
string-array of the class names of the comics
Throws:
JSONException
java.io.IOException

listOfAllComicNames

public static java.lang.String[] listOfAllComicNames(JSONArray classes)
                                              throws JSONException
Given the json-array of classes, this will give the list of all comic names

Parameters:
classes - the json-array.
Returns:
string-array of the names of the comics
Throws:
JSONException

listOfAllComicNames

public static java.lang.String[] listOfAllComicNames(java.lang.String file,
                                                     AssetManager am,
                                                     java.lang.String key)
                                              throws java.io.IOException,
                                                     JSONException
Returns a list of all comic names from the JSON array found in the file (stored in android_asset)

Parameters:
file - the file of interest
am - the asset manager which will be used to find the input file
key - the key which stores the list of all classes
Returns:
string-array of the names of the comics
Throws:
JSONException
java.io.IOException

listOfAllNewComicIndices

public static java.util.ArrayList<java.lang.Integer> listOfAllNewComicIndices(JSONArray classes)
                                                                       throws JSONException
Given the json-array of classes, this will give the list of all new comic indices

Parameters:
classes - the json-array.
Returns:
int-array of the indices of the new comics
Throws:
JSONException

listOfAllNewComicIndices

public static java.util.ArrayList<java.lang.Integer> listOfAllNewComicIndices(java.lang.String file,
                                                                              AssetManager am,
                                                                              java.lang.String key)
                                                                       throws java.io.IOException,
                                                                              JSONException
Returns a list of all new comic indices from the JSON array found in the file (stored in android_asset)

Parameters:
file - the file of interest
am - the asset manager which will be used to find the input file
key - the key which stores the list of all classes
Returns:
int-array of the indices of the new comics
Throws:
JSONException
java.io.IOException

listOfAllComicPrefKeys

public static java.lang.String[] listOfAllComicPrefKeys(JSONArray classes)
                                                 throws JSONException
Given the json-array of classes, this will give the list of all comic pref keys

Parameters:
classes - the json-array.
Returns:
string-array of the pref-keys of the comics
Throws:
JSONException

listOfAllComicPrefKeys

public static java.lang.String[] listOfAllComicPrefKeys(java.lang.String file,
                                                        AssetManager am,
                                                        java.lang.String key)
                                                 throws java.io.IOException,
                                                        JSONException
Returns a list of all new comic indices from the JSON array found in the file (stored in android_asset)

Parameters:
file - the file of interest
am - the asset manager which will be used to find the input file
key - the key which stores the list of all classes
Returns:
string-array of the pref-keys of the comics
Throws:
JSONException
java.io.IOException