@Test public void headTest() throws Exception { LazyImmutableRep rep = new LazyImmutableRep(text, in("some awesome text")); assertEquals("some aweso", string(rep.head(10))); assertEquals("some ", string(rep.head(5))); assertEquals("some awesome te", string(rep.head(15))); assertEquals("some awesome text", string(rep.head(20))); }
public byte[] head(int n) { byte[] got = get(); int k = got.length; int m = Integer.min(k, n); byte[] give = new byte[m]; for (int i = 0; i < m; i++) { give[i] = got[i]; } return give; }
LazyImmutableRep implements Representation { public byte[] head(int n) { byte[] got = get(); int k = got.length; int m = Integer.min(k, n); byte[] give = new byte[m]; for (int i = 0; i < m; i++) { give[i] = got[i]; } return give; } }
LazyImmutableRep implements Representation { public byte[] head(int n) { byte[] got = get(); int k = got.length; int m = Integer.min(k, n); byte[] give = new byte[m]; for (int i = 0; i < m; i++) { give[i] = got[i]; } return give; } LazyImmutableRep(String contentType, InputStream data); }
LazyImmutableRep implements Representation { public byte[] head(int n) { byte[] got = get(); int k = got.length; int m = Integer.min(k, n); byte[] give = new byte[m]; for (int i = 0; i < m; i++) { give[i] = got[i]; } return give; } LazyImmutableRep(String contentType, InputStream data); byte[] head(int n); byte[] get(); @Override String contentType(); @Override void write(OutputStream out); @Override String show(); @Override boolean eq(Representation that); }
LazyImmutableRep implements Representation { public byte[] head(int n) { byte[] got = get(); int k = got.length; int m = Integer.min(k, n); byte[] give = new byte[m]; for (int i = 0; i < m; i++) { give[i] = got[i]; } return give; } LazyImmutableRep(String contentType, InputStream data); byte[] head(int n); byte[] get(); @Override String contentType(); @Override void write(OutputStream out); @Override String show(); @Override boolean eq(Representation that);  }