org.joni.Regex.getEncoding()方法的使用及代码示例

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

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

Regex.getEncoding介绍

暂无

代码示例

代码示例来源:origin: org.jruby/jruby-core

@Override
public Encoding getEncoding() {
  return pattern.getEncoding();
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

static Regex getRegexpFromCache(Ruby runtime, ByteList bytes, Encoding enc, RegexpOptions options) {
  Map<ByteList, Regex> cache = patternCache.get();
  Regex regex = cache.get(bytes);
  if (regex != null && regex.getEncoding() == enc && regex.getOptions() == options.toJoniOptions()) return regex;
  regex = makeRegexp(runtime, bytes, options, enc);
  regex.setUserObject(bytes);
  cache.put(bytes, regex);
  return regex;
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

private static Regex getPreprocessedRegexpFromCache(Ruby runtime, ByteList bytes, Encoding enc, RegexpOptions options, ErrorMode mode) {
  Map<ByteList, Regex> cache = preprocessedPatternCache.get();
  Regex regex = cache.get(bytes);
  if (regex != null && regex.getEncoding() == enc && regex.getOptions() == options.toJoniOptions()) return regex;
  ByteList preprocessed = preprocess(runtime, bytes, enc, new Encoding[]{null}, ErrorMode.RAISE);
  regex = makeRegexp(runtime, preprocessed, options, enc);
  regex.setUserObject(preprocessed);
  cache.put(bytes, regex);
  return regex;
}

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

static Regex getQuotedRegexpFromCache(Ruby runtime, ByteList bytes, Encoding enc, RegexpOptions options) {
  Map<ByteList, Regex> cache = quotedPatternCache.get();
  Regex regex = cache.get(bytes);
  if (regex != null && regex.getEncoding() == enc && regex.getOptions() == options.toJoniOptions()) return regex;
  ByteList quoted = quote(bytes, enc);
  regex = makeRegexp(runtime, quoted, options, enc);
  regex.setUserObject(quoted);
  cache.put(bytes, regex);
  return regex;
}

代码示例来源:origin: org.jruby/jruby-complete

public final Regex preparePattern(RubyString str) {
  // checkEncoding does `check();` no need to here
  Encoding enc = prepareEncoding(str, true);
  if (enc == pattern.getEncoding()) return pattern;
  return getPreprocessedRegexpFromCache(getRuntime(), this.str, enc, options, RegexpSupport.ErrorMode.PREPROCESS);
}

代码示例来源:origin: org.jruby/jruby-core

public final Regex preparePattern(RubyString str) {
  // checkEncoding does `check();` no need to here
  Encoding enc = prepareEncoding(str, true);
  if (enc == pattern.getEncoding()) return pattern;
  return getPreprocessedRegexpFromCache(getRuntime(), this.str, enc, options, RegexpSupport.ErrorMode.PREPROCESS);
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

static Regex getQuotedRegexpFromCache19(Ruby runtime, ByteList bytes, RegexpOptions options, boolean asciiOnly) {
  Map<ByteList, Regex> cache = quotedPatternCache.get();
  Regex regex = cache.get(bytes);
  Encoding enc = asciiOnly ? USASCIIEncoding.INSTANCE : bytes.getEncoding();
  if (regex != null && regex.getEncoding() == enc && regex.getOptions() == options.toJoniOptions()) return regex;
  ByteList quoted = quote19(bytes, asciiOnly);
  regex = makeRegexp(runtime, quoted, options, quoted.getEncoding());
  regex.setUserObject(quoted);
  cache.put(bytes, regex);
  return regex;
}

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

public final Regex preparePattern(RubyString str) {
  check();
  Encoding enc = checkEncoding(str, true);
  if (enc == pattern.getEncoding()) return pattern;
  return getPreprocessedRegexpFromCache(getRuntime(), this.str, enc, options, ErrorMode.PREPROCESS);
}

代码示例来源:origin: org.jruby/jruby-complete

@JRubyMethod
public IRubyObject encoding(ThreadContext context) {
  Encoding enc = (pattern == null) ? str.getEncoding() : pattern.getEncoding();
  return context.runtime.getEncodingService().getEncoding(enc);
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

@JRubyMethod(name = "encoding", compat = CompatVersion.RUBY1_9)
public IRubyObject encoding(ThreadContext context) {
  Encoding enc = (pattern == null) ? str.getEncoding() : pattern.getEncoding();
  return context.runtime.getEncodingService().getEncoding(enc);
}

代码示例来源:origin: org.jruby/jruby-core

@JRubyMethod
public IRubyObject encoding(ThreadContext context) {
  Encoding enc = (pattern == null) ? str.getEncoding() : pattern.getEncoding();
  return context.runtime.getEncodingService().getEncoding(enc);
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

private Encoding getEncodingForKCodeDefault(Ruby runtime, Regex pattern, IRubyObject pat) {
  Encoding enc = pattern.getEncoding();
  if (enc != runtime.getKCode().getEncoding() && pat instanceof RubyRegexp) {
    RubyRegexp regexp = (RubyRegexp) pat;
    if (regexp.isKCodeDefault()) {
      enc = runtime.getKCode().getEncoding();
    }
  }
  return enc;
}

代码示例来源:origin: org.jruby/jruby-complete

public static Regex getRegexpFromCache(Ruby runtime, ByteList bytes, Encoding enc, RegexpOptions options) {
  Regex regex = patternCache.get(bytes);
  if (regex != null && regex.getEncoding() == enc && regex.getOptions() == options.toJoniOptions()) return regex;
  regex = makeRegexp(runtime, bytes, options, enc);
  regex.setUserObject(bytes);
  patternCache.put(bytes, regex);
  return regex;
}

代码示例来源:origin: org.jruby/jruby-core

public static Regex getRegexpFromCache(Ruby runtime, ByteList bytes, Encoding enc, RegexpOptions options) {
  Regex regex = patternCache.get(bytes);
  if (regex != null && regex.getEncoding() == enc && regex.getOptions() == options.toJoniOptions()) return regex;
  regex = makeRegexp(runtime, bytes, options, enc);
  regex.setUserObject(bytes);
  patternCache.put(bytes, regex);
  return regex;
}

代码示例来源:origin: org.jruby/jruby-complete

private static Regex getPreprocessedRegexpFromCache(Ruby runtime, ByteList bytes, Encoding enc, RegexpOptions options, RegexpSupport.ErrorMode mode) {
  Regex regex = preprocessedPatternCache.get(bytes);
  if (regex != null && regex.getEncoding() == enc && regex.getOptions() == options.toJoniOptions()) return regex;
  ByteList preprocessed = RegexpSupport.preprocess(runtime, bytes, enc, new Encoding[]{null}, RegexpSupport.ErrorMode.RAISE);
  regex = makeRegexp(runtime, preprocessed, options, enc);
  regex.setUserObject(preprocessed);
  preprocessedPatternCache.put(bytes, regex);
  return regex;
}

代码示例来源:origin: org.jruby/jruby-core

private static Regex getPreprocessedRegexpFromCache(Ruby runtime, ByteList bytes, Encoding enc, RegexpOptions options, RegexpSupport.ErrorMode mode) {
  Regex regex = preprocessedPatternCache.get(bytes);
  if (regex != null && regex.getEncoding() == enc && regex.getOptions() == options.toJoniOptions()) return regex;
  ByteList preprocessed = RegexpSupport.preprocess(runtime, bytes, enc, new Encoding[]{null}, RegexpSupport.ErrorMode.RAISE);
  regex = makeRegexp(runtime, preprocessed, options, enc);
  regex.setUserObject(preprocessed);
  preprocessedPatternCache.put(bytes, regex);
  return regex;
}

代码示例来源:origin: org.jruby/jruby-complete

/** rb_reg_source
 *
 */
@JRubyMethod
public IRubyObject source() {
  check();
  Encoding enc = (pattern == null) ? str.getEncoding() : pattern.getEncoding();
  ByteList newStr = str.dup();
  newStr.setEncoding(enc);
  return RubyString.newString(getRuntime(), newStr).infectBy(this);
}

代码示例来源:origin: org.jruby/jruby-core

/** rb_reg_source
 *
 */
@JRubyMethod
public IRubyObject source() {
  check();
  Encoding enc = (pattern == null) ? str.getEncoding() : pattern.getEncoding();
  ByteList newStr = str.dup();
  newStr.setEncoding(enc);
  return RubyString.newString(getRuntime(), newStr).infectBy(this);
}

代码示例来源:origin: org.jruby/jruby-complete

static Regex getQuotedRegexpFromCache(Ruby runtime, RubyString str, RegexpOptions options) {
  final ByteList bytes = str.getByteList();
  Regex regex = quotedPatternCache.get(bytes);
  Encoding enc = str.isAsciiOnly() ? USASCIIEncoding.INSTANCE : bytes.getEncoding();
  if (regex != null && regex.getEncoding() == enc && regex.getOptions() == options.toJoniOptions()) return regex;
  final ByteList quoted = quote(str);
  regex = makeRegexp(runtime, quoted, options, quoted.getEncoding());
  regex.setUserObject(quoted);
  quotedPatternCache.put(bytes, regex);
  return regex;
}

代码示例来源:origin: org.jruby/jruby-core

static Regex getQuotedRegexpFromCache(Ruby runtime, RubyString str, RegexpOptions options) {
  final ByteList bytes = str.getByteList();
  Regex regex = quotedPatternCache.get(bytes);
  Encoding enc = str.isAsciiOnly() ? USASCIIEncoding.INSTANCE : bytes.getEncoding();
  if (regex != null && regex.getEncoding() == enc && regex.getOptions() == options.toJoniOptions()) return regex;
  final ByteList quoted = quote(str);
  regex = makeRegexp(runtime, quoted, options, quoted.getEncoding());
  regex.setUserObject(quoted);
  quotedPatternCache.put(bytes, regex);
  return regex;
}

相关文章