1.Special Variables and Values 特殊的變量和值
In addition to the scope modifiers: 'this', 'super', 'global',
BeanShell supports a number of pre.defined system variables, "magic" values, and methods.
為了增加作用域的使用:'this','super','global',
Beanshell提供一些提前定義好的系統變量,"magic"值,和方法。
Special Values 特殊值
· $_ . The value of the last expression evaluated.
The strange construct for this is drawn from Perl,
but the idea exists in many scrīpting languages.
It is useful for getting back the last result when you are working interactively.
$_最後一個表達式。
這個奇怪的構造是從perl中過來的,但是這個創意存在于很多腳本語言中。
當你在互動式的運作的時候,在取到最後的結果上面它是很有用的。
· $_e . The last uncaught exception object thrown.
This is useful in interactive use for retrieving the last exception to inspect it for details.
最後一個沒有捕獲的異常對象
在互動式使用中去檢查它得細節而重新取得最後一個異常,它是有用的,
· bsh . The BeanShell root system object, containing system information and variables.
Beanshell根系統對象,包含系統資訊和變量。
· bsh.args . An array of Strings passed as command line arguments to the BeanShell interpreter.
通過指令行參數到Beanshell解釋器得到的一個字元串數組。
· bsh.shared . A special static space which is shared across all interpreter instances.
Normally each bsh.Interpreter instance is entirely independent;
having its own unique global namespace and settings.
bsh.shared is implemented as a static namespace in the bsh.Interpreter class.
It was added primarily to support communication among instances for the GUI desktop.
一個特殊的靜态空間,和所有的解釋器執行個體共享。
正常的每個bsh.Interpreter執行個體是完全獨立的;
有他們自己單獨的全局名字空間和設定。
在bsh.Interpreter類中,bsh.shared是作為一個靜态的名字空間實作的。
它最初加進來是為了,支援執行個體和GUI平台之間的通信。
· bsh.console . If BeanShell is running in its GUI desktop mode,
this variable holds a reference to the current interpreter's console, if it has one.
如果Beanshell運作在它的桌面模式,這個變量儲存一個引用指向目前的解釋器控制台,
當然它隻有一個。
· bsh.appletcontext . If BeanShell is running inside an Applet,
the current applet context, if one exists.
如果Beanshell運作在一個Applet中,就是指這個目前的applet環境。
· bsh.cwd . A String representing the current working directory of the BeanShell interpreter.
This is used or manipulated by the cd(), dir(), pwd(), and pathToFile() commands.
一個字元串,直接為Beanshell解釋器工作的,
這些是被使用或者是通過cd(),dir(),pwd(),pathToFile()指令來操作。
· bsh.show . A boolean value used by the show() command.
It indicates whether results are always printed, for interactive use.
用在show()指令中的布爾值,它表示結果是否要被列印,在互動使用中。
· bsh.interactive .
A boolean indicating whether this interpreter running in an interactive mode。
一個布爾值,表示解釋器是否運作在一個互動模式下。
· bsh.evalOnly .
A boolean indicating whether this interpreter has an input stream or whether is it only
serving as an engine for eval() operations (e.g. for embedded use).
一個布爾值,表示解釋器是否有一個輸入流,
或者它作為一個引擎僅僅是為eval()操作服務的。
Note: 提示:
The choice of "bsh" for the root system object name was somewhat unfortunate
because it conflicts with the current package name for BeanShell (also bsh).
This means that if you wish to work with BeanShell classes explicitly from BeanShell scrīpts
(e.g. bsh.Interpreter)
you must first import them, e.g.:
對于系統根對象名來說,"bsh"的選擇在有些情況下不太好。
因為它對Beanshell來說避免了目前的包名。
這些表明了,如果你希望和Beanshell中的類一起工作,你必須首先導入他們。
import bsh.Interpreter;
i=new Interpreter();
2.Special Members of 'this' type References 'this'類型引用的特别屬性
'this' type references have several "magic" members: 'this'類型引用有幾類"magic"屬性
· this.variables .
An array of Strings listing the variables defined in the current method context(namespace).
一個字元串數組列出了定義在目前函數環境(名字空間)的變量。
· this.methods .
An array of Strings listing the methods defined the current method context(namespace).
一個字元串數組列出了定義在目前函數環境(名字空間)的變量。
· this.interpreter .
A bsh.Interpreter reference to the currently executing BeanShell Interpreter object.
bsh.Interpreter引用指向目前執行的Beanshell解釋器對象。
· this.namespace .
A bsh.NameSpace reference to the BeanShell NameSpace object of the current method context.
See "Advanced Topics".
bsh.NameSpace引用指向Beanshell目前函數環境名字空間對象。請看"進階話題"。
· this.caller .
A bsh.This reference to the calling BeanShell method context.
See "Variables and Scope Modifiers".
bsh.This引用指向Beanshell函數環境。請看"變量和作用域修改"。
· this.callstack .
An array of bsh.NameSpace references representing the "call stack" up to the current method context.
See "Advanced Topics".
一個bsh.NameSpace引用數組表示,"call stack"指向目前函數環境。請看"進階話題"。
These magic references are primarily used by BeanShell commands.
這些魔術引用是最初使用在Beansehll指令中。