Package net.sf.saxon.serialize
Class UTF8Writer
java.lang.Object
java.io.Writer
net.sf.saxon.serialize.UTF8Writer
- All Implemented Interfaces:
- Closeable,- Flushable,- Appendable,- AutoCloseable,- UnicodeWriter
Specialized buffering UTF-8 writer.
 The main reason for custom version is to allow for efficient
 buffer recycling; the second benefit is that encoder has less
 overhead for short content encoding (compared to JDK default
 codecs).
- 
Field Summary
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidclose()Complete the writing of characters to the result.voidflush()Flush the contents of any buffers.voidwrite(char[] cbuf) voidwrite(char[] cbuf, int off, int len) voidwrite(int c) Write a single char.voidProcess a supplied stringvoidvoidwrite(UnicodeString chars) Process a supplied stringvoidwriteAscii(byte[] content) Write a sequence of ASCII characters.voidwriteAscii(byte[] chars, int off, int len) Write a sequence of ASCII characters.voidwriteCodePoint(int codepoint) Process a single character.voidwriteLatin1(byte[] bytes, int off, int len) voidwriteRepeatedAscii(byte ch, int repeat) Write an ASCII character repeatedly.Methods inherited from class java.io.Writerappend, append, append, nullWriter
- 
Constructor Details- 
UTF8Writer
- 
UTF8Writer
 
- 
- 
Method Details- 
closeDescription copied from interface:UnicodeWriterComplete the writing of characters to the result. The default implementation does nothing.- Specified by:
- closein interface- AutoCloseable
- Specified by:
- closein interface- Closeable
- Specified by:
- closein interface- UnicodeWriter
- Specified by:
- closein class- Writer
- Throws:
- IOException- if processing fails for any reason
 
- 
flushDescription copied from interface:UnicodeWriterFlush the contents of any buffers. The default implementation does nothing.- Specified by:
- flushin interface- Flushable
- Specified by:
- flushin interface- UnicodeWriter
- Specified by:
- flushin class- Writer
- Throws:
- IOException- if processing fails for any reason
 
- 
write- Overrides:
- writein class- Writer
- Throws:
- IOException
 
- 
write- Specified by:
- writein class- Writer
- Throws:
- IOException
 
- 
writeLatin1- Throws:
- IOException
 
- 
writeAsciiWrite a sequence of ASCII characters. The caller is responsible for ensuring that each byte represents a character in the range 1-127- Specified by:
- writeAsciiin interface- UnicodeWriter
- Parameters:
- content- the content to be written
- Throws:
- IOException- if processing fails for any reason
 
- 
writeAsciiWrite a sequence of ASCII characters. The caller is responsible for ensuring that each byte represents a character in the range 1-127- Parameters:
- chars- the characters to be written
- off- the offset of the first character to be included
- len- the number of characters to be written
- Throws:
- IOException
 
- 
writeRepeatedAsciiWrite an ASCII character repeatedly. Used for serializing whitespace.- Specified by:
- writeRepeatedAsciiin interface- UnicodeWriter
- Parameters:
- ch- the ASCII character to be serialized (must be less than 0x7f)
- repeat- the number of occurrences to output
- Throws:
- IOException- if it fails
 
- 
writeCodePointProcess a single character. Default implementation wraps the codepoint into a single-characterUnicodeString- Specified by:
- writeCodePointin interface- UnicodeWriter
- Parameters:
- codepoint- the character to be processed. Must not be a surrogate
- Throws:
- IOException- if processing fails for any reason
 
- 
writeWrite a single char.Note (MHK) Although the Writer interface says that the top half of the int is ignored, this implementation appears to accept a Unicode codepoint which is output as a 4-byte UTF-8 sequence. - Overrides:
- writein class- Writer
- Parameters:
- c- the char to be written
- Throws:
- IOException- If an I/O error occurs
 
- 
writeProcess a supplied string- Specified by:
- writein interface- UnicodeWriter
- Parameters:
- chars- the characters to be processed
- Throws:
- IOException- if processing fails for any reason
 
- 
writeDescription copied from interface:UnicodeWriterProcess a supplied string- Specified by:
- writein interface- UnicodeWriter
- Overrides:
- writein class- Writer
- Parameters:
- str- the characters to be processed
- Throws:
- IOException- if processing fails for any reason
 
- 
write- Overrides:
- writein class- Writer
- Throws:
- IOException
 
 
-