org.jruby.Ruby.newEncodingCompatibilityError()方法的使用及代码示例

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

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

Ruby.newEncodingCompatibilityError介绍

暂无

代码示例

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

private static void encodingMatchError(Ruby runtime, Regex pattern, Encoding strEnc) {
  throw runtime.newEncodingCompatibilityError("incompatible encoding regexp match (" +
      pattern.getEncoding() + " regexp with " + strEnc + " string)");
}

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

private Encoding checkDummyEncoding() {
  Encoding enc = value.getEncoding();
  if (enc.isDummy()) throw getRuntime().newEncodingCompatibilityError(
      "incompatible encoding with this operation: " + enc);
  return enc;
}

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

private Encoding checkDummyEncoding() {
  Encoding enc = value.getEncoding();
  if (enc.isDummy()) throw getRuntime().newEncodingCompatibilityError(
      "incompatible encoding with this operation: " + enc);
  return enc;
}

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

private Encoding checkDummyEncoding() {
  Encoding enc = value.getEncoding();
  if (enc.isDummy()) throw getRuntime().newEncodingCompatibilityError(
      "incompatible encoding with this operation: " + enc);
  return enc;
}

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

private Encoding checkDummyEncoding() {
  Encoding enc = value.getEncoding();
  if (enc.isDummy()) throw getRuntime().newEncodingCompatibilityError(
      "incompatible encoding with this operation: " + enc);
  return enc;
}

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

final Encoding checkEncoding(EncodingCapable other) {
  Encoding enc = isCompatibleWith(other);
  if (enc == null) throw getRuntime().newEncodingCompatibilityError("incompatible character encodings: " +
              value.getEncoding() + " and " + other.getEncoding());
  return enc;
}

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

final Encoding checkEncoding(EncodingCapable other) {
  Encoding enc = isCompatibleWith(other);
  if (enc == null) throw getRuntime().newEncodingCompatibilityError("incompatible character encodings: " +
              value.getEncoding() + " and " + other.getEncoding());
  return enc;
}

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

public final Encoding checkEncoding(RubyString other) {
  Encoding enc = isCompatibleWith(other);
  if (enc == null) throw getRuntime().newEncodingCompatibilityError("incompatible character encodings: " + 
              value.getEncoding() + " and " + other.value.getEncoding());
  return enc;
}

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

public final Encoding checkEncoding(RubyString other) {
  Encoding enc = isCompatibleWith(other);
  if (enc == null) throw getRuntime().newEncodingCompatibilityError("incompatible character encodings: " + 
              value.getEncoding() + " and " + other.value.getEncoding());
  return enc;
}

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

@Override
public final Encoding checkEncoding(CodeRangeable other) {
  Encoding enc = StringSupport.areCompatible(this, other);
  if (enc == null) throw getRuntime().newEncodingCompatibilityError("incompatible character encodings: " +
      value.getEncoding() + " and " + other.getByteList().getEncoding());
  return enc;
}

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

@JRubyMethod(name = "oct", compat = RUBY1_9)
public IRubyObject oct19(ThreadContext context) {
  if (!value.getEncoding().isAsciiCompatible()) {
    throw context.runtime.newEncodingCompatibilityError("ASCII incompatible encoding: " + value.getEncoding());
  }
  return oct(context);
}

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

@JRubyMethod(name = "hex", compat = RUBY1_9)
public IRubyObject hex19(ThreadContext context) {
  if (!value.getEncoding().isAsciiCompatible()) {
    throw context.runtime.newEncodingCompatibilityError("ASCII incompatible encoding: " + value.getEncoding());
  }
  return stringToInum19(16, false);
}

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

@JRubyMethod(name = "oct", compat = RUBY1_9)
public IRubyObject oct19(ThreadContext context) {
  if (!value.getEncoding().isAsciiCompatible()) {
    throw context.runtime.newEncodingCompatibilityError("ASCII incompatible encoding: " + value.getEncoding());
  }
  return oct(context);
}

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

