本文整理了Java中org.apache.commons.lang.StringEscapeUtils.unescapeCsv()
方法的一些代码示例,展示了StringEscapeUtils.unescapeCsv()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。StringEscapeUtils.unescapeCsv()
方法的具体详情如下:
包路径:org.apache.commons.lang.StringEscapeUtils
类名称:StringEscapeUtils
方法名:unescapeCsv
[英]Returns a String
value for an unescaped CSV column.
If the value is enclosed in double quotes, and contains a comma, newline or double quote, then quotes are removed.
Any double quote escaped characters (a pair of double quotes) are unescaped to just one double quote.
If the value is not enclosed in double quotes, or is and does not contain a comma, newline or double quote, then the String value is returned unchanged.
see Wikipedia and RFC 4180.
[中]返回一个String
值,该值用于一个未转换的CSV列。
如果该值用双引号括起来,并且包含逗号、换行符或双引号,则会删除引号。
任何双引号转义字符(一对双引号)都不会转换为一个双引号。
如果该值未包含在双引号中,或者不包含逗号、换行符或双引号,则返回的字符串值将保持不变。
见Wikipedia和{$1$}。
代码示例来源:origin: apache/kylin
private String unescapeCsv(String str) {
if (str == null || str.length() < 2)
return str;
str = StringEscapeUtils.unescapeCsv(str);
// unescapeCsv may not remove the outer most quotes
if (str.charAt(0) == CSV_QUOTE && str.charAt(str.length() - 1) == CSV_QUOTE)
str = str.substring(1, str.length() - 1);
return str;
}
代码示例来源:origin: commons-lang/commons-lang
unescapeCsv(writer, str);
return writer.toString();
} catch (IOException ioe) {
代码示例来源:origin: SonarSource/sonarqube
String[] options = s.split(CSV_SPLIT_REGEX);
for (String option : options) {
String opt = StringEscapeUtils.unescapeCsv(option);
if (opt.startsWith(VALUES_PARAM + PARAMETER_SEPARATOR)) {
values = StringEscapeUtils.unescapeCsv(StringUtils.substringAfter(opt, VALUES_PARAM + PARAMETER_SEPARATOR));
} else if (opt.startsWith(MULTIPLE_PARAM + PARAMETER_SEPARATOR)) {
multiple = Boolean.parseBoolean(StringUtils.substringAfter(opt, MULTIPLE_PARAM + PARAMETER_SEPARATOR));
代码示例来源:origin: KylinOLAP/Kylin
private String unescapeCsv(String str) {
if (str == null || str.length() < 2)
return str;
str = StringEscapeUtils.unescapeCsv(str);
// unescapeCsv may not remove the outer most quotes
if (str.charAt(0) == CSV_QUOTE && str.charAt(str.length() - 1) == CSV_QUOTE)
str = str.substring(1, str.length() - 1);
return str;
}
代码示例来源:origin: perfectsense/dari
public static String unescapeCsv(String string) {
return string == null ? null : StringEscapeUtils.unescapeCsv(string);
}
代码示例来源:origin: org.owasp.jbrofuzz/jbrofuzz
private static String decodeEscCsv(final String decodeText) {
return StringEscapeUtils.unescapeCsv(decodeText);
}
代码示例来源:origin: zznate/cassandra-tutorial
GeoDataLine(String line) {
vals = StringUtils.split(StringEscapeUtils.unescapeCsv(line), SEPARATOR_CHAR);
log.debug("array size: {} for row: {}", vals.length, line);
}
代码示例来源:origin: org.apache.kylin/kylin-engine-mr
private String unescapeCsv(String str) {
if (str == null || str.length() < 2)
return str;
str = StringEscapeUtils.unescapeCsv(str);
// unescapeCsv may not remove the outer most quotes
if (str.charAt(0) == CSV_QUOTE && str.charAt(str.length() - 1) == CSV_QUOTE)
str = str.substring(1, str.length() - 1);
return str;
}
代码示例来源:origin: org.apache.kylin/kylin-dictionary
private String unescapeCsv(String str) {
if (str == null || str.length() < 2)
return str;
str = StringEscapeUtils.unescapeCsv(str);
// unescapeCsv may not remove the outer most quotes
if (str.charAt(0) == CSV_QUOTE && str.charAt(str.length() - 1) == CSV_QUOTE)
str = str.substring(1, str.length() - 1);
return str;
}
代码示例来源:origin: vmware/hillview
void parse(String line, String[] output) {
Matcher m = pattern.matcher(line);
if (!m.find())
this.error("Could not parse line");
output[0] = m.group(1); // Time
output[1] = m.group(2); // Role
output[2] = m.group(3); // Level
output[3] = m.group(4); // Machine
output[4] = m.group(5); // Thread
output[5] = m.group(6); // Class
output[6] = m.group(7); // Method
output[7] = m.group(8); // Message
String arguments = StringEscapeUtils.unescapeCsv(m.group(9));
output[8] = arguments.replace("\\n", "\n"); // Arguments
}
代码示例来源:origin: tflobbe/solrmeter
protected void loadExtraParameters(String property) {
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();
}
}
代码示例来源:origin: knowitall/reverb
public static String removeHtml(String content) {
if (!initialized)
initPatterns();
// Normalize whitespace
content = whiteSpace.matcher(content).replaceAll(" ");
// Remove and break text
content = applyPatterns(removePatterns, content);
content = applyPatterns(breakPatterns, content);
// Remove tags
content = tag.matcher(content).replaceAll("");
// Escape HTML codes
content = StringEscapeUtils.unescapeCsv(content);
// Fix more whitespace
content = multiSpace.matcher(content).replaceAll(" ");
content = multiBreaks.matcher(content).replaceAll("\n");
content = content.replace(';', '\n');
return content;
}
代码示例来源:origin: jhpoelen/eol-globi-data
public static String columnValueOrNull(Record record, String columnName) {
String value = record.getMetaData().containsColumn(columnName)
? StringUtils.trim(record.getString(columnName))
: null;
return StringUtils.equals("null", value) || StringUtils.equalsIgnoreCase("NA", value) ? null : StringEscapeUtils.unescapeCsv(value);
}
代码示例来源:origin: edu.washington.cs.knowitall/reverb-core
public static String removeHtml(String content) {
if (!initialized)
initPatterns();
// Normalize whitespace
content = whiteSpace.matcher(content).replaceAll(" ");
// Remove and break text
content = applyPatterns(removePatterns, content);
content = applyPatterns(breakPatterns, content);
// Remove tags
content = tag.matcher(content).replaceAll("");
// Escape HTML codes
content = StringEscapeUtils.unescapeCsv(content);
// Fix more whitespace
content = multiSpace.matcher(content).replaceAll(" ");
content = multiBreaks.matcher(content).replaceAll("\n");
content = content.replace(';', '\n');
return content;
}
代码示例来源:origin: org.codehaus.sonar/sonar-plugin-api
String[] options = s.split(CSV_SPLIT_REGEX);
for (String option : options) {
String opt = StringEscapeUtils.unescapeCsv(option);
if (opt.startsWith(VALUES_PARAM + PARAMETER_SEPARATOR)) {
values = StringEscapeUtils.unescapeCsv(StringUtils.substringAfter(opt, VALUES_PARAM + PARAMETER_SEPARATOR));
} else if (opt.startsWith(MULTIPLE_PARAM + PARAMETER_SEPARATOR)) {
multiple = Boolean.parseBoolean(StringUtils.substringAfter(opt, MULTIPLE_PARAM + PARAMETER_SEPARATOR));
代码示例来源:origin: baishui2004/common_gui_tools
/**
* 还原转义字符.
*
* @param string 转义字符
* @param type 字符类型
*/
public static String unescape(String string, String type) {
String escape = "转义字符还原遇到错误";
if (type.equals(LanguageUtils.CONST_HTML)) {
escape = StringEscapeUtils.unescapeHtml(string);
} else if (type.equals(LanguageUtils.CONST_XML)) {
escape = StringEscapeUtils.unescapeXml(string);
} else if (type.equals(LanguageUtils.CONST_SQL)) {
escape = type + "转义字符不能进行还原";
} else if (type.equals(LanguageUtils.CONST_JAVA)) {
escape = StringEscapeUtils.unescapeJava(string);
} else if (type.equals(LanguageUtils.CONST_JavaScript)) {
escape = StringEscapeUtils.unescapeJavaScript(string);
} else if (type.equals(LanguageUtils.CONST_CSV)) {
escape = StringEscapeUtils.unescapeCsv(string);
}
return escape;
}
代码示例来源:origin: tflobbe/solrmeter
@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();
}
}
代码示例来源:origin: org.apache.lens/lens-query-lib
String[] names = tbl.getProperty(LIST_COLUMNS).split("(?!\"),(?!\")");
for (String name : names) {
columnNames.add(StringEscapeUtils.unescapeCsv(name));
代码示例来源:origin: NationalSecurityAgency/datawave
protected void processFields(HashMultimap<String,String> fields, String[] dataFields) {
for (int i = 0; i < Math.max(dataFields.length, helper.getHeader().length); i++) {
if (i < helper.getHeader().length) {
String fieldName = helper.getHeader()[i];
if (keepField(fieldName) && dataFields[i] != null) {
String fieldValue = StringEscapeUtils.unescapeCsv(dataFields[i]);
fieldValue = helper.clean(fieldName, fieldValue);
if (fieldValue != null) {
processPreSplitField(fields, fieldName, fieldValue);
}
}
} else if (helper.processExtraFields()) {
// We have gone beyond the length of the header. In some cases,
// this will contain optional fields in the form of a map.
// Split on equals, to break the key and value
String fieldValue = StringEscapeUtils.unescapeCsv(dataFields[i]);
if (fieldValue != null) {
processExtraField(fields, fieldValue);
}
} else {
break;
}
}
}
代码示例来源:origin: zznate/cassandra-tutorial
/**
* Creates an HColumn with a column name composite of the form:
* ['country_code']:['state]:['city name'])
* and a value of ['timezone']
* @return
*/
HColumn<Composite,String> staticColumnFrom() {
Composite composite = new Composite();
composite.addComponent(getCountryCode(), StringSerializer.get());
composite.addComponent(getAdmin1Code(), StringSerializer.get());
// extra un-escape to handle the case of "Washington, D.C."
composite.addComponent(StringEscapeUtils.unescapeCsv(getAsciiName()), StringSerializer.get());
HColumn<Composite,String> col =
HFactory.createColumn(composite, getTimezone(), new CompositeSerializer(), StringSerializer.get());
return col;
}
内容来源于网络,如有侵权,请联系作者删除!