Java 类org.apache.commons.csv.CSVUtils 实例源码

项目:solrmeter    文件:TablePropertyPanel.java   
@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();
    }

}
项目:solrmeter    文件:ComplexQueryGenerator.java   
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();
  }
}
项目:visual-programming    文件:DDwrtValues.java   
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);

        }
    }