SK.gnome.dwarf.utils.io
Class HTMLPrintWriter

java.lang.Object
  extended byjava.io.Writer
      extended byjava.io.PrintWriter
          extended bySK.gnome.dwarf.utils.io.HTMLPrintWriter

public class HTMLPrintWriter
extends java.io.PrintWriter

Provides a writer for HTML rendering.

This writer replaces "<", ">", "&" and double quotes with the special HTML entities &lt;, &gt;, &amp; and &quot;. It should be used primarily for writing small portions of an ordinary text when it will be HTML-rendered before displaying to the user. This prevents disappearing some text in the rendered output because of these special characters.


Field Summary
 
Fields inherited from class java.io.PrintWriter
out
 
Fields inherited from class java.io.Writer
lock
 
Constructor Summary
HTMLPrintWriter(java.io.Writer out)
          Creates a new HTMLPrintWriter.
HTMLPrintWriter(java.io.Writer out, boolean autoFlush)
          Creates a new HTMLPrintWriter writer.
 
Method Summary
static java.lang.String decode(java.lang.String s)
          Decodes the given string.
static java.lang.String encode(java.lang.String s)
          Encodes the given string.
 void write(char[] cbuf, int off, int len)
          Writes a portion of an array of characters.
 void write(int c)
          Writes a single character.
 void write(java.lang.String s, int off, int len)
          Writes a portion of a string.
 
Methods inherited from class java.io.PrintWriter
close, flush, checkError, print, print, print, print, print, print, print, print, print, println, println, println, println, println, println, println, println, println, println, setError, write, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HTMLPrintWriter

public HTMLPrintWriter(java.io.Writer out)
Creates a new HTMLPrintWriter.

Parameters:
out - a Writer object to provide the underlying stream

HTMLPrintWriter

public HTMLPrintWriter(java.io.Writer out,
                       boolean autoFlush)
Creates a new HTMLPrintWriter writer.

Parameters:
out - a Writer object to provide the underlying stream.
autoFlush - a boolean; if true, the println() methods will flush the output buffer.
Method Detail

write

public void write(int c)
Writes a single character.

Parameters:
c - a character

write

public void write(char[] cbuf,
                  int off,
                  int len)
Writes a portion of an array of characters.

Parameters:
cbuf - buffer of characters to be written
off - offset from which to start reading characters
len - number of characters to be written

write

public void write(java.lang.String s,
                  int off,
                  int len)
Writes a portion of a string.

Parameters:
s - A String
off - Offset from which to start writing characters
len - Number of characters to write

encode

public static java.lang.String encode(java.lang.String s)
Encodes the given string.

Replaces "<", ">", "&" and double quotes in the string with the special HTML entities &lt;, &gt;, &amp; and &quot;.

Parameters:
s - string to encode
Returns:
the encoded string

decode

public static java.lang.String decode(java.lang.String s)
Decodes the given string.

Replaces the special HTML entities &lt;, &gt;, &amp; and &quot; in the string with the "<", ">", "&" and double quotes characters.

Parameters:
s - string to decode
Returns:
the decoded string


Copyright (c) 1999-2005, Gnome Ltd. All rights reserved.