X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Forg%2Fxwt%2FStream.java;h=c28b070b1b3f44871bd7d884014fe1f2da78fe94;hb=16ad8b9430571d806f2aeb18ec472a277ff69423;hp=0d5f0378acf002ee31324f4540bc17b11bfe905e;hpb=220fdfe36b610a003eb9163949a8b2c78b6530fa;p=org.ibex.core.git diff --git a/src/org/xwt/Stream.java b/src/org/xwt/Stream.java index 0d5f037..c28b070 100644 --- a/src/org/xwt/Stream.java +++ b/src/org/xwt/Stream.java @@ -9,7 +9,12 @@ import org.xwt.util.*; import org.xwt.translators.MSPack; import org.bouncycastle.util.encoders.Base64; -/** Base class for XWT resources */ +/** + * Essentiall an InputStream "factory". You can repeatedly ask a + * Stream for an InputStream, and each InputStream you get back will + * be totally independent of the others (ie separate stream position + * and state) although they draw from the same data source. + */ public abstract class Stream extends JS.Cloneable { // Public Interface ////////////////////////////////////////////////////////////////////////////// @@ -40,7 +45,8 @@ public abstract class Stream extends JS.Cloneable { private byte[] bytes; private String cacheKey; ByteArray(byte[] bytes, String cacheKey) { this.bytes = bytes; this.cacheKey = cacheKey; } - public String getCacheKey() throws NotCacheableException { return cacheKey; } + public String getCacheKey() throws NotCacheableException { + if (cacheKey == null) throw new NotCacheableException(); return cacheKey; } public InputStream getInputStream() throws IOException { return new ByteArrayInputStream(bytes); } } @@ -60,9 +66,9 @@ public abstract class Stream extends JS.Cloneable { private String path; Zip(Stream parent) { this(parent, null); } Zip(Stream parent, String path) { - this.parent=parent; - while (path != null && path.startsWith("/")) path = path.substring(1); - this.path=path; + while(path != null && path.startsWith("/")) path = path.substring(1); + this.parent = parent; + this.path = path; } public String getCacheKey() throws NotCacheableException { return parent.getCacheKey() + "!zip:"; } public Object get(Object key) throws JSExn { return new Zip(parent, path==null?(String)key:path+'/'+(String)key); }