本文整理汇总了Java中org.apache.commons.lang3.StringEscapeUtils.escapeJava方法的典型用法代码示例。如果您正苦于以下问题:Java StringEscapeUtils.escapeJava方法的具体用法?Java StringEscapeUtils.escapeJava怎么用?Java StringEscapeUtils.escapeJava使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.lang3.StringEscapeUtils
的用法示例。
在下文中一共展示了StringEscapeUtils.escapeJava方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: json
import org.apache.commons.lang3.StringEscapeUtils; //导入方法依赖的package包/类
private static String json(Type<?> p) {
if (p == null) return "null";
if (p instanceof NumericType || p instanceof Bool) {
return p.getValue().toString();
}
if (p instanceof Array) {
return "[" + json(((Array<?>) p).getValue()) + "]";
}
Object value = p.getValue();
String str;
if (value instanceof byte[]) {
str = Numeric.toHexStringNoPrefix((byte[]) value);
} else {
str = value.toString();
}
return "\"" + StringEscapeUtils.escapeJava(str) + "\"";
}
示例2: setText
import org.apache.commons.lang3.StringEscapeUtils; //导入方法依赖的package包/类
public void setText(String text)
{
// TODO: update StringEscapeUtils and use escapeJavaScript() instead
text = StringEscapeUtils.escapeJava(text);
codeBodyProperty.set(text);
System.out.println("Setting value");
webView.getEngine().executeScript(
"window.onload = function() {"
+ "editor.on(\"change\", function(){});"
+ "editor.setValue(\"" + text + "\","
+ text.length() + ");"
+ "editor.on(\"change\", function() {"
+ "javaContentModel.updateTextFromJavascript(editor.getValue());"
+ "});"
+ "javaContentModel.println(\"Value Set\");"
+ "};"
);
}
示例3: buildActionStep
import org.apache.commons.lang3.StringEscapeUtils; //导入方法依赖的package包/类
private String buildActionStep(TestStepDTO testStepDTO) {
String actionString = "";
actionString = "\t\tseleniumKeywords."
+ ActionsMapping.getAction(testStepDTO.getAction().toLowerCase());
actionString += "(\"" + testStepDTO.getLocateElement().getBy() + "\"";
String locatorValue = testStepDTO.getLocateElement().getValue();
actionString += ", \"" + StringEscapeUtils.escapeJava(locatorValue) + "\"";
if (testStepDTO.getThirdPara() != null) {
actionString += ", \"" + testStepDTO.getThirdPara() + "\");";
} else {
actionString += ");";
}
return actionString;
}
示例4: onRowAdded
import org.apache.commons.lang3.StringEscapeUtils; //导入方法依赖的package包/类
protected void onRowAdded(List<? extends SpecificationRow<C>> added) {
for (SpecificationRow<C> addedRow : added) {
// Check correctness of added row
if (addedRow.getCells().size() != columnHeaders.size()) {
throw new IllegalArgumentException(
"Illegal width for row " + StringEscapeUtils.escapeJava(addedRow.toString())
+ ", expected width: " + columnHeaders.size());
}
if (!addedRow.getCells().keySet().stream()
.allMatch(columnId -> getOptionalColumnHeaderByName(columnId).isPresent())) {
throw new IllegalArgumentException("Added row contains unknown IoVariable: "
+ StringEscapeUtils.escapeJava(addedRow.toString()));
}
}
}
示例5: tryToGetValidName
import org.apache.commons.lang3.StringEscapeUtils; //导入方法依赖的package包/类
private static String tryToGetValidName(FreeVariable freeVariable)
throws InvalidFreeVariableProblem {
String varName = freeVariable.getName();
if (VariableExpr.IDENTIFIER_PATTERN.matcher(varName).matches()) {
return varName;
}
else {
throw new InvalidFreeVariableProblem(
"Variable has illegal characters in name: "
+ StringEscapeUtils.escapeJava(varName));
}
}
示例6: tryToGetValidType
import org.apache.commons.lang3.StringEscapeUtils; //导入方法依赖的package包/类
private static Type tryToGetValidType(FreeVariable freeVariable,
Map<String, Type> typesByName) throws InvalidFreeVariableProblem {
Type foundType = typesByName.get(freeVariable.getType());
if (foundType == null) {
throw new InvalidFreeVariableProblem(
"Variable has unknown type: " + StringEscapeUtils
.escapeJava(freeVariable.getType()));
}
return foundType;
}
示例7: getEscapedSearchString
import org.apache.commons.lang3.StringEscapeUtils; //导入方法依赖的package包/类
/**
* Gets the text of the search query.
* @return String containing the query target.
*/
public String getEscapedSearchString() {
return StringEscapeUtils.escapeJava(searchString);
}
示例8: escapeJava
import org.apache.commons.lang3.StringEscapeUtils; //导入方法依赖的package包/类
/**
* Escapes the characters in a {@code String} using Java String rules.
*
* Deals correctly with quotes and control-chars (tab, backslash, cr, ff, etc.)
*
* So a tab becomes the characters {@code '\\'} and
* {@code 't'}.
*
* Example:
* <pre>
* input string: He didn't say, "Stop!"
* output string: He didn't say, \"Stop!\"
* </pre>
*
* @param input String to escape values in, may be null
* @return String with escaped values, {@code null} if null string input
*/
public static final String escapeJava(String input) {
return StringEscapeUtils.escapeJava(input);
}
示例9: escapeJava
import org.apache.commons.lang3.StringEscapeUtils; //导入方法依赖的package包/类
/**
* Escapes the characters in a {@code String} according to Java string literal
* rules.
*
* Deals correctly with quotes and control-chars (tab, backslash, cr, ff,
* etc.) so, for example, a tab becomes the characters {@code '\\'} and
* {@code 't'}.
*
* Example:
* <pre>
* input string: He didn't say, "Stop!"
* output string: He didn't say, \"Stop!\"
* </pre>
*
* @param input String to escape values in, may be null
* @return String with escaped values, {@code null} if null string input
*/
public static final String escapeJava(String input) {
return StringEscapeUtils.escapeJava(input);
}
示例10: debuggingString
import org.apache.commons.lang3.StringEscapeUtils; //导入方法依赖的package包/类
/**
* <p>
* Prints a minimal string including the string representation and optionally adds the comment, if
* not null.
* </p>
*
* <p>
* (should only used for debugging purposes, i.e. in toString methods)
* </p>
*
* @return a minimal string
*/
default String debuggingString() {
return getAsString() + (getComment() == null ? ""
: " (comment: \"" + StringEscapeUtils.escapeJava(getComment()) + "\")");
}
示例11: DuplicateFreeVariableProblem
import org.apache.commons.lang3.StringEscapeUtils; //导入方法依赖的package包/类
/**
* Private constructor: DuplicateFreeVariableProblems can only be created from the static
* method {@link DuplicateFreeVariableProblem#checkForDuplicates}.
* @param freeVariableName the name of the duplicate variable
*/
private DuplicateFreeVariableProblem(String freeVariableName) {
super(
"More than one free variable with name " + StringEscapeUtils.escapeJava(freeVariableName));
}