gpt4 book ai didi

com.atlassian.core.util.XMLUtils类的使用及代码示例

转载 作者:知者 更新时间:2024-03-22 22:07:05 30 4
gpt4 key购买 nike

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

XMLUtils介绍

暂无

代码示例

代码示例来源:origin: com.atlassian.jira/jira-core

public String xmlEscape(final String text)
  {
    return XMLUtils.escape(text);
  }
}

代码示例来源:origin: com.atlassian.core/atlassian-core

/**
 * Escape XML character with a user specified transformation policy for invalid characters.
 *
 * @since 6.0
 */
public static String escape(final int codePoint, final TransformPolicy policy) {
  final StringBuilder sb = new StringBuilder();
  transform(sb, codePoint, policy);
  return sb.toString();
}

代码示例来源:origin: com.atlassian.core/atlassian-core

/**
 * @since 3.19 / 3.10.1
 */
// http://www.w3.org/TR/REC-xml/#charsets
@Deprecated
public static boolean validXml(final char ch) {
  return validXml(ch);
}

代码示例来源:origin: com.atlassian.core/atlassian-core

/**
 * Append escaped version of character to the end of the StringBuilder
 */
private static void transform(final StringBuilder sb, final int codePoint, final TransformPolicy policy) {
  if (!validXml(codePoint)) {
    sb.append(policy.handle((char)codePoint));
  } else {
    String charRef = getEntityRef(codePoint);
    if (charRef != null) {
      sb.append("&").append(charRef).append(";");
    } else if ((codePoint >= ' ' && codePoint <= _lastPrintable && codePoint != 0xF7) ||
        codePoint == '\n' || codePoint == '\r' || codePoint == '\t') {
      // If the character is not printable, print as character reference.
      // Non printables are below ASCII space but not tab or line
      // terminator, ASCII delete, or above a certain Unicode threshold.
      sb.append(Character.toChars(codePoint));
    } else {
      sb.append("&#").append(codePoint).append(";");
    }
  }
}

代码示例来源:origin: com.atlassian.core/atlassian-core

public static String escapeForCdata(String source) {
  if (source == null) {
    return null;
  }
  final StringBuilder sb = new StringBuilder();
  int index;
  int oldIndex = 0;
  while ((index = source.indexOf("]]>", oldIndex)) > -1) {
    final String str = source.substring(oldIndex, index);
    transformCData(sb, str, DEFAULT_POLICY);
    oldIndex = index + 3;
    sb.append("]]]]><![CDATA[>");
  }
  final String rest = source.substring(oldIndex);
  transformCData(sb, rest, DEFAULT_POLICY);
  return sb.toString();
}

代码示例来源:origin: com.atlassian.core/atlassian-core-user

if (operation == null)
  operation = "String";
String name = XMLUtils.getContainedText(preference, "name");
String value = XMLUtils.getContainedText(preference, "value");
if ("String".equals(operation))
  backingPS.setString(name, value);

代码示例来源:origin: com.atlassian.core/atlassian-core-xml

/**
 * Append escaped version of character to the end of the StringBuilder
 */
private static void transform(final StringBuilder sb, final char ch, final TransformPolicy policy)
{
  if (!validXml(ch))
  {
    sb.append(policy.handle(ch));
  }
  else
  {
    String charRef = getEntityRef(ch);
    if (charRef != null)
    {
      sb.append("&").append(charRef).append(";");
    }
    else if ((ch >= ' ' && ch <= _lastPrintable && ch != 0xF7) ||
        ch == '\n' || ch == '\r' || ch == '\t')
    {
      // If the character is not printable, print as character reference.
      // Non printables are below ASCII space but not tab or line
      // terminator, ASCII delete, or above a certain Unicode threshold.
      sb.append(ch);
    }
    else
    {
      sb.append("&#").append(Integer.toString(ch)).append(";");
    }
  }
}

代码示例来源:origin: com.atlassian.core/atlassian-core-xml

public static String escapeForCdata(String source)
{
  if (source == null)
  {
    return null;
  }
  final StringBuilder sb = new StringBuilder();
  int index;
  int oldIndex = 0;
  while ((index = source.indexOf("]]>", oldIndex)) > -1)
  {
    final String str = source.substring(oldIndex, index);
    transformCData(sb, str, DEFAULT_POLICY);
    oldIndex = index + 3;
    sb.append("]]]]><![CDATA[>");
  }
  final String rest = source.substring(oldIndex);
  transformCData(sb, rest, DEFAULT_POLICY);
  return sb.toString();
}

代码示例来源:origin: com.atlassian.core/atlassian-core

