/**
 * 用于点播整体数据保存
 * 
 * **/

package com.wasu.cs.model;

import java.util.ArrayList;

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

import com.wasu.common.WError;
import com.wasu.module.datafetch.DataFetchException;
import com.wasu.module.datafetch.ObjectBase;
public class DetailSeriesSet extends ObjectBase {
	private static final long serialVersionUID = -5527490341174985997L;
	ArrayList<Integer>serieslist=new ArrayList<Integer>();

    @Override
	public void createFromResponse(String response) throws DataFetchException {
		try {
			JSONObject JsonData = new JSONObject(response);
			if (JsonData.getInt("code")!=200){
				throw new DataFetchException(WError.ERROR_INVALID_DATA, JsonData.getString("message"));
			}
			JSONObject playInfoJson = JsonData.getJSONObject("data");
			JSONArray setsArray=playInfoJson.optJSONArray("onlineList");
			if (setsArray == null) {
                throw new DataFetchException(WError.ERROR_INVALID_DATA, "电视剧集合地址不存在");
            }
			for (int i = 0; i < setsArray.length(); i++) {
				serieslist.add(setsArray.optInt(i));
			}
		}catch (JSONException e) {
			e.printStackTrace();
            throw new DataFetchException(WError.ERROR_INVALID_DATA, "详情页电视剧集合数据错误");
		}
	}
    public ArrayList<Integer> getSerieslist(){
    	return serieslist;
    }
    public int getSize(){
    	return serieslist.size();
    }
}
