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

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

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

StringEscapeUtils.unescapeJava介绍

[英]Unescapes any Java literals found in the String. For example, it will turn a sequence of '' and 'n' into a newline character, unless the ''is preceded by another ''.
[中]取消扫描字符串中找到的任何Java文本。例如,它会将“\”和“n”的序列转换为换行符,除非“\”前面有另一个“\”。

代码示例

代码示例来源:origin: iBotPeaches/Apktool

/**
   * <p>Unescapes any Java literals found in the <code>String</code>.
   * For example, it will turn a sequence of <code>'\'</code> and
   * <code>'n'</code> into a newline character, unless the <code>'\'</code>
   * is preceded by another <code>'\'</code>.</p>
   *
   * @param str  the <code>String</code> to unescape, may be null
   * @return a new unescaped <code>String</code>, <code>null</code> if null string input
   */
  public static String unescapeString(String str) {
    return StringEscapeUtils.unescapeJava(str);
  }
}

代码示例来源:origin: Graylog2/graylog2-server

public static String unescape(String string) {
  return StringEscapeUtils.unescapeJava(string);
}

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

/**
 * Unescapes any Java literals found in the {@code String}.
 * For example, it will turn a sequence of {@code '\'} and
 * {@code 'n'} into a newline character, unless the {@code '\'}
 * is preceded by another {@code '\'}.
 *
 * @param input  the {@code String} to unescape, may be null
 * @return a new unescaped {@code String}, {@code null} if null string input
 */
public static final String unescapeJava(String input) {
 return StringEscapeUtils.unescapeJava(input);
}

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

final public String JsonString() throws ParseException {
Token t;
 t = jj_consume_token(STRING_LITERAL);
 String betweenQuotes = t.image.substring(1, t.image.length() - 1);
 {if (true) return StringEscapeUtils.unescapeJava(betweenQuotes);}
 throw new Error("Missing return statement in function");
}

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

@Override
public HiveScan getPhysicalScan(String userName, JSONOptions selection, List<SchemaPath> columns, SessionOptionManager options) throws IOException {
 HiveReadEntry hiveReadEntry = selection.getListWith(new ObjectMapper(), new TypeReference<HiveReadEntry>(){});
 try {
  Map<String, String> confProperties = new HashMap<>();
  if (options != null) {
   String value = StringEscapeUtils.unescapeJava(options.getString(ExecConstants.HIVE_CONF_PROPERTIES));
   logger.trace("[{}] is set to {}.", ExecConstants.HIVE_CONF_PROPERTIES, value);
   try {
    Properties properties = new Properties();
    properties.load(new StringReader(value));
    confProperties =
     properties.stringPropertyNames().stream()
      .collect(
       Collectors.toMap(
        Function.identity(),
        properties::getProperty,
        (o, n) -> n));
    } catch (IOException e) {
     logger.warn("Unable to parse Hive conf properties {}, ignoring them.", value);
   }
  }
  return new HiveScan(userName, hiveReadEntry, this, columns, null, confProperties);
 } catch (ExecutionSetupException e) {
  throw new IOException(e);
 }
}

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

throw new IOException("Druid broker address not specified in configuration");
String druidQuery = StringEscapeUtils.unescapeJava(conf.get(Constants.DRUID_QUERY_JSON));

代码示例来源:origin: bwssytems/ha-bridge

theUrlBody = StringEscapeUtils.unescapeJava(theUrlBody);
sendData = theUrlBody.getBytes();

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

