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

Java RubyNil类代码示例

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

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



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

示例1: createJRubyObject

import org.jruby.RubyNil; //导入依赖的package包/类
/**
 * Create a new JRuby-scripted object from the given script source.
 * @param scriptSource the script source text
 * @param interfaces the interfaces that the scripted Java object is to implement
 * @param classLoader the {@link ClassLoader} to create the script proxy with
 * @return the scripted Java object
 * @throws JumpException in case of JRuby parsing failure
 */
public static Object createJRubyObject(String scriptSource, Class<?>[] interfaces, ClassLoader classLoader) {
	Ruby ruby = initializeRuntime();

	Node scriptRootNode = ruby.parseEval(scriptSource, "", null, 0);
       IRubyObject rubyObject = ruby.runNormally(scriptRootNode);

	if (rubyObject instanceof RubyNil) {
		String className = findClassName(scriptRootNode);
		rubyObject = ruby.evalScriptlet("\n" + className + ".new");
	}
	// still null?
	if (rubyObject instanceof RubyNil) {
		throw new IllegalStateException("Compilation of JRuby script returned RubyNil: " + rubyObject);
	}

	return Proxy.newProxyInstance(classLoader, interfaces, new RubyObjectInvocationHandler(rubyObject, ruby));
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:26,代码来源:JRubyScriptUtils.java


示例2: createJRubyObject

import org.jruby.RubyNil; //导入依赖的package包/类
/**
 * Create a new JRuby-scripted object from the given script source.
 * @param scriptSource the script source text
 * @param interfaces the interfaces that the scripted Java object is to implement
 * @param classLoader the {@link ClassLoader} to create the script proxy with
 * @return the scripted Java object
 * @throws JumpException in case of JRuby parsing failure
 */
@SuppressWarnings("deprecation")
public static Object createJRubyObject(String scriptSource, Class<?>[] interfaces, ClassLoader classLoader) {
	Ruby ruby = initializeRuntime();

	Node scriptRootNode = ruby.parseEval(scriptSource, "", null, 0);
	// Keep using the deprecated runNormally variant for JRuby 1.1/1.2 compatibility...
       IRubyObject rubyObject = ruby.runNormally(scriptRootNode, false);

	if (rubyObject instanceof RubyNil) {
		String className = findClassName(scriptRootNode);
		rubyObject = ruby.evalScriptlet("\n" + className + ".new");
	}
	// still null?
	if (rubyObject instanceof RubyNil) {
		throw new IllegalStateException("Compilation of JRuby script returned RubyNil: " + rubyObject);
	}

	return Proxy.newProxyInstance(classLoader, interfaces, new RubyObjectInvocationHandler(rubyObject, ruby));
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:28,代码来源:JRubyScriptUtils.java


示例3: rubyToPig

import org.jruby.RubyNil; //导入依赖的package包/类
/**
 * This method facilitates conversion from Ruby objects to Pig objects. This is
 * a general class which detects the subclass and invokes the appropriate conversion
 * routine. It will fail on an unsupported datatype.
 *
 * @param  rbObject      a Ruby object to convert
 * @return               the Pig analogue of the Ruby object
 * @throws ExecException if rbObject is not of a known type that can be converted
 */
@SuppressWarnings("unchecked")
public static Object rubyToPig(IRubyObject rbObject) throws ExecException {
    if (rbObject == null || rbObject instanceof RubyNil) {
        return null;
    } else if (rbObject instanceof RubyArray) {
        return rubyToPig((RubyArray)rbObject);
    } else if (rbObject instanceof RubyHash) {
        return rubyToPig((RubyHash)rbObject);
    } else if (rbObject instanceof RubyString) {
        return rubyToPig((RubyString)rbObject);
    } else if (rbObject instanceof RubyBignum) {
        return rubyToPig((RubyBignum)rbObject);
    } else if (rbObject instanceof RubyFixnum) {
        return rubyToPig((RubyFixnum)rbObject);
    } else if (rbObject instanceof RubyFloat) {
        return rubyToPig((RubyFloat)rbObject);
    } else if (rbObject instanceof RubyInteger) {
        return rubyToPig((RubyInteger)rbObject);
    } else if (rbObject instanceof RubyDataBag) {
        return rubyToPig((RubyDataBag)rbObject);
    } else if (rbObject instanceof RubyDataByteArray) {
        return rubyToPig((RubyDataByteArray)rbObject);
    } else if (rbObject instanceof RubySchema) {
        return rubyToPig((RubySchema)rbObject);
    } else if (rbObject instanceof RubyBoolean) {
        return rubyToPig((RubyBoolean)rbObject);
    } else {
        throw new ExecException("Cannot cast into any pig supported type: " + rbObject.getClass().getName());
    }
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:40,代码来源:PigJrubyLibrary.java


示例4: root_set

import org.jruby.RubyNil; //导入依赖的package包/类
@JRubyMethod(name="root=")
public IRubyObject root_set(ThreadContext context, IRubyObject newRoot_) {
    // in case of document fragment, temporary root node should be deleted.

    // Java can't have a root whose value is null. Instead of setting null,
    // the method sets user data so that other methods are able to know the root
    // should be nil.
    if (newRoot_ instanceof RubyNil) {
        getDocument().getDocumentElement().setUserData(NokogiriHelpers.VALID_ROOT_NODE, false, null);
        return newRoot_;
    }
    XmlNode newRoot = asXmlNode(context, newRoot_);

    IRubyObject root = root(context);
    if (root.isNil()) {
        Node newRootNode;
        if (getDocument() == newRoot.getOwnerDocument()) {
            newRootNode = newRoot.node;
        } else {
            // must copy otherwise newRoot may exist in two places
            // with different owner document.
            newRootNode = getDocument().importNode(newRoot.node, true);
        }
        add_child_node(context, getCachedNodeOrCreate(context.getRuntime(), newRootNode));
    } else {
        Node rootNode = asXmlNode(context, root).node;
        ((XmlNode)getCachedNodeOrCreate(context.getRuntime(), rootNode)).replace_node(context, newRoot);
    }

    return newRoot;
}
 
开发者ID:gocd,项目名称:gocd,代码行数:32,代码来源:XmlDocument.java


示例5: node_name

import org.jruby.RubyNil; //导入依赖的package包/类
/**
 * Returns the local part of the element name.
 */
@Override
@JRubyMethod
public IRubyObject node_name(ThreadContext context) {
    IRubyObject value = getAttribute(context, "name");
    if (value instanceof RubyNil) value = name;
    return value;
}
 
开发者ID:gocd,项目名称:gocd,代码行数:11,代码来源:XmlEntityDecl.java


示例6: content

import org.jruby.RubyNil; //导入依赖的package包/类
@JRubyMethod
public IRubyObject content(ThreadContext context) {
    IRubyObject value = getAttribute(context, "value");
    if (value instanceof RubyNil) value = content;
    return value;
}
 
开发者ID:gocd,项目名称:gocd,代码行数:7,代码来源:XmlEntityDecl.java


示例7: system_id

import org.jruby.RubyNil; //导入依赖的package包/类
@JRubyMethod
public IRubyObject system_id(ThreadContext context) {
    IRubyObject value = getAttribute(context, "sysid");
    if (value instanceof RubyNil) value = system_id;
    return value;
}
 
开发者ID:gocd,项目名称:gocd,代码行数:7,代码来源:XmlEntityDecl.java


示例8: external_id

import org.jruby.RubyNil; //导入依赖的package包/类
@JRubyMethod
public IRubyObject external_id(ThreadContext context) {
    IRubyObject value = getAttribute(context, "pubid");
    if (value instanceof RubyNil) value = external_id;
    return value;
}
 
开发者ID:gocd,项目名称:gocd,代码行数:7,代码来源:XmlEntityDecl.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java RandomPicks类代码示例发布时间:2022-05-22
下一篇:
Java PositiveIntOutputs类代码示例发布时间: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