gpt4 book ai didi

org.zkoss.xml.XMLs.escapeXML()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-19 21:00:40 25 4
gpt4 key购买 nike

本文整理了Java中org.zkoss.xml.XMLs.escapeXML()方法的一些代码示例,展示了XMLs.escapeXML()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XMLs.escapeXML()方法的具体详情如下:
包路径:org.zkoss.xml.XMLs
类名称:XMLs
方法名:escapeXML

XMLs.escapeXML介绍

[英]Escapes a character into a string if it is a special XML character, returns null if not a special character. & -> &
< -> <

-> >
" -> "
' -> '
[中]如果字符是特殊的XML字符,则将其转义为字符串;如果不是特殊字符,则返回null。&->&amp;
<->&lt;
->&gt;
" -> "
' -> '

代码示例

代码示例来源:origin: org.zkoss.common/zcommon

/** Encodes a string that special characters are quoted to be compatible
 * with HTML/XML.
 * For example, &lt; is translated to &amp;lt;.
 *
 *    &amp; -> &amp;amp;<br/>
 *    &lt; -> &amp;lt;<br/>
 *    &gt; -> &amp;gt;<br/>
 *    " -> &amp;#034;<br/>
 *    ' -> &amp;#039;<br/>
 *
 * @param s the string to quote; null is OK
 * @return the escaped string, or an empty string if s is null
 */
public static final String escapeXML(String s) {
  if (s == null) return "";
  final StringBuffer sb = new StringBuffer(s.length() + 16);
  for (int j = 0, len = s.length(); j < len; ++j) {
    final char cc = s.charAt(j);
    final String esc = escapeXML(cc);
    if (esc != null) sb.append(esc);
    else sb.append(cc);
  }
  return s.length() == sb.length() ? s: sb.toString();
}
/** Escapes a character into a string if it is a special XML character,

代码示例来源:origin: org.zkoss.zk/zhtml

/**
 * @param hideUuidIfNoId
 *            whether not to generate UUID if possible
 */
/* package */ String getPrologHalf(boolean hideUuidIfNoId) {
  final StringBuilder sb = new StringBuilder(128).append('<').append(_tagnm);
  if ((!hideUuidIfNoId && !shallHideId()) || getId().length() > 0)
    sb.append(" id=\"").append(getUuid()).append('"');
  if (_props != null) {
    for (Iterator it = _props.entrySet().iterator(); it.hasNext();) {
      final Map.Entry me = (Map.Entry) it.next();
      if (!"textContent".equals(me.getKey())) { // ignore textContent
        // ZK-3011: should getValue if it's a deferredValue
        Object v = me.getValue();
        if (v instanceof DeferredValue) {
          v = ((DeferredValue) v).getValue();
        }
        sb.append(' ').append(me.getKey()).append("=\"")
            .append(XMLs.encodeAttribute(Objects.toString(v))).append('"');
      }
    }
  }
  if (!isOrphanTag())
    sb.append('/');
  sb.append('>');
  Object textContent = getDynamicProperty("textContent");
  if (textContent != null)
    sb.append(XMLs.escapeXML((String) textContent));
  return sb.toString();
}

代码示例来源:origin: org.zkoss.common/zweb

replace = "&nbsp;";
else
  replace = XMLs.escapeXML(cc);

代码示例来源:origin: org.zkoss.common/zweb

response.sendError(HttpServletResponse.SC_NOT_FOUND, XMLs.escapeXML(path));
return;

代码示例来源:origin: org.zkoss.common/zweb

log.error("Not found: " + path);
response.sendError(HttpServletResponse.SC_NOT_FOUND, XMLs.escapeXML(path));
return;

代码示例来源:origin: org.zkoss.common/zweb

if (Servlets.isIncluded(request))
  log.error("Resource not found: " + Encodes.encodeURI(pi));
response.sendError(HttpServletResponse.SC_NOT_FOUND, XMLs.escapeXML(pi));
return;

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com