All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.ttianjun.common.kit.parse.XJDataNode Maven / Gradle / Ivy

package com.ttianjun.common.kit.parse;

import java.util.List;
import java.util.Map;

import com.ttianjun.common.kit.Lists;

/**
 * json xml通用bean
* json的直接get(key)
* xml的所有都是节点 所以需要getNode("key").get("text") 或者 getNode("key").get("attrName"); * @author TianJun * @Date 2015年3月2日 * @Description: */ public class XJDataNode { private Map propMap; private Map> childNode; public XJDataNode() { super(); propMap = Lists.newHashMap(); childNode = Lists.newHashMap(); } public String get(String key){ return propMap.get(key); } public List getNodeList(String key){ return childNode.get(key); } public XJDataNode getNode(String key){ List nodeList = childNode.get(key); if(nodeList!=null && !nodeList.isEmpty()) return nodeList.get(0); return null; } public void put(String key,String value){ propMap.put(key,value); } public void put(String key,List nodeList){ if(childNode.containsKey(key)) nodeList.addAll(nodeList); else childNode.put(key,nodeList); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy