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

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

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

Ruby.newIndexError介绍

暂无

代码示例

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

  1. private int subpatSetCheck(Ruby runtime, int nth, Region regs) {
  2. int numRegs = regs == null ? 1 : regs.numRegs;
  3. if (nth < numRegs) {
  4. if (nth < 0) {
  5. if (-nth < numRegs) return nth + numRegs;
  6. } else {
  7. return nth;
  8. }
  9. }
  10. throw runtime.newIndexError("index " + nth + " out of regexp");
  11. }

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

  1. private int subpatSetCheck(Ruby runtime, int nth, Region regs) {
  2. int numRegs = regs == null ? 1 : regs.numRegs;
  3. if (nth < numRegs) {
  4. if (nth < 0) {
  5. if (-nth < numRegs) return nth + numRegs;
  6. } else {
  7. return nth;
  8. }
  9. }
  10. throw runtime.newIndexError("index " + nth + " out of regexp");
  11. }

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

  1. public static final void checkBounds(Ruby runtime, long size, long off, long len) {
  2. if ((off | len | (off + len) | (size - (off + len))) < 0) {
  3. throw runtime.newIndexError("Memory access offset="
  4. + off + " size=" + len + " is out of bounds");
  5. }
  6. }

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

  1. private int endCommon(Ruby runtime, int i) {
  2. check();
  3. if (i < 0 || (regs == null ? 1 : regs.numRegs) <= i) throw runtime.newIndexError("index " + i + " out of matches");
  4. return regs == null ? end : regs.end[i];
  5. }

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

  1. private int endCommon(Ruby runtime, int i) {
  2. check();
  3. if (i < 0 || (regs == null ? 1 : regs.numRegs) <= i) throw runtime.newIndexError("index " + i + " out of matches");
  4. return regs == null ? end : regs.end[i];
  5. }

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

  1. final IRubyObject aref(int idx) {
  2. int newIdx = idx < 0 ? values.length + idx : idx;
  3. if (newIdx < 0) {
  4. throw getRuntime().newIndexError("offset " + idx + " too small for struct(size:" + values.length + ")");
  5. }
  6. if (newIdx >= values.length) {
  7. throw getRuntime().newIndexError("offset " + idx + " too large for struct(size:" + values.length + ")");
  8. }
  9. return values[newIdx];
  10. }

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

  1. private IRubyObject aset(int idx, IRubyObject value) {
  2. int newIdx = idx < 0 ? values.length + idx : idx;
  3. if (newIdx < 0) {
  4. throw getRuntime().newIndexError("offset " + idx + " too small for struct(size:" + values.length + ")");
  5. } else if (newIdx >= values.length) {
  6. throw getRuntime().newIndexError("offset " + idx + " too large for struct(size:" + values.length + ")");
  7. }
  8. modify();
  9. return values[newIdx] = value;
  10. }

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

  1. private IRubyObject aset(int idx, IRubyObject value) {
  2. int newIdx = idx < 0 ? values.length + idx : idx;
  3. if (newIdx < 0) {
  4. throw getRuntime().newIndexError("offset " + idx + " too small for struct(size:" + values.length + ")");
  5. } else if (newIdx >= values.length) {
  6. throw getRuntime().newIndexError("offset " + idx + " too large for struct(size:" + values.length + ")");
  7. }
  8. modify();
  9. return values[newIdx] = value;
  10. }

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

  1. private void insert(long pos, IRubyObject val) {
  2. if (pos == -1) pos = realLength;
  3. else if (pos < 0) {
  4. long minpos = -realLength - 1;
  5. if (pos < minpos) {
  6. throw getRuntime().newIndexError("index " + pos + " too small for array; minimum: " + minpos);
  7. }
  8. pos++;
  9. }
  10. spliceOne(pos, val); // rb_ary_new4
  11. }

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

  1. @JRubyMethod(name = "[]")
  2. public final IRubyObject aref(ThreadContext context, IRubyObject indexArg) {
  3. final int index = RubyNumeric.num2int(indexArg);
  4. final int offset = index * typeSize;
  5. if (offset >= size) {
  6. throw context.runtime.newIndexError(String.format("Index %d out of range", index));
  7. }
  8. return slice(context.runtime, offset);
  9. }

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

  1. @JRubyMethod(name = "[]")
  2. public final IRubyObject aref(ThreadContext context, IRubyObject indexArg) {
  3. final int index = RubyNumeric.num2int(indexArg);
  4. final int offset = index * typeSize;
  5. if (offset >= size) {
  6. throw context.runtime.newIndexError(String.format("Index %d out of range", index));
  7. }
  8. return slice(context.runtime, offset);
  9. }

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

  1. @JRubyMethod(name = "[]")
  2. public final IRubyObject aref(ThreadContext context, IRubyObject indexArg) {
  3. final int index = RubyNumeric.num2int(indexArg);
  4. final int offset = index * typeSize;
  5. if (offset >= size) {
  6. throw context.runtime.newIndexError(String.format("Index %d out of range", index));
  7. }
  8. return slice(context.runtime, offset);
  9. }

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

  1. public int getNameToBackrefNumber(String name) {
  2. try {
  3. byte[] bytes = name.getBytes();
  4. return getPattern().nameToBackrefNumber(bytes, 0, bytes.length, regs);
  5. } catch (JOniException je) {
  6. throw getRuntime().newIndexError(je.getMessage());
  7. }
  8. }

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

  1. public int getNameToBackrefNumber(String name) {
  2. try {
  3. byte[] bytes = name.getBytes();
  4. return getPattern().nameToBackrefNumber(bytes, 0, bytes.length, regs);
  5. } catch (JOniException je) {
  6. throw getRuntime().newIndexError(je.getMessage());
  7. }
  8. }

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

  1. private static int nameToBackrefNumber(Ruby runtime, Regex pattern, Region regs, ByteListHolder str) {
  2. if (pattern == null) {
  3. throw runtime.newIndexError("undefined group name reference: " + str);
  4. }
  5. ByteList value = str.getByteList();
  6. try {
  7. return pattern.nameToBackrefNumber(value.getUnsafeBytes(), value.getBegin(), value.getBegin() + value.getRealSize(), regs);
  8. } catch (JOniException je) {
  9. throw runtime.newIndexError(je.getMessage());
  10. }
  11. }

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

  1. private static int nameToBackrefNumber(Ruby runtime, Regex pattern, Region regs, ByteListHolder str) {
  2. if (pattern == null) {
  3. throw runtime.newIndexError("undefined group name reference: " + str);
  4. }
  5. ByteList value = str.getByteList();
  6. try {
  7. return pattern.nameToBackrefNumber(value.getUnsafeBytes(), value.getBegin(), value.getBegin() + value.getRealSize(), regs);
  8. } catch (JOniException je) {
  9. throw runtime.newIndexError(je.getMessage());
  10. }
  11. }

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

  1. private long getOffset(int index) {
  2. if (index < 0 || (index >= arrayType.length() && arrayType.length() > 0)) {
  3. throw getRuntime().newIndexError("index " + index + " out of bounds");
  4. }
  5. return index * (long) arrayType.getComponentType().getNativeSize();
  6. }

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

  1. private final long getOffset(int index) {
  2. if (index < 0 || (index >= arrayType.length() && arrayType.length() > 0)) {
  3. throw getRuntime().newIndexError("index " + index + " out of bounds");
  4. }
  5. return (long) (index * arrayType.getComponentType().getNativeSize());
  6. }

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

  1. private final long getOffset(int index) {
  2. if (index < 0 || (index >= arrayType.length() && arrayType.length() > 0)) {
  3. throw getRuntime().newIndexError("index " + index + " out of bounds");
  4. }
  5. return (long) (index * arrayType.getComponentType().getNativeSize());
  6. }

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

  1. private int nameToBackrefNumber(RubyString str) {
  2. ByteList value = str.getByteList();
  3. try {
  4. return pattern.nameToBackrefNumber(value.getUnsafeBytes(), value.getBegin(), value.getBegin() + value.getRealSize(), regs);
  5. } catch (JOniException je) {
  6. throw getRuntime().newIndexError(je.getMessage());
  7. }
  8. }

相关文章

Ruby类方法