2 import java
.io
.InputStream
;
3 import java
.io
.IOException
;
5 import java
.net
.URLDecoder
;
7 import com
.sun
.star
.uno
.XComponentContext
;
8 import com
.sun
.star
.script
.framework
.provider
.PathUtils
;
9 import com
.sun
.star
.script
.framework
.runtime
.XScriptContext
;
11 public class DebugRunner
{
13 private static final String FILE_URL_PREFIX
=
14 System
.getProperty("os.name").startsWith("Windows") == true ?
15 "file:///" : "file://";
17 public void go(final XScriptContext xsctxt
, String language
, String uri
,
20 OOScriptDebugger debugger
;
23 if (language
.equals("JavaScript")) {
24 debugger
= new OORhinoDebugger();
26 else if (language
.equals("BeanShell")) {
27 debugger
= new OOBeanShellDebugger();
33 if (uri
.startsWith(FILE_URL_PREFIX
)) {
34 uri
= URLDecoder
.decode(uri
);
35 String s
= uri
.substring(FILE_URL_PREFIX
.length());
39 if (f
.isDirectory()) {
40 if (!filename
.equals("")) {
41 path
= new File(f
, filename
).getAbsolutePath();
45 path
= f
.getAbsolutePath();
48 debugger
.go(xsctxt
, path
);
51 if (!uri
.endsWith("/")) {
55 String script
= uri
+ filename
;
59 is
= PathUtils
.getScriptFileStream(
60 script
, xsctxt
.getComponentContext());
63 debugger
.go(xsctxt
, is
);
66 catch (IOException ioe
) {
67 System
.out
.println("Error loading script: " + script
);