/*
* Created on 2004/11/03
* Author aki@www.xucker.jpn.org
* License Apache2.0 or Common Public License
*/
package org.jpn.xucker.commons.google;
import org.jpn.xucker.commons.util.TagUtil;
import java.util.List;
import java.util.Map;
import java.util.Vector;
/**
*
*
*/
public class GoogleAdSenseChannelParser {
public Channel[] parseActiveChannel(String text){
List channelList=new Vector();
String selects[]=TagUtil.getTagByName(text,"select");
//System.out.println("select:"+selects.length);
for(int i=0;i<selects.length;i++){
String name=(String)TagUtil.getAttribute(selects[i]).get("name");
if("activechannelcode".equals(name)){
String options[]=TagUtil.getTagByName(selects[i],"option");
for(int j=0;j<options.length;j++){
Map map=TagUtil.getAttribute(options[j]);
String value=(String)map.get("value");
String nameValue=TagUtil.getContain(options[j]);
nameValue=nameValue.replaceAll(" ","");
//System.out.println(""+value+","+nameValue);
if(nameValue!=null && value!=null){
channelList.add(new Channel(nameValue,value));
}
}
break;
}
}
return (Channel[])channelList.toArray(new Channel[channelList.size()]);
}
}
|