org.apache.logging.log4j.util.Strings.quote()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(2.8k)|赞(0)|评价(0)|浏览(128)

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

Strings.quote介绍

[英]Returns a quoted string.
[中]返回带引号的字符串。

代码示例

代码示例来源:origin: org.apache.logging.log4j/log4j-api

/**
 * A Constructor that helps conformance to RFC 5424.
 *
 * @param name The name portion of the id.
 * @param enterpriseNumber The enterprise number.
 * @param required The list of keys that are required for this id.
 * @param optional The list of keys that are optional for this id.
 * @param maxLength The maximum length of the StructuredData Id key.
 * @since 2.9
 */
public StructuredDataId(final String name, final int enterpriseNumber, final String[] required,
    final String[] optional, final int maxLength) {
  if (name == null) {
    throw new IllegalArgumentException("No structured id name was supplied");
  }
  if (name.contains(AT_SIGN)) {
    throw new IllegalArgumentException("Structured id name cannot contain an " + Strings.quote(AT_SIGN));
  }
  if (enterpriseNumber <= 0) {
    throw new IllegalArgumentException("No enterprise number was supplied");
  }
  this.name = name;
  this.enterpriseNumber = enterpriseNumber;
  final String id = name + AT_SIGN + enterpriseNumber;
  if (maxLength > 0 && id.length() > maxLength) {
    throw new IllegalArgumentException("Length of id exceeds maximum of " + maxLength + " characters: " + id);
  }
  this.required = required;
  this.optional = optional;
}

代码示例来源:origin: org.apache.logging.log4j/log4j-api

@Test
public void testQuote() {
  Assert.assertEquals("'Q'", Strings.quote("Q"));
}

代码示例来源:origin: org.apache.logging.log4j/log4j-web

ctx.log(getClass().getName() + " unable to resolve key " + Strings.quote(key));
return null;

代码示例来源:origin: ops4j/org.ops4j.pax.logging

/**
 * A Constructor that helps conformance to RFC 5424.
 *
 * @param name The name portion of the id.
 * @param enterpriseNumber The enterprise number.
 * @param required The list of keys that are required for this id.
 * @param optional The list of keys that are optional for this id.
 * @param maxLength The maximum length of the StructuredData Id key.
 * @since 2.9
 */
public StructuredDataId(final String name, final int enterpriseNumber, final String[] required,
    final String[] optional, final int maxLength) {
  if (name == null) {
    throw new IllegalArgumentException("No structured id name was supplied");
  }
  if (name.contains(AT_SIGN)) {
    throw new IllegalArgumentException("Structured id name cannot contain an " + Strings.quote(AT_SIGN));
  }
  if (enterpriseNumber <= 0) {
    throw new IllegalArgumentException("No enterprise number was supplied");
  }
  this.name = name;
  this.enterpriseNumber = enterpriseNumber;
  final String id = name + AT_SIGN + enterpriseNumber;
  if (maxLength > 0 && id.length() > maxLength) {
    throw new IllegalArgumentException("Length of id exceeds maximum of " + maxLength + " characters: " + id);
  }
  this.required = required;
  this.optional = optional;
}

相关文章