找回密码
 注册
查看: 4520|回复: 0

R语言 rJava包 jcall()函数中文帮助文档(中英文对照)

[复制链接]
发表于 2012-2-22 21:13:15 | 显示全部楼层 |阅读模式
jcall(rJava)
jcall()所属R语言包:rJava

                                         Call a Java method
                                         调用Java方法

                                         译者:生物统计家园网 机器人LoveR

描述----------Description----------

.jcall calls a Java method with the supplied arguments.
.jcall提供的参数调用Java方法。


用法----------Usage----------


.jcall(obj, returnSig = "V", method, ..., evalArray = TRUE,
    evalString = TRUE, check = TRUE, interface = "RcallMethod",
    use.true.class = FALSE)



参数----------Arguments----------

参数:obj
Java object (jobjRef as returned by .jcall or .jnew) or fully qualified class name in JNI notation (e.g. "java/lang/String").
Java对象(jobjRef.jcall或返回.jnew)或在JNI符号完全合格的类名(例如"java/lang/String")。


参数:returnSig
Return signature in JNI notation (e.g. "V" for void, "[I" for int[] etc.). For convenience additional type "S" is supported and expanded to "Ljava/lang/String;", re-mapping "T" to represent the type short.
返回JNI的符号(如“V”为无效,“我”int[]等)的签名。重新映射为方便其他类型的"S"支持和扩大"Ljava/lang/String;","T"代表类型short,。


参数:method
The name of the method to be called
该方法的名称,被称为


参数:...
Any parametes that will be passed to the Java method. The parameter types are determined automatically and/or taken from the jobjRef object. All named parameters are discarded.
将传递给Java方法的任何指标的影响。参数类型决定自动和/或采取从jobjRef对象。所有命名参数被丢弃。


参数:evalArray
This flag determines whether the array return value is evaluated (TRUE) or passed back as Java object reference (FALSE).
此标志确定是否数组返回值评估(TRUE),或通过为Java对象的引用(FALSE)。


参数:evalString
This flag determines whether string result is returned as characters or as Java object reference.
此标志确定是否结果为Java对象的引用返回的字符或字符串。


参数:check
If set to TRUE then checks for exceptions are performed before and after the call using .jcheck(silent=FALSE). This is usually the desired behavior, because all calls fail until an expection is cleared.
如果设置为TRUE然后进行例外检查之前和之后的使用.jcheck(silent=FALSE)通话。这就是通常所期望的行为,因为所有的呼叫失败,直到一个expection被清除。


参数:interface
This option is experimental and specifies the interface used for calling the Java method; the current implementation supports two interfaces:   
此选项是实验,并指定用于调用Java方法的接口;当前的实现支持两种接口:

"RcallMethod"the default interface.  
"RcallMethod"的默认界面。

"RcallSyncMethod"synchronized call of a method. This has simmilar effect as using synchronize in Java.  
"RcallSyncMethod"同步的方法调用。这为使用在Java synchronizesimmilar效果。


参数:use.true.class
logical. If set to TRUE, the true class of the returned object will be used instead of the declared signature.  TRUE allows for example to grab the actual class of an object when  the return type is an interface, or allows to grab an array when the  declared type is Object and the returned object is an array. Use FALSE  for efficiency when you are sure about the return type.  
逻辑。如果设置为TRUE,返回对象的真正的类将被用来代替宣布签名。 TRUE允许例如抢当返回类型是一个接口的类的对象的实际,或允许抢一个数组声明的类型是Object,并返回的对象是一个数组。使用FALSE效率,“当你确定返回类型。


Details

详情----------Details----------

.jcall requires exact match of argument and return types. For higher efficiency .jcall doesn't perform any lookup in the reflection tables. This means that passing subclasses of the classes present in the method definition requires explicit casting using .jcast. Passing null arguments also needs a proper class specification with .jnull.
.jcall需要的参数和返回类型完全匹配。更高的效率.jcall不执行任何反射表中查找。这意味着传递的类的子类,目前在方法定义中需要明确的铸造使用.jcast。通过null参数也需要适当的类规范与.jnull。

Java types long and float have no corresponding types in R and therefore any such parameters must be flagged as such using .jfloat and .jlong functions respectively.
Java类型long和floatR中有没有相应的类型,因此任何这些参数必须标记为分别使用.jfloat和.jlong功能等。

Java also distinguishes scalar and array types whereas R doesn't have the concept of a scalar. In R a scalar is basically a vector (called array in Java-speak) of the length 1. Therefore passing vectors of the length 1 is ambiguous. .jcall assumes that any vector of the length 1 that corresponds to a native Java type is a scalar. All other vectors are passed as arrays. Therefore it is important to use .jarray if an arbitrary vector (including those of the length 1) is to be passed as an array parameter.
Java也区分标量和数组类型,而R没有一个标量的概念。在R基本上是一个标量向量的长度为1(称为数组Java中的发言)。因此,通过长度为1的向量是模糊的。 .jcall假定任何向量的长度为1,相当于本地Java类型是一个标量。所有其他媒介传递数组。因此,重要的是使用.jarray如果任意一个向量(包括长度为1)是被作为一个数组参数传递。

Important note about encoding of character vectors: Java interface always works with strings in UTF-8 encoding, therefore the safest way is to run R in a UTF-8 locale. If that is not possible for some reason, rJava can be used in non-UTF-8 locales, but care must be taken. Since R 2.7.0 it is possible to associate encoding with strings and rJava will flag all strings it produces with the appropriate UTF-8 tag. R will then perform corresponding appropriate conversions where possible (at a cost of speed and memory usage), but 3rd party code may not (e.g. older packages). Also rJava relies on correct encoding flags for strings passed to it and will attempt to perform conversions where necessary. If some 3rd party code produces strings incorreclty flagged, all bets are off.
重要说明:有关编码字符向量Java接口总是以UTF-8编码的字符串,因此最安全的方式是一个UTF-8语言环境中运行ŕ。如果是没有可能出于某种原因,rJava可以在非UTF-8语言环境中使用,但必须小心。 2.7.0由于R,它是可能的关联编码字符串和rJava将标记的所有字符串,它与相应的UTF-8标签生产。 R将进行相应的适当的转换,在可能的情况下(在速度和内存使用成本),但第三方代码可能无法(如旧的套件)。也rJava依赖于正确的编码标志传递给它的字符串,并尝试在必要时执行转换。如果一些第三方代码产生字符串incorreclty标记的,所有的赌注都关闭。

Finally, for performance reasons class, method and field names as well as signatures are not always converted and should not contain non-ASCII characters.
最后,出于性能原因,类,方法和字段名以及签名并不总是转换,不应该包含非ASCII字符。


值----------Value----------

Returns the result of the method.
返回结果的方法。


参见----------See Also----------

.jnew, .jcast, .jnull, .jarray
.jnew,.jcast,.jnull,.jarray


举例----------Examples----------



.jcall("java/lang/System","S","getProperty","os.name")
if (!nzchar(Sys.getenv("NOAWT"))) {
  f <- .jnew("java/awt/Frame","Hello")
  .jcall(f,,"setVisible",TRUE)
}

转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。


注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|小黑屋|生物统计家园 网站价格

GMT+8, 2025-1-22 13:29 , Processed in 0.023755 second(s), 16 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表