gpt4 book ai didi

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

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

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

XMLs.encodeAttribute介绍

[英]Encodes a value such that it could be used as XML attribute.
[中]对值进行编码,使其可以用作XML属性。

代码示例

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

private static final void writeAttr(Writer out, String name, String value) throws IOException {
  out.write(' ');
  out.write(name);
  out.write("=\"");
  out.write(XMLs.encodeAttribute(value));
  out.write('"');
}

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

private static final void writeAttr(Writer out, String name, String value)
  throws IOException {
    out.write(' ');
    out.write(name);
    out.write("=\"");
    out.write(XMLs.encodeAttribute(value));
    out.write('"');
  }
}

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

/** Appends an attribute to the string buffer,
 * if <code>attrValue</code> is not null.
 */
protected static final void append(StringBuffer sb, String attrName, String attrValue) {
  if (attrValue != null)
    sb.append(' ').append(attrName).append("=\"").append(XMLs.encodeAttribute(attrValue)).append('"');
  //it might contain " or other special characters
}

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

/** Appends an attribute to the string buffer for HTML/XML (name="val").
 * If val is null or empty (if String), nothing is generated.
 *
 * <p>Note: {@link XMLs#encodeAttribute} is called automatically
 * to encode val.
 */
public static final
void appendAttribute(StringBuffer sb, String name, String val) {
  if (val != null && val.length() != 0)
    sb.append(' ').append(name).append("=\"")
      .append(XMLs.encodeAttribute(val)).append('"');
}
/** Appends an attribute to the string buffer for HTML/XML (name="val").

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

/** Appends an attribute to the string buffer for HTML/XML (name="val").
 * If emptyIgnored is true and val is null or empty (if String),
 * nothing is generated.
 *
 * <p>Note: {@link XMLs#encodeAttribute} is called automatically
 * to encode val.
 *
 * @param emptyIgnored whether to ignore a null or empty string.
 * If false, it is always generated (null is generated as "null").
 */
public static final
void appendAttribute(StringBuffer sb, String name, String val,
boolean emptyIgnored) {
  if (!emptyIgnored || (val != null && val.length() != 0))
    sb.append(' ').append(name).append("=\"")
      .append(val != null ? XMLs.encodeAttribute(val): null)
      .append('"');
}
/** Appends an attribute with a int value to the string buffer for HTML/XML (name="val").

代码示例来源: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();
}

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