Document xmlDoc = db.parse(url.openConnection().getInputStream());
Element root = xmlDoc.getDocumentElement();
String locale = XMLUtils.getContainedText(root, LOCALE_TAG_NAME);
if (!Strings.nullToEmpty(locale).isEmpty()) {
  installedLocales.add(getLocale(locale));

代码示例来源:origin: com.atlassian.core/atlassian-core

/**
 * Escape an XML string using a default policy of replacing invalid XML characters.
 */
public static String escape(final String source) {
  return escape(source, DEFAULT_POLICY);
}

代码示例来源:origin: com.atlassian.core/atlassian-core-xml

/**
 * Escape XML characters with a user specified transformation policy for invalid characters.
 *
 * @since 3.19 / 3.10.1
 */
public static String escape(final char ch, final TransformPolicy policy)
{
  final StringBuilder sb = new StringBuilder();
  transform(sb, ch, policy);
  return sb.toString();
}

代码示例来源:origin: com.atlassian.core/atlassian-core

/**
 * Append escaped version of CData "character data" to the end of the StringBuilder
 */
private static void transformCData(final StringBuilder sb, final String cdata, final TransformPolicy policy) {
  cdata.codePoints().forEach(codePoint -> {
    if (!validXml(codePoint)) {
      sb.append(policy.handle((char) codePoint));
    } else {
      sb.append(Character.toChars(codePoint));
    }
  });
}

代码示例来源:origin: com.atlassian.core/atlassian-core-xml

/**
 * Escape an XML string using a default policy of replacing invalid XML characters.
 */
public static String escape(final String source)
{
  return escape(source, DEFAULT_POLICY);
}

代码示例来源:origin: com.atlassian.core/atlassian-core

/**
 * Escape XML characters with a user specified transformation policy for invalid characters.
 *
 * @deprecated use {@link com.atlassian.core.util.XMLUtils#escape(int, TransformPolicy)} instead
 * @since 3.19 / 3.10.1
 */
@Deprecated
public static String escape(final char ch, final TransformPolicy policy) {
  final StringBuilder sb = new StringBuilder();
  transform(sb, ch, policy);
  return sb.toString();
}

代码示例来源:origin: com.atlassian.core/atlassian-core-xml

/**
 * Append escaped version of CData "character data" to the end of the StringBuilder
 */
private static void transformCData(final StringBuilder sb, final String cdata, final TransformPolicy policy)
{
  for (int i = 0; i < cdata.toCharArray().length; i++)
  {
    char ch = cdata.toCharArray()[i];
    if (!validXml(ch))
    {
      sb.append(policy.handle(ch));
    }
    else
    {
      sb.append(ch);
    }
  }
}

代码示例来源:origin: com.atlassian.core/atlassian-core

/**
 * If there is a suitable entity reference for this character, return it. The list of available entity references is
 * almost but not identical between XML and HTML. This uses a default transformation policy of replacing invalid XML
 * characters.
 *
 * @since 6.0
 */
public static String escape(final int codePoint) {
  return escape(codePoint, DEFAULT_POLICY);
}

代码示例来源:origin: com.atlassian.core/atlassian-core-xml

/**
 * Escapes a string so it may be returned as text content or attribute value. Non printable characters are escaped
 * using character references. Where the format specifies a deault entity reference, that reference is used (e.g.
 * <tt>&amp;lt;</tt>).
 *
 * @param source the string to escape or "" for null.
 * @param policy how to handle invalid XML characters
 * @since 3.19 / 3.10.1
 */
public static String escape(final String source, final TransformPolicy policy)
{
  if (source == null)
  {
    return "";
  }
  StringBuilder sb = new StringBuilder(source.length() + 30);  // lets allocate a StringBuilder that is roughly the same length
  for (int i = 0; i < source.length(); ++i)
  {
    transform(sb, source.charAt(i), policy);
  }
  return sb.toString();
}

代码示例来源:origin: com.atlassian.core/atlassian-core-xml

/**
 * If there is a suitable entity reference for this character, return it. The list of available entity references is
 * almost but not identical between XML and HTML. This uses a default transformation policy of replacing invalid XML
 * characters.
 */
public static String escape(final char ch)
{
  return escape(ch, DEFAULT_POLICY);
}

代码示例来源:origin: com.atlassian.core/atlassian-core

/**
 * Escapes a string so it may be returned as text content or attribute value. Non printable characters are escaped
 * using character references. Where the format specifies a deault entity reference, that reference is used (e.g.
 * <tt>&amp;lt;</tt>).
 *
 * @param source the string to escape or "" for null.
 * @param policy how to handle invalid XML characters
 * @since 3.19 / 3.10.1
 */
public static String escape(final String source, final TransformPolicy policy) {
  if (source == null) {
    return "";
  }
  StringBuilder sb = new StringBuilder(source.length() + 30);  // lets allocate a StringBuilder that is roughly the same length
  source.codePoints().forEach(codePoint -> transform(sb, codePoint, policy));
  return sb.toString();
}

代码示例来源:origin: com.atlassian.core/atlassian-core

/**
 * If there is a suitable entity reference for this character, return it. The list of available entity references is
 * almost but not identical between XML and HTML. This uses a default transformation policy of replacing invalid XML
 * characters.
 *
 * @deprecated use {@link com.atlassian.core.util.XMLUtils#escape(int)} instead
 */
@Deprecated
public static String escape(final char ch) {
  return escape(ch, DEFAULT_POLICY);
}

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