From: david Date: Fri, 30 Jan 2004 07:41:56 +0000 (+0000) Subject: 2003/11/19 02:40:17 X-Git-Tag: RC3~325 X-Git-Url: http://git.megacz.com/?p=org.ibex.core.git;a=commitdiff_plain;h=42ee7468a94513c2b0aa4f42252dfa705ba6f530 2003/11/19 02:40:17 darcs-hash:20040130074156-0c9ea-6379ba5a1b4c4aea3b1d9fe5ee1bbe27262f8d6e.gz --- diff --git a/src/org/xwt/Res.java b/src/org/xwt/Res.java index d35be09..ae2b50f 100644 --- a/src/org/xwt/Res.java +++ b/src/org/xwt/Res.java @@ -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); diff --git a/src/org/xwt/Template.java b/src/org/xwt/Template.java index 25159b4..90f5565 100644 --- a/src/org/xwt/Template.java +++ b/src/org/xwt/Template.java @@ -89,7 +89,12 @@ public class Template { // Methods to apply templates //////////////////////////////////////////////////////// - private Template(Res r) { this.r = r; } + private Template(Res r) { + this.r = r; + String f = r.toString(); + if (f != null && !f.equals("")) + fileName = f.substring(f.lastIndexOf('/')+1, f.endsWith(".xwt") ? f.length() - 4 : f.length()); + } /** called before this template is applied or its static object can be externally referenced */ JSScope getStatic() {