本文整理了Java中org.jruby.RubyHash.entrySet
方法的一些代码示例,展示了RubyHash.entrySet
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RubyHash.entrySet
方法的具体详情如下:
包路径:org.jruby.RubyHash
类名称:RubyHash
方法名:entrySet
暂无
代码示例来源:origin: code4craft/webmagic
case JRuby:
RubyHash oRuby = (RubyHash) engine.eval(defines + "\n" + script, context);
Iterator itruby = oRuby.entrySet().iterator();
while (itruby.hasNext()) {
Map.Entry pairs = (Map.Entry) itruby.next();
代码示例来源:origin: asciidoctor/asciidoctorj
private Map<String, Object> createJavaMap() {
Map<String, Object> copy = new HashMap<String, Object>();
Set<Entry<Object, Object>> rubyEntrySet = rubyHash.entrySet();
for (Entry<Object, Object> o: rubyEntrySet) {
String key;
Object rubyKey = o.getKey();
Object rubyValue = o.getValue();
if (rubyKey instanceof RubyString) {
key = ((RubyString) rubyKey).asJavaString();
} else if (rubyKey instanceof String) {
key = (String) rubyKey;
} else if (rubyKey instanceof Number) {
key = String.valueOf(rubyKey);
} else {
continue;
}
Object value = convertRubyValue(rubyValue);
copy.put(key, value);
}
return copy;
}
代码示例来源:origin: org.apache.pig/pig
/**
* A type specific conversion routine.
*
* @param rbObject object to convert
* @return analogous Pig type
*/
@SuppressWarnings("unchecked")
public static Map<String, ?> rubyToPig(RubyHash rbObject) throws ExecException {
Map<String, Object> newMap = Maps.newHashMap();
for (Map.Entry<Object, Object> entry : (Set<Map.Entry<Object, Object>>)rbObject.entrySet()) {
Object key = entry.getKey();
if (!(key instanceof String || key instanceof RubyString || key instanceof RubySymbol))
throw new ExecException("Hash must have String or Symbol key. Was given: " + key.getClass().getName());
String keyStr = key.toString();
if (entry.getValue() instanceof IRubyObject) {
newMap.put(keyStr, rubyToPig((IRubyObject)entry.getValue()));
} else {
newMap.put(keyStr, entry.getValue());
}
}
return newMap;
}
代码示例来源:origin: org.asciidoctor/asciidoctorj
private Map<String, Object> createJavaMap() {
Map<String, Object> copy = new HashMap<String, Object>();
Set<Entry<Object, Object>> rubyEntrySet = rubyHash.entrySet();
for (Entry<Object, Object> o: rubyEntrySet) {
String key;
Object rubyKey = o.getKey();
Object rubyValue = o.getValue();
if (rubyKey instanceof RubyString) {
key = ((RubyString) rubyKey).asJavaString();
} else if (rubyKey instanceof String) {
key = (String) rubyKey;
} else if (rubyKey instanceof Number) {
key = String.valueOf(rubyKey);
} else {
continue;
}
Object value = convertRubyValue(rubyValue);
copy.put(key, value);
}
return copy;
}
代码示例来源:origin: org.asciidoctor/asciidoctorj
private Map<String, Object> createJavaMap() {
Map<String, Object> copy = new HashMap<String, Object>();
Set<Entry<Object, Object>> rubyEntrySet = rubyHash.entrySet();
for (Map.Entry<Object, Object> o: rubyEntrySet) {
String key = null;
Object value;
Object rubyKey = o.getKey();
Object rubyValue = o.getValue();
if (rubyKey instanceof RubySymbol) {
key = ((RubySymbol) rubyKey).asJavaString();
} else if (rubyKey instanceof RubyString) {
key = ((RubyString) rubyKey).asJavaString();
} else if (rubyKey instanceof String) {
key = (String) rubyKey;
} else if (rubyKey instanceof Long) {
// Skip it silently, it is a positional attribute
} else {
throw new IllegalStateException("Did not expect key " + rubyKey + " of type " + rubyKey.getClass());
}
if (key != null) {
value = convertRubyValue(rubyValue);
copy.put(key, value);
}
}
return copy;
}
代码示例来源:origin: asciidoctor/asciidoctorj
private Map<String, Object> createJavaMap() {
Map<String, Object> copy = new HashMap<String, Object>();
Set<Entry<Object, Object>> rubyEntrySet = rubyHash.entrySet();
for (Map.Entry<Object, Object> o: rubyEntrySet) {
String key = null;
Object value;
Object rubyKey = o.getKey();
Object rubyValue = o.getValue();
if (rubyKey instanceof RubySymbol) {
key = ((RubySymbol) rubyKey).asJavaString();
} else if (rubyKey instanceof RubyString) {
key = ((RubyString) rubyKey).asJavaString();
} else if (rubyKey instanceof String) {
key = (String) rubyKey;
} else if (rubyKey instanceof Long) {
// Skip it silently, it is a positional attribute
} else {
throw new IllegalStateException("Did not expect key " + rubyKey + " of type " + rubyKey.getClass());
}
if (key != null) {
value = convertRubyValue(rubyValue);
copy.put(key, value);
}
}
return copy;
}
代码示例来源:origin: org.jruby/jruby-complete
for (Map.Entry<String, String> e : (Set<Map.Entry<String, String>>)hash.entrySet()) {
代码示例来源:origin: org.jruby/jruby-core
for (Map.Entry<String, String> e : (Set<Map.Entry<String, String>>)hash.entrySet()) {
内容来源于网络,如有侵权,请联系作者删除!