package AdThreeAnalysis;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

import AdThreeAnalysis.ONAViewTools.ItemHolder;
import StructuralClass.ChannelDataResponse;
import StructuralClass.TempletLine;
import TX_OtherClass.JceStruct;

public class AnalysisAd {
	
	public ArrayList GetAd(JceStruct unPackageJceResponse){
		ArrayList ret = null;
		ArrayList data = null;
		TempletLine datatempline = null;
		if(null == unPackageJceResponse){
			return null;
		}
		ret = new ArrayList();
		data = (ArrayList) ((ChannelDataResponse)unPackageJceResponse).data;
		for(int i=0; i<data.size(); i++){
			datatempline = (TempletLine) data.get(i);
			if(datatempline.lineId.indexOf("ad_") != -1){//如果是目标类型广告才去解析
				ONAAdPoster itemholder = ONAViewTools.builderItemHolder(datatempline);
				if(null != itemholder){
					HashMap<String, AdReport> m_prot = new HashMap();
					m_prot = (HashMap<String, AdReport>) itemholder.report;
			
					AdReport hprot = m_prot.get("click");
					if(null != hprot){
						System.out.println("click->"+hprot.url);
					}
					System.out.println("adId->"+itemholder.adId);
					System.out.println("title->"+itemholder.title);
					System.out.println("subtitle->"+itemholder.subtitle);
					System.out.println("imageUrl->"+itemholder.imageUrl);
					ret.add(itemholder);
				}
			}
			
		}
		
		return ret;
		
	}

}
