org.eclipse.persistence.internal.helper.Helper.convertLikeToRegex()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(1.7k)|赞(0)|评价(0)|浏览(96)

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

Helper.convertLikeToRegex介绍

[英]Convert the SQL like pattern to a regex pattern.
[中]将类似SQL的模式转换为正则表达式模式。

代码示例

代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.core

/**
 * INTERNAL:
 * An implementation of in memory queries with Like which uses the
 * regular expression framework.
 */
public static Boolean conformLike(Object left, Object right) {
  if ((left == null) && (right == null)) {
    return Boolean.TRUE;
  } else if ((left == null) || (right == null)) {
    return Boolean.FALSE;
  }
  left = String.valueOf(left);
  right = String.valueOf(right);
  // PERF: First check the pattern cache for the pattern.
  // Note that the original string is the key, to avoid having to translate it first.
  Pattern pattern = (Pattern)patternCache.get(right);
  if (pattern == null) {
    // Bug 3936427 - Replace regular expression reserved characters with escaped version of those characters
    // For instance replace ? with \?
    String convertedRight = Helper.convertLikeToRegex((String)right);
    pattern = Pattern.compile(convertedRight);
    // Ensure cache does not grow beyond 100.
    if (patternCache.size() > 100) {
      patternCache.remove(patternCache.keySet().iterator().next());
    }
    patternCache.put(right, pattern);
  }
  return pattern.matcher((String)left).matches();
}

代码示例来源:origin: com.haulmont.thirdparty/eclipselink

String convertedRight = Helper.convertLikeToRegex((String)right);

代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.nosql

DatabaseRecord nested = new DatabaseRecord();
if (!this.isLikeRegex) {
  pattern = Helper.convertLikeToRegex(pattern);

相关文章

Helper类方法