当前位置: 首页>>代码示例>>Java>>正文


Java RubyHash.put方法代码示例

本文整理汇总了Java中org.jruby.RubyHash.put方法的典型用法代码示例。如果您正苦于以下问题:Java RubyHash.put方法的具体用法?Java RubyHash.put怎么用?Java RubyHash.put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jruby.RubyHash的用法示例。


在下文中一共展示了RubyHash.put方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: map2hash

import org.jruby.RubyHash; //导入方法依赖的package包/类
@SuppressWarnings("unchecked") private static RubyHash map2hash(Ruby ruby, Map<String, Object> ourCaps) {
    RubyHash hash = new RubyHash(ruby);
    Set<String> keySet = ourCaps.keySet();
    for (String key : keySet) {
        RubySymbol keySym = RubySymbol.newSymbol(ruby, key);
        Object v = ourCaps.get(key);
        if (v instanceof String) {
            hash.put(keySym, RubyString.newString(ruby, (String) v));
        } else if(v instanceof Boolean) {
            hash.put(keySym, RubyBoolean.newBoolean(ruby, (boolean) v));
        } else if (v instanceof List) {
            hash.put(keySym, map2list(ruby, (List<?>) v));
        } else {
            hash.put(keySym, map2hash(ruby, (Map<String, Object>) v));
        }
    }
    return hash;
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:19,代码来源:MarathonRuby.java

示例2: pigToRuby

import org.jruby.RubyHash; //导入方法依赖的package包/类
/**
 * A type specific conversion routine for Pig Maps. This only deals with maps
 * with String keys, which is all that Pig supports.
 *
 * @param  ruby          the Ruby runtime to create objects in
 * @param  object        map to convert. In Pig, only maps with String keys are
 *                       supported
 * @return               analogous Ruby type
 * @throws ExecException object contains a key that can't be convert to a Ruby type
 */
public static <T> RubyHash pigToRuby(Ruby ruby, Map<T, ?> object) throws ExecException {
    RubyHash newMap = RubyHash.newHash(ruby);

    boolean checkType = false;

    for (Map.Entry<T, ?> entry : object.entrySet()) {
        T key = entry.getKey();
        if (!checkType) {
            if (!(key instanceof String))
                throw new ExecException("pigToRuby only supports converting Maps with String keys");
            checkType = true;
        }
        newMap.put(key, pigToRuby(ruby, entry.getValue()));
    }

    return newMap;
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:28,代码来源:PigJrubyLibrary.java

示例3: convertToRubyHash

import org.jruby.RubyHash; //导入方法依赖的package包/类
private RubyHash convertToRubyHash(Set<Map.Entry<String, Object>> entries) {
  RubyHash hash = newHash(runtime);

  for (Map.Entry<String, Object> entry : entries) {
    String key = entry.getKey();
    Object value = entry.getValue();

    if (key.equals("rack.input")) {
      value = new JRubyRackInput(runtime, (RackInput) value);
    }

    if (key.equals("rack.version")) {
      value = convertToRubyArray((List<Integer>) value);
    }

    hash.put(key, value);
  }

  return hash;
}
 
开发者ID:square,项目名称:rack-servlet,代码行数:21,代码来源:JRubyRackApplication.java

示例4: convertJavaMapToRubyHash

import org.jruby.RubyHash; //导入方法依赖的package包/类
@SuppressWarnings("rawtypes")
public static RubyHash convertJavaMapToRubyHash(Ruby runtime, Map map) {
    RubyHash rubyHash = RubyHash.newHash( runtime );
    for (Object object : map.entrySet()) {
        Entry entry = (Entry) object;
        rubyHash.put( entry.getKey(), entry.getValue() );
    }
    return rubyHash;
}
 
开发者ID:projectodd,项目名称:wunderboss,代码行数:10,代码来源:RubyHelper.java

示例5: convertMapToRubyHashWithSymbolsIfNecessary

import org.jruby.RubyHash; //导入方法依赖的package包/类
public static RubyHash convertMapToRubyHashWithSymbolsIfNecessary(Ruby rubyRuntime, Map<Object, Object> options) {

        RubyHash rubyHash = new RubyHash(rubyRuntime);

        Set<Entry<Object, Object>> optionsSet = options.entrySet();

        for (Entry<Object, Object> entry : optionsSet) {

            Object keyType = entry.getKey();

            if (isNotARubySymbol(keyType)) {
                String key = (String) keyType;
                Object value = entry.getValue();

                RubySymbol newSymbol = RubyUtils.toSymbol(rubyRuntime, key);
                IRubyObject iRubyValue = toRubyObject(rubyRuntime, value);

                rubyHash.put(newSymbol, iRubyValue);
            }

        }

        return rubyHash;

    }
 
开发者ID:asciidoctor,项目名称:asciidoctorj,代码行数:26,代码来源:RubyHashUtil.java

示例6: convertMapToRubyHashWithSymbols

import org.jruby.RubyHash; //导入方法依赖的package包/类
public static RubyHash convertMapToRubyHashWithSymbols(Ruby rubyRuntime, Map<String, Object> options) {

        RubyHash rubyHash = new RubyHash(rubyRuntime);

        Set<Entry<String, Object>> optionsSet = options.entrySet();

        for (Entry<String, Object> entry : optionsSet) {

            String key = entry.getKey();
            Object value = entry.getValue();

            RubySymbol newSymbol = RubyUtils.toSymbol(rubyRuntime, key);
            IRubyObject iRubyValue = toRubyObject(rubyRuntime, value);

            rubyHash.put(newSymbol, iRubyValue);

        }

        return rubyHash;

    }
 
开发者ID:asciidoctor,项目名称:asciidoctorj,代码行数:22,代码来源:RubyHashUtil.java

示例7: toNoneSymbolsRubyHash

import org.jruby.RubyHash; //导入方法依赖的package包/类
public static RubyHash toNoneSymbolsRubyHash(Ruby rubyRuntime, Map<String, Object> map) {

        RubyHash rubyHash = new RubyHash(rubyRuntime);

        Set<Entry<String, Object>> entrySet = map.entrySet();

        for (Entry<String, Object> entry : entrySet) {
            rubyHash.put(toJavaObject(entry.getKey()), toJavaObject(entry.getValue()));
        }

        return rubyHash;

    }
 
开发者ID:asciidoctor,项目名称:asciidoctorj,代码行数:14,代码来源:RubyHashUtil.java


注:本文中的org.jruby.RubyHash.put方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。