org.apache.jackrabbit.util.Text.escapeIllegalXpathSearchChars()方法的使用及代码示例

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

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

Text.escapeIllegalXpathSearchChars介绍

[英]Escapes illegal XPath search characters at the end of a string.

Example:
A search string like 'test?' will run into a ParseException documented in http://issues.apache.org/jira/browse/JCR-1248
[中]在字符串末尾转义非法的XPath搜索字符。
例子:
像“test”这样的搜索字符串将遇到ParseException,记录在http://issues.apache.org/jira/browse/JCR-1248

代码示例

代码示例来源:origin: io.wcm/io.wcm.wcm.ui.extjs

/**
 * @param expressions
 * @return array of escaped xPath query expressions
 */
private String[] escapeXPathQueryExpressions(String[] expressions) {
 List<String> escapedExpressions = new ArrayList<>();
 for (String expr : expressions) {
  escapedExpressions.add(Text.escapeIllegalXpathSearchChars(expr));
 }
 return escapedExpressions.toArray(new String[escapedExpressions.size()]);
}

代码示例来源:origin: io.wcm/io.wcm.sling.commons

/**
 * Convert a string to a JCR search expression literal, suitable for use in jcr:contains() (inside XPath)
 * or contains (JCR-SQL2). The characters - and " have special meaning, and may be escaped with a backslash
 * to obtain their literal value.
 * See JSR-283 specification v2.0, Section 4.6.6.19.
 * @param value Any string.
 * @return A valid string literal suitable for use in JCR contains clauses, including enclosing quotes.
 */
@SuppressWarnings("null")
public static @NotNull String jcrQueryContainsExpr(@NotNull String value) {
 if (value == null || value.isEmpty()) {
  throw new IllegalArgumentException("Invalid query string value: " + value);
 }
 // Escape special characters not allowed in jcr:contains expression
 return jcrQueryLiteral(Text.escapeIllegalXpathSearchChars(value));
}

代码示例来源:origin: org.apache.sling/org.apache.sling.cms.core

public SearchResults(SlingHttpServletRequest request) {
  if (StringUtils.isNotEmpty(request.getParameter("type"))) {
    type = request.getParameter("type");
  }
  if (StringUtils.isNotEmpty(request.getParameter("path"))) {
    path = request.getParameter("path");
  }
  term = Text.escapeIllegalXpathSearchChars(request.getParameter("term")).replaceAll("'", "''");
  this.request = request;
}

相关文章