@Override
public final Encoding checkEncoding(CodeRangeable other) {
  Encoding enc = StringSupport.areCompatible(this, other);
  if (enc == null) throw getRuntime().newEncodingCompatibilityError("incompatible character encodings: " +
      value.getEncoding() + " and " + other.getByteList().getEncoding());
  return enc;
}

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

/** rb_str_to_inum
 *
 */
public IRubyObject stringToInum(int base, boolean badcheck) {
  final ByteList str = this.value;
  if (!str.getEncoding().isAsciiCompatible()) {
    throw getRuntime().newEncodingCompatibilityError("ASCII incompatible encoding: " + str.getEncoding());
  }
  return ConvertBytes.byteListToInum(getRuntime(), str, base, badcheck);
}

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

/** rb_str_to_inum
 *
 */
public IRubyObject stringToInum(int base, boolean badcheck) {
  final ByteList str = this.value;
  if (!str.getEncoding().isAsciiCompatible()) {
    throw getRuntime().newEncodingCompatibilityError("ASCII incompatible encoding: " + str.getEncoding());
  }
  return ConvertBytes.byteListToInum(getRuntime(), str, base, badcheck);
}

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

private Encoding subBangVerifyEncoding(ThreadContext context, final RubyString repl, final int beg, final int end) {
  final ByteList value = this.value;
  byte[] bytes = value.getUnsafeBytes();
  int p = value.getBegin();
  int len = value.getRealSize();
  Encoding strEnc = value.getEncoding();
  if (codeRangeScan(strEnc, bytes, p, beg) != CR_7BIT ||
    codeRangeScan(strEnc, bytes, p + end, len - end) != CR_7BIT) {
    throw context.runtime.newEncodingCompatibilityError(
        "incompatible character encodings " + strEnc + " and " + repl.value.getEncoding());
  }
  return repl.value.getEncoding();
}

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

private Encoding subBangVerifyEncoding(ThreadContext context, final RubyString repl, final int beg, final int end) {
  final ByteList value = this.value;
  byte[] bytes = value.getUnsafeBytes();
  int p = value.getBegin();
  int len = value.getRealSize();
  Encoding strEnc = value.getEncoding();
  if (codeRangeScan(strEnc, bytes, p, beg) != CR_7BIT ||
    codeRangeScan(strEnc, bytes, p + end, len - end) != CR_7BIT) {
    throw context.runtime.newEncodingCompatibilityError(
        "incompatible character encodings " + strEnc + " and " + repl.value.getEncoding());
  }
  return repl.value.getEncoding();
}

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

@JRubyMethod
public static IRubyObject warn(ThreadContext context, IRubyObject recv, IRubyObject arg) {
  Ruby runtime = context.runtime;
  if (!runtime.warningsEnabled()) return context.nil;
  TypeConverter.checkType(context, arg, runtime.getString());
  RubyString str = (RubyString) arg;
  if (!str.getEncoding().isAsciiCompatible()) {
    throw runtime.newEncodingCompatibilityError("ASCII incompatible encoding: " + str.getEncoding());
  }
  writeWarningToError(runtime.getCurrentContext(), str);
  return context.nil;
}

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

@JRubyMethod
public static IRubyObject warn(ThreadContext context, IRubyObject recv, IRubyObject arg) {
  Ruby runtime = context.runtime;
  if (!runtime.warningsEnabled()) return context.nil;
  TypeConverter.checkType(context, arg, runtime.getString());
  RubyString str = (RubyString) arg;
  if (!str.getEncoding().isAsciiCompatible()) {
    throw runtime.newEncodingCompatibilityError("ASCII incompatible encoding: " + str.getEncoding());
  }
  writeWarningToError(runtime.getCurrentContext(), str);
  return context.nil;
}

相关文章

微信公众号

最新文章

更多

Ruby类方法