Android Open Source - isidore Region

From Project

Back to project page isidore.


The source code is released under:

GNU General Public License

If you think the Android project isidore listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.tbardici.isidore;
/* w w  w.  j  a  v a 2  s  . co  m*/
import java.util.ArrayList;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

 * @author Teo
public class Region {
  public final int id;
  public final String slug;
  public final String name;
  public Region(JSONObject from) throws JSONException{ =     from.getInt("id"); =   from.getString("name");
    this.slug =   from.getString("slug");
  private static ArrayList<Region> regions = new ArrayList<Region>();
  private static String rawJson;
  public static void initialize(JSONObject obj) throws JSONException{
    Region.regions = new ArrayList<Region>();
    if (obj != null){
      Region.rawJson = obj.toString();
      JSONArray array = obj.getJSONArray("regions");
      for (int i = 0; i < array.length(); i++){
        Region.regions.add(new Region(array.getJSONObject(i)));  
  public static Region getWithId(int id){
    for (int i = 0; i < Region.regions.size(); i++){
      if (Region.regions.get(i).id == id){
        return Region.regions.get(i);
    return null;
  public static ArrayList<Region> getRegions(){
    return Region.regions;
  public static String getRawJson(){
    return Region.rawJson;
  public String toString() {
    return name;

Java Source Code List