com.ondelette.servlet.webforum
Class HTMLUtil

java.lang.Object
  |
  +--com.ondelette.servlet.webforum.HTMLUtil

public final class HTMLUtil
extends java.lang.Object

Useful HTML methods


Field Summary
static java.lang.String[] mAllowedClosingHTML
           
static java.lang.String[] mAllowedHTML
          These HTML tags can be opened but must be closed.
static java.lang.String[] mSafeClosingHTML
           
static java.lang.String[] mSafeHTML
           
 
Method Summary
static int getNumberOfLines(java.lang.String s)
          Count the number of lines
protected static java.lang.String givebackQuotes(java.lang.String str)
          Used inside tags to revert back from "
static void main(java.lang.String[] args)
           
static java.lang.String makeStringHTMLSafe(java.lang.String str)
          Make the string HTML safe, removes <,>, " and replace with HTML entities
static java.lang.String readNextString(java.io.InputStreamReader in)
          Read a string and use <, > as separators.
static java.lang.String readString(java.io.InputStreamReader in)
          Read a string and use <, > as separators.
static java.lang.String recoverHTML(java.lang.String str)
          Recover string from HTML by converting HTML entities to chars (&< goes to < and &> goes to > and " goes to ") (Does that comment come out ok in HTML?) It will only allow some HTML tags by default.
static java.lang.String recoverHTMLOld(java.lang.String str)
           
static java.lang.String replaceLinesWithParagraphs(java.lang.String s)
          Replace \r\n or \n by <BR />
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mAllowedHTML

public static java.lang.String[] mAllowedHTML
These HTML tags can be opened but must be closed. We don't expect browsers toString() do miracles. This will also block malicious users.

Since:
0.35

mAllowedClosingHTML

public static java.lang.String[] mAllowedClosingHTML

mSafeHTML

public static java.lang.String[] mSafeHTML

mSafeClosingHTML

public static java.lang.String[] mSafeClosingHTML
Method Detail

getNumberOfLines

public static int getNumberOfLines(java.lang.String s)
Count the number of lines

Parameters:
s -
Returns:
The numberOfLines value
Since:
0.30

readString

public static java.lang.String readString(java.io.InputStreamReader in)
                                   throws java.io.IOException
Read a string and use <, > as separators. This is actually used for XML parsing. This specific method keeps reading until it finds an actual string so that when applied to '<>>
Parameters:
in -
Returns:
Throws:
java.io.IOException
Since:
0.30

readNextString

public static java.lang.String readNextString(java.io.InputStreamReader in)
                                       throws java.io.IOException
Read a string and use <, > as separators. This is actually used for XML parsing. This specific method returns the first string it finds so that when applied to '<>>
Parameters:
in -
Returns:
Throws:
java.io.IOException
Since:
0.35

replaceLinesWithParagraphs

public static java.lang.String replaceLinesWithParagraphs(java.lang.String s)
Replace \r\n or \n by <BR />

Parameters:
s -
Returns:
Since:
0.30

makeStringHTMLSafe

public static java.lang.String makeStringHTMLSafe(java.lang.String str)
Make the string HTML safe, removes <,>, " and replace with HTML entities

Parameters:
str -
Returns:
Since:
0.30

recoverHTMLOld

public static java.lang.String recoverHTMLOld(java.lang.String str)

recoverHTML

public static java.lang.String recoverHTML(java.lang.String str)
Recover string from HTML by converting HTML entities to chars (&< goes to < and &> goes to > and " goes to ") (Does that comment come out ok in HTML?) It will only allow some HTML tags by default. Can be extended.

Parameters:
str -
Returns:
Since:
0.30

givebackQuotes

protected static java.lang.String givebackQuotes(java.lang.String str)
Used inside tags to revert back from "

Parameters:
str -
Returns:
Since:
0.35

main

public static void main(java.lang.String[] args)