|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
ObjectWriter
UTF8ByteBufferWriter
public final class UTF8ByteBufferWriter
This class represents a UTF-8 j2me.nio.ByteBuffer
writer.
This writer supports surrogate char pairs (representing
characters in the range [U+10000 .. U+10FFFF]). It can also be used
to write characters from their unicodes (31 bits) directly
(ref. write(int)).
Instances of this class can be reused for different output streams
and can be part of a higher level component (e.g. serializer) in order
to avoid dynamic buffer allocation when the destination output changes.
Also wrapping using a java.io.BufferedWriter is unnescessary
as instances of this class embed their own data buffers.
Note: This writer is unsynchronized and always produces well-formed UTF-8 sequences.
UTF8ByteBufferReader| Field Summary |
|---|
| Fields inherited from class Writer |
|---|
lock |
| Constructor Summary | |
|---|---|
UTF8ByteBufferWriter()
Default constructor. |
|
| Method Summary | |
|---|---|
void |
close()
Closes and resets this writer for reuse. |
void |
flush()
Flushes the stream (this method has no effect, the data is always directly written to the ByteBuffer). |
void |
reset()
Resets the internal state of this object to its default values. |
UTF8ByteBufferWriter |
setByteBuffer(ByteBuffer byteBuffer)
Deprecated. Replaced by setOutput(ByteBuffer) |
UTF8ByteBufferWriter |
setOutput(ByteBuffer byteBuffer)
Sets the byte buffer to use for writing until this writer is closed. |
void |
write(char c)
Writes a single character. |
void |
write(char[] cbuf,
int off,
int len)
Writes a portion of an array of characters. |
void |
write(CharSequence csq)
Writes the specified character sequence. |
void |
write(int code)
Writes a character given its 31-bits Unicode. |
void |
write(String str,
int off,
int len)
Writes a portion of a string. |
| Methods inherited from class Writer |
|---|
append, append, append, write, write |
| Methods inherited from class Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public UTF8ByteBufferWriter()
| Method Detail |
|---|
public UTF8ByteBufferWriter setOutput(ByteBuffer byteBuffer)
byteBuffer - the destination byte buffer.
IllegalStateException - if this writer is being reused and
it has not been closed or reset.
public void write(char c)
throws IOException
c - char the character to be written (possibly
a surrogate).
IOException - if an I/O error occurs.
public void write(int code)
throws IOException
write in class Writercode - the 31 bits Unicode of the character to be written.
IOException - if an I/O error occurs.
public void write(char[] cbuf,
int off,
int len)
throws IOException
write in class Writercbuf - the array of characters.off - the offset from which to start writing characters.len - the number of characters to write.
IOException - if an I/O error occurs.
public void write(String str,
int off,
int len)
throws IOException
write in class Writerstr - a String.off - the offset from which to start writing characters.len - the number of characters to write.
IOException - if an I/O error occurs
public void write(CharSequence csq)
throws IOException
csq - the character sequence.
IOException - if an I/O error occurs
public void flush()
throws IOException
ByteBuffer).
flush in interface Flushableflush in class WriterIOException - if an I/O error occurs.
public void close()
throws IOException
resets this writer for reuse.
close in interface Closeableclose in class WriterIOException - if an I/O error occurspublic void reset()
Reusable
reset in interface Reusablepublic UTF8ByteBufferWriter setByteBuffer(ByteBuffer byteBuffer)
setOutput(ByteBuffer)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||