本文整理汇总了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");
}
}
示例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();
}