summaryrefslogtreecommitdiff
path: root/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSBundle.java
diff options
context:
space:
mode:
authorBenjamin Culkin <scorpress@gmail.com>2024-05-20 17:58:16 -0400
committerBenjamin Culkin <scorpress@gmail.com>2024-05-20 17:58:16 -0400
commit40a9d99496e098562f090fb7ffce9e749011b131 (patch)
tree437df24d65470582e943e494a52db8ed65a881ae /projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSBundle.java
parentff072dfe782f6f22123cd4ba050828d35c0d0fbd (diff)
Formatting pass
Diffstat (limited to 'projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSBundle.java')
-rw-r--r--projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSBundle.java101
1 files changed, 43 insertions, 58 deletions
diff --git a/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSBundle.java b/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSBundle.java
index b735404..49dda88 100644
--- a/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSBundle.java
+++ b/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSBundle.java
@@ -67,7 +67,7 @@ public class NSBundle {
private static NSMutableDictionary _languageCodes = new NSMutableDictionary();
private static NSBundle _mainBundle = null;
-
+
protected static NetworkClassLoader _classLoader = new NetworkClassLoader(ClassLoader.getSystemClassLoader());
/* Instance variables */
@@ -94,8 +94,8 @@ public class NSBundle {
/**
* The default constructor, which is only public to support other framework
- * functionality, and to be API compatible with Apple's WebObjects.
- * Generally, framework users should use bundleForXXXX() methods.
+ * functionality, and to be API compatible with Apple's WebObjects. Generally,
+ * framework users should use bundleForXXXX() methods.
*/
public NSBundle() {
}
@@ -118,11 +118,10 @@ public class NSBundle {
}
/**
- * Returns the bundle that contains the provided class, if any. Otherwise,
- * it returns null. Because NSBundles have a specialized class-loader, if
- * any two bundles contain duiplicates of the same class, the second will
- * fail to load. TODO: Determine if class-load scoping of duplicate classes
- * is appropriate.
+ * Returns the bundle that contains the provided class, if any. Otherwise, it
+ * returns null. Because NSBundles have a specialized class-loader, if any two
+ * bundles contain duiplicates of the same class, the second will fail to load.
+ * TODO: Determine if class-load scoping of duplicate classes is appropriate.
*
* @param class1
* @return NSBundle
@@ -133,8 +132,7 @@ public class NSBundle {
}
/**
- * @deprecated Apple's WebObjects says you should not load from arbitrary
- * path.
+ * @deprecated Apple's WebObjects says you should not load from arbitrary path.
* @param path
* @return
*/
@@ -150,9 +148,9 @@ public class NSBundle {
/**
* <strong>Note:</strong>This method is only in Wotonomy.
*
- * This method returns a bundle at a given URL, registering that bundle as
- * well. If the bundle has already been loaded/registered, it is simply
- * returned from the cache.
+ * This method returns a bundle at a given URL, registering that bundle as well.
+ * If the bundle has already been loaded/registered, it is simply returned from
+ * the cache.
*
* @param url
* @return
@@ -170,14 +168,11 @@ public class NSBundle {
StringBuffer filename = new StringBuffer(f.getName());
int extensionIndex = filename.lastIndexOf(".");
if (extensionIndex == -1) {
- NSLog.err
- .appendln("Named URL does not point to a bundle with an extension: "
- + url);
+ NSLog.err.appendln("Named URL does not point to a bundle with an extension: " + url);
return null;
}
String basename = filename.substring(0, extensionIndex);
- String extension = filename.substring(extensionIndex + 1, filename
- .length());
+ String extension = filename.substring(extensionIndex + 1, filename.length());
System.out.println("basename: " + basename);
System.out.println("extension: " + extension);
result = new NSBundle();
@@ -185,16 +180,15 @@ public class NSBundle {
result.isFramework = extension.equals("framework");
if (f.isDirectory()) {
try {
- File javadir = new File(f.getCanonicalPath() + sep + "Contents"
- + sep + "Resources" + sep + "Java");
+ File javadir = new File(f.getCanonicalPath() + sep + "Contents" + sep + "Resources" + sep + "Java");
System.out.println(javadir);
System.out.println(javadir.exists());
File[] jars = javadir.listFiles();
-
- } catch (IOException e) { }
+
+ } catch (IOException e) {
+ }
} else {
- throw new RuntimeException(
- "Compressed bundle files not currently supported.");
+ throw new RuntimeException("Compressed bundle files not currently supported.");
}
throw new RuntimeException("Method not finished.");
} else {
@@ -205,10 +199,8 @@ public class NSBundle {
JarFile f;
throw new RuntimeException("Method not finished.");
} catch (IOException e) {
- NSLog.err
- .appendln("IOException loading framework jar from URL "
- + url + " - message: "
- + e.getLocalizedMessage());
+ NSLog.err.appendln(
+ "IOException loading framework jar from URL " + url + " - message: " + e.getLocalizedMessage());
StringWriter stacktrace = new StringWriter();
e.printStackTrace(new PrintWriter(stacktrace));
NSLog.err.appendln(stacktrace);
@@ -218,10 +210,9 @@ public class NSBundle {
}
/**
- * This method returns a bundle, either from cache, or if it doesn't exist
- * yet, it attempts to look it up - first from the classpath, then from the
- * resource path. TODO: Determine if the lookup order is the desired
- * semantic.
+ * This method returns a bundle, either from cache, or if it doesn't exist yet,
+ * it attempts to look it up - first from the classpath, then from the resource
+ * path. TODO: Determine if the lookup order is the desired semantic.
*
* @param name
* @return
@@ -237,9 +228,9 @@ public class NSBundle {
/**
* Used to set the "Main" application bundle, in which primary resources are
- * loaded for GUI applications. This is mostly only relevant for
- * XXApplication objects. This should therefore not be generally used by
- * consumers of the framework.
+ * loaded for GUI applications. This is mostly only relevant for XXApplication
+ * objects. This should therefore not be generally used by consumers of the
+ * framework.
*
* @param aBundle
*/
@@ -252,14 +243,13 @@ public class NSBundle {
}
/**
- * Get the default prefix for locale. TODO: This really needs to be made
- * dynamic somehow.
+ * Get the default prefix for locale. TODO: This really needs to be made dynamic
+ * somehow.
*
* @return
*/
protected static String defaultLocalePrefix() {
- String language = (String) _languageCodes.objectForKey(Locale
- .getDefault().getLanguage());
+ String language = (String) _languageCodes.objectForKey(Locale.getDefault().getLanguage());
return language + ".lproj";
}
@@ -283,8 +273,8 @@ public class NSBundle {
}
/**
- * Returns a byte array for the given resource path. TODO: Lookup semantics
- * in WebObjects javadocs.
+ * Returns a byte array for the given resource path. TODO: Lookup semantics in
+ * WebObjects javadocs.
*
* @param path
* @return
@@ -303,8 +293,8 @@ public class NSBundle {
}
/**
- * Returns an input stream for a given resource path. TODO: Lookup semantics
- * in WebObjects javadocs.
+ * Returns an input stream for a given resource path. TODO: Lookup semantics in
+ * WebObjects javadocs.
*
* @param path
* @return
@@ -339,14 +329,12 @@ public class NSBundle {
* @deprecated Don't use this method, use
* resourcePathForLocalizedResourceNamed() instead.
*/
- public String pathForResource(String aName, String anExtension,
- String subDir) {
+ public String pathForResource(String aName, String anExtension, String subDir) {
return this.resourcePathForLocalizedResourceNamed(aName, subDir);
}
/**
- * @deprecated Don't use this method, use resourcePathsForResources()
- * instead.
+ * @deprecated Don't use this method, use resourcePathsForResources() instead.
*/
public NSArray pathsForResources(String aName, String anExtension) {
throw new UnsupportedOperationException("Method not yet implemented.");
@@ -362,27 +350,24 @@ public class NSBundle {
}
/**
- * @deprecated Resources are now accessed using the bytesForResourcePath()
- * and inputStreamForResourcePath() methods.
+ * @deprecated Resources are now accessed using the bytesForResourcePath() and
+ * inputStreamForResourcePath() methods.
*/
public String resourcePath() {
throw new UnsupportedOperationException("Method not yet implemented.");
// TODO: Implement.
}
- public String resourcePathForLocalizedResourceNamed(String aName,
- String subDir) {
+ public String resourcePathForLocalizedResourceNamed(String aName, String subDir) {
throw new UnsupportedOperationException("Method not yet implemented.");
// TODO: Implement.
}
- public NSArray resourcePathsForDirectories(String extension,
- String subdirPath) {
+ public NSArray resourcePathsForDirectories(String extension, String subdirPath) {
throw new UnsupportedOperationException("Method not yet implemented.");
}
- public NSArray resourcePathsForLocalizedResources(String extension,
- String subdirPath) {
+ public NSArray resourcePathsForLocalizedResources(String extension, String subdirPath) {
throw new UnsupportedOperationException("Method not yet implemented.");
}
@@ -395,8 +380,8 @@ public class NSBundle {
int i = 0;
if (classNames != null)
i = classNames.count();
- return "<" + getClass().getName() + " name:'" + name + "' bundlePath:'"
- + path + "' packages:'" + packages + "' " + i + " classes >";
+ return "<" + getClass().getName() + " name:'" + name + "' bundlePath:'" + path + "' packages:'" + packages
+ + "' " + i + " classes >";
}
/* Static initialization code */
@@ -412,7 +397,7 @@ public class NSBundle {
static {
NSBundle._initLanguages();
-
+
}
}