private final byte[] bytes;
private final int off;
private final int len;
+ protected ByteArray(String s) {
+ try {
+ byte[] bytes = s.getBytes("UTF-8");
+ this.bytes = bytes;
+ this.off = 0;
+ this.len = bytes.length;
+ } catch (UnsupportedEncodingException e) {
+ throw new RuntimeException(e);
+ }
+ }
public ByteArray(byte[] bytes) { this(bytes, 0, bytes.length); }
public ByteArray(byte[] bytes, int off, int len) { this.bytes = bytes; this.off=off; this.len=len; }
public Stream getStream() { return new Stream(bytes, off, len); }
public int getNumLines() { return Stream.countLines(getStream()); }
}
- public static class StringFountain implements Fountain {
- String s;
- public StringFountain(String s) { this.s = s; }
- public Stream getStream() { return new Stream(s); }
- public int getLength() { return s.length(); } // FIXME ENCODING ISSUES!!!!!
- public int getNumLines() { return Stream.countLines(getStream()); }
+
+ public static class StringFountain extends ByteArray {
+ public StringFountain(String s) { super(s); }
}
public static class Concatenate implements Fountain {