Example usage for com.google.gson.stream JsonReader beginObject

List of usage examples for com.google.gson.stream JsonReader beginObject

Introduction

In this page you can find the example usage for com.google.gson.stream JsonReader beginObject.

Prototype

public void beginObject() throws IOException 

Source Link

Document

Consumes the next token from the JSON stream and asserts that it is the beginning of a new object.

Usage

From source file:net.evecom.android.json.JsonMainPersonViewData.java

License:Open Source License

public static ArrayList<T_PERSON_INTERVIEW> getData(final String path, String entity_str) throws Exception {

    URL url = new URL(path);
    HttpURLConnection conn = (HttpURLConnection) url.openConnection();
    conn.setRequestMethod("POST");
    byte[] entity = entity_str.getBytes();
    conn.setConnectTimeout(5000);//from   www  .  j av a  2  s.  com
    conn.setDoOutput(true);
    conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
    conn.setRequestProperty("Content-Length", String.valueOf(entity.length));
    conn.getOutputStream().write(entity);
    if (conn.getResponseCode() == 200) {
        InputStream inputstream = conn.getInputStream();
        StringBuffer buffer = new StringBuffer();
        byte[] b = new byte[1024];
        for (int i; (i = inputstream.read(b)) != -1;) {
            buffer.append(new String(b, 0, i));
        }
        StringReader reader = new StringReader(buffer.toString());
        JsonReader jsonReader = new JsonReader(reader);
        list = new ArrayList<T_PERSON_INTERVIEW>();
        jsonReader.beginArray();
        while (jsonReader.hasNext()) {
            jsonReader.beginObject();
            T_PERSON_INTERVIEW person_view = new T_PERSON_INTERVIEW();
            while (jsonReader.hasNext()) {
                String nextName = jsonReader.nextName();
                String nextValue = "";
                if (nextName.equals("INTERVIEWEFFECT")) {
                    nextValue = jsonReader.nextString();
                    person_view.setINTERVIEWEFFECT(nextValue);
                } else if (nextName.equals("PERSONNAME")) {
                    nextValue = jsonReader.nextString();
                    person_view.setPERSONNAME(nextValue);
                } else if (nextName.equals("INTERVIEWTIME")) {
                    nextValue = jsonReader.nextString();
                    person_view.setINTERVIEWTIME(nextValue);
                } else if (nextName.equals("INTERVIEWID")) {
                    nextValue = jsonReader.nextString();
                    person_view.setINTERVIEWID(nextValue);
                } else if (nextName.equals("INTERVIEWTYPE")) {
                    nextValue = jsonReader.nextString();
                    person_view.setINTERVIEWTYPE(nextValue);
                } else if (nextName.equals("BIRTH")) {
                    nextValue = jsonReader.nextString();
                    person_view.setBIRTH(nextValue);
                } else if (nextName.equals("MALEDICTID")) {
                    nextValue = jsonReader.nextString();
                    person_view.setMALEDICTID(nextValue);
                } else if (nextName.equals("PERSONID")) {
                    nextValue = jsonReader.nextString();
                    person_view.setPERSONID(nextValue);
                }
            }
            list.add(person_view);
            person_view = null;
            jsonReader.endObject();
        }
        jsonReader.endArray();
        return list;
    } else {
        return null;
    }
}

From source file:net.evecom.android.json.JsonMainPlaceKeyPlaceData.java

License:Open Source License

