map to list conversion

mysterious

New Member
I have two classes in which one is implementing map and i want to change it to list, but the problem i am facing is in get and put method.My first class is parsing the xml and return it into map so please help me to convert it to listThis is my first class\[code\]public class XmlReaderPrompt { public Map<String, PromptBean> load(String langMode) { String fileName="db_processor/English.xml"; DocumentBuilderFactory dbf=DocumentBuilderFactory.newInstance(); InputStream prompt_configfile=Thread.currentThread().getContextClassLoader().getResourceAsStream(fileName); DocumentBuilder db = null; Map<String, PromptBean> promptMap = new HashMap<String, PromptBean>(); try { try { db = dbf.newDocumentBuilder(); } catch (ParserConfigurationException e) { e.printStackTrace(); } Document doc = null; try { doc = db.parse(prompt_configfile); } catch(FileNotFoundException fnfexp) { fnfexp.printStackTrace(); } catch (SAXException e) { e.printStackTrace(); } NodeList nodeList=doc.getElementsByTagName("prompt"); for(int i=0;i<nodeList.getLength();i++) { Node node=nodeList.item(i); if(node.getNodeType()==Node.ELEMENT_NODE) { Element element=(Element)node; String id = element.getAttribute("id"); String name = element.getAttribute("name"); String prompt=getTextValue(element); promptMap.put(id, new PromptBean(id,name,prompt)); } } } catch(Exception io) { io.printStackTrace(); } finally { db=null; dbf=null; } return promptMap; } private String getTextValue(Element element) { String textValue=http://stackoverflow.com/questions/12668553/element.getFirstChild().getTextContent().toString(); return textValue; } }\[/code\]Second class functionality is to parse the xml and return it to map while i want to use list but i am getting error at put ad get methods of Map\[code\]public class UserFunction{ Map<String,PromptBean> promptObject=new HashMap<String,PromptBean>(); Map<String,AudioBean> audioObject = new HashMap<String,AudioBean>(); XmlReaderPrompt xrpObject=new XmlReaderPrompt(); public String getPromptFunction(String promptTag,String langMode ) { Map<String, PromptBean> promptObject=xrpObject.load(langMode); PromptBean promptBean= (PromptBean)promptObject.get(promptTag); String pv=StringEscapeUtils.escapeXml(promptBean.getPrompt()); return pv; }}\[/code\]
 
Back
Top