java.lang.Object
java.io.Writer
java.io.FilterWriter
i2p.susi.util.EscapeHTMLWriter
- All Implemented Interfaces:
Closeable, Flushable, Appendable, AutoCloseable
Writer that escapes HTML characters during streaming. Streaming version of
DataHelper.escapeHTML(), also escapes '--' for comment safety since '--' is disallowed inside HTML comments.Field Summary
FieldsModifier and TypeFieldDescriptionprivate intTrack state: 0=normal, 1=saw '<', 2=saw '<-', 3=prev was '-'.private static final StringEntity for an ampersand.private static final StringEntity for an apostrophe.private static final StringMarkup for a line break.private static final StringEntity for a greater-than sign.private static final StringEntity for a less-than sign.private static final StringEntity for a dash, escaped to avoid mojibake.private static final StringEntity for a double quote.Fields inherited from class FilterWriter
outConstructor Summary
ConstructorsConstructorDescriptionEscapeHTMLWriter(Writer out) Create an EscapeHTMLWriter wrapping the given writer.Method Summary
All MethodsModifier and TypeMethodDescriptionvoidclose()Does nothing.voidwrite(char[] cbuf, int off, int len) Write characters from a buffer, escaping HTML special characters.voidwrite(int c) Write a single character, escaping HTML special characters.voidWrite characters from a string, escaping HTML special characters.Methods inherited from class FilterWriter
flush
Field Details
AMP
QUOT
LT
GT
APOS
MDASH
Entity for a dash, escaped to avoid mojibake.- See Also:
BR
_commentState
private int _commentStateTrack state: 0=normal, 1=saw '<', 2=saw '<-', 3=prev was '-'.
Constructor Details
EscapeHTMLWriter
Create an EscapeHTMLWriter wrapping the given writer.- Parameters:
out- the underlying writer
Method Details
write
Write a single character, escaping HTML special characters.- Overrides:
writein classFilterWriter- Parameters:
c- the character value- Throws:
IOException- on I/O error
write
Write characters from a buffer, escaping HTML special characters.- Overrides:
writein classFilterWriter- Parameters:
cbuf- the character bufferoff- the start offset in the bufferlen- the number of characters to write- Throws:
IOException- on I/O error
write
Write characters from a string, escaping HTML special characters.- Overrides:
writein classFilterWriter- Parameters:
str- the string to writeoff- the start offset in the stringlen- the number of characters to write- Throws:
IOException- on I/O error
close
public void close()Does nothing. Does not close the underlying writer.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classFilterWriter