本文整理了Java中org.apache.commons.text.StringEscapeUtils.escapeXml10()
方法的一些代码示例,展示了StringEscapeUtils.escapeXml10()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。StringEscapeUtils.escapeXml10()
方法的具体详情如下:
包路径:org.apache.commons.text.StringEscapeUtils
类名称:StringEscapeUtils
方法名:escapeXml10
暂无
代码示例来源:origin: igniterealtime/Openfire
public BasicStreamID(String id) {
if ( id == null || id.isEmpty() ) {
throw new IllegalArgumentException( "Argument 'id' cannot be null." );
}
this.id = StringEscapeUtils.escapeXml10( id );
}
代码示例来源:origin: apache/nifi
String attName = atts.getQName(i);
attributeNames.add(attName);
String attValue = StringEscapeUtils.escapeXml10(atts.getValue(i));
sb.append(" ").append(attName).append("=").append("\"").append(attValue).append("\"");
代码示例来源:origin: igniterealtime/Openfire
return false;
if (!StringEscapeUtils.escapeXml10(name).equals(name)) {
throw new IllegalArgumentException("Property name cannot contain XML entities.");
String propValue = StringEscapeUtils.escapeXml10(value);
代码示例来源:origin: igniterealtime/Openfire
String propValue = StringEscapeUtils.escapeXml10(value);
代码示例来源:origin: org.apache.commons/commons-configuration2
private void writeProperty(final Document document, final Node properties, final String key, final Object value)
{
final Element entry = document.createElement("entry");
properties.appendChild(entry);
// escape the key
final String k = StringEscapeUtils.escapeXml10(key);
entry.setAttribute("key", k);
if (value != null)
{
final String v = escapeValue(value);
entry.setTextContent(v);
}
}
代码示例来源:origin: jamesagnew/hapi-fhir
@Override
public void write(char[] theCbuf, int theOff, int theLen) throws IOException {
boolean hasEscapable = false;
for (int i = 0; i < theLen && !hasEscapable; i++) {
char nextChar = theCbuf[i + theOff];
switch (nextChar) {
case '<':
case '>':
case '"':
case '&':
hasEscapable = true;
break;
default:
break;
}
}
if (!hasEscapable) {
theW.write(theCbuf, theOff, theLen);
return;
}
String escaped = StringEscapeUtils.escapeXml10(new String(theCbuf, theOff, theLen));
theW.write(escaped.toCharArray());
}
};
代码示例来源:origin: org.apache.commons/commons-configuration2
/**
* Escapes a property value before it is written to disk.
*
* @param value the value to be escaped
* @return the escaped value
*/
private String escapeValue(final Object value)
{
final String v = StringEscapeUtils.escapeXml10(String.valueOf(value));
return String.valueOf(getListDelimiterHandler().escape(v,
ListDelimiterHandler.NOOP_TRANSFORMER));
}
代码示例来源:origin: org.apache.commons/commons-configuration2
/**
* Write a property.
*
* @param out the output stream
* @param key the key of the property
* @param value the value of the property
*/
private void writeProperty(final PrintWriter out, final String key, final Object value)
{
// escape the key
final String k = StringEscapeUtils.escapeXml10(key);
if (value != null)
{
final String v = escapeValue(value);
out.println(" <entry key=\"" + k + "\">" + v + "</entry>");
}
else
{
out.println(" <entry key=\"" + k + "\"/>");
}
}
代码示例来源:origin: org.apache.commons/commons-configuration2
out.println(padding + "<key>" + StringEscapeUtils.escapeXml10(node.getNodeName()) + "</key>");
代码示例来源:origin: org.apache.commons/commons-configuration2
writer.println(" <comment>" + StringEscapeUtils.escapeXml10(getHeader()) + "</comment>");
代码示例来源:origin: org.apache.commons/commons-configuration2
comment.setTextContent(StringEscapeUtils.escapeXml10(getHeader()));
代码示例来源:origin: org.apache.commons/commons-text
@Test
public void testEscapeXml10() {
assertEquals("a<b>c"d'e&f", StringEscapeUtils.escapeXml10("a<b>c\"d'e&f"));
assertEquals("a\tb\rc\nd", StringEscapeUtils.escapeXml10("a\tb\rc\nd"),
"XML 1.0 should not escape \t \n \r");
assertEquals("ab", StringEscapeUtils.escapeXml10("a\u0000\u0001\u0008\u000b\u000c\u000e\u001fb"),
"XML 1.0 should omit most #x0-x8 | #xb | #xc | #xe-#x19");
assertEquals("a\ud7ff \ue000b", StringEscapeUtils.escapeXml10("a\ud7ff\ud800 \udfff \ue000b"),
"XML 1.0 should omit #xd800-#xdfff");
assertEquals("a\ufffdb", StringEscapeUtils.escapeXml10("a\ufffd\ufffe\uffffb"),
"XML 1.0 should omit #xfffe | #xffff");
assertEquals("a\u007e„\u0085†Ÿ\u00a0b",
StringEscapeUtils.escapeXml10("a\u007e\u007f\u0084\u0085\u0086\u009f\u00a0b"),
"XML 1.0 should escape #x7f-#x84 | #x86 - #x9f, for XML 1.1 compatibility");
}
代码示例来源:origin: org.apache.commons/commons-configuration2
out.println(padding + "<data>" + StringEscapeUtils.escapeXml10(base64) + "</data>");
out.println(padding + "<string>" + StringEscapeUtils.escapeXml10(String.valueOf(value)) + "</string>");
代码示例来源:origin: sakaiproject/sakai
/**
* Simple wrapper over commons lang util method, but we may add additional
* logic in the future for special QTI export purposes.
* @param s
* @return escaped string e.g.
* < \u04D0rnesen & Jones > becomes <Ӑrnesen & Jones >
*/
public static String escapeXml(String s)
{
if (s==null) return "";
return StringEscapeUtils.escapeXml10(s);
}
代码示例来源:origin: com.github.hazendaz/displaytag
/**
* @see org.displaytag.export.BaseExportView#escapeColumnValue(java.lang.Object)
*/
@Override
protected String escapeColumnValue(Object value)
{
return StringEscapeUtils.escapeXml10(value.toString());
}
代码示例来源:origin: org.apereo.cas/cas-server-support-validation
/**
* Encode attribute value.
*
* @param value the value
* @return the string
*/
protected String encodeAttributeValue(final Object value) {
return StringEscapeUtils.escapeXml10(value.toString().trim());
}
}
代码示例来源:origin: org.nuxeo.connect/nuxeo-connect-client
public final void attr(String name, String value) {
if (value != null) {
sb.append(" ").append(name).append("=\"").append(StringEscapeUtils.escapeXml10(value)).append("\"");
}
}
代码示例来源:origin: org.nuxeo.connect/nuxeo-connect-client
public void element(String name, String value) {
if (value != null) {
sb.append(indent)
.append('<')
.append(name)
.append('>')
.append(StringEscapeUtils.escapeXml10(value))
.append("</")
.append(name)
.append(">\n");
}
}
代码示例来源:origin: com.github.hazendaz/displaytag
/**
* @see org.displaytag.decorator.DisplaytagColumnDecorator#decorate(Object, PageContext, MediaTypeEnum)
*/
@Override
public Object decorate(Object columnValue, PageContext pageContext, MediaTypeEnum media)
{
if (columnValue == null || (!media.equals(MediaTypeEnum.HTML) && !media.equals(MediaTypeEnum.XML)))
{
return columnValue;
}
return StringEscapeUtils.escapeXml10(columnValue.toString());
}
代码示例来源:origin: com.norconex.jef/norconex-jef
private void writeJobId(Writer out,
JobSuiteStatusSnapshot statusTree, IJobStatus status) throws IOException {
out.write("<job name=\"");
out.write(StringEscapeUtils.escapeXml10(status.getJobId()));
out.write("\">");
for (IJobStatus child : statusTree.getChildren(status)) {
writeJobId(out, statusTree, child);
}
out.write("</job>");
}
内容来源于网络,如有侵权,请联系作者删除!