2003/11/19 02:40:17
[org.ibex.core.git] / src / org / xwt / Res.java
index d35be09..ae2b50f 100644 (file)
@@ -57,6 +57,7 @@ public abstract class Res extends JS {
         private boolean disk = false;
         private String key;
         public String getCacheKey() throws NotCacheableException { return key; }
+        public String toString() { return key; }
         private Hash cachedInputStreams = new Hash();
         public CachedRes(Res p, String s, boolean d) throws NotCacheableException {
             this.parent = p; this.disk = d; this.key = p.getCacheKey();
@@ -89,6 +90,7 @@ public abstract class Res extends JS {
     public static class HTTP extends Res {
         private String url;
         HTTP(String url) { while (url.endsWith("/")) url = url.substring(0, url.length() - 1); this.url = url; }
+        public String toString() { return url; }
         public String getCacheKey() throws NotCacheableException { return url; }
         public InputStream getInputStream(String path) throws IOException { return new org.xwt.HTTP(url + path).GET(); }
     }
@@ -98,6 +100,7 @@ public abstract class Res extends JS {
         private byte[] bytes;
         private String cacheKey = null;
         ByteArray(byte[] bytes, String cacheKey) { this.bytes = bytes; this.cacheKey = cacheKey; }
+        public String toString() { return "byte[]"; }
         public String getCacheKey() throws NotCacheableException { return cacheKey; }
         public InputStream getInputStream(String path) throws IOException {
             if (!"".equals(path)) throw new JSExn("can't get subresources of a byte[] resource");
@@ -112,6 +115,7 @@ public abstract class Res extends JS {
             while (path.endsWith(java.io.File.separatorChar + "")) path = path.substring(0, path.length() - 1);
             this.path = path;
         }
+        public String toString() { return "file:" + path; }
         public String getCacheKey() throws NotCacheableException { throw notCacheable; }  // already on the disk!
         public InputStream getInputStream(String rest) throws IOException {
             return new FileInputStream((path + rest).replace('/', java.io.File.separatorChar)); }
@@ -121,6 +125,7 @@ public abstract class Res extends JS {
     public static class Zip extends Res {
         private Res parent;
         Zip(Res parent) { this.parent = parent; }
+        public String toString() { return parent.toString() + "!zip"; }
         public String getCacheKey() throws NotCacheableException { return parent.getCacheKey() + "!zip:"; }
         public InputStream getInputStream(String path) throws IOException {
             if (path.startsWith("/")) path = path.substring(1);
@@ -137,6 +142,7 @@ public abstract class Res extends JS {
     public static class Cab extends Res {
         private Res parent;
         Cab(Res parent) { this.parent = parent; }
+        public String toString() { return parent.toString() + "!cab"; }
         public String getCacheKey() throws NotCacheableException { return parent.getCacheKey() + "!cab:"; }
         public InputStream getInputStream(String path) throws IOException {
             if (path.startsWith("/")) path = path.substring(1);
@@ -146,12 +152,13 @@ public abstract class Res extends JS {
 
     /** the Builtin resource */
     public static class Builtin extends Res {
-       public Builtin() { };
-       public String getCacheKey() throws NotCacheableException { throw notCacheable; }    // not cacheable
-       public InputStream getInputStream(String path) throws IOException {
-           if (!path.equals("")) throw new IOException("the builtin resource has no subresources");
-           return Platform.getBuiltinInputStream();
-       }
+        public Builtin() { };
+        public String getCacheKey() throws NotCacheableException { throw notCacheable; }    // not cacheable
+        public String toString() { return "builtin:"; }
+        public InputStream getInputStream(String path) throws IOException {
+            if (!path.equals("")) throw new IOException("the builtin resource has no subresources");
+            return Platform.getBuiltinInputStream();
+        }
     }
 
     /** what you get when you reference a subresource */
@@ -171,6 +178,7 @@ public abstract class Res extends JS {
         final Res watchee;
         JSFunction callback;
         ProgressWatcher(Res watchee, JSFunction callback) { this.watchee = watchee; this.callback = callback; }
+        public String toString() { return watchee.toString(); }
         public String getCacheKey() throws NotCacheableException { return watchee.getCacheKey(); }
         public InputStream getInputStream(String s) throws IOException {
             final InputStream is = watchee.getInputStream(s);