com.lightdev.app.shtm

Class SHTMLDocument

public class SHTMLDocument extends HTMLDocument

Extends HTMLDocument by a custom reader which supports the SPAN tag.

Author: Ulrich Hilger Light Development http://www.lightdev.com info@lightdev.com published under the terms and conditions of the GNU General Public License, for details see file gpl.txt in the distribution package of this software

Nested Class Summary
classSHTMLDocument.SHTMLReader
This reader extends HTMLDocument.HTMLReader by the capability to handle SPAN tags
Field Summary
static StringSUFFIX
Constructor Summary
SHTMLDocument()
Constructs an SHTMLDocument.
SHTMLDocument(StyleSheet styles)
Constructs an SHTMLDocument with the default content storage implementation and the given style/attribute storage mechanism.
SHTMLDocument(Content c, StyleSheet styles)
Constructs an SHTMLDocument with the given content storage implementation and the given style/attribute storage mechanism.
Method Summary
voidaddAttributes(Element e, AttributeSet a)
apply a set of attributes to a given document element
voidendCompoundEdit()
protected voidfireUndoableEditUpdate(UndoableEditEvent e)
URLgetBase()
StringgetDocumentTitle()
get the title of this SHTMLDocument
intgetLastDocumentPosition()
ElementgetParagraphElement(int pos)
ElementgetParagraphElement(int pos, boolean noPImplied)
Gets the current paragraph element, retracing out of p-implied if the parameter noImplied is true.
ParserCallbackgetReader(int pos)
Fetches the reader for the parser to use to load the document with HTML.
StringgetStyleRef()
get the style sheet reference of the document in this DocumentPane.
booleanhasStyleRef()
check whether or not this SHTMLDocument has an explicit style sheet reference
voidinsertAfterEnd(Element elem, String htmlText)
voidinsertAfterStart(Element elem, String htmlText)
voidinsertBeforeEnd(Element elem, String htmlText)
voidinsertBeforeStart(Element elem, String htmlText)
voidinsertStyleRef()
insert a style sheet reference into the head of this SHTMLDocument
voidremoveElements(Element element, int index, int count)
Removes a consecutive group of child elements.
voidremoveParagraphAttributes(int offset, int length)
voidreplaceHTML(Element firstElement, int number, String htmlText)
voidsetBase(URL u)
voidsetDocumentTitle(String title)
set the title of this SHTMLDocument
voidsetOuterHTML(Element paragraphElement, String htmlText)
voidsetParagraphAttributes(int offset, int length, AttributeSet s, boolean replace)
voidstartCompoundEdit()

Field Detail

SUFFIX

public static final String SUFFIX

Constructor Detail

SHTMLDocument

public SHTMLDocument()
Constructs an SHTMLDocument.

SHTMLDocument

public SHTMLDocument(StyleSheet styles)
Constructs an SHTMLDocument with the default content storage implementation and the given style/attribute storage mechanism.

Parameters: styles the styles

SHTMLDocument

public SHTMLDocument(Content c, StyleSheet styles)
Constructs an SHTMLDocument with the given content storage implementation and the given style/attribute storage mechanism.

Parameters: c the container for the content styles the styles

Method Detail

addAttributes

public void addAttributes(Element e, AttributeSet a)
apply a set of attributes to a given document element

Parameters: e the element to apply attributes to a the set of attributes to apply

endCompoundEdit

public void endCompoundEdit()

fireUndoableEditUpdate

protected void fireUndoableEditUpdate(UndoableEditEvent e)

getBase

public URL getBase()

getDocumentTitle

public String getDocumentTitle()
get the title of this SHTMLDocument

Returns: the title of this document or null if none was set so far

getLastDocumentPosition

public int getLastDocumentPosition()

getParagraphElement

public Element getParagraphElement(int pos)

getParagraphElement

public Element getParagraphElement(int pos, boolean noPImplied)
Gets the current paragraph element, retracing out of p-implied if the parameter noImplied is true.

See Also: javax.swing.text.DefaultStyledDocument#getParagraphElement(int)

getReader

public ParserCallback getReader(int pos)
Fetches the reader for the parser to use to load the document with HTML. This is implemented to return an instance of SHTMLDocument.SHTMLReader.

getStyleRef

public String getStyleRef()
get the style sheet reference of the document in this DocumentPane.

Returns: the reference to this document's style sheet or null if none is found

hasStyleRef

public boolean hasStyleRef()
check whether or not this SHTMLDocument has an explicit style sheet reference

Returns: true, if a style sheet reference was found, false if not

insertAfterEnd

public void insertAfterEnd(Element elem, String htmlText)

insertAfterStart

public void insertAfterStart(Element elem, String htmlText)

insertBeforeEnd

public void insertBeforeEnd(Element elem, String htmlText)

insertBeforeStart

public void insertBeforeStart(Element elem, String htmlText)

insertStyleRef

public void insertStyleRef()
insert a style sheet reference into the head of this SHTMLDocument

removeElements

public void removeElements(Element element, int index, int count)
Removes a consecutive group of child elements.

Parameters: element the parent element to remove child elements from index the index of the first child element to remove count the number of child elements to remove

removeParagraphAttributes

public void removeParagraphAttributes(int offset, int length)

replaceHTML

public void replaceHTML(Element firstElement, int number, String htmlText)

setBase

public void setBase(URL u)

setDocumentTitle

public void setDocumentTitle(String title)
set the title of this SHTMLDocument

Parameters: title the title this document shall have

setOuterHTML

public void setOuterHTML(Element paragraphElement, String htmlText)

setParagraphAttributes

public void setParagraphAttributes(int offset, int length, AttributeSet s, boolean replace)

startCompoundEdit

public void startCompoundEdit()