Javolution 6.0.0 java
|
Public Member Functions | |
UTF8StreamWriter () | |
UTF8StreamWriter (int capacity) | |
UTF8StreamWriter | setOutput (OutputStream out) |
void | write (char c) throws IOException |
void | write (int code) throws IOException |
void | write (char cbuf[], int off, int len) throws IOException |
void | write (String str, int off, int len) throws IOException |
void | write (CharSequence csq) throws IOException |
void | flush () throws IOException |
void | close () throws IOException |
void | reset () |
UTF8StreamWriter | setOutputStream (OutputStream out) |
Private Member Functions | |
void | write2 (int c) throws IOException |
void | flushBuffer () throws IOException |
Private Attributes | |
OutputStream | _outputStream |
final byte[] | _bytes |
int | _index |
char | _highSurrogate |
A UTF-8 stream 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.
Definition at line 36 of file UTF8StreamWriter.java.
javolution.io.UTF8StreamWriter.UTF8StreamWriter | ( | ) |
Creates a UTF-8 writer having a byte buffer of moderate capacity (2048).
Definition at line 56 of file UTF8StreamWriter.java.
References javolution.io.UTF8StreamWriter._bytes.
javolution.io.UTF8StreamWriter.UTF8StreamWriter | ( | int | capacity | ) |
Creates a UTF-8 writer having a byte buffer of specified capacity.
capacity | the capacity of the byte buffer. |
Definition at line 65 of file UTF8StreamWriter.java.
References javolution.io.UTF8StreamWriter._bytes.
void javolution.io.UTF8StreamWriter.close | ( | ) | throws IOException |
Closes and resets this writer for reuse.
IOException | if an I/O error occurs |
Definition at line 306 of file UTF8StreamWriter.java.
References javolution.io.UTF8StreamWriter._outputStream, javolution.io.UTF8StreamWriter.flushBuffer(), and javolution.io.UTF8StreamWriter.reset().
Referenced by javolution.xml.ws.WebServiceClient.invoke().
void javolution.io.UTF8StreamWriter.flush | ( | ) | throws IOException |
Flushes the stream. If the stream has saved any characters from the various write() methods in a buffer, write them immediately to their intended destination. Then, if that destination is another character or byte stream, flush it. Thus one flush() invocation will flush all the buffers in a chain of Writers and OutputStreams.
IOException | if an I/O error occurs. |
Definition at line 296 of file UTF8StreamWriter.java.
References javolution.io.UTF8StreamWriter._outputStream, and javolution.io.UTF8StreamWriter.flushBuffer().
|
private |
Flushes the internal bytes buffer.
IOException | if an I/O error occurs |
Definition at line 319 of file UTF8StreamWriter.java.
References javolution.io.UTF8StreamWriter._bytes, javolution.io.UTF8StreamWriter._index, and javolution.io.UTF8StreamWriter._outputStream.
Referenced by javolution.io.UTF8StreamWriter.close(), javolution.io.UTF8StreamWriter.flush(), javolution.io.UTF8StreamWriter.write(), and javolution.io.UTF8StreamWriter.write2().
void javolution.io.UTF8StreamWriter.reset | ( | ) |
Definition at line 326 of file UTF8StreamWriter.java.
References javolution.io.UTF8StreamWriter._highSurrogate, javolution.io.UTF8StreamWriter._index, and javolution.io.UTF8StreamWriter._outputStream.
Referenced by javolution.io.UTF8StreamWriter.close(), javolution.xml.ws.WebServiceClient.invoke(), and javolution.xml.internal.stream.XMLStreamWriterImpl.reset().
UTF8StreamWriter javolution.io.UTF8StreamWriter.setOutput | ( | OutputStream | out | ) |
Sets the output stream to use for writing until this writer is closed. For example:[code] Writer writer = new UTF8StreamWriter().setOutputStream(out); [/code] is equivalent but writes faster than [code] Writer writer = new java.io.OutputStreamWriter(out, "UTF-8"); [/code]
out | the output stream. |
Definition at line 82 of file UTF8StreamWriter.java.
References javolution.io.UTF8StreamWriter._outputStream.
Referenced by javolution.xml.ws.WebServiceClient.invoke(), javolution.xml.internal.stream.XMLStreamWriterImpl.setOutput(), and javolution.io.UTF8StreamWriter.setOutputStream().
UTF8StreamWriter javolution.io.UTF8StreamWriter.setOutputStream | ( | OutputStream | out | ) |
Definition at line 335 of file UTF8StreamWriter.java.
References javolution.io.UTF8StreamWriter.setOutput().
void javolution.io.UTF8StreamWriter.write | ( | char | c | ) | throws IOException |
Writes a single character. This method supports 16-bits character surrogates.
c | char the character to be written (possibly a surrogate). |
IOException | if an I/O error occurs. |
Definition at line 97 of file UTF8StreamWriter.java.
References javolution.io.UTF8StreamWriter._highSurrogate.
Referenced by javolution.io.UTF8StreamWriter.write().
void javolution.io.UTF8StreamWriter.write | ( | char | cbuf[], |
int | off, | ||
int | len | ||
) | throws IOException |
Writes a portion of an array of characters.
cbuf | 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. |
Definition at line 228 of file UTF8StreamWriter.java.
References javolution.io.UTF8StreamWriter._bytes, javolution.io.UTF8StreamWriter._index, javolution.io.UTF8StreamWriter.flushBuffer(), and javolution.io.UTF8StreamWriter.write().
void javolution.io.UTF8StreamWriter.write | ( | CharSequence | csq | ) | throws IOException |
Writes the specified character sequence.
csq | the character sequence. |
IOException | if an I/O error occurs |
Definition at line 272 of file UTF8StreamWriter.java.
References javolution.io.UTF8StreamWriter._bytes, javolution.io.UTF8StreamWriter._index, javolution.io.UTF8StreamWriter.flushBuffer(), and javolution.io.UTF8StreamWriter.write().
void javolution.io.UTF8StreamWriter.write | ( | int | code | ) | throws IOException |
Writes a character given its 31-bits Unicode.
code | the 31 bits Unicode of the character to be written. |
IOException | if an I/O error occurs. |
Definition at line 117 of file UTF8StreamWriter.java.
References javolution.io.UTF8StreamWriter._bytes, javolution.io.UTF8StreamWriter._index, javolution.io.UTF8StreamWriter.flushBuffer(), and javolution.io.UTF8StreamWriter.write2().
void javolution.io.UTF8StreamWriter.write | ( | String | str, |
int | off, | ||
int | len | ||
) | throws IOException |
Writes a portion of a string.
str | 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 |
Definition at line 251 of file UTF8StreamWriter.java.
References javolution.io.UTF8StreamWriter._bytes, javolution.io.UTF8StreamWriter._index, javolution.io.UTF8StreamWriter.flushBuffer(), and javolution.io.UTF8StreamWriter.write().
|
private |
Definition at line 128 of file UTF8StreamWriter.java.
References javolution.io.UTF8StreamWriter._bytes, javolution.io.UTF8StreamWriter._index, and javolution.io.UTF8StreamWriter.flushBuffer().
Referenced by javolution.io.UTF8StreamWriter.write().
|
private |
Holds the bytes' buffer.
Definition at line 46 of file UTF8StreamWriter.java.
Referenced by javolution.io.UTF8StreamWriter.flushBuffer(), javolution.io.UTF8StreamWriter.UTF8StreamWriter(), javolution.io.UTF8StreamWriter.write(), and javolution.io.UTF8StreamWriter.write2().
|
private |
Definition at line 109 of file UTF8StreamWriter.java.
Referenced by javolution.io.UTF8StreamWriter.reset(), and javolution.io.UTF8StreamWriter.write().
|
private |
Holds the bytes buffer index.
Definition at line 51 of file UTF8StreamWriter.java.
Referenced by javolution.io.UTF8StreamWriter.flushBuffer(), javolution.io.UTF8StreamWriter.reset(), javolution.io.UTF8StreamWriter.write(), and javolution.io.UTF8StreamWriter.write2().
|
private |
Holds the current output stream or null
if closed.
Definition at line 41 of file UTF8StreamWriter.java.
Referenced by javolution.io.UTF8StreamWriter.close(), javolution.io.UTF8StreamWriter.flush(), javolution.io.UTF8StreamWriter.flushBuffer(), javolution.io.UTF8StreamWriter.reset(), and javolution.io.UTF8StreamWriter.setOutput().