@Override protected void setSelectedValue(String value) { this.table.removeAll(); String[] values; try { values = CSVUtils.parseLine(value); for (String val : values) { val = StringEscapeUtils.unescapeCsv(val); String[] pair = val.split("="); if (pair.length == 2) { this.table.setProperty(pair[0].trim(), pair[1].trim()); } else if (pair.length == 1) { this.table.setProperty(pair[0].trim(), ""); } } } catch (IOException e) { e.printStackTrace(); } }
protected void loadExtraParameters(String property) { extraParameters = new HashMap<String, String>(); if(property == null || "".equals(property.trim())) { return; } String[] values; try { values = CSVUtils.parseLine(property); for (String val : values) { val = StringEscapeUtils.unescapeCsv(val); int equalSignIndex = val.indexOf("="); if(equalSignIndex > 0) { extraParameters.put(val.substring(0, equalSignIndex).trim(), val.substring(equalSignIndex + 1).trim()); } } } catch (IOException e) { e.printStackTrace(); } }
private void parse(String s) throws IOException { BufferedReader reader = new BufferedReader(new StringReader(s)); while (true) { String line = reader.readLine(); if (line == null) break; // strip {} line = line.substring(1, line.length() - 1); int index = line.indexOf("::"); String key = line.substring(0, index); String valueString = line.substring(index + 2); String valueArray[] = null; if (valueString.indexOf("','") > 0) { valueString = valueString.replaceAll("'", "\""); valueArray = CSVUtils.parseLine(valueString); } else { valueArray = new String[1]; valueArray[0] = valueString; } map.put(key, valueArray); } }