org.quasiliteral.html
Class SafeHTMLParser

java.lang.Object
  |
  +--javax.swing.text.html.parser.Parser
        |
        +--org.quasiliteral.html.SafeHTMLParser
All Implemented Interfaces:
DTDConstants

public class SafeHTMLParser
extends Parser

Untamed: Parses html and throws an exception if the html contains any unsafe tags.

Author:
Mark S. Miller
See Also:
JEditorPane#setText(String)

Field Summary
private  String myText
           
static ConstMap SafeTagMap
          Enabled:
private static String[][] SafeTags
          Each row is a safe tag followed by its allowed safe attributes.
 
Fields inherited from class javax.swing.text.html.parser.Parser
dtd, strict
 
Fields inherited from interface javax.swing.text.html.parser.DTDConstants
ANY, CDATA, CONREF, CURRENT, DEFAULT, EMPTY, ENDTAG, ENTITIES, ENTITY, FIXED, GENERAL, ID, IDREF, IDREFS, IMPLIED, MD, MODEL, MS, NAME, NAMES, NMTOKEN, NMTOKENS, NOTATION, NUMBER, NUMBERS, NUTOKEN, NUTOKENS, PARAMETER, PI, PUBLIC, RCDATA, REQUIRED, SDATA, STARTTAG, SYSTEM
 
Constructor Summary
private SafeHTMLParser(DTD dtd, String text)
           
 
Method Summary
protected  void handleEmptyTag(TagElement tag)
          Called when an empty tag is encountered.
protected  void handleError(int ln, String msg)
          An error has occurred.
protected  void handleStartTag(TagElement tag)
          Called when a start tag is encountered.
private static SafeHTMLParser make(String text)
           
static void parseText(String text)
          Enabled:
 
Methods inherited from class javax.swing.text.html.parser.Parser
endTag, error, error, error, error, flushAttributes, getAttributes, getCurrentLine, getCurrentPos, handleComment, handleEndTag, handleEOFInComment, handleText, handleTitle, makeTag, makeTag, markFirstTime, parse, parseDTDMarkup, parseMarkupDeclarations, startTag
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SafeTags

private static final String[][] SafeTags
Each row is a safe tag followed by its allowed safe attributes.

This list is expected to grow over time.


SafeTagMap

public static final ConstMap SafeTagMap
Enabled:


myText

private final String myText
Constructor Detail

SafeHTMLParser

private SafeHTMLParser(DTD dtd,
                       String text)
Method Detail

make

private static SafeHTMLParser make(String text)

parseText

public static void parseText(String text)
Enabled:


handleEmptyTag

protected void handleEmptyTag(TagElement tag)
                       throws ChangedCharSetException
Called when an empty tag is encountered.

Overrides:
handleEmptyTag in class Parser
ChangedCharSetException

handleStartTag

protected void handleStartTag(TagElement tag)
Called when a start tag is encountered.

Overrides:
handleStartTag in class Parser

handleError

protected void handleError(int ln,
                           String msg)
An error has occurred.

Overrides:
handleError in class Parser


comments?