本文整理了Java中org.jruby.RubyHash.directEntrySet
方法的一些代码示例,展示了RubyHash.directEntrySet
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RubyHash.directEntrySet
方法的具体详情如下:
包路径:org.jruby.RubyHash
类名称:RubyHash
方法名:directEntrySet
暂无
代码示例来源:origin: org.jruby/jruby-complete
/** hash_le_i
*
*/
private boolean hash_le(RubyHash other) {
return other.directEntrySet().containsAll(directEntrySet());
}
代码示例来源:origin: org.jruby/jruby-core
/** hash_le_i
*
*/
private boolean hash_le(RubyHash other) {
return other.directEntrySet().containsAll(directEntrySet());
}
代码示例来源:origin: org.jruby/jruby-complete
@SuppressWarnings("unchecked")
public String[] getEnv() {
RubyHash hash = (RubyHash) runtime.getObject().getConstant("ENV");
String[] env = new String[hash.size()];
if (env.length == 0) return env;
StringBuilder str = new StringBuilder(); int i=0;
for (Iterator<Entry<Object, Object>> iter = hash.directEntrySet().iterator(); iter.hasNext(); i++) {
Map.Entry<Object, Object> entry = iter.next();
str.setLength(0);
str.append(entry.getKey()).append('=').append(entry.getValue());
env[i] = str.toString();
}
return env;
}
代码示例来源:origin: org.jruby/jruby-core
@SuppressWarnings("unchecked")
public String[] getEnv() {
RubyHash hash = (RubyHash) runtime.getObject().getConstant("ENV");
String[] env = new String[hash.size()];
if (env.length == 0) return env;
StringBuilder str = new StringBuilder(); int i=0;
for (Iterator<Entry<Object, Object>> iter = hash.directEntrySet().iterator(); iter.hasNext(); i++) {
Map.Entry<Object, Object> entry = iter.next();
str.setLength(0);
str.append(entry.getKey()).append('=').append(entry.getValue());
env[i] = str.toString();
}
return env;
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
@SuppressWarnings("unchecked")
public String[] getEnv() {
RubyHash hash = (RubyHash) runtime.getObject().getConstant("ENV");
int i=0;
String[] env = new String[hash.size()];
for (Iterator<Entry<Object, Object>> iter = hash.directEntrySet().iterator(); iter.hasNext(); i++) {
Map.Entry<Object, Object> entry = iter.next();
env[i] = entry.getKey().toString() + "=" + entry.getValue().toString();
}
return env;
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
@SuppressWarnings("unchecked")
public String[] getEnv() {
RubyHash hash = (RubyHash) runtime.getObject().getConstant("ENV");
int i=0;
String[] env = new String[hash.size()];
for (Iterator<Entry<Object, Object>> iter = hash.directEntrySet().iterator(); iter.hasNext(); i++) {
Map.Entry<Object, Object> entry = iter.next();
env[i] = entry.getKey().toString() + "=" + entry.getValue().toString();
}
return env;
}
代码示例来源:origin: org.jruby/jruby-complete
private static void buildEnvp(Ruby runtime, ExecArg eargp, IRubyObject envtbl) {
String[] envp_str;
List<String> envp_buf;
envp_buf = new ArrayList();
for (Map.Entry<IRubyObject, IRubyObject> entry : (Set<Map.Entry<IRubyObject, IRubyObject>>)((RubyHash)envtbl).directEntrySet()) {
IRubyObject key = entry.getKey();
IRubyObject val = entry.getValue();
envp_buf.add(StringSupport.checkEmbeddedNulls(runtime, key).toString()
+ "="
+ StringSupport.checkEmbeddedNulls(runtime, val));
}
envp_str = new String[envp_buf.size()];
envp_buf.toArray(envp_str);
eargp.envp_str = envp_str;
eargp.envp_buf = envp_buf;
}
代码示例来源:origin: org.jruby/jruby-core
private static void buildEnvp(Ruby runtime, ExecArg eargp, IRubyObject envtbl) {
String[] envp_str;
List<String> envp_buf;
envp_buf = new ArrayList();
for (Map.Entry<IRubyObject, IRubyObject> entry : (Set<Map.Entry<IRubyObject, IRubyObject>>)((RubyHash)envtbl).directEntrySet()) {
IRubyObject key = entry.getKey();
IRubyObject val = entry.getValue();
envp_buf.add(StringSupport.checkEmbeddedNulls(runtime, key).toString()
+ "="
+ StringSupport.checkEmbeddedNulls(runtime, val));
}
envp_str = new String[envp_buf.size()];
envp_buf.toArray(envp_str);
eargp.envp_str = envp_str;
eargp.envp_buf = envp_buf;
}
代码示例来源:origin: org.jruby/jruby-complete
private void setupStructValuesFromHash(ThreadContext context, RubyHash kwArgs) {
RubyArray __members__ = __member__();
Set<Map.Entry<IRubyObject, IRubyObject>> entries = kwArgs.directEntrySet();
entries.stream().forEach(
entry -> {
IRubyObject key = entry.getKey();
if (!(key instanceof RubySymbol))
key = context.runtime.newSymbol(key.convertToString().getByteList());
IRubyObject index = __members__.index(context, key);
if (index.isNil()) throw context.runtime.newArgumentError("unknown keywords: " + key);
values[index.convertToInteger().getIntValue()] = entry.getValue();
});
}
代码示例来源:origin: org.jruby/jruby-core
private void setupStructValuesFromHash(ThreadContext context, RubyHash kwArgs) {
RubyArray __members__ = __member__();
Set<Map.Entry<IRubyObject, IRubyObject>> entries = kwArgs.directEntrySet();
entries.stream().forEach(
entry -> {
IRubyObject key = entry.getKey();
if (!(key instanceof RubySymbol))
key = context.runtime.newSymbol(key.convertToString().getByteList());
IRubyObject index = __members__.index(context, key);
if (index.isNil()) throw context.runtime.newArgumentError("unknown keywords: " + key);
values[index.convertToInteger().getIntValue()] = entry.getValue();
});
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
for (Map.Entry entry : (Set<Map.Entry<Object, Object>>)methodNames.directEntrySet()) {
String name = entry.getValue().toString();
if (methods.containsKey(entry.getValue().toString())) {
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
for (Map.Entry entry : (Set<Map.Entry<Object, Object>>)methodNames.directEntrySet()) {
String name = entry.getValue().toString();
if (methods.containsKey(entry.getValue().toString())) {
代码示例来源:origin: org.jruby/jruby-complete
for (Map.Entry<IRubyObject, IRubyObject> entry : (Set<Map.Entry<IRubyObject, IRubyObject>>)methodNames.directEntrySet()) {
String name = entry.getValue().toString();
if (methods.containsKey(entry.getValue().toString())) {
代码示例来源:origin: headius/jo
@JRubyMethod(module = true)
public static IRubyObject select(ThreadContext context, IRubyObject self, IRubyObject hash) {
Ruby runtime = context.runtime;
RubyHash cases = hash.convertToHash();
Set<RubyHash.RubyHashEntry> entries = (Set<RubyHash.RubyHashEntry>)cases.directEntrySet();
Object[] entryArray = entries.toArray();
OUTER: while (true) {
for (Object _entry : entryArray) {
RubyHash.RubyHashEntry entry = (RubyHash.RubyHashEntry)_entry;
IRubyObject _channel = (IRubyObject)entry.getKey();
if (!(_channel instanceof JoChannel)) throw runtime.newTypeError(_channel, runtime.getClassFromPath("Jo::Channel"));
IRubyObject _proc = (IRubyObject)entry.getValue();
IRubyObject value;
if ((value = ((JoChannel)_channel).queue.poll()) != null) {
_proc.callMethod(context, "call", value);
break OUTER;
}
Thread.yield();
}
}
return context.nil;
}
}
代码示例来源:origin: org.jruby/jruby-core
for (Map.Entry<IRubyObject, IRubyObject> entry : (Set<Map.Entry<IRubyObject, IRubyObject>>)methodNames.directEntrySet()) {
String name = entry.getValue().toString();
if (methods.containsKey(entry.getValue().toString())) {
代码示例来源:origin: org.jruby/jruby-complete
static IRubyObject handleOptionsCommon(ThreadContext context, Ruby runtime, ExecArg eargp, RubyHash opthash, boolean raise) {
if (opthash.isEmpty())
return null;
RubyHash nonopts = null;
for (Map.Entry<IRubyObject, IRubyObject> entry : (Set<Map.Entry<IRubyObject, IRubyObject>>)opthash.directEntrySet()) {
IRubyObject key = entry.getKey();
IRubyObject val = entry.getValue();
if (execargAddopt(context, runtime, eargp, key, val) != ST_CONTINUE) {
if (raise) {
if (key instanceof RubySymbol) {
switch (key.toString()) {
case "gid" :
throw runtime.newNotImplementedError("popen does not support :gid option in JRuby");
case "uid" :
throw runtime.newNotImplementedError("popen does not support :uid option in JRuby");
default :
throw runtime.newArgumentError("wrong exec option symbol: " + key);
}
}
else {
throw runtime.newArgumentError("wrong exec option: " + key);
}
}
if (nonopts == null) nonopts = RubyHash.newHash(runtime);
nonopts.op_aset(context, key, val);
}
}
return nonopts != null ? nonopts : context.nil;
}
代码示例来源:origin: org.jruby/jruby-core
static IRubyObject handleOptionsCommon(ThreadContext context, Ruby runtime, ExecArg eargp, RubyHash opthash, boolean raise) {
if (opthash.isEmpty())
return null;
RubyHash nonopts = null;
for (Map.Entry<IRubyObject, IRubyObject> entry : (Set<Map.Entry<IRubyObject, IRubyObject>>)opthash.directEntrySet()) {
IRubyObject key = entry.getKey();
IRubyObject val = entry.getValue();
if (execargAddopt(context, runtime, eargp, key, val) != ST_CONTINUE) {
if (raise) {
if (key instanceof RubySymbol) {
switch (key.toString()) {
case "gid" :
throw runtime.newNotImplementedError("popen does not support :gid option in JRuby");
case "uid" :
throw runtime.newNotImplementedError("popen does not support :uid option in JRuby");
default :
throw runtime.newArgumentError("wrong exec option symbol: " + key);
}
}
else {
throw runtime.newArgumentError("wrong exec option: " + key);
}
}
if (nonopts == null) nonopts = RubyHash.newHash(runtime);
nonopts.op_aset(context, key, val);
}
}
return nonopts != null ? nonopts : context.nil;
}
代码示例来源:origin: org.jruby/jruby-complete
public static RubyArray checkExecEnv(ThreadContext context, RubyHash hash, ExecArg pathArg) {
Ruby runtime = context.runtime;
RubyArray env;
env = runtime.newArray();
for (Map.Entry<IRubyObject, IRubyObject> entry : (Set<Map.Entry<IRubyObject, IRubyObject>>)hash.directEntrySet()) {
IRubyObject key = entry.getKey();
IRubyObject val = entry.getValue();
String k;
k = StringSupport.checkEmbeddedNulls(runtime, key).toString();
if (k.indexOf('=') != -1)
throw runtime.newArgumentError("environment name contains a equal : " + k);
if (!val.isNil())
val = StringSupport.checkEmbeddedNulls(runtime, val);
key = key.convertToString().export(context);
if (!val.isNil()) val = val.convertToString().export(context);
if (key.convertToString().toString().equalsIgnoreCase("PATH")) {
pathArg.path_env = val;
}
env.push(runtime.newArray(key, val));
}
return env;
}
代码示例来源:origin: org.jenkins-ci/jruby-xstream
public void marshal(Object o, HierarchicalStreamWriter writer, MarshallingContext context) {
RubyHash hash = (RubyHash) o;
resolver.marshal(hash,writer,context);
writer.addAttribute("ruby-class", hash.getType().getName());
for (Entry e : (Set<Entry>)hash.directEntrySet()) {
writer.startNode("entry");
writer.startNode("key");
context.convertAnother(e.getKey());
writer.endNode();
writer.startNode("value");
context.convertAnother(e.getValue());
writer.endNode();
writer.endNode();
}
}
代码示例来源:origin: org.jruby/jruby-core
public static RubyArray checkExecEnv(ThreadContext context, RubyHash hash, ExecArg pathArg) {
Ruby runtime = context.runtime;
RubyArray env;
env = runtime.newArray();
for (Map.Entry<IRubyObject, IRubyObject> entry : (Set<Map.Entry<IRubyObject, IRubyObject>>)hash.directEntrySet()) {
IRubyObject key = entry.getKey();
IRubyObject val = entry.getValue();
String k;
k = StringSupport.checkEmbeddedNulls(runtime, key).toString();
if (k.indexOf('=') != -1)
throw runtime.newArgumentError("environment name contains a equal : " + k);
if (!val.isNil())
val = StringSupport.checkEmbeddedNulls(runtime, val);
key = key.convertToString().export(context);
if (!val.isNil()) val = val.convertToString().export(context);
if (key.convertToString().toString().equalsIgnoreCase("PATH")) {
pathArg.path_env = val;
}
env.push(runtime.newArray(key, val));
}
return env;
}
内容来源于网络,如有侵权,请联系作者删除!