protected String modelToString(DefaultListModel m) {
    String      result;
    String      tmpStr;
    int         i;
    int         n;
    boolean     quote;

    result = "";

    for (i = 0; i < m.size(); i++) {
      if (i > 0)
        result += ",";
      
      tmpStr = m.get(i).toString();
      quote  = (tmpStr.indexOf(",") > -1) || (tmpStr.indexOf(" ") > -1);
      
      if (quote)
        result += "\"";
      
      for (n = 0; n < tmpStr.length(); n++) {
        // double quotes
        if (tmpStr.charAt(n) == '"')
          result += "" + "\"\"";
        // normal character
        else
          result += "" + tmpStr.charAt(n);
      }
      
      if (quote)
        result += "\"";
    }

    return result;
  }