de.matthiasmann.twl.textarea
Class HTMLTextAreaModel

java.lang.Object
  extended by de.matthiasmann.twl.model.HasCallback
      extended by de.matthiasmann.twl.textarea.HTMLTextAreaModel
All Implemented Interfaces:
TextAreaModel, WithRunnableCallback, java.lang.Iterable<TextAreaModel.Element>

public class HTMLTextAreaModel
extends HasCallback
implements TextAreaModel

A simple XHTML parser. The following tags are supported:

The following generic CSS attributes are supported: Numeric values must use on of the following units: em, ex, px, %


Nested Class Summary
 
Nested classes/interfaces inherited from interface de.matthiasmann.twl.textarea.TextAreaModel
TextAreaModel.BlockElement, TextAreaModel.Clear, TextAreaModel.ContainerElement, TextAreaModel.Display, TextAreaModel.Element, TextAreaModel.FloatPosition, TextAreaModel.HAlignment, TextAreaModel.ImageElement, TextAreaModel.LineBreakElement, TextAreaModel.LinkElement, TextAreaModel.ListElement, TextAreaModel.OrderedListElement, TextAreaModel.ParagraphElement, TextAreaModel.TableCellElement, TextAreaModel.TableElement, TextAreaModel.TextElement, TextAreaModel.VAlignment, TextAreaModel.WidgetElement
 
Constructor Summary
HTMLTextAreaModel()
          Creates a new HTMLTextAreaModel without content.
HTMLTextAreaModel(java.io.Reader r)
          Creates a new HTMLTextAreaModel and parses the content of the given Reader.
HTMLTextAreaModel(java.lang.String html)
          Creates a new HTMLTextAreaModel and parses the given html.
 
Method Summary
 void domModified()
           
 TextAreaModel.Element getElementById(java.lang.String id)
           
 java.lang.Iterable<java.lang.String> getStyleSheetLinks()
          Returns all links to CSS style sheets
 java.lang.String getTitle()
          Returns the title of this XHTML document or null if it has no title.
 java.util.Iterator<TextAreaModel.Element> iterator()
           
 void parseXHTML(java.io.Reader reader)
          Parse a XHTML document.
 void readHTMLFromStream(java.io.Reader r)
          Deprecated. use parseXHTML(java.io.Reader)
 void readHTMLFromURL(java.net.URL url)
          Reads HTML from the given URL.
 void setHtml(java.lang.String html)
          Sets the a html to parse.
 
Methods inherited from class de.matthiasmann.twl.model.HasCallback
addCallback, doCallback, hasCallbacks, removeCallback
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface de.matthiasmann.twl.textarea.TextAreaModel
addCallback, removeCallback
 

Constructor Detail

HTMLTextAreaModel

public HTMLTextAreaModel()
Creates a new HTMLTextAreaModel without content.


HTMLTextAreaModel

public HTMLTextAreaModel(java.lang.String html)
Creates a new HTMLTextAreaModel and parses the given html.

Parameters:
html - the HTML to parse
See Also:
setHtml(java.lang.String)

HTMLTextAreaModel

public HTMLTextAreaModel(java.io.Reader r)
                  throws java.io.IOException
Creates a new HTMLTextAreaModel and parses the content of the given Reader.

Parameters:
r - the reader to parse html from
Throws:
java.io.IOException - if an error occured while reading
See Also:
parseXHTML(java.io.Reader)
Method Detail

setHtml

public void setHtml(java.lang.String html)
Sets the a html to parse.

Parameters:
html - the html.

readHTMLFromStream

public void readHTMLFromStream(java.io.Reader r)
                        throws java.io.IOException
Deprecated. use parseXHTML(java.io.Reader)

Reads HTML from the given Reader.

Parameters:
r - the reader to parse html from
Throws:
java.io.IOException - if an error occured while reading
See Also:
setHtml(java.lang.String)

readHTMLFromURL

public void readHTMLFromURL(java.net.URL url)
                     throws java.io.IOException
Reads HTML from the given URL.

Parameters:
url - the URL to parse.
Throws:
java.io.IOException - if an error occured while reading
See Also:
parseXHTML(java.io.Reader)

iterator

public java.util.Iterator<TextAreaModel.Element> iterator()
Specified by:
iterator in interface java.lang.Iterable<TextAreaModel.Element>

getStyleSheetLinks

public java.lang.Iterable<java.lang.String> getStyleSheetLinks()
Returns all links to CSS style sheets

Returns:
an Iterable containing all hrefs

getTitle

public java.lang.String getTitle()
Returns the title of this XHTML document or null if it has no title.

Returns:
the title of this XHTML document or null if it has no title.

getElementById

public TextAreaModel.Element getElementById(java.lang.String id)

domModified

public void domModified()

parseXHTML

public void parseXHTML(java.io.Reader reader)
Parse a XHTML document. The root element must be <html>

Parameters:
reader - the reader used to read the XHTML document.