• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java RubySymbol类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.jruby.RubySymbol的典型用法代码示例。如果您正苦于以下问题:Java RubySymbol类的具体用法?Java RubySymbol怎么用?Java RubySymbol使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: map2hash

import org.jruby.RubySymbol; //导入依赖的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: rubyToPig

import org.jruby.RubySymbol; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:25,代码来源:PigJrubyLibrary.java


示例3: convertRubyHashMapToMap

import org.jruby.RubySymbol; //导入依赖的package包/类
public static Map<Object, Object> convertRubyHashMapToMap(Map<Object, Object> rubyHashMap) {

        Map<Object, Object> map = new HashMap<Object, Object>();

        Set<Entry<Object, Object>> elements = rubyHashMap.entrySet();

        for (Entry<Object, Object> element : elements) {
            if(element.getKey() instanceof RubySymbol) {
                map.put(toJavaString((RubySymbol)element.getKey()), toJavaObject(element.getValue()));
            } else {
                map.put(toJavaObject(element.getKey()).toString(), toJavaObject(element.getValue()));
            }
        }

        return map;

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


示例4: scanToAutoEnable

import org.jruby.RubySymbol; //导入依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void scanToAutoEnable() {
    Object evalResult = eval("Module.constants");
    if (evalResult == null || !(evalResult instanceof Collection)) {
        return;
    }

    List processorRubyTypes = PROCESSOR_CLASSES.values().stream().map(processorClass -> eval(processorClass.getSimpleName()))
            .collect(Collectors.toList());

    List<Object> autoEnabled = new ArrayList<>();
    ((Collection) evalResult).forEach(element -> {
        Object symbol = eval(((RubySymbol) element).asJavaString());
        if (symbol != null && symbol instanceof RubyClass) {
            RubyClass rubyClass = (RubyClass) symbol;
            if (!processorRubyTypes.contains(rubyClass)
                    && CollectionUtils.containsAny(rubyClass.getAncestorList(), processorRubyTypes)) {
                if (!isProcessorAbstract(rubyClass.getName())) {
                    autoEnabled.add(rubyClass);
                    ((JRubyKnowledgeBaseEngineOperations) getEngineOperations()).enable(rubyClass);
                }
            }
        }
    });

    if (logger.isDebugEnabled() && !autoEnabled.isEmpty()) {
        logger.debug("Auto-enabling: {}", autoEnabled);
    }
}
 
开发者ID:softelnet,项目名称:sponge,代码行数:31,代码来源:JRubyKnowledgeBaseInterpreter.java


示例5: getEntriesDir

import org.jruby.RubySymbol; //导入依赖的package包/类
private Path getEntriesDir(final AbstractBlock abstractBlock, final String target) {
    final Map<Object, Object> documentOptions = abstractBlock.document().getOptions();

    final String currentDir = documentOptions.entrySet().stream()
            .filter(e -> "base_dir".equals(RubySymbol.objectToSymbolString((RubySymbol) e.getKey())))
            .map(e -> (String) e.getValue())
            .findFirst().orElse("");

    return Paths.get(currentDir + '/' + target);
}
 
开发者ID:sdaschner,项目名称:asciidoctor-blog-extension,代码行数:11,代码来源:BlogEntriesProcessor.java


示例6: toSymbol

import org.jruby.RubySymbol; //导入依赖的package包/类
public static RubySymbol toSymbol(Ruby rubyRuntime, String key) {
    RubySymbol newSymbol = RubySymbol.newSymbol(rubyRuntime, key);
    return newSymbol;
}
 
开发者ID:asciidoctor,项目名称:asciidoctorj,代码行数:5,代码来源:RubyUtils.java


示例7: convertMapToRubyHashWithSymbolsIfNecessary

import org.jruby.RubySymbol; //导入依赖的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


示例8: convertMapToRubyHashWithSymbols

import org.jruby.RubySymbol; //导入依赖的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


示例9: toJavaString

import org.jruby.RubySymbol; //导入依赖的package包/类
private static String toJavaString(RubySymbol element) {
    return element.asJavaString();
}
 
开发者ID:asciidoctor,项目名称:asciidoctorj,代码行数:4,代码来源:RubyHashUtil.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java CSVParser类代码示例发布时间:2022-05-22
下一篇:
Java PackageDeclaration类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap