code: public String csv(String text) {
          if (text == null || text.isEmpty()) {
              return "\"\"";
          }
          final String str = text.trim().replace("\n", " ");
          if (str.length() == 0) {
              return "\"\"";
          }
          return StringEscapeUtils.escapeCsv(str);
      }
docs: Formats text for CSV format. This includes trimming whitespace, replace
  line breaks with spaces, and if necessary quotes the text and/or escapes
  contained quotes.
  
  @param text the text to escape and quote
  @return the escaped and quoted text