public static ArrayList<T_PLACE_PLACE> getData(final String path, String entity_str) throws Exception {
    URL url = new URL(path);
    HttpURLConnection conn = (HttpURLConnection) url.openConnection();
    conn.setRequestMethod("POST");
    byte[] entity = entity_str.getBytes();
    conn.setConnectTimeout(5000);/*from   w w w .j a v  a  2s . co m*/
    conn.setDoOutput(true);
    conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
    conn.setRequestProperty("Content-Length", String.valueOf(entity.length));
    conn.getOutputStream().write(entity);
    if (conn.getResponseCode() == 200) {
        InputStream inputstream = conn.getInputStream();
        StringBuffer buffer = new StringBuffer();
        byte[] b = new byte[1024];
        for (int i; (i = inputstream.read(b)) != -1;) {
            buffer.append(new String(b, 0, i));
        }
        StringReader reader = new StringReader(buffer.toString());
        JsonReader jsonReader = new JsonReader(reader);
        list = new ArrayList<T_PLACE_PLACE>();
        jsonReader.beginArray();
        while (jsonReader.hasNext()) {
            jsonReader.beginObject();
            T_PLACE_PLACE person_view = new T_PLACE_PLACE();
            while (jsonReader.hasNext()) {
                String nextName = jsonReader.nextName();
                String nextValue = "";
                if (nextName.equals("PLACEADDR")) {
                    nextValue = jsonReader.nextString();
                    person_view.setPLACEADDR(nextValue);
                } else if (nextName.equals("PLACETYPED")) {
                    nextValue = jsonReader.nextString();
                    person_view.setPLACETYPED(nextValue);
                } else if (nextName.equals("PLACENAME")) {
                    nextValue = jsonReader.nextString();
                    person_view.setPLACENAME(nextValue);
                } else if (nextName.equals("PLACEID")) {
                    nextValue = jsonReader.nextString();
                    person_view.setPLACEID(nextValue);
                }
            }
            list.add(person_view);
            person_view = null;
            jsonReader.endObject();
        }
        jsonReader.endArray();
        return list;
    } else {
        return null;
    }
}

From source file:net.evecom.android.json.JsonMainPlayCheckData.java

License:Open Source License

public static ArrayList<T_PERSON_INSPECTION> getData(final String path, String entity_str) throws Exception {
    URL url = new URL(path);
    HttpURLConnection conn = (HttpURLConnection) url.openConnection();
    conn.setRequestMethod("POST");
    byte[] entity = entity_str.getBytes();
    conn.setConnectTimeout(5000);//from ww w.  ja  v a2  s .  co  m
    conn.setDoOutput(true);
    conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
    conn.setRequestProperty("Content-Length", String.valueOf(entity.length));
    conn.getOutputStream().write(entity);
    if (conn.getResponseCode() == 200) {
        InputStream inputstream = conn.getInputStream();
        StringBuffer buffer = new StringBuffer();
        byte[] b = new byte[1024];
        for (int i; (i = inputstream.read(b)) != -1;) {
            buffer.append(new String(b, 0, i));
        }
        StringReader reader = new StringReader(buffer.toString());
        JsonReader jsonReader = new JsonReader(reader);
        list = new ArrayList<T_PERSON_INSPECTION>();
        jsonReader.beginArray();
        while (jsonReader.hasNext()) {
            jsonReader.beginObject();
            T_PERSON_INSPECTION person_view = new T_PERSON_INSPECTION();
            while (jsonReader.hasNext()) {
                String nextName = jsonReader.nextName();
                String nextValue = "";
                if (nextName.equals("INSDATE")) {
                    nextValue = jsonReader.nextString();
                    person_view.setINSDATE(nextValue);
                } else if (nextName.equals("RECTSTATE")) {
                    nextValue = jsonReader.nextString();
                    person_view.setRECTSTATE(nextValue);
                } else if (nextName.equals("INSPLACE")) {
                    nextValue = jsonReader.nextString();
                    person_view.setINSPLACE(nextValue);
                } else if (nextName.equals("INSRESULT")) {
                    nextValue = jsonReader.nextString();
                    person_view.setINSRESULT(nextValue);
                } else if (nextName.equals("INSPLACEID")) {
                    nextValue = jsonReader.nextString();
                    person_view.setINSPLACEID(nextValue);
                } else if (nextName.equals("PERSONID")) {
                    nextValue = jsonReader.nextString();
                    person_view.setPERSONID(nextValue);
                } else if (nextName.equals("SYSID")) {
                    nextValue = jsonReader.nextString();
                    person_view.setSYSID(nextValue);
                }
            }
            list.add(person_view);
            person_view = null;
            jsonReader.endObject();
        }
        jsonReader.endArray();
        return list;
    } else {
        return null;
    }
}

From source file:net.evecom.android.json.JsonSysOrgansData.java

