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

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

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

RubyHash.has_key_p介绍

[英]rb_hash_has_key
[中]rb_hash_有密钥

代码示例

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

RubyHash env = (RubyHash) runtime.getObject().getConstant("ENV");
RubyString env_home = runtime.newString("HOME");
if (env.has_key_p(env_home).isFalse()) {
  return null;

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

RubyHash env = (RubyHash) runtime.getObject().getConstant("ENV");
RubyString env_home = runtime.newString("HOME");
if (env.has_key_p(env_home).isFalse()) {
  return null;

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

@JRubyMethod(name = "find")
public IRubyObject find(final ThreadContext context, IRubyObject query){
  if (taggedEnums.has_key_p(context, query).isTrue()){
    return taggedEnums.fastARef(query);
  }
  for (int i = 0; i < allEnums.getLength(); i++){
    IRubyObject item = (IRubyObject)allEnums.entry(i);
    if (((RubyArray)item.callMethod(context, "symbols")).include_p(context, query).isTrue()){
      return item;
    }
  }
  return context.nil;
}

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

@JRubyMethod(name = "find")
public IRubyObject find(final ThreadContext context, IRubyObject query){
  if (taggedEnums.has_key_p(context, query).isTrue()){
    return taggedEnums.fastARef(query);
  }
  for (int i = 0; i < allEnums.getLength(); i++){
    IRubyObject item = (IRubyObject)allEnums.entry(i);
    if (((RubyArray)item.callMethod(context, "symbols")).include_p(context, query).isTrue()){
      return item;
    }
  }
  return context.nil;
}

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

@Deprecated
protected LoadServiceResource tryResourceFromHome(SearchState state, String baseName, SuffixType suffixType) throws RaiseException {
  LoadServiceResource foundResource = null;
  RubyHash env = (RubyHash) runtime.getObject().getConstant("ENV");
  RubyString env_home = runtime.newString("HOME");
  if (env.has_key_p(env_home).isFalse()) {
    return null;
  }
  String home = env.op_aref(runtime.getCurrentContext(), env_home).toString();
  String path = baseName.substring(2);
  for (String suffix : suffixType.getSuffixes()) {
    String namePlusSuffix = path + suffix;
    // check home directory; if file exists, retrieve URL and return resource
    try {
      JRubyFile file = JRubyFile.create(home, RubyFile.expandUserPath(runtime.getCurrentContext(), namePlusSuffix));
      debugLogTry("resourceFromHome", file.toString());
      if (file.isFile() && file.isAbsolute() && file.canRead()) {
        boolean absolute = true;
        state.setLoadName(file.getPath());
        foundResource = new LoadServiceResource(file, state.loadName, absolute);
        debugLogFound(foundResource);
        break;
      }
    } catch (IllegalArgumentException illArgEx) {
    } catch (SecurityException secEx) {
    }
  }
  return foundResource;
}

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

@Deprecated
protected LoadServiceResource tryResourceFromHome(SearchState state, String baseName, SuffixType suffixType) throws RaiseException {
  LoadServiceResource foundResource = null;
  RubyHash env = (RubyHash) runtime.getObject().getConstant("ENV");
  RubyString env_home = runtime.newString("HOME");
  if (env.has_key_p(env_home).isFalse()) {
    return null;
  }
  String home = env.op_aref(runtime.getCurrentContext(), env_home).toString();
  String path = baseName.substring(2);
  for (String suffix : suffixType.getSuffixes()) {
    String namePlusSuffix = path + suffix;
    // check home directory; if file exists, retrieve URL and return resource
    try {
      JRubyFile file = JRubyFile.create(home, RubyFile.expandUserPath(runtime.getCurrentContext(), namePlusSuffix));
      debugLogTry("resourceFromHome", file.toString());
      if (file.isFile() && file.isAbsolute() && file.canRead()) {
        boolean absolute = true;
        state.setLoadName(file.getPath());
        foundResource = new LoadServiceResource(file, state.loadName, absolute);
        debugLogFound(foundResource);
        break;
      }
    } catch (IllegalArgumentException illArgEx) {
    } catch (SecurityException secEx) {
    }
  }
  return foundResource;
}

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

protected LoadServiceResource tryResourceFromHome(SearchState state, String baseName, SuffixType suffixType) throws RaiseException {
  LoadServiceResource foundResource = null;
  RubyHash env = (RubyHash) runtime.getObject().getConstant("ENV");
  RubyString env_home = runtime.newString("HOME");
  if (env.has_key_p(env_home).isFalse()) {
    return null;
  }
  String home = env.op_aref(runtime.getCurrentContext(), env_home).toString();
  String path = baseName.substring(2);
  for (String suffix : suffixType.getSuffixes()) {
    String namePlusSuffix = path + suffix;
    // check home directory; if file exists, retrieve URL and return resource
    try {
      JRubyFile file = JRubyFile.create(home, RubyFile.expandUserPath(runtime.getCurrentContext(), namePlusSuffix));
      debugLogTry("resourceFromHome", file.toString());
      if (file.isFile() && file.isAbsolute() && file.canRead()) {
        boolean absolute = true;
        state.loadName = file.getPath();
        foundResource = new LoadServiceResource(file, state.loadName, absolute);
        debugLogFound(foundResource);
        break;
      }
    } catch (IllegalArgumentException illArgEx) {
    } catch (SecurityException secEx) {
    }
  }
  return foundResource;
}

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

RubySymbol sym = runtime.newSymbol(name);
if (keyValues.has_key_p(sym).isFalse()) {
  kasgn.interpret(runtime, context, self, Block.NULL_BLOCK);
} else {

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

protected LoadServiceResource tryResourceFromHome(SearchState state, String baseName, SuffixType suffixType) throws RaiseException {
  LoadServiceResource foundResource = null;
  RubyHash env = (RubyHash) runtime.getObject().getConstant("ENV");
  RubyString env_home = runtime.newString("HOME");
  if (env.has_key_p(env_home).isFalse()) {
    return null;
  }
  String home = env.op_aref(runtime.getCurrentContext(), env_home).toString();
  String path = baseName.substring(2);
  for (String suffix : suffixType.getSuffixes()) {
    String namePlusSuffix = path + suffix;
    // check home directory; if file exists, retrieve URL and return resource
    try {
      JRubyFile file = JRubyFile.create(home, RubyFile.expandUserPath(runtime.getCurrentContext(), namePlusSuffix));
      debugLogTry("resourceFromHome", file.toString());
      if (file.isFile() && file.isAbsolute() && file.canRead()) {
        boolean absolute = true;
        state.loadName = file.getPath();
        foundResource = new LoadServiceResource(file, state.loadName, absolute);
        debugLogFound(foundResource);
        break;
      }
    } catch (IllegalArgumentException illArgEx) {
    } catch (SecurityException secEx) {
    }
  }
  return foundResource;
}

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

RubyString env_rubylib = runtime.newString("RUBYLIB");
ThreadContext currentContext = runtime.getCurrentContext();
if (env.has_key_p(currentContext, env_rubylib).isTrue()) {
  String rubylib = env.op_aref(currentContext, env_rubylib).toString();
  String[] paths = rubylib.split(File.pathSeparator);

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

RubyString env_rubylib = runtime.newString("RUBYLIB");
ThreadContext currentContext = runtime.getCurrentContext();
if (env.has_key_p(currentContext, env_rubylib).isTrue()) {
  String rubylib = env.op_aref(currentContext, env_rubylib).toString();
  String[] paths = rubylib.split(File.pathSeparator);

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

if (env.has_key_p(env_rubylib).isTrue()) {
  String rubylib = env.op_aref(runtime.getCurrentContext(), env_rubylib).toString();
  String[] paths = rubylib.split(File.pathSeparator);

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

if (env.has_key_p(env_rubylib).isTrue()) {
  String rubylib = env.op_aref(runtime.getCurrentContext(), env_rubylib).toString();
  String[] paths = rubylib.split(File.pathSeparator);

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

RubySymbol sym = runtime.newSymbol(name);
if (keyValues.has_key_p(sym).isFalse()) {
  kasgn.interpret(runtime, context, self, Block.NULL_BLOCK);
} else {

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

if ( last instanceof RubyHash ) {
  RubyHash opt = (RubyHash) last; RubySymbol key;
  if ( ! opt.isEmpty() && ( opt.has_key_p( context, key = runtime.newSymbol("cause") ) == runtime.getTrue() ) ) {
    cause = opt.delete(context, key, Block.NULL_BLOCK);
    forceCause = true;

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

if ( last instanceof RubyHash ) {
  RubyHash opt = (RubyHash) last; RubySymbol key;
  if ( ! opt.isEmpty() && ( opt.has_key_p( context, key = runtime.newSymbol("cause") ) == runtime.getTrue() ) ) {
    cause = opt.delete(context, key, Block.NULL_BLOCK);
    forceCause = true;

相关文章

微信公众号

最新文章

更多

RubyHash类方法