List of usage examples for org.apache.commons.lang3 StringEscapeUtils escapeCsv
public static final String escapeCsv(final String input)
From source file:Client.Message.java
public Message(MessageType type, String author) { this.type = type; this.author = author; message = type.toString() + "," + StringEscapeUtils.escapeCsv(author) + ",,"; }
From source file:Client.Message.java
public Message(MessageType type, String author, String text) { this.type = type; this.author = author; this.text = text; message = type.toString() + "," + StringEscapeUtils.escapeCsv(author) + "," + StringEscapeUtils.escapeCsv(text) + ","; }
From source file:com.axibase.tsd.collector.AtsdUtil.java
public static String escapeCSV(String s) { if (s == null || s.trim().length() == 0) { s = EMPTY_MESSAGE;//w ww . ja v a2s .c om } else s = StringEscapeUtils.escapeCsv(s.trim()); if (s.contains(" ") && !s.startsWith("\"")) { StringBuilder sb = new StringBuilder("\""); s = sb.append(s).append("\"").toString(); } return s; }
From source file:com.axibase.tsd.collector.AtsdUtil.java
public static String sanitizeName(String s) { s = StringEscapeUtils.escapeCsv(SPACE.matcher(s.trim()).replaceAll("_")); if (s.contains("=") && !s.startsWith("\"")) { StringBuilder sb = new StringBuilder("\""); s = sb.append(s).append("\"").toString(); }/*from w ww . ja va 2 s . co m*/ return s; }
From source file:com.igormaznitsa.jcp.expression.functions.FunctionSTR2CSV.java
@Override @Nonnull/*from w w w . j ava 2 s . c o m*/ public Value executeStr(@Nonnull final PreprocessorContext context, @Nonnull final Value value) { final String escaped = StringEscapeUtils.escapeCsv(value.asString()); return Value.valueOf(escaped); }
From source file:com.khs.sherpa.parser.StringParamParser.java
private String applyEncoding(String value, String format) { String result = value;/*from w w w . j a v a2 s .co m*/ if (format != null) { if (format.equals(Encode.XML)) { result = StringEscapeUtils.escapeXml(value); } else if (format.equals(Encode.HTML)) { result = StringEscapeUtils.escapeHtml4(value); } else if (format.equals(Encode.CSV)) { result = StringEscapeUtils.escapeCsv(value); } } return result; }
From source file:io.ecarf.core.compress.callback.DictionaryEncodeCallback.java
@Override public String processNTriple(Node[] nodes) throws IOException { String[] terms = new String[4]; String term;//from w w w. jav a2 s. com long enc = 0; for (int i = 0; i < nodes.length; i++) { // we are not going to unscape literals, these can contain new line and // unscaping those will slow down the bigquery load, unless offcourse we use JSON // instead of CSV https://cloud.google.com/bigquery/preparing-data-for-bigquery if ((i == 2) && (nodes[i] instanceof Literal)) { terms[3] = StringEscapeUtils.escapeCsv(nodes[i].toN3()); } else { //TODO if we are creating a dictionary why unscape this term anyway? //term = NxUtil.unescape(nodes[i].toN3()); term = nodes[i].toN3(); if (nodes[i] instanceof BNode) { enc = dictionary.encodeBlankNode(term); } else { enc = dictionary.encode(term); } terms[i] = Long.toString(enc); } } return StringUtils.join(terms, ','); }
From source file:com.github.dactiv.common.utils.EncodeUtils.java
/** * Csv ?. */ public static String escapeCsv(String csv) { return StringEscapeUtils.escapeCsv(csv); }
From source file:de.fau.cs.osr.hddiff.utils.Report.java
public void writeCsv(File outFile, Locale locale, String encoding) throws IOException { try (OutputStream os = new FileOutputStream(outFile)) { try (PrintStream ps = new PrintStream(os, true, encoding)) { ArrayList<String> headers = new ArrayList<String>(this.headers); Collections.sort(headers); int cols = headers.size(); int i = 0; for (String header : headers) { ps.print(StringEscapeUtils.escapeCsv(header)); if (++i < cols) ps.print(','); }//from www . ja v a 2 s . c o m ps.println(); i = 0; for (String header : headers) { String unit = units.get(header); if (unit != null) ps.print(StringEscapeUtils.escapeCsv(unit)); if (++i < cols) ps.print(','); } ps.println(); for (ReportItem item : items) { Map<String, Indicator> values = item.getIndicators(); i = 0; for (String header : headers) { Indicator ind = values.get(header); if (ind != null) ps.print(StringEscapeUtils.escapeCsv(ind.formatValue(locale))); if (++i < cols) ps.print(','); } ps.println(); } } } }
From source file:io.ecarf.core.compress.callback.StringEscapeCallback.java
@Override public String processNTriple(Node[] nodes) throws IOException { String[] terms = new String[3]; for (int i = 0; i < nodes.length; i++) { // we are not going to unscape literals, these can contain new line and // unscaping those will slow down the bigquery load, unless offcourse we use JSON // instead of CSV https://cloud.google.com/bigquery/preparing-data-for-bigquery if (nodes[i] instanceof Literal) { terms[i] = nodes[i].toN3();/*from w w w. j ava 2 s . c o m*/ } else { terms[i] = NxUtil.unescape(nodes[i].toN3()); } } if (counter != null) { counter.count(terms); } for (int i = 0; i < terms.length; i++) { // bigquery requires data to be properly escaped terms[i] = StringEscapeUtils.escapeCsv(terms[i]); } return StringUtils.join(terms, ','); }