本文整理了Java中com.fsck.k9.mail.Address.quoteString()
方法的一些代码示例,展示了Address.quoteString()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Address.quoteString()
方法的具体详情如下:
包路径:com.fsck.k9.mail.Address
类名称:Address
方法名:quoteString
[英]Ensures that the given string starts and ends with the double quote character. The string is not modified in any way except to add the double quote character to start and end if it's not already there. sample -> "sample" "sample" -> "sample" ""sample"" -> ""sample"" "sample"" -> "sample" sa"mp"le -> "sa"mp"le" "sa"mp"le" -> "sa"mp"le" (empty string) -> "" " -> """
[中]确保给定字符串以双引号字符开头和结尾。字符串不会以任何方式修改,除非添加双引号字符以开始和结束(如果不存在)。样本->样本->样本->样本->样本->样本->样本“sa”mp“le->“sa”mp“le”sa“mp”le“sa”mp“le”->“sa”mp“le”->“sa”mp“le”(空字符串)->”
代码示例来源:origin: k9mail/k-9
/**
* Quote a string, if necessary, based upon the definition of an "atom," as defined by RFC2822
* (http://tools.ietf.org/html/rfc2822#section-3.2.4). Strings that consist purely of atoms are
* left unquoted; anything else is returned as a quoted string.
* @param text String to quote.
* @return Possibly quoted string.
*/
public static String quoteAtoms(final String text) {
if (ATOM.matcher(text).matches()) {
return text;
} else {
return quoteString(text);
}
}
代码示例来源:origin: k9mail/k-9
@Test
public void stringQuotationShouldCorrectlyQuote() {
assertEquals("\"sample\"", Address.quoteString("sample"));
assertEquals("\"\"sample\"\"", Address.quoteString("\"\"sample\"\""));
assertEquals("\"sample\"", Address.quoteString("\"sample\""));
assertEquals("\"sa\"mp\"le\"", Address.quoteString("sa\"mp\"le"));
assertEquals("\"sa\"mp\"le\"", Address.quoteString("\"sa\"mp\"le\""));
assertEquals("\"\"\"", Address.quoteString("\""));
}
内容来源于网络,如有侵权,请联系作者删除!