License:Open Source License

public static ArrayList<MianPerson> getData(final String path, String entity_str) throws Exception {

    URL url = new URL(path);
    HttpURLConnection conn = (HttpURLConnection) url.openConnection();
    conn.setRequestMethod("POST");
    byte[] entity = entity_str.getBytes();
    conn.setConnectTimeout(5000);/*from  w ww. j a v a 2s  .co  m*/
    conn.setDoOutput(true);
    conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
    conn.setRequestProperty("Content-Length", String.valueOf(entity.length));
    conn.getOutputStream().write(entity);
    if (conn.getResponseCode() == 200) {
        InputStream inputstream = conn.getInputStream();
        StringBuffer buffer = new StringBuffer();
        byte[] b = new byte[1024];
        for (int i; (i = inputstream.read(b)) != -1;) {
            buffer.append(new String(b, 0, i));
        }
        StringReader reader = new StringReader(buffer.toString());
        JsonReader jsonReader = new JsonReader(reader);
        list = new ArrayList<MianPerson>();
        jsonReader.beginObject();
        while (jsonReader.hasNext()) {
            String nextname1 = "";
            if (jsonReader.peek() == JsonToken.NULL) {
                jsonReader.nextNull();
            } else if (jsonReader.peek() == JsonToken.NUMBER) {
                nextname1 = jsonReader.nextInt() + "";
            } else {
                nextname1 = jsonReader.nextName();
            }
            if ("rows".equals(nextname1)) {
                jsonReader.beginArray();
                while (jsonReader.hasNext()) {
                    jsonReader.beginObject();
                    MianPerson person = new MianPerson();
                    while (jsonReader.hasNext()) {
                        String nextName = "";
                        if (jsonReader.peek() == JsonToken.NULL) {
                            jsonReader.nextNull();
                        } else if (jsonReader.peek() == JsonToken.NUMBER) {
                            nextName = jsonReader.nextInt() + "";
                        } else if (jsonReader.peek() == JsonToken.STRING) {
                            nextName = jsonReader.nextString() + "";
                        } else {
                            nextName = jsonReader.nextName();
                        }
                        String nextValue = "";
                        if (nextName.equals("IDCARDNO")) {// 
                            if (jsonReader.peek() == JsonToken.NULL) {
                                jsonReader.nextNull();
                            } else if (jsonReader.peek() == JsonToken.NUMBER) {
                                nextValue = jsonReader.nextInt() + "";
                            } else {
                                nextValue = jsonReader.nextString();
                            }
                            // nextValue = jsonReader.nextString();
                            person.setIDCARDNO(nextValue);
                        } else if (nextName.equals("HOUSEHOLDID")) {// 
                            if (jsonReader.peek() == JsonToken.NULL) {
                                jsonReader.nextNull();
                            } else if (jsonReader.peek() == JsonToken.NUMBER) {
                                nextValue = jsonReader.nextInt() + "";
                            } else {
                                nextValue = jsonReader.nextString();
                            }
                            // nextValue = jsonReader.nextString();
                            person.setHOUSEHOLDID(nextValue);
                        } else if (nextName.equals("AREAID")) {// id
                            if (jsonReader.peek() == JsonToken.NULL) {
                                jsonReader.nextNull();
                            } else if (jsonReader.peek() == JsonToken.NUMBER) {
                                nextValue = jsonReader.nextInt() + "";
                            } else {
                                nextValue = jsonReader.nextString();
                            }
                            // nextValue = jsonReader.nextString();
                            person.setAREAID(nextValue);
                        } else if (nextName.equals("AREANAME")) {// 
                            if (jsonReader.peek() == JsonToken.NULL) {
                                jsonReader.nextNull();
                            } else if (jsonReader.peek() == JsonToken.NUMBER) {
                                nextValue = jsonReader.nextInt() + "";
                            } else {
                                nextValue = jsonReader.nextString();
                            }
                            // nextValue = jsonReader.nextString();
                            person.setAREANAME(nextValue);
                        } else if (nextName.equals("PERSONNAME")) {// 
                            if (jsonReader.peek() == JsonToken.NULL) {
                                jsonReader.nextNull();
                            } else if (jsonReader.peek() == JsonToken.NUMBER) {
                                nextValue = jsonReader.nextInt() + "";
                            } else {
                                nextValue = jsonReader.nextString();
                            }
                            // nextValue = jsonReader.nextString();
                            person.setPERSONNAME(nextValue);
                        } else if (nextName.equals("MALEDICTID")) {//  1
                                                                   // 2
                            if (jsonReader.peek() == JsonToken.NULL) {
                                jsonReader.nextNull();
                            } else if (jsonReader.peek() == JsonToken.NUMBER) {
                                nextValue = jsonReader.nextInt() + "";
                            } else {
                                nextValue = jsonReader.nextString();
                            }
                            // nextValue = jsonReader.nextString();
                            if (null != nextValue && "1".equals(nextValue)) {
                                person.setMALEDICTID("");
                            } else if (null != nextValue && "2".equals(nextValue)) {
                                person.setMALEDICTID("");
                            }
                        } else if (nextName.equals("BIRTH")) {// 
                            if (jsonReader.peek() == JsonToken.NULL) {
                                jsonReader.nextNull();
                            } else if (jsonReader.peek() == JsonToken.NUMBER) {
                                nextValue = jsonReader.nextInt() + "";
                            } else {
                                nextValue = jsonReader.nextString();
                            }
                            // nextValue = jsonReader.nextString();
                            person.setBIRTH(nextValue);
                        } else if (nextName.equals("HOUSEADDR")) {// 
                            if (jsonReader.peek() == JsonToken.NULL) {
                                jsonReader.nextNull();
                            } else if (jsonReader.peek() == JsonToken.NUMBER) {
                                nextValue = jsonReader.nextInt() + "";
                            } else {
                                nextValue = jsonReader.nextString();
                            }
                            // nextValue = jsonReader.nextString();
                            person.setHOUSEADDR(nextValue);
                        } else if (nextName.equals("PERSONID")) {// id
                            if (jsonReader.peek() == JsonToken.NULL) {
                                jsonReader.nextNull();
                            } else if (jsonReader.peek() == JsonToken.NUMBER) {
                                nextValue = jsonReader.nextInt() + "";
                            } else {
                                nextValue = jsonReader.nextString();
                            }
                            // nextValue = jsonReader.nextString();
                            person.setPERSONID(nextValue);
                        }
                        System.out.println(nextName + "=" + nextValue);
                    }
                    list.add(person);
                    person = null;
                    jsonReader.endObject();
                }
                jsonReader.endArray();
            }
            //
        }
        jsonReader.endObject();

        // XmlPullParser xml = Xml.newPullParser();
        // xml.setInput(inputstream, "UTF-8");
        // int event = xml.getEventType();
        // while (event != XmlPullParser.END_DOCUMENT) {
        // switch (event) {
        // // 
        // case XmlPullParser.START_DOCUMENT:
        // list = new ArrayList<SysOrgan>();
        // break;
        // case XmlPullParser.START_TAG:
        //
        // String value = xml.getName();
        // if (value.equals("QY")) {
        // organ = new SysOrgan();
        // } else if (value.equals("SO_ID")) {
        // organ.setSoId(xml.nextText());
        // } else if (value.equals("so_Name")) {
        // organ.setSoName(xml.nextText());
        // }
        // break;
        // case XmlPullParser.END_TAG:
        // if (xml.getName().equals("QY")) {
        // list.add(organ);
        // organ = null;
        // }
        // break;
        // default:
        // break;
        // }
        // // 
        // event = xml.next();
        // }
        return list;
    } else {
        return null;
    }
}

