org.apache.commons.text.StringEscapeUtils.unescapeJava()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(6.6k)|赞(0)|评价(0)|浏览(221)

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

StringEscapeUtils.unescapeJava介绍

暂无

代码示例

代码示例来源:origin: apache/nifi

private static String unescapeString(String input) {
    if (input.length() > 1) {
      input = StringEscapeUtils.unescapeJava(input);
    }
    return input;
  }
}

代码示例来源:origin: apache/nifi

private static String unescapeString(String input) {
    if (input.length() > 1) {
      input = StringEscapeUtils.unescapeJava(input);
    }
    return input;
  }
}

代码示例来源:origin: apache/nifi

private String unescapeString(String input) {
    if (input != null && input.length() > 1) {
      input = StringEscapeUtils.unescapeJava(input);
    }
    return input;
  }
};

代码示例来源:origin: apache/nifi

private static char getUnescapedChar(final PropertyContext context, final PropertyDescriptor property) {
  return StringEscapeUtils.unescapeJava(context.getProperty(property).getValue()).charAt(0);
}

代码示例来源:origin: org.apache.commons/commons-configuration2

/**
 * Performs unescaping on the given property name.
 *
 * @param name the property name
 * @return the unescaped property name
 * @since 2.4
 */
protected String unescapePropertyName(String name)
{
  return StringEscapeUtils.unescapeJava(name);
}

代码示例来源:origin: org.apache.commons/commons-text

private void assertUnescapeJava(final String unescaped, final String original, final String message)
    throws IOException {
  final String expected = unescaped;
  final String actual = StringEscapeUtils.unescapeJava(original);
  assertEquals(expected, actual, "unescape(String) failed"
          + (message == null ? "" : (": " + message))
          + ": expected '" + StringEscapeUtils.escapeJava(expected)
          // we escape this so we can see it in the error message
          + "' actual '" + StringEscapeUtils.escapeJava(actual) + "'");
  final StringWriter writer = new StringWriter();
  StringEscapeUtils.UNESCAPE_JAVA.translate(original, writer);
  assertEquals(unescaped, writer.toString());
}

代码示例来源:origin: org.apache.commons/commons-text

/**
 * Tests https://issues.apache.org/jira/browse/LANG-911
 */
@Test
public void testLang911() {
  final String bellsTest = "\ud83d\udc80\ud83d\udd14";
  final String value = StringEscapeUtils.escapeJava(bellsTest);
  final String valueTest = StringEscapeUtils.unescapeJava(value);
  assertEquals(bellsTest, valueTest);
}

代码示例来源:origin: org.apache.nifi/nifi-standard-record-utils

private String unescapeString(String input) {
    if (input != null && input.length() > 1) {
      input = StringEscapeUtils.unescapeJava(input);
    }
    return input;
  }
};

代码示例来源:origin: org.apache.nifi/nifi-kite-processors

private static String unescapeString(String input) {
    if (input.length() > 1) {
      input = StringEscapeUtils.unescapeJava(input);
    }
    return input;
  }
}

代码示例来源:origin: org.apache.nifi/nifi-kite-processors

private static String unescapeString(String input) {
    if (input.length() > 1) {
      input = StringEscapeUtils.unescapeJava(input);
    }
    return input;
  }
}

代码示例来源:origin: com.jkoolcloud/tnt4j

/**
 * Parses replacements configuration string and puts replacements into provided map.
 *
 * @param repCfgStr
 *            replacements configuration string
 * @param replacementsMap
 *            replacements map to alter
 */
public static void parseReplacements(String repCfgStr, Map<String, String> replacementsMap) {
  Matcher m = Utils.REP_CFG_PATTERN.matcher(repCfgStr);
  while (m.find()) {
    replacementsMap.put(StringEscapeUtils.unescapeJava(m.group(1)), StringEscapeUtils.unescapeJava(m.group(3)));
  }
}

代码示例来源:origin: jiaqi/jmxterm

