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


Java Ruby.getNil方法代码示例

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


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

示例1: pigToRuby

import org.jruby.Ruby; //导入方法依赖的package包/类
/**
 * This is the method which provides conversion from Pig to Ruby. In this case, an
 * instance of the Ruby runtime is necessary. This method provides the general detection
 * of the type and then calls the more specific conversion methods.
 *
 * @param  ruby          the Ruby runtime to create objects in
 * @param  object        the Pig object to convert to Ruby
 * @return               Ruby analogue of object
 * @throws ExecException object is not a convertible Pig type
 */
@SuppressWarnings("unchecked")
public static IRubyObject pigToRuby(Ruby ruby, Object object) throws ExecException {
    if (object == null) {
        return ruby.getNil();
    } else if (object instanceof Tuple) {
        return pigToRuby(ruby, (Tuple)object);
    } else if (object instanceof DataBag) {
       return pigToRuby(ruby, (DataBag)object);
    } else if (object instanceof Map<?, ?>) {
        return pigToRuby(ruby, (Map<String, ?>)object);
    } else if (object instanceof DataByteArray) {
        return pigToRuby(ruby, (DataByteArray)object);
    } else if (object instanceof Schema) {
        return pigToRuby(ruby, ((Schema)object));
    } else if (object instanceof String) {
        return pigToRuby(ruby, (String)object);
    } else if (object instanceof Integer) {
        return pigToRuby(ruby, (Integer)object);
    } else if (object instanceof Long) {
        return pigToRuby(ruby, (Long)object);
    } else if (object instanceof Float) {
        return pigToRuby(ruby, (Float)object);
    } else if (object instanceof Double) {
        return pigToRuby(ruby, (Double)object);
    } else if (object instanceof Boolean) {
        return pigToRuby(ruby, (Boolean)object);
    } else {
        throw new ExecException("Object of unknown type " + object.getClass().getName() + " passed to pigToRuby");
    }
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:41,代码来源:PigJrubyLibrary.java

示例2: each

import org.jruby.Ruby; //导入方法依赖的package包/类
@JRubyMethod
public IRubyObject each(ThreadContext context, Block block) {
    Ruby runtime = context.runtime;
    for (Descriptors.EnumValueDescriptor enumValueDescriptor : descriptor.getValues()) {
        block.yield(context, runtime.newArray(runtime.newSymbol(enumValueDescriptor.getName()),
                runtime.newFixnum(enumValueDescriptor.getNumber())));
    }
    return runtime.getNil();
}
 
开发者ID:bazelbuild,项目名称:bazel,代码行数:10,代码来源:RubyEnumDescriptor.java


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