From source file:net.evecom.android.MainOneActivity.java

License:Open Source License

/**
 * getTreeOne/*from   w  w w. jav  a 2s. co  m*/
 */
private void getTreeOne(final String sbd_id) {
    progressDialog_getInfo = ProgressDialog.show(MainOneActivity.this, "", "...");

    list_jd.removeAll(list_jd);

    // getAreaJsonReader("0");

    new Thread(new Runnable() {
        @Override
        public void run() {
            msg_listData = new Message();
            String strUrl = HttpUtil.BASE_URL + "teventAndroid/queryChildTree?pid=" + "0";
            String strResult = null;
            try {
                strResult = connServerForResult(strUrl);
            } catch (Exception e) {
                msg_listData.what = MESSAGETYPE_02;
                handler1.sendMessage(msg_listData);
                if (null != e) {
                    e.printStackTrace();
                }
                return;
            }
            // DialogToast(strResult);
            // System.out.println(strResult);
            if (null == strResult || "".equals(strResult)) {
                msg_listData.what = MESSAGETYPE_02;
                handler1.sendMessage(msg_listData);
                return;
            }
            StringReader reader = new StringReader(strResult);
            JsonReader jsonReader = new JsonReader(reader);
            try {
                jsonReader.beginArray();
                while (jsonReader.hasNext()) {
                    jsonReader.beginObject();
                    SysBaseDict dict = new SysBaseDict();
                    while (jsonReader.hasNext()) {
                        String nextName = jsonReader.nextName();
                        String nextValue = "";
                        if (nextName.equals("id")) {
                            nextValue = jsonReader.nextString();
                            dict.setSbdCode(nextValue);
                        } else if (nextName.equals("name")) {
                            nextValue = jsonReader.nextString();
                            dict.setSbdName(nextValue);
                        } else if (nextName.equals("isparent")) {
                            nextValue = jsonReader.nextString();
                            dict.setSbdType(nextValue);
                        } else if (nextName.equals("pid")) {
                            nextValue = jsonReader.nextString();
                            dict.setSbdPid(nextValue);
                        } else if (nextName.equals("type")) {
                            nextValue = jsonReader.nextString();
                            dict.setSbdType(nextValue);
                        }

                        // System.out.println(nextName+"="+nextValue);
                    }
                    list_jd.add(dict);
                    dict = null;
                    jsonReader.endObject();

                }
                jsonReader.endArray();
            } catch (IOException e) {
                if (null != e) {
                    e.printStackTrace();
                }
            }
            if (null == list_jd || list_jd.size() < 1) {
                msg_listData.what = MESSAGETYPE_02;
            } else {
                msg_listData.what = MESSAGETYPE_01;
            }
            handler1.sendMessage(msg_listData);
        }
    }).start();

}

