Map或List中null转成空串

	public Map NullConvertEmptyForMap(Map map) {
		Map convertedMap = null;
		Set mapset = map.entrySet();
		String EMPTYSTR = "";
		if (map != null) {
			convertedMap = new HashMap();
			for (Iterator it = mapset.iterator(); it.hasNext();) {
				Entry entry = (Entry) it.next();
				if (entry.getValue() == null) {
					convertedMap.put(entry.getKey(), EMPTYSTR);
				}
				else {
					convertedMap.put(entry.getKey(), entry.getValue());
				}
			}
		}

		return convertedMap;
	}

	public List NullConvertEmptyForList(List list) {
		List convertedList = null;
		if (list != null && list.size() > 0) {
			convertedList = new ArrayList();
			Iterator it = list.iterator();
			while (it.hasNext()) {
				Map map = (Map) it.next();
				Map convertedMap = NullConvertEmptyForMap(map);
				convertedList.add(convertedMap);
			}
		}
		return convertedList;
	}

你可能感兴趣的:(list)