package com.wodexiangce.util.partner;
import java.io.IOException;
import java.util.Iterator;
import java.util.List;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder;
import cn.net.emay.metone.api.Client;
/**
* 特殊合作单位
* 1.把特殊合作单位配到xml中
* 2.判断是否是特殊合作的单位
* @author luqinglong
*
*/
public class PartnerHandler{
public static String path = "D:\\test.xml" ;
/*序列码,合作单位给的*/
public static String serialCode = "0SDK-EMY-0405-JBTRL" ;
public static String password = "227890" ;
/**
* 根据inviteid,判断是否为特殊合作
* @param inviteid
* @return true:特殊合作 false:正常用户
*/
public static boolean isSpecialInviteid(String inviteid){
/* 采用默认解析*/
inviteid = inviteid.trim();
SAXBuilder builder=new SAXBuilder(false);
try {
Document doc=builder.build(path);
Element ids =doc.getRootElement();
List idList=ids.getChildren("param");
for (Iterator iter = idList.iterator(); iter.hasNext();) {
Element param = (Element) iter.next();
String a = param.getAttributeValue("inviteid");
if(inviteid.equals(a)){
return true ;
}
}
} catch (JDOMException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return false ;
}
public static void main(String[] args) throws Exception{
System.out.println(isSpecialInviteid("dsadsa"));
}
}
jdom 简单用法
最新推荐文章于 2016-10-23 17:27:31 发布