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 TypeClassDescriptionclassThis 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.RunElementNested classes/interfaces inherited from class javax.swing.text.DefaultStyledDocument
DefaultStyledDocument.AttributeUndoableEdit, DefaultStyledDocument.ElementBuffer, DefaultStyledDocument.ElementSpec, DefaultStyledDocument.SectionElementNested 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
AdditionalCommentsFields inherited from class javax.swing.text.DefaultStyledDocument
buffer, BUFFER_SIZE_DEFAULTFields inherited from class javax.swing.text.AbstractDocument
BAD_LOCATION, BidiElementName, ContentElementName, ElementNameAttribute, listenerList, ParagraphElementName, SectionElementNameFields 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 TypeMethodDescriptionvoidaddAttributes(Element e, AttributeSet a) apply a set of attributes to a given document elementvoidprotected voidgetBase()get the title of this SHTMLDocumentintgetParagraphElement(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.booleancheck whether or not this SHTMLDocument has an explicit style sheet referencevoidinsertAfterEnd(Element elem, String htmlText) voidinsertAfterStart(Element elem, String htmlText) voidinsertBeforeEnd(Element elem, String htmlText) voidinsertBeforeStart(Element elem, String htmlText) voidinsert a style sheet reference into the head of this SHTMLDocumentvoidremoveElements(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) voidvoidsetDocumentTitle(String title) set the title of this SHTMLDocumentvoidsetOuterHTML(Element paragraphElement, String htmlText) voidsetParagraphAttributes(int offset, int length, AttributeSet s, boolean replace) voidMethods 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, setTokenThresholdMethods inherited from class javax.swing.text.DefaultStyledDocument
addDocumentListener, addStyle, getBackground, getCharacterElement, getDefaultRootElement, getFont, getForeground, getLogicalStyle, getStyle, getStyleNames, removeDocumentListener, removeElement, removeStyle, removeUpdate, setCharacterAttributes, setLogicalStyle, styleChangedMethods 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, writeUnlockMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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:
setOuterHTMLin classHTMLDocument- Throws:
BadLocationExceptionIOException
-
insertAfterEnd
- Overrides:
insertAfterEndin classHTMLDocument- Throws:
BadLocationExceptionIOException
-
insertAfterStart
public void insertAfterStart(Element elem, String htmlText) throws BadLocationException, IOException - Overrides:
insertAfterStartin classHTMLDocument- Throws:
BadLocationExceptionIOException
-
insertBeforeEnd
- Overrides:
insertBeforeEndin classHTMLDocument- Throws:
BadLocationExceptionIOException
-
insertBeforeStart
public void insertBeforeStart(Element elem, String htmlText) throws BadLocationException, IOException - Overrides:
insertBeforeStartin classHTMLDocument- Throws:
BadLocationExceptionIOException
-
replaceHTML
public void replaceHTML(Element firstElement, int number, String htmlText) throws BadLocationException, IOException - Throws:
BadLocationExceptionIOException
-
startCompoundEdit
public void startCompoundEdit() -
endCompoundEdit
public void endCompoundEdit() -
fireUndoableEditUpdate
- Overrides:
fireUndoableEditUpdatein 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:
getReaderin classHTMLDocument
-
getParagraphElement
- Specified by:
getParagraphElementin interfaceStyledDocument- Overrides:
getParagraphElementin classDefaultStyledDocument
-
getParagraphElement
Gets the current paragraph element, retracing out of p-implied if the parameter noImplied is true. -
getLastDocumentPosition
public int getLastDocumentPosition() -
setParagraphAttributes
- Specified by:
setParagraphAttributesin interfaceStyledDocument- Overrides:
setParagraphAttributesin classHTMLDocument
-
removeParagraphAttributes
public void removeParagraphAttributes(int offset, int length) -
getBase
- Overrides:
getBasein classHTMLDocument
-
setBase
- Overrides:
setBasein classHTMLDocument
-