PageRenderTime 41ms CodeModel.GetById 38ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/jEdit/tags/jedit-4-3-pre5/bsh/commands/source.bsh

#
Unknown | 23 lines | 19 code | 4 blank | 0 comment | 0 complexity | df72bd369409d2aef3fc9cc7c0c4109d MD5 | raw file
 1/**
 2	Read filename into the interpreter and evaluate it in the current
 3	namespace.  Like the Bourne Shell "." command.
 4	This command acts exactly like the eval() command but reads from a file 
 5	or URL source.
 6	@see eval() for more information.
 7	@throws bsh.EvalError or bsh.TargetError on errors in the sourced script.
 8*/
 9
10bsh.help.source = "usage: source( filename | URL )";
11
12Object source( String filename ) {
13	// source with filename preserves file name in error messages
14	return this.interpreter.source( filename, this.caller.namespace );
15}
16
17Object source( URL url ) {
18	return this.interpreter.eval( 
19		new InputStreamReader(url.openStream()), this.caller.namespace,  
20		"URL: "+url.toString()
21	);
22}
23