package ve.gob.cnti.receiver.utils;

import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Logger;

import javax.jms.JMSException;
import javax.jms.MapMessage;

public class MapMessageConverter  implements IMapMessageConverter{
	
	private static final Logger log = Logger.getLogger(MapMessageConverter.class.getName());
	@SuppressWarnings("rawtypes")
	public Map<String,String> converMapMessageToMap(MapMessage mapMessage){		
		Enumeration mapNames;
		Map<String,String> values=new HashMap<String,String>();
		try {
			mapNames = mapMessage.getMapNames();
			String       eachName;
			String       eachValue;
			
			while ( mapNames.hasMoreElements() ){		  
					eachName  = (String) mapNames.nextElement();
					if(eachName.indexOf("Bytes")<0){
						eachValue = (String) mapMessage.getObject(eachName);
						values.put(eachName,eachValue);
						log.info("nombre"+eachName+"value"+eachValue);
					}
					
						    	
			}
		} catch (JMSException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return values;
	}
	
	

}
