@Test public void streamLoadable() throws Exception { File file = new File("target/streams-junit/FileInvariantStream-" + System.currentTimeMillis() + ".txt"); InvariantStream stream = new FileInvariantStream(file, null, "fakeHash", null); stream.append("Hello"); stream.append("Xanadu"); }
@Override public InvariantSpan append(String text) throws IOException, MalformedSpanException { if (Strings.isNullOrEmpty(text)) { throw new MalformedSpanException("No text - span length is 0"); } FileLock lock = channel.lock(); try { InvariantSpan span = new InvariantSpan(channel.position() + 1, text.length(), documentHash); buffer.clear(); buffer.put(text.getBytes()); buffer.flip(); while (buffer.hasRemaining()) { channel.write(buffer); } channel.force(true); return span; } finally { lock.release(); } }
FileInvariantStream implements InvariantStream { @Override public InvariantSpan append(String text) throws IOException, MalformedSpanException { if (Strings.isNullOrEmpty(text)) { throw new MalformedSpanException("No text - span length is 0"); } FileLock lock = channel.lock(); try { InvariantSpan span = new InvariantSpan(channel.position() + 1, text.length(), documentHash); buffer.clear(); buffer.put(text.getBytes()); buffer.flip(); while (buffer.hasRemaining()) { channel.write(buffer); } channel.force(true); return span; } finally { lock.release(); } } }
FileInvariantStream implements InvariantStream { @Override public InvariantSpan append(String text) throws IOException, MalformedSpanException { if (Strings.isNullOrEmpty(text)) { throw new MalformedSpanException("No text - span length is 0"); } FileLock lock = channel.lock(); try { InvariantSpan span = new InvariantSpan(channel.position() + 1, text.length(), documentHash); buffer.clear(); buffer.put(text.getBytes()); buffer.flip(); while (buffer.hasRemaining()) { channel.write(buffer); } channel.force(true); return span; } finally { lock.release(); } } FileInvariantStream(File file, File encryptedFile, String documentHash, Key key); }
FileInvariantStream implements InvariantStream { @Override public InvariantSpan append(String text) throws IOException, MalformedSpanException { if (Strings.isNullOrEmpty(text)) { throw new MalformedSpanException("No text - span length is 0"); } FileLock lock = channel.lock(); try { InvariantSpan span = new InvariantSpan(channel.position() + 1, text.length(), documentHash); buffer.clear(); buffer.put(text.getBytes()); buffer.flip(); while (buffer.hasRemaining()) { channel.write(buffer); } channel.force(true); return span; } finally { lock.release(); } } FileInvariantStream(File file, File encryptedFile, String documentHash, Key key); @Override InvariantSpan append(String text); @Override String getText(InvariantSpan ispan); }
FileInvariantStream implements InvariantStream { @Override public InvariantSpan append(String text) throws IOException, MalformedSpanException { if (Strings.isNullOrEmpty(text)) { throw new MalformedSpanException("No text - span length is 0"); } FileLock lock = channel.lock(); try { InvariantSpan span = new InvariantSpan(channel.position() + 1, text.length(), documentHash); buffer.clear(); buffer.put(text.getBytes()); buffer.flip(); while (buffer.hasRemaining()) { channel.write(buffer); } channel.force(true); return span; } finally { lock.release(); } } FileInvariantStream(File file, File encryptedFile, String documentHash, Key key); @Override InvariantSpan append(String text); @Override String getText(InvariantSpan ispan);  }