with(rJava)
with()所属R语言包:rJava
with and within methods for Java objects and class names
Java对象的方法和类名与内
译者:生物统计家园网 机器人LoveR
描述----------Description----------
Convenience wrapper that allow calling methods of Java object and classes from within the object (or class).
方便的包装,使Java对象和类的方法调用的对象(或类)内。
用法----------Usage----------
## S3 method for class 'jobjRef'
with(data, expr, ...)
## S3 method for class 'jobjRef'
within(data, expr, ...)
## S3 method for class 'jarrayRef'
with(data, expr, ...)
## S3 method for class 'jarrayRef'
within(data, expr, ...)
## S3 method for class 'jclassName'
with(data, expr, ...)
## S3 method for class 'jclassName'
within(data, expr, ...)
参数----------Arguments----------
参数:data
A Java object reference or a java class name. See J
一个Java对象的引用或Java类的名称。看到J
参数:expr
R expression to evaluate
R的表达,以评估
参数:...
ignored
忽视
Details
详情----------Details----------
The expression is evaluated in an environment that contains a mapping between the public fields and methods of the object.
表达式求值的环境中包含的公共字段和方法的对象之间的映射。
The methods of the object are mapped to standard R functions in the environment. In case of classes, only static methods are used.
对象的方法映射到标准的R环境中的功能。在班级的情况下,只有静态方法的使用。
The fields of the object are mapped to active bindings (see makeActiveBinding) so that they can be accessed and modified from within the environment. For classes, only static fields are used.
对象的字段来积极绑定(见makeActiveBinding)的映射,使他们能够从环境中进行访问和修改。对于类,只有静态字段。
值----------Value----------
with returns the value of the expression and within returns the data argument
with返回表达式的值和within返回data参数
作者(S)----------Author(s)----------
Romain Francois <francoisromain@free.fr>
参考文献----------References----------
http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/package-summary.html
举例----------Examples----------
if (!nzchar(Sys.getenv("NOAWT"))) {
p <- .jnew( "java/awt/Point", 0L, 0L )
with( p, {
# x and y and now 0[x和y,现在0]
move( 10L, 10L )
# x and y are now 10[x和y是现在10]
x <- x + y
} )
f <- within( .jnew( "javax/swing/JFrame" ) , {
layout <- .jnew( "java/awt/BorderLayout" )
setLayout( layout )
add( .jnew( "javax/swing/JLabel", "north" ), layout$NORTH )
add( .jnew( "javax/swing/JLabel", "south" ), layout$SOUTH )
add( .jnew( "javax/swing/JLabel", "west" ), layout$WEST )
add( .jnew( "javax/swing/JLabel", "east" ), layout$EAST )
setSize( .jnew( "java/awt/Dimension", 400L, 400L ) )
setVisible( TRUE )
} )
}
Double <- J("java.lang.Double")
with( Double, MIN_VALUE )
with( Double, parseDouble( "10.2" ) )
## Not run: [#无法运行:]
# inner class example[内部类的例子]
HashMap <- J("java.util.HashMap")
with( HashMap, new( SimpleEntry, "key", "value" ) )
with( HashMap, SimpleEntry )
## End(Not run)[#结束(不运行)]
with( J("java.lang.System"), getProperty("java.home") )
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|