/**
  * Parse given syntax of string
  *
  * @param value String value
  * @return Escaped string value
  */
 public static String parseValue(String value) {
  if (StringUtils.isEmpty(value)) {
   return null;
  }
  if (value.equals(NULL)) {
   return null;
  }
  String s;
  if (value.charAt(0) == '\"' && value.charAt(value.length() - 1) == '\"') {
   s = value.substring(1, value.length() - 1);
  } else {
   s = value;
  }
  return StringEscapeUtils.unescapeJava(s);
 }
}

代码示例来源:origin: dhis2/dhis2-core

@Override
public final Object visitStringLiteral( StringLiteralContext ctx )
{
  return unescapeJava( ctx.getText().substring( 1, ctx.getText().length() - 1 ) );
}

代码示例来源:origin: georocket/georocket

private void QUOTED_STRING_action(RuleContext _localctx, int actionIndex) {
  switch (actionIndex) {
  case 0:
      String s = getText();
      s = s.substring(1, s.length() - 1);
      s = StringEscapeUtils.unescapeJava(s);
      setText(s);
     
    break;
  }
}

代码示例来源:origin: com.github.hazendaz/displaytag

/**
 * Escape certain values that are not permitted in excel cells.
 * @param rawValue the object value
 * @return the escaped value
 */
public static String escapeColumnValue(Object rawValue)
{
  if (rawValue == null)
  {
    return null;
  }
  String returnString = rawValue.toString();
  // escape the String to get the tabs, returns, newline explicit as \t \r \n
  returnString = StringEscapeUtils.escapeJava(StringUtils.trimToEmpty(returnString));
  // remove tabs, insert four whitespaces instead
  returnString = StringUtils.replace(StringUtils.trim(returnString), "\\t", "    ");
  // remove the return, only newline valid in excel
  returnString = StringUtils.replace(StringUtils.trim(returnString), "\\r", " ");
  // unescape so that \n gets back to newline
  returnString = StringEscapeUtils.unescapeJava(returnString);
  return returnString;
}

代码示例来源:origin: org.apache.commons/commons-text

@Test
public void testUnescapeJava() throws IOException {
  assertNull(StringEscapeUtils.unescapeJava(null));
  try {
    StringEscapeUtils.UNESCAPE_JAVA.translate(null, null);
    StringEscapeUtils.unescapeJava("\\u02-3");
    fail("Exception expected!");
  } catch (final RuntimeException ex) {

代码示例来源:origin: org.apache.nifi/nifi-standard-record-utils

private static char getUnescapedChar(final PropertyContext context, final PropertyDescriptor property) {
  return StringEscapeUtils.unescapeJava(context.getProperty(property).getValue()).charAt(0);
}

代码示例来源:origin: org.apache.james/james-server-jmap-integration-testing

@Then("^the htmlBody of the message is \"([^\"]*)\"$")
public void assertHtmlBodyOfTheFirstMessage(String htmlBody) {
  assertThat(httpClient.jsonPath.<String>read(FIRST_MESSAGE + ".htmlBody")).isEqualTo(StringEscapeUtils.unescapeJava(htmlBody));
}

代码示例来源:origin: org.apache.james/james-server-jmap-integration-testing

@Then("^the textBody of the message is \"([^\"]*)\"$")
public void assertTextBodyOfTheFirstMessage(String textBody) {
  assertThat(httpClient.jsonPath.<String>read(FIRST_MESSAGE + ".textBody")).isEqualTo(StringEscapeUtils.unescapeJava(textBody));
}

代码示例来源:origin: org.apache.james/james-server-jmap-integration-testing

@Then("^the preview of the message is \"([^\"]*)\"$")
public void assertPreviewOfTheFirstMessage(String preview) {
  String actual = httpClient.jsonPath.<String>read(FIRST_MESSAGE + ".preview").replace("\n", " ");
  assertThat(actual).isEqualToIgnoringWhitespace(StringEscapeUtils.unescapeJava(preview));
}

相关文章