Package com.yahoo.io
Class AbstractByteWriter
- java.lang.Object
-
- java.io.Writer
-
- com.yahoo.text.GenericWriter
-
- com.yahoo.io.AbstractByteWriter
-
- All Implemented Interfaces:
WritableByteTransmitter
,java.io.Closeable
,java.io.Flushable
,java.lang.Appendable
,java.lang.AutoCloseable
- Direct Known Subclasses:
ByteWriter
public abstract class AbstractByteWriter extends GenericWriter implements WritableByteTransmitter
Base class for writers needing to accept binary data.- Author:
- Steinar Knutsen, baldersheim
-
-
Field Summary
Fields Modifier and Type Field Description protected BufferChain
buffer
protected java.nio.CharBuffer
charBuffer
protected java.nio.charset.CharsetEncoder
encoder
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractByteWriter(java.nio.charset.CharsetEncoder encoder)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
append(byte alreadyEncoded)
void
append(byte[] alreadyEncoded)
void
append(byte[] alreadyEncoded, int offset, int length)
void
append(java.nio.ByteBuffer alreadyEncoded)
long
appended()
Return the number of bytes this writer will produce for the underlying layer.java.nio.charset.Charset
getEncoding()
Returns the charset this encodes its output inGenericWriter
write(boolean v)
void
write(char[] cbuf, int offset, int len)
GenericWriter
write(double v)
GenericWriter
write(float v)
void
write(int v)
Do note, if writing the first character of a surrogate pair, the next character written must be the second part of the pair.GenericWriter
write(long v)
GenericWriter
write(short v)
GenericWriter
write(AbstractUtf8Array v)
-
Methods inherited from class com.yahoo.text.GenericWriter
write, write, write
-
Methods inherited from class java.io.Writer
append, append, append, close, flush, nullWriter, write, write, write
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.yahoo.io.WritableByteTransmitter
send
-
-
-
-
Field Detail
-
encoder
protected final java.nio.charset.CharsetEncoder encoder
-
buffer
protected final BufferChain buffer
-
charBuffer
protected final java.nio.CharBuffer charBuffer
-
-
Method Detail
-
getEncoding
public java.nio.charset.Charset getEncoding()
Returns the charset this encodes its output in
-
write
public GenericWriter write(AbstractUtf8Array v) throws java.io.IOException
- Overrides:
write
in classGenericWriter
- Throws:
java.io.IOException
-
write
public GenericWriter write(long v) throws java.io.IOException
- Overrides:
write
in classGenericWriter
- Throws:
java.io.IOException
-
write
public void write(int v) throws java.io.IOException
Do note, if writing the first character of a surrogate pair, the next character written must be the second part of the pair. If this is not the case, the surrogate will be omitted from output.- Overrides:
write
in classjava.io.Writer
- Throws:
java.io.IOException
-
write
public GenericWriter write(double v) throws java.io.IOException
- Overrides:
write
in classGenericWriter
- Throws:
java.io.IOException
-
write
public GenericWriter write(float v) throws java.io.IOException
- Overrides:
write
in classGenericWriter
- Throws:
java.io.IOException
-
write
public GenericWriter write(short v) throws java.io.IOException
- Overrides:
write
in classGenericWriter
- Throws:
java.io.IOException
-
write
public GenericWriter write(boolean v) throws java.io.IOException
- Overrides:
write
in classGenericWriter
- Throws:
java.io.IOException
-
write
public void write(char[] cbuf, int offset, int len) throws java.io.IOException
- Specified by:
write
in classjava.io.Writer
- Throws:
java.io.IOException
-
append
public void append(java.nio.ByteBuffer alreadyEncoded) throws java.io.IOException
- Throws:
java.io.IOException
-
append
public void append(byte alreadyEncoded) throws java.io.IOException
- Throws:
java.io.IOException
-
append
public void append(byte[] alreadyEncoded) throws java.io.IOException
- Throws:
java.io.IOException
-
append
public void append(byte[] alreadyEncoded, int offset, int length) throws java.io.IOException
- Throws:
java.io.IOException
-
appended
public long appended()
Return the number of bytes this writer will produce for the underlying layer. That is, it sums the length of the raw bytes received and the number of bytes in the written strings after encoding.- Returns:
- the number of bytes appended to this writer
-
-