package com.blueland.bpm.engine.util;

import java.util.Map;

public class PageFieldsUtil {
	public static String fieldsToXml(Map<String, Object> fieldsMap){
		StringBuffer xmlBuf=new StringBuffer();
		if(fieldsMap==null||fieldsMap.isEmpty())
			return xmlBuf.toString();
		xmlBuf.append("<fields>");
		for (Map.Entry<String, Object> entryField : fieldsMap.entrySet()) {
			xmlBuf.append("<");
			xmlBuf.append(entryField.getKey());
			xmlBuf.append(">");
			xmlBuf.append(entryField.getValue());
			xmlBuf.append("</");
			xmlBuf.append(entryField.getKey());
			xmlBuf.append(">");
		}
		xmlBuf.append("</fields>");
		return xmlBuf.toString();
	}
	public static Map<String,Object> fieldsToMap(String fieldsXml){
		return Dom4jUtil.xmlToMap(fieldsXml);
	}
	
}