/**
 * 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.commons/commons-lang3

private void assertUnescapeJava(final String message, final String unescaped, final String original) throws IOException {
  final String expected = unescaped;
  final String actual = StringEscapeUtils.unescapeJava(original);
  assertEquals("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) + "'",
      expected, actual);
  final StringWriter writer = new StringWriter();
  StringEscapeUtils.UNESCAPE_JAVA.translate(original, writer);
  assertEquals(unescaped, writer.toString());
}

代码示例来源:origin: Swagger2Markup/swagger2markup

example = StringEscapeUtils.unescapeJava(example);
  example = StringEscapeUtils.unescapeJava(example);

代码示例来源:origin: bwssytems/ha-bridge

public void publishMessage(String topic, String content, Integer qos, Boolean retain) {
  MqttMessage message = new MqttMessage(StringEscapeUtils.unescapeJava(content).getBytes());
  message.setQos(Optional.ofNullable(qos).orElse(1));
  message.setRetained(Optional.ofNullable(retain).orElse(false));
  try {
    if(!myClient.isConnected()) {
      try {
        myClient.connect();
      } catch (MqttSecurityException e1) {
        log.error("Could not retry connect to MQTT client for name: " + myConfig.getName() + " and ip: " + myConfig.getIp() + " with message: " + e1.getMessage());
        return;
      } catch (MqttException e1) {
        log.error("Could not retry connect to MQTT client for name: " + myConfig.getName() + " and ip: " + myConfig.getIp() + " with message: " + e1.getMessage());
        return;
      }
    }
    myClient.publish(topic, message);
  } catch (MqttException e) {
    log.error("Could not publish to MQTT client for name: " + myConfig.getName() + " and ip: " + myConfig.getIp() + " with message: " + e.getMessage());
  }
}

代码示例来源:origin: bwssytems/ha-bridge

theUrlBody = ColorDecode.replaceColorData(theUrlBody, colorData, BrightnessDecode.calculateIntensity(intensity, targetBri, targetBriInc), false);	
theUrlBody = StringEscapeUtils.unescapeJava(theUrlBody);
sendData = theUrlBody.getBytes();

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

private static char getCharacter(String s) {
  String unescaped = StringEscapeUtils.unescapeJava(s);
  if (unescaped.length() > 1) {
    throw new IllegalArgumentException("Invalid single character: '" + unescaped + "'");
  }
  return unescaped.charAt(0);
}

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

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

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

String delimString = StringEscapeUtils.unescapeJava(cmdLine.getOptionValue(DELIMITER_OPT.getOpt()));
if (delimString.length() != 1) {
  throw new IllegalArgumentException("Illegal delimiter character: " + delimString);

代码示例来源:origin: spring-projects/spring-roo

public void formatFieldComment(FieldDetails fieldDetails) {
 // If a comment was defined, we need to format it
 if (fieldDetails.getComment() != null) {
  // First replace all "" with the proper escape sequence \"
  String unescapedMultiLineComment = fieldDetails.getComment().replaceAll("\"\"", "\\\\\"");
  // Then unescape all characters
  unescapedMultiLineComment = StringEscapeUtils.unescapeJava(unescapedMultiLineComment);
  CommentFormatter commentFormatter = new CommentFormatter();
  String javadocComment = commentFormatter.formatStringAsJavadoc(unescapedMultiLineComment);
  fieldDetails.setComment(commentFormatter.format(javadocComment, 1));
 }
}

代码示例来源:origin: spring-projects/spring-roo

public void formatFieldComment(FieldDetails fieldDetails) {
 // If a comment was defined, we need to format it
 if (fieldDetails.getComment() != null) {
  // First replace all "" with the proper escape sequence \"
  String unescapedMultiLineComment = fieldDetails.getComment().replaceAll("\"\"", "\\\\\"");
  // Then unescape all characters
  unescapedMultiLineComment = StringEscapeUtils.unescapeJava(unescapedMultiLineComment);
  CommentFormatter commentFormatter = new CommentFormatter();
  String javadocComment = commentFormatter.formatStringAsJavadoc(unescapedMultiLineComment);
  fieldDetails.setComment(commentFormatter.format(javadocComment, 1));
 }
}

代码示例来源:origin: spring-projects/spring-roo

public void formatFieldComment(FieldDetails fieldDetails) {
 // If a comment was defined, we need to format it
 if (fieldDetails.getComment() != null) {
  // First replace all "" with the proper escape sequence \"
  String unescapedMultiLineComment = fieldDetails.getComment().replaceAll("\"\"", "\\\\\"");
  // Then unescape all characters
  unescapedMultiLineComment = StringEscapeUtils.unescapeJava(unescapedMultiLineComment);
  CommentFormatter commentFormatter = new CommentFormatter();
  String javadocComment = commentFormatter.formatStringAsJavadoc(unescapedMultiLineComment);
  fieldDetails.setComment(commentFormatter.format(javadocComment, 1));
 }
}

代码示例来源:origin: dremio/dremio-oss

/**
 * Unescapes any Java literals found in the {@code String}.
 * For example, it will turn a sequence of {@code '\'} and
 * {@code 'n'} into a newline character, unless the {@code '\'}
 * is preceded by another {@code '\'}.
 *
 * @param input  the {@code String} to unescape, may be null
 * @return a new unescaped {@code String}, {@code null} if null string input
 */
public static final String unescapeJava(String input) {
 return StringEscapeUtils.unescapeJava(input);
}

代码示例来源:origin: stanford-futuredata/macrobase

private DelimiterClause(Optional<NodeLocation> location, String delimiter) {
  super(location);
  requireNonNull(delimiter, "delimiter is null");
  this.delimiter = StringEscapeUtils.unescapeJava(delimiter);
}

相关文章