public static void storeNVListToHashMap( String filename, OptionList options, Map<String, String> dstMap) { if (options == null || options.getOption() == null || options.getOption().isEmpty()) { return; } List<NameValue> optionNvList = options.getOption(); for (int i = 0; i < optionNvList.size(); i++) { NameValue nv = optionNvList.get(i); dstMap.put(nv.getName(), nv.getValue()); } }
public static void putNVList( String filename, String containerName, Element optionContainer, List<NameValue> outList) throws Exception { NodeList childElements = DomParseUtils.getImmediateChildrenByTagName(optionContainer, "option"); if (childElements == null) { return; } for (int i = 0; i < childElements.getLength(); i++) { Element option = (Element) childElements.item(i); String name = option.getAttribute("name"); if (name == null || name.length() == 0) { throwError(filename, "Missing option name in option list: '" + containerName + "'"); } String value = DomParseUtils.getText(option); if (value == null) { throwError(filename, "Missing option value for option list: '" + containerName + "'"); } NameValue nv = new NameValue(); nv.setName(name); nv.setValue(value); outList.add(nv); } }