import java.io.*;
import java.util.zip.*;
import org.ibex.util.*;
-import org.ibex.plat.*;
import org.ibex.net.*;
-import org.ibex.core.*;
/**
* Essentiall an InputStream "factory". You can repeatedly ask a
- * Stream for an InputStream, and each InputStream you get back will
+ * Fountain 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 abstract class Fountain extends JS.Cloneable {
// Public Interface //////////////////////////////////////////////////////////////////////////////
- public static InputStream getInputStream(Object js) throws IOException { return ((Stream)((JS)js).unclone()).getInputStream();}
+ public static InputStream getInputStream(Object js) throws IOException { return ((Fountain)((JS)js).unclone()).getInputStream();}
public static class NotCacheableException extends Exception { }
// streams are "sealed" by default to prevent accidental object leakage
protected String getCacheKey() throws NotCacheableException { throw new NotCacheableException(); }
/** HTTP or HTTPS resource */
- public static class HTTP extends Stream {
+ public static class HTTP extends Fountain {
private String url;
public String toString() { return "Stream.HTTP:" + url; }
public HTTP(String url) { while (url.endsWith("/")) url = url.substring(0, url.length() - 1); this.url = url; }
public Object _get(Object key) { return new HTTP(url + "/" + (String)key); }
public String getCacheKey(Vec path) throws NotCacheableException { return url; }
- public InputStream getInputStream() throws IOException { return new org.ibex.net.HTTP(url).GET(); }
+ public InputStream getInputStream() throws IOException { return new org.ibex.net.HTTP(url).GET(null, null); }
}
/** byte arrays */
- public static class ByteArray extends Stream {
+ public static class ByteArray extends Fountain {
private byte[] bytes;
private String cacheKey;
public ByteArray(byte[] bytes, String cacheKey) { this.bytes = bytes; this.cacheKey = cacheKey; }
}
/** a file */
- public static class File extends Stream {
+ public static class File extends Fountain {
private String path;
public File(String path) { this.path = path; }
public String toString() { return "file:" + path; }
}
/** "unwrap" a Zip archive */
- public static class Zip extends Stream {
- private Stream parent;
+ public static class Zip extends Fountain {
+ private Fountain parent;
private String path;
- public Zip(Stream parent) { this(parent, null); }
- public Zip(Stream parent, String path) {
+ public Zip(Fountain parent) { this(parent, null); }
+ public Zip(Fountain parent, String path) {
while(path != null && path.startsWith("/")) path = path.substring(1);
this.parent = parent;
this.path = path;
}
/** "unwrap" a Cab archive */
- public static class Cab extends Stream {
- private Stream parent;
+ /* temporarily disabled due to dependency issues
+ public static class Cab extends Fountain {
+ private Fountain parent;
private String path;
- public Cab(Stream parent) { this(parent, null); }
- public Cab(Stream parent, String path) { this.parent = parent; this.path = path; }
+ public Cab(Fountain parent) { this(parent, null); }
+ public Cab(Fountain parent, String path) { this.parent = parent; this.path = path; }
public String getCacheKey() throws NotCacheableException { return parent.getCacheKey() + "!cab:"; }
public Object _get(Object key) { return new Cab(parent, path==null?(String)key:path+'/'+(String)key); }
public InputStream getInputStream() throws IOException { return new MSPack(parent.getInputStream()).getInputStream(path); }
}
+ */
/** the Builtin resource */
- public static class Builtin extends Stream {
+ /* temporarily disabled due to dependency issues
+ public static class Builtin extends Fountain {
public String getCacheKey() throws NotCacheableException { throw new NotCacheableException(); }
public InputStream getInputStream() throws IOException { return Platform.getBuiltinInputStream(); }
}
+ */
/** shadow resource which replaces the graft */
- public static class ProgressWatcher extends Stream {
- final Stream watchee;
+ /* temporarily disabled due to dependency issues
+ public static class ProgressWatcher extends Fountain {
+ final Fountain watchee;
JS callback;
- public ProgressWatcher(Stream watchee, JS callback) { this.watchee = watchee; this.callback = callback; }
+ public ProgressWatcher(Fountain watchee, JS callback) { this.watchee = watchee; this.callback = callback; }
public String getCacheKey() throws NotCacheableException { return watchee.getCacheKey(); }
public InputStream getInputStream() throws IOException {
final InputStream is = watchee.getInputStream();
};
}
}
+ */
/** subclass from this if you want a CachedInputStream for each path */
- public static class CachedStream extends Stream {
- private Stream parent;
+ /* temporarily disabled due to dependency issues
+ public static class CachedStream extends Fountain {
+ private Fountain parent;
private boolean disk = false;
private String key;
public String getCacheKey() throws NotCacheableException { return key; }
CachedInputStream cis = null;
- public CachedStream(Stream p, String s, boolean d) throws NotCacheableException {
+ public CachedStream(Fountain p, String s, boolean d) throws NotCacheableException {
this.parent = p; this.disk = d; this.key = p.getCacheKey();
}
public InputStream getInputStream() throws IOException {
return cis.getInputStream();
}
}
+ */
}