From source file:net.evecom.android.MainOneActivity.java

License:Open Source License

/**
 * getTreeTwo//  ww  w .j  a v  a2  s  .com
 */
private void getTreeTwo(final String oneStr) {
    progressDialog_getInfo = ProgressDialog.show(MainOneActivity.this, "", "...");
    list_jd.removeAll(list_jd);
    msg_listData = new Message();

    new Thread(new Runnable() {
        @Override
        public void run() {
            String strUrl = HttpUtil.BASE_URL + "teventAndroid/queryChildTree?pid=" + oneStr;
            String strResult = null;
            try {
                strResult = connServerForResult(strUrl);
            } catch (Exception e) {
                msg_listData.what = MESSAGETYPE_02;
                handler2.sendMessage(msg_listData);
                if (null != e) {
                    e.printStackTrace();
                }
                return;
            }
            // DialogToast(strResult);
            // System.out.println(strResult);
            if (null == strResult || "".equals(strResult)) {
                return;
            }
            StringReader reader = new StringReader(strResult);
            JsonReader jsonReader = new JsonReader(reader);

            try {
                jsonReader.beginArray();
                while (jsonReader.hasNext()) {
                    jsonReader.beginObject();
                    SysBaseDict dict = new SysBaseDict();
                    while (jsonReader.hasNext()) {
                        String nextName = jsonReader.nextName();
                        String nextValue = "";
                        if (nextName.equals("id")) {
                            nextValue = jsonReader.nextString();
                            dict.setSbdCode(nextValue);
                        } else if (nextName.equals("name")) {
                            nextValue = jsonReader.nextString();
                            dict.setSbdName(nextValue);
                        } else if (nextName.equals("isparent")) {
                            nextValue = jsonReader.nextString();
                            dict.setSbdType(nextValue);
                        } else if (nextName.equals("pid")) {
                            nextValue = jsonReader.nextString();
                            dict.setSbdPid(nextValue);
                        } else if (nextName.equals("type")) {
                            nextValue = jsonReader.nextString();
                            dict.setSbdType(nextValue);
                        }
                        // System.out.println(nextName+"="+nextValue);
                    }
                    list_jd.add(dict);
                    dict = null;
                    jsonReader.endObject();

                }
                jsonReader.endArray();
            } catch (IOException e) {
                if (null != e) {
                    e.printStackTrace();
                }
            }
            if (null == list_jd || list_jd.size() < 1) {
                msg_listData.what = MESSAGETYPE_02;
            } else {
                msg_listData.what = MESSAGETYPE_01;
            }
            handler2.sendMessage(msg_listData);
        }
    }).start();

}

