Package com.lightdev.app.shtm
Class SHTMLDocument
java.lang.Object
javax.swing.text.AbstractDocument
javax.swing.text.DefaultStyledDocument
javax.swing.text.html.HTMLDocument
com.lightdev.app.shtm.SHTMLDocument
- All Implemented Interfaces:
Serializable
,Document
,StyledDocument
Extends
HTMLDocument
by a custom reader which supports
the SPAN tag.- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclass
This reader extends HTMLDocument.HTMLReader by the capability to handle SPAN tagsNested classes/interfaces inherited from class javax.swing.text.html.HTMLDocument
HTMLDocument.BlockElement, HTMLDocument.HTMLReader, HTMLDocument.Iterator, HTMLDocument.RunElement
Nested classes/interfaces inherited from class javax.swing.text.DefaultStyledDocument
DefaultStyledDocument.AttributeUndoableEdit, DefaultStyledDocument.ElementBuffer, DefaultStyledDocument.ElementSpec, DefaultStyledDocument.SectionElement
Nested classes/interfaces inherited from class javax.swing.text.AbstractDocument
AbstractDocument.AbstractElement, AbstractDocument.AttributeContext, AbstractDocument.BranchElement, AbstractDocument.Content, AbstractDocument.DefaultDocumentEvent, AbstractDocument.ElementEdit, AbstractDocument.LeafElement
-
Field Summary
FieldsFields inherited from class javax.swing.text.html.HTMLDocument
AdditionalComments
Fields inherited from class javax.swing.text.DefaultStyledDocument
buffer, BUFFER_SIZE_DEFAULT
Fields inherited from class javax.swing.text.AbstractDocument
BAD_LOCATION, BidiElementName, ContentElementName, ElementNameAttribute, listenerList, ParagraphElementName, SectionElementName
Fields inherited from interface javax.swing.text.Document
StreamDescriptionProperty, TitleProperty
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs an SHTMLDocument.SHTMLDocument
(AbstractDocument.Content c, StyleSheet styles) Constructs an SHTMLDocument with the given content storage implementation and the given style/attribute storage mechanism.SHTMLDocument
(StyleSheet styles) Constructs an SHTMLDocument with the default content storage implementation and the given style/attribute storage mechanism. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addAttributes
(Element e, AttributeSet a) apply a set of attributes to a given document elementvoid
protected void
getBase()
get the title of this SHTMLDocumentint
getParagraphElement
(int pos) getParagraphElement
(int pos, boolean noPImplied) Gets the current paragraph element, retracing out of p-implied if the parameter noImplied is true.getReader
(int pos) Fetches the reader for the parser to use to load the document with HTML.get the style sheet reference of the document in thisDocumentPane
.boolean
check whether or not this SHTMLDocument has an explicit style sheet referencevoid
insertAfterEnd
(Element elem, String htmlText) void
insertAfterStart
(Element elem, String htmlText) void
insertBeforeEnd
(Element elem, String htmlText) void
insertBeforeStart
(Element elem, String htmlText) void
insert a style sheet reference into the head of this SHTMLDocumentvoid
removeElements
(Element element, int index, int count) Removes a consecutive group of child elements.void
removeParagraphAttributes
(int offset, int length) void
replaceHTML
(Element firstElement, int number, String htmlText) void
void
setDocumentTitle
(String title) set the title of this SHTMLDocumentvoid
setOuterHTML
(Element paragraphElement, String htmlText) void
setParagraphAttributes
(int offset, int length, AttributeSet s, boolean replace) void
Methods inherited from class javax.swing.text.html.HTMLDocument
create, createBranchElement, createDefaultRoot, createLeafElement, fireChangedUpdate, getElement, getElement, getIterator, getParser, getPreservesUnknownTags, getReader, getStyleSheet, getTokenThreshold, insert, insertUpdate, processHTMLFrameHyperlinkEvent, setInnerHTML, setParser, setPreservesUnknownTags, setTokenThreshold
Methods inherited from class javax.swing.text.DefaultStyledDocument
addDocumentListener, addStyle, getBackground, getCharacterElement, getDefaultRootElement, getFont, getForeground, getLogicalStyle, getStyle, getStyleNames, removeDocumentListener, removeElement, removeStyle, removeUpdate, setCharacterAttributes, setLogicalStyle, styleChanged
Methods inherited from class javax.swing.text.AbstractDocument
addUndoableEditListener, createPosition, dump, fireInsertUpdate, fireRemoveUpdate, getAsynchronousLoadPriority, getAttributeContext, getBidiRootElement, getContent, getCurrentWriter, getDocumentFilter, getDocumentListeners, getDocumentProperties, getEndPosition, getLength, getListeners, getProperty, getRootElements, getStartPosition, getText, getText, getUndoableEditListeners, insertString, postRemoveUpdate, putProperty, readLock, readUnlock, remove, removeUndoableEditListener, render, replace, setAsynchronousLoadPriority, setDocumentFilter, setDocumentProperties, writeLock, writeUnlock
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface javax.swing.text.Document
addUndoableEditListener, createPosition, getEndPosition, getLength, getProperty, getRootElements, getStartPosition, getText, getText, insertString, putProperty, remove, removeUndoableEditListener, render
-
Field Details
-
SUFFIX
- See Also:
-
-
Constructor Details
-
SHTMLDocument
public SHTMLDocument()Constructs an SHTMLDocument. -
SHTMLDocument
Constructs an SHTMLDocument with the default content storage implementation and the given style/attribute storage mechanism.- Parameters:
styles
- the styles
-
SHTMLDocument
Constructs an SHTMLDocument with the given content storage implementation and the given style/attribute storage mechanism.- Parameters:
c
- the container for the contentstyles
- the styles
-
-
Method Details
-
addAttributes
apply a set of attributes to a given document element- Parameters:
e
- the element to apply attributes toa
- the set of attributes to apply
-
removeElements
Removes a consecutive group of child elements.- Parameters:
element
- the parent element to remove child elements fromindex
- the index of the first child element to removecount
- the number of child elements to remove- Throws:
BadLocationException
-
setOuterHTML
public void setOuterHTML(Element paragraphElement, String htmlText) throws BadLocationException, IOException - Overrides:
setOuterHTML
in classHTMLDocument
- Throws:
BadLocationException
IOException
-
insertAfterEnd
- Overrides:
insertAfterEnd
in classHTMLDocument
- Throws:
BadLocationException
IOException
-
insertAfterStart
public void insertAfterStart(Element elem, String htmlText) throws BadLocationException, IOException - Overrides:
insertAfterStart
in classHTMLDocument
- Throws:
BadLocationException
IOException
-
insertBeforeEnd
- Overrides:
insertBeforeEnd
in classHTMLDocument
- Throws:
BadLocationException
IOException
-
insertBeforeStart
public void insertBeforeStart(Element elem, String htmlText) throws BadLocationException, IOException - Overrides:
insertBeforeStart
in classHTMLDocument
- Throws:
BadLocationException
IOException
-
replaceHTML
public void replaceHTML(Element firstElement, int number, String htmlText) throws BadLocationException, IOException - Throws:
BadLocationException
IOException
-
startCompoundEdit
public void startCompoundEdit() -
endCompoundEdit
public void endCompoundEdit() -
fireUndoableEditUpdate
- Overrides:
fireUndoableEditUpdate
in classHTMLDocument
-
setDocumentTitle
set the title of this SHTMLDocument- Parameters:
title
- the title this document shall have
-
getDocumentTitle
get the title of this SHTMLDocument- Returns:
- the title of this document or null if none was set so far
-
insertStyleRef
public void insertStyleRef()insert a style sheet reference into the head of this SHTMLDocument -
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
-
getStyleRef
get the style sheet reference of the document in thisDocumentPane
.- Returns:
- the reference to this document's style sheet or null if none is found
-
getReader
Fetches the reader for the parser to use to load the document with HTML. This is implemented to return an instance of SHTMLDocument.SHTMLReader.- Overrides:
getReader
in classHTMLDocument
-
getParagraphElement
- Specified by:
getParagraphElement
in interfaceStyledDocument
- Overrides:
getParagraphElement
in classDefaultStyledDocument
-
getParagraphElement
Gets the current paragraph element, retracing out of p-implied if the parameter noImplied is true.- See Also:
-
getLastDocumentPosition
public int getLastDocumentPosition() -
setParagraphAttributes
- Specified by:
setParagraphAttributes
in interfaceStyledDocument
- Overrides:
setParagraphAttributes
in classHTMLDocument
-
removeParagraphAttributes
public void removeParagraphAttributes(int offset, int length) -
getBase
- Overrides:
getBase
in classHTMLDocument
-
setBase
- Overrides:
setBase
in classHTMLDocument
-