Implemented OfferWriter and RequestWriter, made all the writers

reusable (though not thread-safe), and guiced the readers.
This commit is contained in:
akwizgran
2011-07-26 21:36:55 +01:00
parent 426e415676
commit 9e78837055
23 changed files with 249 additions and 46 deletions

View File

@@ -15,7 +15,7 @@ class AckWriterImpl implements AckWriter {
private final OutputStream out;
private final Writer w;
private boolean started = false, finished = false;
private boolean started = false;
AckWriterImpl(OutputStream out, WriterFactory writerFactory) {
this.out = out;
@@ -23,7 +23,6 @@ class AckWriterImpl implements AckWriter {
}
public boolean writeBatchId(BatchId b) throws IOException {
if(finished) throw new IllegalStateException();
if(!started) {
w.writeUserDefinedTag(Tags.ACK);
w.writeListStart();
@@ -36,7 +35,6 @@ class AckWriterImpl implements AckWriter {
}
public void finish() throws IOException {
if(finished) throw new IllegalStateException();
if(!started) {
w.writeUserDefinedTag(Tags.ACK);
w.writeListStart();
@@ -44,6 +42,6 @@ class AckWriterImpl implements AckWriter {
}
w.writeListEnd();
out.flush();
finished = true;
started = false;
}
}