org.apache.hadoop.http
Class HtmlQuoting

java.lang.Object
  extended by org.apache.hadoop.http.HtmlQuoting

public class HtmlQuoting
extends Object

This class is responsible for quoting HTML characters.


Constructor Summary
HtmlQuoting()
           
 
Method Summary
static void main(String[] args)
           
static boolean needsQuoting(byte[] data, int off, int len)
          Does the given string need to be quoted?
static boolean needsQuoting(String str)
          Does the given string need to be quoted?
static void quoteHtmlChars(OutputStream output, byte[] buffer, int off, int len)
          Quote all of the active HTML characters in the given string as they are added to the buffer.
static String quoteHtmlChars(String item)
          Quote the given item to make it html-safe.
static OutputStream quoteOutputStream(OutputStream out)
          Return an output stream that quotes all of the output.
static String unquoteHtmlChars(String item)
          Remove HTML quoting from a string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HtmlQuoting

public HtmlQuoting()
Method Detail

needsQuoting

public static boolean needsQuoting(byte[] data,
                                   int off,
                                   int len)
Does the given string need to be quoted?

Parameters:
data - the string to check
off - the starting position
len - the number of bytes to check
Returns:
does the string contain any of the active html characters?

needsQuoting

public static boolean needsQuoting(String str)
Does the given string need to be quoted?

Parameters:
str - the string to check
Returns:
does the string contain any of the active html characters?

quoteHtmlChars

public static void quoteHtmlChars(OutputStream output,
                                  byte[] buffer,
                                  int off,
                                  int len)
                           throws IOException
Quote all of the active HTML characters in the given string as they are added to the buffer.

Parameters:
output - the stream to write the output to
buffer - the byte array to take the characters from
off - the index of the first byte to quote
len - the number of bytes to quote
Throws:
IOException

quoteHtmlChars

public static String quoteHtmlChars(String item)
Quote the given item to make it html-safe.

Parameters:
item - the string to quote
Returns:
the quoted string

quoteOutputStream

public static OutputStream quoteOutputStream(OutputStream out)
                                      throws IOException
Return an output stream that quotes all of the output.

Parameters:
out - the stream to write the quoted output to
Returns:
a new stream that the application show write to
Throws:
IOException - if the underlying output fails

unquoteHtmlChars

public static String unquoteHtmlChars(String item)
Remove HTML quoting from a string.

Parameters:
item - the string to unquote
Returns:
the unquoted string

main

public static void main(String[] args)
                 throws Exception
Throws:
Exception


Copyright © 2009 The Apache Software Foundation