summaryrefslogtreecommitdiff
path: root/jurt
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2014-10-15 14:43:35 +0200
committerNoel Grandin <noel@peralex.com>2014-10-16 08:15:48 +0200
commit973eb2f6db60c0939299a968a3121e3310e6d1f5 (patch)
tree9eece355c20bc4d930e7e58943fc2d33bedfcfd0 /jurt
parentfa652cdd2314f485359119a8ff081a7afd1c01b0 (diff)
java: reduce the depth of some deeply nested if blocks
Change-Id: I3c0c7f08d4d8ea594e72fc0d9b93d085d4ab4bf5
Diffstat (limited to 'jurt')
-rw-r--r--jurt/com/sun/star/comp/loader/JavaLoader.java80
-rw-r--r--jurt/com/sun/star/lib/util/NativeLibraryLoader.java39
2 files changed, 60 insertions, 59 deletions
diff --git a/jurt/com/sun/star/comp/loader/JavaLoader.java b/jurt/com/sun/star/comp/loader/JavaLoader.java
index fb7c6d8372da..8244d43c326c 100644
--- a/jurt/com/sun/star/comp/loader/JavaLoader.java
+++ b/jurt/com/sun/star/comp/loader/JavaLoader.java
@@ -84,49 +84,49 @@ public class JavaLoader implements XImplementationLoader,
*/
private String expand_url( String url ) throws RuntimeException
{
- if (url != null && url.startsWith( EXPAND_PROTOCOL_PREFIX )) {
- try {
- if (m_xMacroExpander == null) {
- XPropertySet xProps =
- UnoRuntime.queryInterface(
- XPropertySet.class, multiServiceFactory );
- if (xProps == null) {
- throw new com.sun.star.uno.RuntimeException(
- "service manager does not support XPropertySet!",
- this );
- }
- XComponentContext xContext = (XComponentContext)
- AnyConverter.toObject(
- new Type( XComponentContext.class ),
- xProps.getPropertyValue( "DefaultContext" ) );
- m_xMacroExpander = (XMacroExpander)AnyConverter.toObject(
- new Type( XMacroExpander.class ),
- xContext.getValueByName(
- "/singletons/com.sun.star.util.theMacroExpander" )
- );
- }
- // decode uric class chars
- String macro = URLDecoder.decode(
- StringHelper.replace(
- url.substring( EXPAND_PROTOCOL_PREFIX.length() ),
- '+', "%2B" ), "UTF-8" );
- // expand macro string
- String ret = m_xMacroExpander.expandMacros( macro );
- if (DEBUG) {
- System.err.println(
- "JavaLoader.expand_url(): " + url + " => " +
- macro + " => " + ret );
+ if (url == null || !url.startsWith( EXPAND_PROTOCOL_PREFIX )) {
+ return url;
+ }
+ try {
+ if (m_xMacroExpander == null) {
+ XPropertySet xProps =
+ UnoRuntime.queryInterface(
+ XPropertySet.class, multiServiceFactory );
+ if (xProps == null) {
+ throw new com.sun.star.uno.RuntimeException(
+ "service manager does not support XPropertySet!",
+ this );
}
- return ret;
- } catch (com.sun.star.uno.Exception exc) {
- throw new com.sun.star.uno.RuntimeException(
- exc.getMessage(), this );
- } catch (java.lang.Exception exc) {
- throw new com.sun.star.uno.RuntimeException(
- exc.getMessage(), this );
+ XComponentContext xContext = (XComponentContext)
+ AnyConverter.toObject(
+ new Type( XComponentContext.class ),
+ xProps.getPropertyValue( "DefaultContext" ) );
+ m_xMacroExpander = (XMacroExpander)AnyConverter.toObject(
+ new Type( XMacroExpander.class ),
+ xContext.getValueByName(
+ "/singletons/com.sun.star.util.theMacroExpander" )
+ );
+ }
+ // decode uric class chars
+ String macro = URLDecoder.decode(
+ StringHelper.replace(
+ url.substring( EXPAND_PROTOCOL_PREFIX.length() ),
+ '+', "%2B" ), "UTF-8" );
+ // expand macro string
+ String ret = m_xMacroExpander.expandMacros( macro );
+ if (DEBUG) {
+ System.err.println(
+ "JavaLoader.expand_url(): " + url + " => " +
+ macro + " => " + ret );
}
+ return ret;
+ } catch (com.sun.star.uno.Exception exc) {
+ throw new com.sun.star.uno.RuntimeException(
+ exc.getMessage(), this );
+ } catch (java.lang.Exception exc) {
+ throw new com.sun.star.uno.RuntimeException(
+ exc.getMessage(), this );
}
- return url;
}
/**
diff --git a/jurt/com/sun/star/lib/util/NativeLibraryLoader.java b/jurt/com/sun/star/lib/util/NativeLibraryLoader.java
index 099cf69d1881..d9486550855e 100644
--- a/jurt/com/sun/star/lib/util/NativeLibraryLoader.java
+++ b/jurt/com/sun/star/lib/util/NativeLibraryLoader.java
@@ -89,33 +89,34 @@ public final class NativeLibraryLoader {
// (scheme://auth/dir1/name). The second step is important in a typical
// OOo installation, where the JAR files are in the program/classes
// directory while the shared libraries are in the program directory.
- if (loader instanceof URLClassLoader) {
- URL[] urls = ((URLClassLoader) loader).getURLs();
- for (int i = 0; i < urls.length; ++i) {
- File path = UrlToFileMapper.mapUrlToFile(urls[i]);
- if (path != null) {
- File dir = path.isDirectory() ? path : path.getParentFile();
+ if (!(loader instanceof URLClassLoader)) {
+ return null;
+ }
+ URL[] urls = ((URLClassLoader) loader).getURLs();
+ for (int i = 0; i < urls.length; ++i) {
+ File path = UrlToFileMapper.mapUrlToFile(urls[i]);
+ if (path != null) {
+ File dir = path.isDirectory() ? path : path.getParentFile();
+ if (dir != null) {
+ path = new File(dir, name);
+ if (path.exists()) {
+ return path;
+ }
+ dir = dir.getParentFile();
if (dir != null) {
path = new File(dir, name);
if (path.exists()) {
return path;
}
- dir = dir.getParentFile();
- if (dir != null) {
- path = new File(dir, name);
+ // On OS X, dir is now the Resources dir,
+ // we want to look in Frameworks
+ if (System.getProperty("os.name").startsWith("Mac")
+ && dir.getName().equals("Resources")) {
+ dir = dir.getParentFile();
+ path = new File(dir, "Frameworks/" + name);
if (path.exists()) {
return path;
}
- // On OS X, dir is now the Resources dir,
- // we want to look in Frameworks
- if (System.getProperty("os.name").startsWith("Mac")
- && dir.getName().equals("Resources")) {
- dir = dir.getParentFile();
- path = new File(dir, "Frameworks/" + name);
- if (path.exists()) {
- return path;
- }
- }
}
}
}