本文整理匯總了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));
}