* Added ChannelBufferOutputStream.writtenBytes()

* Javadoc
This commit is contained in:
Trustin Lee 2009-06-17 08:24:52 +00:00
parent c838c2aea3
commit ca11f90270
3 changed files with 13 additions and 4 deletions

View File

@ -83,7 +83,7 @@ import java.util.NoSuchElementException;
* starts with {@code read} or {@code skip} will get or skip the data at the
* current {@link #readerIndex() readerIndex} and increase it by the number of
* read bytes. If the argument of the read operation is also a
* {@link ChannelBuffer} and no start index is specified, the specified
* {@link ChannelBuffer} and no destination index is specified, the specified
* buffer's {@link #readerIndex() readerIndex} is increased together.
* <p>
* If there's not enough content left, {@link IndexOutOfBoundsException} is
@ -104,7 +104,7 @@ import java.util.NoSuchElementException;
* whose name ends with {@code write} will write the data at the current
* {@link #writerIndex() writerIndex} and increase it by the number of written
* bytes. If the argument of the write operation is also a {@link ChannelBuffer},
* and no start index is specified, the specified buffer's
* and no source index is specified, the specified buffer's
* {@link #readerIndex() readerIndex} is increased together.
* <p>
* If there's not enough writable bytes left, {@link IndexOutOfBoundsException}
@ -215,7 +215,7 @@ import java.util.NoSuchElementException;
* <h4>Strings</h4>
*
* Various {@link #toString(String)} methods convert a {@link ChannelBuffer}
* into a {@link String}. Plesae note that {@link #toString()} is not a
* into a {@link String}. Please note that {@link #toString()} is not a
* conversion method.
*
* <h4>I/O Streams</h4>

View File

@ -24,7 +24,7 @@ package org.jboss.netty.buffer;
/**
* Locates an index of data in {@link ChannelBuffer}.
* Locates an index of data in a {@link ChannelBuffer}.
* <p>
* This interface enables the sequential search for the data which meets more
* complex and dynamic condition than just a simple value matching. Please

View File

@ -49,6 +49,7 @@ import java.io.OutputStream;
public class ChannelBufferOutputStream extends OutputStream implements DataOutput {
private final ChannelBuffer buffer;
private final int startIndex;
private final DataOutputStream utf8out = new DataOutputStream(this);
/**
@ -59,6 +60,14 @@ public class ChannelBufferOutputStream extends OutputStream implements DataOutpu
throw new NullPointerException("buffer");
}
this.buffer = buffer;
startIndex = buffer.writerIndex();
}
/**
* Returns the number of written bytes by this stream so far.
*/
public int writtenBytes() {
return buffer.writerIndex() - startIndex;
}
@Override