Patch for source(URL url)

[email protected] Fri, 13 Jan 2006 19:11:26 +0000
Newsgroups gmane.comp.java.beanshell.devel
Message-ID <011320061911.19902.43C7FB5E0008E41500004DBE2197924741CA9B9D0A0D019D0306@mchsi.com>
Hi All,
Please find here a patch to fix the URL load for source scripts.

file: Interpreter.java

fixes:source(URL url)
      source(URL url, NameSpace namespace)

example usage:
a file named somescript.bsh in folder /scripts inside jar file.

  Interpreter i = new Interpreter();
  URL scriptUrl = Example.class.getResource("/scripts/somescript.bsh");
  i.source(scriptUrl);


I apologize for the format differences.

----- begin diff -----
39a40
> import java.net.URL;
586a588,622
> 
> 	/**
> 		Read text from URL and eval it.
> 	*/
>     public Object source( URL url, NameSpace nameSpace ) 
> 		throws FileNotFoundException, IOException, EvalError 
> 	{
> 	BufferedReader sourceIn = new BufferedReader(
> 	  new InputStreamReader(url.openStream(),"UTF-8")
> 	  );
> 
> 
> 	String filename = url.getFile();
> 	if ( Interpreter.DEBUG ) debug("Sourcing file: "+ filename);
> 	
> 	try {
> 	  return eval( sourceIn, nameSpace, filename );
> 	  } finally {
> 	    sourceIn.close();
> 	    }
> 	}
> 
> 
> 	/**
> 		Read text from URL and eval it.
> 	*/
>     public Object source( URL url ) 
> 		throws FileNotFoundException, IOException, EvalError 
> 	{
> 	return source( url, globalNameSpace );
> 	}
> 
> 
> 
> 

----- end diff -----



--
Joe Robertson
Yamaha YZF600R Thundercat
http://home.mchsi.com/~jmrobert5/


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click