org.jruby.RubyHash.getRuntime()方法的使用及代码示例

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

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

RubyHash.getRuntime介绍

暂无

代码示例

代码示例来源:origin: org.asciidoctor/asciidoctorj

private IRubyObject convertJavaValue(Object value) {
  if (value == null) {
    return null;
  } else if (value instanceof String && ((String) value).startsWith(":")) {
    return rubyHash.getRuntime().getSymbolTable().getSymbol(((String) value).substring(1));
  } else {
    return JavaEmbedUtils.javaToRuby(rubyHash.getRuntime(), value);
  }
}

代码示例来源:origin: asciidoctor/asciidoctorj

private IRubyObject convertJavaValue(Object value) {
  if (value == null) {
    return null;
  } else if (value instanceof String && ((String) value).startsWith(":")) {
    return rubyHash.getRuntime().getSymbolTable().getSymbol(((String) value).substring(1));
  } else {
    return JavaEmbedUtils.javaToRuby(rubyHash.getRuntime(), value);
  }
}

代码示例来源:origin: asciidoctor/asciidoctorj

private IRubyObject convertJavaValue(Object value) {
  if (value == null) {
    return null;
  } else if (value instanceof String && ((String) value).startsWith(":")) {
    return rubyHash.getRuntime().getSymbolTable().getSymbol(((String) value).substring(1));
  } else {
    return JavaEmbedUtils.javaToRuby(rubyHash.getRuntime(), value);
  }
}

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

@Override
  public boolean remove(RubyHash hash, Object o) {
    IRubyObject value = JavaUtil.convertJavaToUsableRubyObject(hash.getRuntime(), o);
    IRubyObject key = hash.internalIndex(hash.getRuntime().getCurrentContext(), value);
    if (key == null) return false;
    return hash.internalDelete(key) != NO_ENTRY;
  }
};

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

/** rb_hash_empty_p
 *
 */
@JRubyMethod(name = "empty?")
public RubyBoolean empty_p() {
  return size == 0 ? getRuntime().getTrue() : getRuntime().getFalse();
}

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

@Deprecated
public final void visitAll(Visitor visitor) {
  // use -1 to disable concurrency checks
  visitLimited(getRuntime().getCurrentContext(), visitor, -1, null);
}

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

@Override
public Object next() {
  advance(true);
  if (entry == head) {
    peeking = true; // remain where we are
    throw new NoSuchElementException();
  }
  return view.convertEntry(getRuntime(), entry);
}

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

/** rb_hash_size
 *
 */
@JRubyMethod(name = {"size", "length"})
public RubyFixnum rb_size() {
  return getRuntime().newFixnum(size);
}

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

/** rb_hash_reject_bang
 *
 */
public IRubyObject reject_bangInternal(ThreadContext context, Block block) {
  int n = size;
  delete_if(context, block);
  if (n == size) return getRuntime().getNil();
  return this;
}

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

/** rb_hash_hash
 *
 */
@Override
public RubyFixnum hash() {
  return hash(getRuntime().getCurrentContext());
}

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

@Deprecated
public static void checkExecOptions(IRubyObject options) {
  if (options instanceof RubyHash) {
    RubyHash opts = (RubyHash) options;
    ThreadContext context = opts.getRuntime().getCurrentContext();
    checkValidSpawnOptions(context, opts);
    checkUnsupportedOptions(context, opts, UNSUPPORTED_SPAWN_OPTIONS, "unsupported exec option");
  }
}

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

@Deprecated
public static void checkSpawnOptions(IRubyObject options) {
  if (options instanceof RubyHash) {
    RubyHash opts = (RubyHash) options;
    ThreadContext context = opts.getRuntime().getCurrentContext();
    checkValidSpawnOptions(context, opts);
    checkUnsupportedOptions(context, opts, UNSUPPORTED_SPAWN_OPTIONS, "unsupported spawn option");
  }
}

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

/** rb_hash_invert
 *
 */
@JRubyMethod(name = "invert")
public RubyHash invert(final ThreadContext context) {
  final RubyHash result = newHash(getRuntime());
  visitAll(context, InvertVisitor, result);
  return result;
}

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

@Override
public Object get(Object key) {
  IRubyObject gotten = internalGet(JavaUtil.convertJavaToUsableRubyObject(getRuntime(), key));
  return gotten == null ? null : gotten.toJava(Object.class);
}

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

@Override
public boolean equals(Object other) {
  if (!(other instanceof RubyHash)) return false;
  if (this == other) return true;
  return op_equal(getRuntime().getCurrentContext(), (RubyHash)other).isTrue();
}

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

@Override
public boolean equals(Object other) {
  if (!(other instanceof RubyHash)) return false;
  if (this == other) return true;
  return op_equal(getRuntime().getCurrentContext(), (RubyHash)other).isTrue();
}

代码示例来源:origin: asciidoctor/asciidoctorj

@Override
public boolean containsKey(Object key) {
  if (!(key instanceof String)) {
    return false;
  }
  RubySymbol symbol = rubyHash.getRuntime().getSymbolTable().getSymbol((String) key);
  return rubyHash.containsKey(symbol);
}

代码示例来源:origin: asciidoctor/asciidoctorj

@Override
public Object remove(Object key) {
  if (!(key instanceof String)) {
    return null;
  }
  Object oldValue = get(key);
  RubySymbol symbol = rubyHash.getRuntime().getSymbolTable().getSymbol((String) key);
  rubyHash.remove(symbol);
  return convertRubyValue(oldValue);
}

代码示例来源:origin: asciidoctor/asciidoctorj

@Override
public Object put(String key, Object value) {
  Object oldValue = get(key);
  RubySymbol symbol = rubyHash.getRuntime().getSymbolTable().getSymbol(key);
  rubyHash.put(symbol, convertJavaValue(value));
  return oldValue;
}

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

public static void marshalTo(final RubyHash hash, final MarshalStream output) throws IOException {
  output.registerLinkTarget(hash);
  int hashSize = hash.size;
  output.writeInt(hashSize);
  try {
    hash.visitLimited(hash.getRuntime().getCurrentContext(), MarshalDumpVisitor, hashSize, output);
  } catch (VisitorIOException e) {
    throw (IOException)e.getCause();
  }
  if (hash.ifNone != UNDEF) output.dumpObject(hash.ifNone);
}

相关文章

微信公众号

最新文章

更多

RubyHash类方法