From source file:net.evecom.android.MainOneActivity.java

License:Open Source License

/**
 * getTreeThree/*from   w  w w.  j av  a  2 s  .c  o m*/
 */
private void getTreeThree(final String sbd_id) {
    progressDialog_getInfo = ProgressDialog.show(MainOneActivity.this, "", "...");
    list_jd.removeAll(list_jd);
    msg_listData = new Message();

    new Thread(new Runnable() {
        @Override
        public void run() {
            String strUrl = HttpUtil.BASE_URL + "teventAndroid/queryChildTree?pid=" + sbd_id;
            String strResult = null;
            try {
                strResult = connServerForResult(strUrl);
            } catch (Exception e) {
                msg_listData.what = MESSAGETYPE_02;
                handler3.sendMessage(msg_listData);
                if (null != e) {
                    e.printStackTrace();
                }
                return;
            }
            if (null == strResult || "".equals(strResult)) {
                return;
            }
            // System.out.println(strResult);
            StringReader reader = new StringReader(strResult);
            JsonReader jsonReader = new JsonReader(reader);

            try {
                jsonReader.beginArray();
                while (jsonReader.hasNext()) {
                    jsonReader.beginObject();
                    SysBaseDict dict = new SysBaseDict();
                    while (jsonReader.hasNext()) {
                        String nextName = jsonReader.nextName();
                        String nextValue = "";
                        if (nextName.equals("id")) {
                            nextValue = jsonReader.nextString();
                            dict.setSbdCode(nextValue);
                        } else if (nextName.equals("name")) {
                            nextValue = jsonReader.nextString();
                            dict.setSbdName(nextValue);
                        } else if (nextName.equals("isparent")) {
                            nextValue = jsonReader.nextString();
                            dict.setSbdType(nextValue);
                        } else if (nextName.equals("pid")) {
                            nextValue = jsonReader.nextString();
                            dict.setSbdPid(nextValue);
                        } else if (nextName.equals("type")) {
                            nextValue = jsonReader.nextString();
                            dict.setSbdType(nextValue);
                        }
                    }
                    list_jd.add(dict);
                    dict = null;
                    jsonReader.endObject();
                }
                jsonReader.endArray();
            } catch (IOException e) {
                if (null != e) {
                    e.printStackTrace();
                }
            }
            if (null == list_jd || list_jd.size() < 1) {
                msg_listData.what = MESSAGETYPE_02;
            } else {
                msg_listData.what = MESSAGETYPE_01;
            }
            handler3.sendMessage(msg_listData);
        }
    }).start();

}

From source file:net.evecom.android.Welcome.java

License:Open Source License

/**
 * /* w w w  .  j  av a 2 s.  c om*/
 */
