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 //////////////////////////////////////////////////////////////////////////////
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); }
}
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); }