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

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

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

Ruby.getHash介绍

暂无

代码示例

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

public RubyHash(Ruby runtime, IRubyObject defaultValue) {
  super(runtime, runtime.getHash());
  this.ifNone = defaultValue;
  allocFirst();
}

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

public RubyHash(Ruby runtime, IRubyObject defaultValue) {
  super(runtime, runtime.getHash());
  this.ifNone = defaultValue;
  allocFirst();
}

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

public RubyHash(Ruby runtime, IRubyObject defaultValue, int buckets) {
  super(runtime, runtime.getHash());
  this.ifNone = defaultValue;
  allocFirst(buckets);
}

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

public RubyHash(Ruby runtime, IRubyObject defaultValue) {
  super(runtime, runtime.getHash());
  this.ifNone = defaultValue;
  allocFirst();
}

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

public RubyHash(Ruby runtime, IRubyObject defaultValue, int buckets) {
  super(runtime, runtime.getHash());
  this.ifNone = defaultValue;
  if (buckets <= 0) buckets = 1; // FIXME: this hash implementation cannot deal with no buckets so we will add a single one (this constructor will go away once open addressing is added back).
  allocFirst(buckets);
}

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

public static IRubyObject checkHashType(Ruby runtime, IRubyObject obj) {
  if (obj instanceof RubyHash) return obj;
  return TypeConverter.convertToTypeWithCheck(obj, runtime.getHash(), "to_hash");
}

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

public RubyHash(Ruby runtime, IRubyObject defaultValue, int buckets) {
  super(runtime, runtime.getHash());
  this.ifNone = defaultValue;
  if (buckets <= 0) buckets = 1; // FIXME: this hash implementation cannot deal with no buckets so we will add a single one (this constructor will go away once open addressing is added back).
  allocFirst(buckets);
}

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

public RubyHash(Ruby runtime, Map valueMap, IRubyObject defaultValue) {
  super(runtime, runtime.getHash());
  this.ifNone = defaultValue;
  allocFirst();
  for (Iterator iter = valueMap.entrySet().iterator();iter.hasNext();) {
    Map.Entry e = (Map.Entry)iter.next();
    internalPut((IRubyObject)e.getKey(), (IRubyObject)e.getValue());
  }
}

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

public RubyHash(Ruby runtime, Map valueMap, IRubyObject defaultValue) {
  super(runtime, runtime.getHash());
  this.ifNone = defaultValue;
  allocFirst();
  for (Iterator iter = valueMap.entrySet().iterator();iter.hasNext();) {
    Map.Entry e = (Map.Entry)iter.next();
    internalPut((IRubyObject)e.getKey(), (IRubyObject)e.getValue());
  }
}

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

/**
 * Tries to convert this object to a Ruby Hash using the "to_hash"
 * method.
 */
public RubyHash convertToHash() {
  return (RubyHash)TypeConverter.convertToType(this, getRuntime().getHash(), "to_hash");
}

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

private static IRubyObject toHash(ThreadContext context, IRubyObject lastArg) {
  if (lastArg instanceof RubyHash) return (RubyHash) lastArg;
  if (lastArg.respondsTo("to_hash")) {
    lastArg = lastArg.callMethod(context, "to_hash");
    if (lastArg == context.nil) return lastArg;
    TypeConverter.checkType(context, lastArg, context.runtime.getHash());
    return (RubyHash) lastArg;
  }
  return null;
}

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

private static IRubyObject toHash(ThreadContext context, IRubyObject lastArg) {
  if (lastArg instanceof RubyHash) return (RubyHash) lastArg;
  if (lastArg.respondsTo("to_hash")) {
    lastArg = lastArg.callMethod(context, "to_hash");
    if (lastArg == context.nil) return lastArg;
    TypeConverter.checkType(context, lastArg, context.runtime.getHash());
    return (RubyHash) lastArg;
  }
  return null;
}

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

@JRubyMethod
public RubyHash to_h(ThreadContext context) {
  final Ruby runtime = context.runtime;
  return getType() == runtime.getHash() ? this : newHash(runtime).replace(context, this);
}

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

/**
 * Tries to convert this object to a Ruby Hash using the "to_hash" method.
 * @return hash representation of this
 */
@Override
public RubyHash convertToHash() {
  Ruby runtime = getRuntime();
  ThreadContext context = runtime.getCurrentContext();
  BasicObjectSites sites = sites(context);
  return (RubyHash) TypeConverter.convertToType(context, this, runtime.getHash(), sites.to_hash_checked);
}

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

private String formatMessage(final IRubyObject msg) {
 if (getRuntime().getString().equals(msg.getType())) {
  return msg.asJavaString();
 } else if (getRuntime().getHash().equals(msg.getType())) {
  final RubyHash hash = (RubyHash) msg;
  return Objects.toString(hash.get(getRuntime().newSymbol(LOG_PROPERTY_TEXT)));
 }
 throw new IllegalArgumentException(Objects.toString(msg));
}

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

private String formatMessage(final IRubyObject msg) {
 if (getRuntime().getString().equals(msg.getType())) {
  return msg.asJavaString();
 } else if (getRuntime().getHash().equals(msg.getType())) {
  final RubyHash hash = (RubyHash) msg;
  return Objects.toString(hash.get(getRuntime().newSymbol(LOG_PROPERTY_TEXT)));
 }
 throw new IllegalArgumentException(Objects.toString(msg));
}

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

private Cursor getSourceLocation(IRubyObject msg) {
  if (getRuntime().getHash().equals(msg.getType())) {
   final RubyHash hash = (RubyHash) msg;
   final Object sourceLocation = hash.get(getRuntime().newSymbol(LOG_PROPERTY_SOURCE_LOCATION));
   return new CursorImpl((IRubyObject) sourceLocation);
  }
  return null;
 }
}

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

private Cursor getSourceLocation(IRubyObject msg) {
  if (getRuntime().getHash().equals(msg.getType())) {
   final RubyHash hash = (RubyHash) msg;
   final Object sourceLocation = hash.get(getRuntime().newSymbol(LOG_PROPERTY_SOURCE_LOCATION));
   return new CursorImpl((IRubyObject) sourceLocation);
  }
  return null;
 }
}

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

@JRubyMethod(name = "sub!", reads = BACKREF, writes = BACKREF)
public IRubyObject sub_bang(ThreadContext context, IRubyObject arg0, IRubyObject arg1, Block block) {
  Ruby runtime = context.runtime;
  IRubyObject hash = TypeConverter.convertToTypeWithCheck(context, arg1, runtime.getHash(), sites(context).to_hash_checked);
  frozenCheck();
  if (hash == context.nil) {
    return subBangNoIter(context, asRegexpArg(runtime, arg0), arg1.convertToString());
  }
  return subBangIter(context, asRegexpArg(runtime, arg0), (RubyHash) hash, block);
}

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

@JRubyMethod(name = "sub!", reads = BACKREF, writes = BACKREF)
public IRubyObject sub_bang(ThreadContext context, IRubyObject arg0, IRubyObject arg1, Block block) {
  Ruby runtime = context.runtime;
  IRubyObject hash = TypeConverter.convertToTypeWithCheck(context, arg1, runtime.getHash(), sites(context).to_hash_checked);
  frozenCheck();
  if (hash == context.nil) {
    return subBangNoIter(context, asRegexpArg(runtime, arg0), arg1.convertToString());
  }
  return subBangIter(context, asRegexpArg(runtime, arg0), (RubyHash) hash, block);
}

相关文章

Ruby类方法