Beanshell翻译11

上一篇 / 下一篇  2008-09-02 20:22:39 / 个人分类:Beanshell

Beanshell翻译11

http://user.qzone.qq.com/281696143/blog/1218618449  Ronger
1.Undefined Variables 没有定义的变量
You can test to see if a variable is defined using the special value void. For example:
你可以看一下,当一个变量用特殊的值void来进行定义的时候,例如:
if ( foobar == void )
// undefined 没有定义
You can return a variable to the undefined state using the unset() command:
你可以使用unset()命令,返回一个没有定义状态的变量。
a == void; // true
a=5;
unset("a"); // note the quotes 注意这个引用
a == void; // true
Setting the Command Prompt 设置命令提示
Users may set the command line prompt string for use in interactive mode
by setting the value of the variable bsh.prompt or
by defining the scrīpted method (or command) getBshPrompt().
用户可以通过设置命令行prompt字符串,
设置变量bsh.prompt的值或者是通过定义脚本函数getBshPrompt()
来在交互模式下使用。
If the command or method getBshPrompt() is defined
it will be called to get a string to display as the user prompt.
For example, one could define the following method
to place the current working directory into their command prompt:
如果命令或者函数getBshPrompt()被定义,它将被调用,取得一个用于提示用户的字符串。
例如,一个人可以定义下面的函数,将当前的工作路径进入它的命令提示。
getBshPrompt() { return bsh.cwd + " % "; }
The default getBshPrompt() command returns the value of the variable bsh.prompt
if it is defined or the string "bsh % " if not.
If the getBshPrompt() method or command does not exist, throws an exception,
or does not return a String, a default prompt of "bsh % " will be used.
默认的getBshPrompt()命令返回变量bsh.prompt的值,条件是如果它被定义了或者
字符串"bsh % "没有定义。
如果getBshPrompt()函数或者命令不存在,抛出一个异常,
或者没有返回一个字符串,一个默认的"bsh % "的提示将被使用。
BeanShell Commands Beanshell命令
BeanShell commands appear to the user as pre.defined methods such as print(), load(), or save().
BeanShell Commands can be implemented as scrīpted methods or compiled Java classes
which are dynamically loaded on demand from the classpath.
We'll talk about adding your own commands in the next section "Adding BeanShell Commands".
Beanshell命令对用户来说就是一些提前定义的函数例如print(),load(),或者save().
Beanshell命令可以使用脚本函数或者编译好的Java类来实现,其中
Java类是可以按要求从类路径中动态加载的。
我们将在下一章"Adding BeanShell Commands"中谈谈添加你自己的命令。
Tip: 提示:
You can easily override any BeanShell command simply
by defining the method yourself in your scrīpt. For example:
通过在脚本中定义你自己的函数,你可以很容易的重写Beanshell命令。例如:
print( arg ) {
System.out.println( "You printed: " + arg );
}
If you define the method in the global scope it will apply everywhere.
If you define it local to a scrīpted object it will only apply in that object context.
如果你定义函数在全局的作用域中,它将在任何地方应用。
如果你在一个脚本对象中定义它为本地的,它将只能在对象环境中应用。
2.Commands Overview 命令的总的看法
This is a high level overview of the BeanShell command set.
You can find full documentation for all BeanShell commands
in the "BeanShell Commands Documentation" section of this manual.
See also the "BshDoc" section
which covers javadoc style documentation of BeanShell scrīpt files.
这里是Beanshell的命令设置的高度概括。
你可以找到关于Beanshell命令的完整文档,在"Beanshell Commands Documentation"章节中。
也可以"BshDoc"章节,这个章节讲解了Beanshell脚本文件的javadoc样式的文档。
3.Interpreter Modes 解释器模式
The following commands affect general modes of operation of the interpreter.
下面的命令影响解释器操作的常用模式。
exit() Exit the interpreter. (Also Control.D).
退出解释器
show()
Turn on "show" mode
which prints the result of every evaluation that is not of void type.
show() 打开"show"模式,这个模式是用来打印每个计算的结果的。
setAccessibility()
Turn on access to private and protected members of Java classes.
setAccessibility() 打开Java类的私有和受保护变量的存取。
server()
Launch the remote access mode,
allowing remote access to the interpreter from a web browser or telnet client.
server() 打开远程存取模式,允许从一个web浏览器或者是远程登录客户端,对解释器进行远程存取。
debug()
Turns on debug mode. Note: this is very verbose, unstructured output and is primarily of
interest to developers.
debug() 打开调试模式。注意:这里是非常详细的,非结构化的输出,并且最初对开发者来说是很有趣的。
setStrictJava()
Turn on "strict Java" mode
which enforces Java compatibility by dissallowing loose types and undeclared variables.
setStrictJava() 打开"strict Java"模式,
这个模式,这个模式可以强迫Java不接受松散类型和未定义的变量。
Output 输出
The following commands are used for output:
下面的命令是用来做输出的:
print(), error() Print output to standard out or standard error.
print(), error()打印输出到标准输出或者标准错误。
print() always goes to the console,
whereas System.out may or may not be captured by a GUI console or servlet.
print()也可以去控制台,
然而System.out可以被一个GUI控制台或者servlet捕捉,也可以不这样。
frame() Display the AWT or Swing component in a Frame
frame()在一个Frame中显示AWT或者Swing组件
4.Source and Evaluation 源和计算表达式
The following commands are used for evaluation or to run external scrīpts or applications:
下面的命令是用来计算表达式或者运行第三方的脚本或者应用程序:
eval() Evaluate a string as if it were typed in the current scope.
eval() 计算一个字符串,当它定义在当前的作用域中。
source(), sourceRelative()
Read an external scrīpt file into the interpreter and evaluate it in the current scope
读取一个第三方的脚本文件进入解释器并且在当前的作用域中计算它。
run(), bg()
Run an external file in a subordinate interpreter or
in a background thread in a subordinate interpreter.
在一个从属的解释器中,运行一个第三方的文件。
exec()
Run a native executable in the host OS
在主机OS中,运行一个本地的可以执行的脚本。
Utilities 有效性
The following commands are useful utilities:
下面的命令是很有效的:
javap() Print the methods and fields of an object, similar to the output of javap
javap() 打印一个对象的方法和属性,和javap的输出类似。
which()
Like the Unix 'which' command for executables.
Map the classpath and determine the location of the specified class.
就像Unix中的'which'命令一样。
绘制类路径,并且决定特殊类的位置。
load(), save()
load a serializable object from a file or save one to a file.
Special handling is provided for certain objects.
从一个文件中,加载一个序列化的对象,或者将它存到文件中。
特殊处理是提供确定的对象。
object() Create an "empty" object context to hold variables; analogous to a Map.
创建一个空对象环境,用来保存变量;类似于一个Map.
5.Variables and Scope 变量和作用域
The following commands affect the current scope: 下面的命令影响当前的作用域:
clear() Clear all variables, methods and imports from the current scope.
clear() 清理所有的变量,方法和从当前作用域中导入的东西。
unset() Remove a variable from the current scope. (Return it to the "undefined" state).
unset() 从一个当前的作用域中移除一个变量。(将它返回个"undefined"状态)。
setNameSpace()
Set the current namespace to a specified scope.
Effectively bind the current scope to a new parent scope.
设置当前名字空间为一个特殊的作用域。
有效的将当前的作用域绑定到一个新的父亲作用域上面。
6.Classpath 类路径
The following commands manipulate or access the classpath:
下面的命令巧妙的操作来存取类路径:
addClassPath(), setClassPath(), getClassPath() Modify the BeanShell classpath.
修改Beanshell类路径。
reloadClasses() Reload a class or group of classes.
重新加载一个类或者一群类。
getClass()
Load a class explicitly taking into account the BeanShell classpath.
从Beanshell类路径下面明确的加载一个类。
getResource() Get a resource from the classpath.
从类路径中取得一个源。


TAG: Beanshell

FISHY'S TRIBE 引用 删除 fishy   /   2008-09-03 10:09:46
你自己翻译的?
有没有兴趣参加51Testing的译文征稿活动?
我的qq:45281147
 

评分:0

我来说两句

日历

« 2024-03-29  
     12
3456789
10111213141516
17181920212223
24252627282930
31      

数据统计

  • 访问量: 25678
  • 日志数: 25
  • 建立时间: 2008-08-27
  • 更新时间: 2008-09-02

RSS订阅

Open Toolbar