private void getEventTypeFromDictAndParse2ListAndSave2DataBase() {
    new Thread(new Runnable() {
        @Override
        public void run() {
            String strUrl = HttpUtil.BASE_URL + "teventAndroid/addItem";
            Message msg = Message.obtain();
            try {
                eventType_json = connServerForResult(strUrl);
            } catch (Exception e) {
                msg.what = MESSAGETYPE_02;
                handler1.sendMessage(msg);

                if (null != e) {
                    e.printStackTrace();
                }
                return;
            }
            if (null == eventType_json || "".equals(eventType_json)) {
                msg.what = MESSAGETYPE_02;
                handler1.sendMessage(msg);
                return;
            }
            StringReader reader = new StringReader(eventType_json);
            JsonReader jsonReader = new JsonReader(reader);
            try {
                jsonReader.beginArray();
                while (jsonReader.hasNext()) {
                    jsonReader.beginObject();
                    EOS_DICT_ENTRY dict = new EOS_DICT_ENTRY();
                    while (jsonReader.hasNext()) {
                        String nextName = jsonReader.nextName();
                        String nextValue = "";
                        if (nextName.equals("DICTID")) {
                            nextValue = jsonReader.nextString();
                            dict.setDICTID(nextValue);
                        } else if (nextName.equals("PARENTID")) {
                            nextValue = jsonReader.nextString();
                            dict.setPARENTID(nextValue);
                        } else if (nextName.equals("DICTTYPEID")) {
                            nextValue = jsonReader.nextString();
                            dict.setDICTTYPEID(nextValue);
                        } else if (nextName.equals("DICTNAME")) {
                            nextValue = jsonReader.nextString();
                            dict.setDICTNAME(nextValue);
                        }
                    }
                    dict_ENTRYs.add(dict);
                    dict = null;
                    jsonReader.endObject();

                }
                jsonReader.endArray();
            } catch (IOException e) {
                msg.what = MESSAGETYPE_02;
                handler1.sendMessage(msg);
                if (null != e) {
                    e.printStackTrace();
                }
                return;
            }
            if (null == dict_ENTRYs || dict_ENTRYs.size() < 1) {
                msg.what = MESSAGETYPE_02;
            } else {
                msg.what = MESSAGETYPE_01;
            }
            handler1.sendMessage(msg);
            return;
        }
    }).start();
}

From source file:net.oneandone.stool.configuration.adapter.ExtensionsAdapter.java

License:Apache License

@Override
public Extensions read(JsonReader in) throws IOException {
    Extensions extensions;/*ww w.  j av a2  s .co  m*/
    String str;
    String name;
    Extension extension;
    Class<? extends Extension> clazz;

    extensions = new Extensions();
    in.beginObject();
    while (in.peek() == JsonToken.NAME) {
        str = in.nextName();
        name = str.substring(1);
        clazz = factory.type(name);
        if (clazz == null) {
            throw new IOException("extension not found: " + name);
        }
        extension = gson.fromJson(in, clazz);
        extensions.add(name, str.startsWith("+"), extension);
    }
    in.endObject();
    return extensions;
}

From source file:net.visualillusionsent.newu.StationTracker.java

License:Open Source License

private void loadStations() {
    try {//  w  w w  .  jav  a  2  s .  com
        File stationsJSON = new File(NewU.cfgDir, "stations.json");
        if (!stationsJSON.exists()) {
            stationsJSON.createNewFile();
            return;
        }

        JsonReader reader = new JsonReader(new FileReader(stationsJSON));
        reader.beginObject(); // Begin main object
        while (reader.hasNext()) {
            String name = reader.nextName();
            if (name.equals("Station")) {
                NewUStation temp = null;
                reader.beginObject(); // Begin Station
                String foundName = null;
                while (reader.hasNext()) {
                    name = reader.nextName();
                    if (name.equals("Name")) {
                        foundName = reader.nextString();
                        continue;
                    } else if (name.equals("Location")) {
                        reader.beginObject(); // Begin Location
                        temp = new NewUStation(foundName, reader); // Pass reader into NewUStation object for parsing
                        reader.endObject(); // End Location
                    } else if (name.equals("Discoverers")) {
                        reader.beginArray(); // Begin Discoverers
                        while (reader.hasNext()) {
                            if (temp != null) {
                                temp.addDiscoverer(reader.nextString());
                            }
                        }
                        reader.endArray(); // End Discoverers
                    } else {
                        reader.skipValue(); // UNKNOWN THING
                    }
                }
                if (temp != null) {
                    stations.put(temp.getName(), temp);
                }
                reader.endObject(); //End Station
            }
        }

        reader.endObject(); // End main object
        reader.close();
    } catch (IOException e) {
        logger.log(Level.SEVERE, "Failed to load stations...");
    }
}