summaryrefslogtreecommitdiff
path: root/scripting/java/org/openoffice/idesupport/JavaFinder.java
diff options
context:
space:
mode:
Diffstat (limited to 'scripting/java/org/openoffice/idesupport/JavaFinder.java')
-rw-r--r--scripting/java/org/openoffice/idesupport/JavaFinder.java71
1 files changed, 33 insertions, 38 deletions
diff --git a/scripting/java/org/openoffice/idesupport/JavaFinder.java b/scripting/java/org/openoffice/idesupport/JavaFinder.java
index 98043d2198e8..e9385fd3c57e 100644
--- a/scripting/java/org/openoffice/idesupport/JavaFinder.java
+++ b/scripting/java/org/openoffice/idesupport/JavaFinder.java
@@ -65,10 +65,12 @@ public class JavaFinder implements MethodFinder {
return empty;
parcelName = basedir.getName();
+
if (parcelName.equals(ParcelZipper.CONTENTS_DIRNAME))
parcelName = basedir.getParentFile().getName();
String[] classNames = findClassNames(basedir);
+
if (classNames != null && classNames.length != 0) {
ClassLoader classloader;
@@ -78,40 +80,32 @@ public class JavaFinder implements MethodFinder {
else
classloader = getClassLoader();
- for (int i = 0; i < classNames.length; i++)
- {
- try
- {
+ for (int i = 0; i < classNames.length; i++) {
+ try {
Class clazz = classloader.loadClass(classNames[i]);
Method[] methods = clazz.getDeclaredMethods();
- for (int k = 0; k < methods.length; k++)
- {
- if (Modifier.isPublic(methods[k].getModifiers()))
- {
+
+ for (int k = 0; k < methods.length; k++) {
+ if (Modifier.isPublic(methods[k].getModifiers())) {
Class[] params = methods[k].getParameterTypes();
- if(params.length > 0)
- {
- if(params[0].getName().equals(FIRST_PARAM))
- {
+
+ if (params.length > 0) {
+ if (params[0].getName().equals(FIRST_PARAM)) {
ScriptEntry entry =
new ScriptEntry(classNames[i] + "." +
- methods[k].getName(), parcelName);
+ methods[k].getName(), parcelName);
result.add(entry);
}
}
}
}
- }
- catch (ClassNotFoundException e)
- {
+ } catch (ClassNotFoundException e) {
System.err.println("Caught ClassNotFoundException loading: "
- + classNames[i]);
+ + classNames[i]);
continue;
- }
- catch (NoClassDefFoundError nc)
- {
+ } catch (NoClassDefFoundError nc) {
System.err.println("Caught NoClassDefFoundErr loading: " +
- classNames[i]);
+ classNames[i]);
continue;
}
}
@@ -119,6 +113,7 @@ public class JavaFinder implements MethodFinder {
if (result.size() != 0)
return result.toArray(empty);
+
return empty;
}
@@ -133,8 +128,7 @@ public class JavaFinder implements MethodFinder {
if (s != null)
urls.add(new URL(s));
- }
- catch (MalformedURLException mue) {
+ } catch (MalformedURLException mue) {
}
}
@@ -146,7 +140,8 @@ public class JavaFinder implements MethodFinder {
files.add(basedir);
try {
- Iterator<OfficeInstallation> offices = SVersionRCFile.createInstance().getVersions();
+ Iterator<OfficeInstallation> offices =
+ SVersionRCFile.createInstance().getVersions();
while (offices.hasNext()) {
OfficeInstallation oi = offices.next();
@@ -157,14 +152,14 @@ public class JavaFinder implements MethodFinder {
break;
}
}
- }
- catch (IOException ioe) {
+ } catch (IOException ioe) {
return null;
}
URL[] urls = new URL[files.size()];
String urlpath;
File f;
+
for (int i = 0; i < urls.length; i++) {
try {
f = files.get(i);
@@ -172,8 +167,7 @@ public class JavaFinder implements MethodFinder {
if (urlpath != null)
urls[i] = new URL(urlpath);
- }
- catch (MalformedURLException mue) {
+ } catch (MalformedURLException mue) {
// do nothing, go on to next file
}
}
@@ -191,36 +185,36 @@ public class JavaFinder implements MethodFinder {
else if (children[i].getName().endsWith(suffix))
result.add(children[i]);
}
+
return result;
}
- private String[] findClassNames(File basedir)
- {
+ private String[] findClassNames(File basedir) {
ArrayList<File> classFiles = findFiles(basedir, CLASS_SUFFIX);
- if(classFiles == null || classFiles.size() == 0)
+
+ if (classFiles == null || classFiles.size() == 0)
return null;
ArrayList<File> javaFiles = findFiles(basedir, JAVA_SUFFIX);
- if(javaFiles == null || javaFiles.size() == 0)
+
+ if (javaFiles == null || javaFiles.size() == 0)
return null;
ArrayList<String> result = new ArrayList<String>();
- for (int i = 0; i < classFiles.size(); i++)
- {
+
+ for (int i = 0; i < classFiles.size(); i++) {
File classFile = classFiles.get(i);
String className = classFile.getName();
className = className.substring(0, className.lastIndexOf(CLASS_SUFFIX));
boolean finished = false;
- for (int j = 0; j < javaFiles.size() && !finished; j++)
- {
+ for (int j = 0; j < javaFiles.size() && !finished; j++) {
File javaFile = javaFiles.get(j);
String javaName = javaFile.getName();
javaName = javaName.substring(0, javaName.lastIndexOf(JAVA_SUFFIX));
- if (javaName.equals(className))
- {
+ if (javaName.equals(className)) {
String path = classFile.getAbsolutePath();
path = path.substring(basedir.getAbsolutePath().length() + 1);
path = path.replace(File.separatorChar, '.');
@@ -232,6 +226,7 @@ public class JavaFinder implements MethodFinder {
}
}
}
+
return result.toArray(new String[result.size()]);
}
}