| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- package com.usai.apex;
- import java.io.Serializable;
- import java.util.ArrayList;
- import java.util.HashMap;
- import java.util.Iterator;
- import org.json.JSONException;
- import org.json.JSONObject;
- import android.util.Log;
- public class SearchResult implements Serializable
- {
- /**
- *
- */
- private static final long serialVersionUID = 8847830656864696392L;
- int total_count = -1;
- // int direction = 1;
- int offset = 0;
- // int count = 0;
- ArrayList<HashMap<String, String>> records = new ArrayList<HashMap<String, String>>();
- public int get_recordscount() {
- return records.size();
- }
- public HashMap<String, String> get_record(int i) {
- return records.get(i);
- }
- public void add_records(String jsonstr) {
- try {
- records.clear();
- JSONObject objrecords = new JSONObject(jsonstr);
- for (int i = 0; i < objrecords.length(); i++) {
- // offset++;
- JSONObject rec = objrecords.getJSONObject("record" + i);
- Iterator<?> it = rec.keys();
- HashMap<String, String> record = new HashMap<String, String>();
- while (it.hasNext()) // loop for each function
- {
- String field_name = (String) it.next();
- String val = rec.getString(field_name)
- .replace("\n", "");
- record.put(field_name, val);
- }
- records.add(record);
- }
- } catch (JSONException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- String TAG = "init_fields@ResultActivity.SearchResult";
- Log.d(TAG, jsonstr);
- }
- public int get_totalcount() {
- return total_count;
- }
- public void put_totalcount(int c) {
- total_count = c;
- }
- public int get_offset() {
- return offset;
- }
- public void set_offset(int i) {
- offset = i;
- }
- }
|