本文整理了Java中org.apache.commons.lang.StringEscapeUtils.escapeJavaScript()
方法的一些代码示例,展示了StringEscapeUtils.escapeJavaScript()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。StringEscapeUtils.escapeJavaScript()
方法的具体详情如下:
包路径:org.apache.commons.lang.StringEscapeUtils
类名称:StringEscapeUtils
方法名:escapeJavaScript
[英]Escapes the characters in a String
using JavaScript String rules to a Writer
.
A null
string input has no effect.
[中]使用JavaScript字符串规则将String
中的字符转义为Writer
。null
字符串输入无效。
代码示例来源:origin: jeremylong/DependencyCheck
/**
* JavaScript encodes the provided text.
*
* @param text the text to encode
* @return the JavaScript encoded text
*/
public String javascript(String text) {
if (text == null || text.isEmpty()) {
return text;
}
//until lang3 has escapeJavaScript we use this...
return org.apache.commons.lang.StringEscapeUtils.escapeJavaScript(text);
}
代码示例来源:origin: h2oai/h2o-2
StringBuilder tmp = new StringBuilder();
cm.toHTML(tmp, my_actual_domain);
sb.append("\t'" + StringEscapeUtils.escapeJavaScript(tmp.toString()) + "',\n");
代码示例来源:origin: apache/cloudstack
@Override
public boolean updateQuotaEmailTemplate(QuotaEmailTemplateUpdateCmd cmd) {
final String templateName = cmd.getTemplateName();
final String templateSubject = StringEscapeUtils.escapeJavaScript(cmd.getTemplateSubject());
final String templateBody = StringEscapeUtils.escapeJavaScript(cmd.getTemplateBody());
final String locale = cmd.getLocale();
final List<QuotaEmailTemplatesVO> templates = _quotaEmailTemplateDao.listAllQuotaEmailTemplates(templateName);
if (templates.size() == 1) {
final QuotaEmailTemplatesVO template = templates.get(0);
template.setTemplateSubject(templateSubject);
template.setTemplateBody(templateBody);
if (locale != null) {
template.setLocale(locale);
}
return _quotaEmailTemplateDao.updateQuotaEmailTemplate(template);
}
return false;
}
代码示例来源:origin: ai.grakn/grakn-core
/**
* @param string the string to escape
* @return the escaped string, replacing any escapable characters with backslashes
*/
public static String escapeString(String string) {
return StringEscapeUtils.escapeJavaScript(string);
}
代码示例来源:origin: org.netpreserve.openwayback/openwayback-core
/**
* handy shortcut to the Apache StringEscapeUtils.
* <p>Intended for JSP use. Otherwise use {@link StringEscapeUtils#escapeJavaScript(String)} instead.</p>
* @param raw string to be escaped
* @return the string escaped so it's safe for insertion in Javascript
*/
public String escapeJavaScript(String raw) {
return StringEscapeUtils.escapeJavaScript(raw);
}
代码示例来源:origin: org.apache.velocity/com.springsource.org.apache.velocity
/**
* Escapes the characters in a String to be suitable for use in JavaScript.
*
* @param text
* @return An escaped String.
* @see <a href="http://jakarta.apache.org/commons/lang/api/org/apache/commons/lang/StringEscapeUtils.html#escapeJavaScript(java.lang.String)">StringEscapeUtils</a>
*/
protected String escape(Object text)
{
return StringEscapeUtils.escapeJavaScript(text.toString());
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.velocity
/**
* Escapes the characters in a String to be suitable for use in JavaScript.
*
* @param text
* @return An escaped String.
* @see <a href="http://jakarta.apache.org/commons/lang/api/org/apache/commons/lang/StringEscapeUtils.html#escapeJavaScript(java.lang.String)">StringEscapeUtils</a>
*/
protected String escape(Object text)
{
return StringEscapeUtils.escapeJavaScript(text.toString());
}
代码示例来源:origin: com.bbossgroups/bboss-velocity
/**
* Escapes the characters in a String to be suitable for use in JavaScript.
*
* @param text
* @return An escaped String.
* @see <a href="http://jakarta.apache.org/commons/lang/api/org/apache/commons/lang/StringEscapeUtils.html#escapeJavaScript(java.lang.String)">StringEscapeUtils</a>
*/
protected String escape(Object text)
{
return StringEscapeUtils.escapeJavaScript(text.toString());
}
代码示例来源:origin: org.rescarta.rc-web/rc-web
public static String escapeJavaScript(String s) throws IOException {
StringWriter out = new StringWriter();
StringEscapeUtils.escapeJavaScript(out, s);
return out.toString();
}
代码示例来源:origin: com.atlassian.confluence.plugins/confluence-jira3-plugin
private void appendCustomFieldUnformatted(String fieldValueText, StringBuilder jsonIssueElementBuilder, boolean fromAppLink)
{
if (!fromAppLink)
{
fieldValueText = StringEscapeUtils.escapeHtml(fieldValueText);
}
jsonIssueElementBuilder.append("'").append(StringEscapeUtils.escapeJavaScript(fieldValueText)).append("'");
}
代码示例来源:origin: org.apache.myfaces.tomahawk/tomahawk
private static void setStringVariable(StringBuffer script, String name, String value)
{
script.append(name);
script.append(" = \"");
script.append(StringEscapeUtils.escapeJavaScript(value));
script.append("\";\n");
}
代码示例来源:origin: com.manydesigns/elements
public void appendIds(StringBuilder sb) {
SelectSearchField rootField = this;
while (rootField.previousSelectField != null) {
rootField = rootField.previousSelectField;
}
SelectSearchField currentField = rootField;
while (currentField != null) {
sb.append(MessageFormat.format(", ''#{0}''",
StringEscapeUtils.escapeJavaScript(currentField.getId())));
currentField = currentField.nextSelectField;
}
}
代码示例来源:origin: com.atlassian.jira/jira-core
public Map<String, String> getTranslatedTemplates(final JiraAuthenticationContext authenticationContext, final TypeDescriptor<? extends SharedEntity> type, final RenderMode mode)
{
notNull("authenticationContext", authenticationContext);
final Map<String, String> templates = new HashMap<String, String>();
templates.put("share_global_display", StringEscapeUtils.escapeJavaScript(getText(authenticationContext,
"common.sharing.shared.template.everyone")));
templates.put("share_global_description", StringEscapeUtils.escapeJavaScript(getText(authenticationContext,
"common.sharing.shared.template.everyone.desc")));
templates.put("share_global_warning", StringEscapeUtils.escapeJavaScript(getText(authenticationContext,
"common.sharing.shared.template.everyone.warning")));
return Collections.unmodifiableMap(templates);
}
代码示例来源:origin: com.atlassian.confluence.plugins/confluence-jira3-plugin
private void appendMultivalueBuiltinColumn(Element itemElement, String columnName, StringBuilder jsonIssueElementBuilder)
{
jsonIssueElementBuilder.append("'");
jsonIssueElementBuilder.append(StringEscapeUtils.escapeJavaScript(xmlXformer.collapseMultiple(itemElement, columnName).getValue()));
jsonIssueElementBuilder.append("'");
}
代码示例来源:origin: org.jboss.arquillian.ajocado/arquillian-ajocado-impl
@Override
public JavaScript getJavaScriptCondition() {
Validate.notNull(message);
String escapedMessage = escapeJavaScript(message);
return js(
"selenium.isAlertPresent() && ((alertMessage = selenium.getAlert()) == '{0}' "
+ " || selenium.throwError('Alert has been displayed, "
+ "but the message \\'' + alertMessage + '\\' doesn\\'t equal to the expected \\'{0}\\''))")
.parametrize(escapedMessage);
}
代码示例来源:origin: org.jboss.arquillian.ajocado/arquillian-ajocado-impl
@Override
public JavaScript getJavaScriptCondition() {
String escapedLocator = escapeJavaScript(this.elementLocator.inSeleniumRepresentation());
return js("selenium.isVisible('{0}')").parametrize(escapedLocator);
}
代码示例来源:origin: org.jboss.arquillian.ajocado/arquillian-ajocado-impl
/**
* JavaScript expression to retrieve attribute value from element given by attributeLocator
*/
@Override
public JavaScript getJavaScriptRetrieve() {
String escapedLocator = StringEscapeUtils.escapeJavaScript(attributeLocator.inSeleniumRepresentation());
return js("selenium.getAttribute('{0}')").parametrize(escapedLocator);
}
代码示例来源:origin: org.jboss.arquillian.ajocado/arquillian-ajocado-impl
@Override
public JavaScript getJavaScriptCondition() {
String escapedLocator = escapeJavaScript(this.elementLocator.inSeleniumRepresentation());
return js(SimplifiedFormat.format("!selenium.isVisible('{0}')", escapedLocator));
}
代码示例来源:origin: org.jboss.arquillian.ajocado/arquillian-ajocado-impl
private <T> JavaScript prepareCondition(T oldValue, JavaScriptRetriever<T> retriever) {
final String scriptString = retriever.getJavaScriptRetrieve().getAsString();
final String oldValueString = retriever.getConvertor().forwardConversion(oldValue);
final String escapedOldValueString = StringEscapeUtils.escapeJavaScript(oldValueString);
return js("{0} != '{1}'").parametrize(scriptString, escapedOldValueString);
}
代码示例来源:origin: com.lmco.shindig/shindig-gadgets
@Override
protected void outputJs(Uri uri, String data) throws IOException {
print("\"");
print(uri.toString());
print("\":\"");
print(StringEscapeUtils.escapeJavaScript(data));
println("\",");
}
内容来源于网络,如有侵权,请联系作者删除!