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

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

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

StringEscapeUtils.unescapeJava介绍

[英]Unescapes any Java literals found in the String to a Writer.

For example, it will turn a sequence of '\' and 'n' into a newline character, unless the '\' is preceded by another '\'.

A null string input has no effect.
[中]将在String中找到的任何Java文本解压缩为Writer
例如,它会将'\''n'的序列转换为换行符,除非'\'前面有另一个'\'
null字符串输入无效。

代码示例

代码示例来源:origin: commons-lang/commons-lang

/**
 * <p>Unescapes any JavaScript literals found in the <code>String</code>.</p>
 *
 * <p>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>
 *
 * @see #unescapeJava(String)
 * @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 unescapeJavaScript(String str) {
  return unescapeJava(str);
}

代码示例来源:origin: commons-lang/commons-lang

/**
 * <p>Unescapes any JavaScript literals found in the <code>String</code> to a
 * <code>Writer</code>.</p>
 *
 * <p>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>
 *
 * <p>A <code>null</code> string input has no effect.</p>
 * 
 * @see #unescapeJava(Writer,String)
 * @param out  the <code>Writer</code> used to output unescaped characters
 * @param str  the <code>String</code> to unescape, may be null
 * @throws IllegalArgumentException if the Writer is <code>null</code>
 * @throws IOException if error occurs on underlying Writer
 */
public static void unescapeJavaScript(Writer out, String str) throws IOException {
  unescapeJava(out, str);
}

代码示例来源:origin: apache/incubator-druid

@Override
public void exitIdentifierExpr(ExprParser.IdentifierExprContext ctx)
{
 String text = ctx.getText();
 if (text.charAt(0) == '"' && text.charAt(text.length() - 1) == '"') {
  text = StringEscapeUtils.unescapeJava(text.substring(1, text.length() - 1));
 }
 nodes.put(
   ctx,
   new IdentifierExpr(text)
 );
}

代码示例来源:origin: apache/incubator-druid

@Override
public void exitString(ExprParser.StringContext ctx)
{
 String text = ctx.getText();
 String unquoted = text.substring(1, text.length() - 1);
 String unescaped = unquoted.indexOf('\\') >= 0 ? StringEscapeUtils.unescapeJava(unquoted) : unquoted;
 nodes.put(ctx, new StringExpr(unescaped));
}

代码示例来源:origin: commons-lang/commons-lang

/**
 * <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 unescapeJava(String str) {
  if (str == null) {
    return null;
  }
  try {
    StringWriter writer = new StringWriter(str.length());
    unescapeJava(writer, str);
    return writer.toString();
  } catch (IOException ioe) {
    // this should never ever happen while writing to a StringWriter
    throw new UnhandledException(ioe);
  }
}

代码示例来源:origin: ChinaSilence/any-video

String text = StringEscapeUtils.unescapeJava(result.text());
text = text.replace("vjs_149067353337651(", "");
text = text.replace(");", "");

代码示例来源:origin: apache/incubator-pinot

_paddingCharacter = StringEscapeUtils.unescapeJava(padding).charAt(0);

代码示例来源:origin: facebook/jcommon

public static String stripQuotes(String input) {
  if (input.startsWith("'") || input.startsWith("\"")) {
   return StringEscapeUtils.unescapeJava(input.substring(1, input.length() - 1));
  } else {
   return input;
  }
 }
}

代码示例来源:origin: apache/incubator-pinot

if (config.containsKey(SEGMENT_PADDING_CHARACTER)) {
 String padding = config.getString(SEGMENT_PADDING_CHARACTER);
 paddingCharacter = StringEscapeUtils.unescapeJava(padding).charAt(0);

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

HplsqlParser.Copy_optionContext option = ctx.copy_option(i);
if (option.T_DELIMITER() != null) {
 delimiter = StringEscapeUtils.unescapeJava(evalPop(option.expr()).toString());

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

String logMessage = StringEscapeUtils.unescapeJava(jsonCmd);
logMessage = cleanPassword(logMessage);
s_logger.debug("GET request to " + agentUri.toString()
  } else {
    result = EntityUtils.toString(response.getEntity());
    String logResult = cleanPassword(StringEscapeUtils.unescapeJava(result));
    s_logger.debug("Get response is " + logResult);

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

String logMessage = StringEscapeUtils.unescapeJava(jsonCmd);
logMessage = cleanPassword(logMessage);
s_logger.debug("POST request to " + agentUri.toString()
  } else {
    result = EntityUtils.toString(response.getEntity());
    final String logResult = cleanPassword(StringEscapeUtils.unescapeJava(result));
    s_logger.debug("POST response is " + logResult);

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

String logMessage = StringEscapeUtils.unescapeJava(jsonCmd);
logMessage = cleanPassword(logMessage);
s_logger.debug("POST request to " + agentUri.toString()
  } else {
    result = EntityUtils.toString(response.getEntity());
    String logResult = cleanPassword(StringEscapeUtils.unescapeJava(result));
    s_logger.debug("POST response is " + logResult);

代码示例来源:origin: org.apache.phoenix/phoenix-core

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.marketcetera/core

@Override
  public Message unmarshal
    (String msg)
    throws InvalidMessage
  {
    if (msg==null) {
      return null;
    }
    return new Message(StringEscapeUtils.unescapeJava(msg));
  }
}

代码示例来源:origin: org.visallo/visallo-common-rdf

public String getString() {
  String str = getLine().substring(stringStart, stringEnd);
  str = StringEscapeUtils.unescapeJava(str);
  return str;
}

代码示例来源:origin: org.apache.druid/druid-common

@Override
public void exitIdentifierExpr(ExprParser.IdentifierExprContext ctx)
{
 String text = ctx.getText();
 if (text.charAt(0) == '"' && text.charAt(text.length() - 1) == '"') {
  text = StringEscapeUtils.unescapeJava(text.substring(1, text.length() - 1));
 }
 nodes.put(
   ctx,
   new IdentifierExpr(text)
 );
}

代码示例来源:origin: org.apache.druid/druid-common

@Override
public void exitString(ExprParser.StringContext ctx)
{
 String text = ctx.getText();
 String unquoted = text.substring(1, text.length() - 1);
 String unescaped = unquoted.indexOf('\\') >= 0 ? StringEscapeUtils.unescapeJava(unquoted) : unquoted;
 nodes.put(ctx, new StringExpr(unescaped));
}

代码示例来源:origin: org.apache.tajo/tajo-storage-hdfs

public static byte[] getNullCharsAsBytes(TableMeta meta, String key, String defaultVal) {
 byte [] nullChars;
 String nullCharacters = StringEscapeUtils.unescapeJava(meta.getOption(key, defaultVal));
 if (StringUtils.isEmpty(nullCharacters)) {
  nullChars = NullDatum.get().asTextBytes();
 } else {
  nullChars = nullCharacters.getBytes(Bytes.UTF8_CHARSET);
 }
 return nullChars;
}

代码示例来源:origin: org.apache.tajo/tajo-plan

public static byte [] getNullCharsAsBytes(TableMeta meta) {
 byte [] nullChars;
 String nullCharacters = StringEscapeUtils.unescapeJava(meta.getOption(StorageConstants.TEXT_NULL,
   NullDatum.DEFAULT_TEXT));
 if (StringUtils.isEmpty(nullCharacters)) {
  nullChars = NullDatum.get().asTextBytes();
 } else {
  nullChars = nullCharacters.getBytes(Bytes.UTF8_CHARSET);
 }
 return nullChars;
}

相关文章