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:
java.io.Serializable
,javax.swing.text.Document
,javax.swing.text.StyledDocument
public class SHTMLDocument extends javax.swing.text.html.HTMLDocument
ExtendsHTMLDocument
by a custom reader which supports the SPAN tag.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
SHTMLDocument.SHTMLReader
This reader extends HTMLDocument.HTMLReader by the capability to handle SPAN tags-
Nested classes/interfaces inherited from class javax.swing.text.html.HTMLDocument
javax.swing.text.html.HTMLDocument.BlockElement, javax.swing.text.html.HTMLDocument.HTMLReader, javax.swing.text.html.HTMLDocument.Iterator, javax.swing.text.html.HTMLDocument.RunElement
-
Nested classes/interfaces inherited from class javax.swing.text.DefaultStyledDocument
javax.swing.text.DefaultStyledDocument.AttributeUndoableEdit, javax.swing.text.DefaultStyledDocument.ElementBuffer, javax.swing.text.DefaultStyledDocument.ElementSpec, javax.swing.text.DefaultStyledDocument.SectionElement
-
Nested classes/interfaces inherited from class javax.swing.text.AbstractDocument
javax.swing.text.AbstractDocument.AbstractElement, javax.swing.text.AbstractDocument.AttributeContext, javax.swing.text.AbstractDocument.BranchElement, javax.swing.text.AbstractDocument.Content, javax.swing.text.AbstractDocument.DefaultDocumentEvent, javax.swing.text.AbstractDocument.ElementEdit, javax.swing.text.AbstractDocument.LeafElement
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
SUFFIX
-
Constructor Summary
Constructors Constructor Description SHTMLDocument()
Constructs an SHTMLDocument.SHTMLDocument(javax.swing.text.AbstractDocument.Content c, javax.swing.text.html.StyleSheet styles)
Constructs an SHTMLDocument with the given content storage implementation and the given style/attribute storage mechanism.SHTMLDocument(javax.swing.text.html.StyleSheet styles)
Constructs an SHTMLDocument with the default content storage implementation and the given style/attribute storage mechanism.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addAttributes(javax.swing.text.Element e, javax.swing.text.AttributeSet a)
apply a set of attributes to a given document elementvoid
endCompoundEdit()
protected void
fireUndoableEditUpdate(javax.swing.event.UndoableEditEvent e)
java.net.URL
getBase()
java.lang.String
getDocumentTitle()
get the title of this SHTMLDocumentint
getLastDocumentPosition()
javax.swing.text.Element
getParagraphElement(int pos)
javax.swing.text.Element
getParagraphElement(int pos, boolean noPImplied)
Gets the current paragraph element, retracing out of p-implied if the parameter noImplied is true.javax.swing.text.html.HTMLEditorKit.ParserCallback
getReader(int pos)
Fetches the reader for the parser to use to load the document with HTML.java.lang.String
getStyleRef()
get the style sheet reference of the document in thisDocumentPane
.boolean
hasStyleRef()
check whether or not this SHTMLDocument has an explicit style sheet referencevoid
insertAfterEnd(javax.swing.text.Element elem, java.lang.String htmlText)
void
insertAfterStart(javax.swing.text.Element elem, java.lang.String htmlText)
void
insertBeforeEnd(javax.swing.text.Element elem, java.lang.String htmlText)
void
insertBeforeStart(javax.swing.text.Element elem, java.lang.String htmlText)
void
insertStyleRef()
insert a style sheet reference into the head of this SHTMLDocumentvoid
removeElements(javax.swing.text.Element element, int index, int count)
Removes a consecutive group of child elements.void
removeParagraphAttributes(int offset, int length)
void
replaceHTML(javax.swing.text.Element firstElement, int number, java.lang.String htmlText)
void
setBase(java.net.URL u)
void
setDocumentTitle(java.lang.String title)
set the title of this SHTMLDocumentvoid
setOuterHTML(javax.swing.text.Element paragraphElement, java.lang.String htmlText)
void
setParagraphAttributes(int offset, int length, javax.swing.text.AttributeSet s, boolean replace)
void
startCompoundEdit()
-
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
-
-
-
-
Field Detail
-
SUFFIX
public static final java.lang.String SUFFIX
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
SHTMLDocument
public SHTMLDocument()
Constructs an SHTMLDocument.
-
SHTMLDocument
public SHTMLDocument(javax.swing.text.html.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(javax.swing.text.AbstractDocument.Content c, javax.swing.text.html.StyleSheet styles)
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 Detail
-
addAttributes
public void addAttributes(javax.swing.text.Element e, javax.swing.text.AttributeSet a)
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
public void removeElements(javax.swing.text.Element element, int index, int count) throws javax.swing.text.BadLocationException
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:
javax.swing.text.BadLocationException
-
setOuterHTML
public void setOuterHTML(javax.swing.text.Element paragraphElement, java.lang.String htmlText) throws javax.swing.text.BadLocationException, java.io.IOException
- Overrides:
setOuterHTML
in classjavax.swing.text.html.HTMLDocument
- Throws:
javax.swing.text.BadLocationException
java.io.IOException
-
insertAfterEnd
public void insertAfterEnd(javax.swing.text.Element elem, java.lang.String htmlText) throws javax.swing.text.BadLocationException, java.io.IOException
- Overrides:
insertAfterEnd
in classjavax.swing.text.html.HTMLDocument
- Throws:
javax.swing.text.BadLocationException
java.io.IOException
-
insertAfterStart
public void insertAfterStart(javax.swing.text.Element elem, java.lang.String htmlText) throws javax.swing.text.BadLocationException, java.io.IOException
- Overrides:
insertAfterStart
in classjavax.swing.text.html.HTMLDocument
- Throws:
javax.swing.text.BadLocationException
java.io.IOException
-
insertBeforeEnd
public void insertBeforeEnd(javax.swing.text.Element elem, java.lang.String htmlText) throws javax.swing.text.BadLocationException, java.io.IOException
- Overrides:
insertBeforeEnd
in classjavax.swing.text.html.HTMLDocument
- Throws:
javax.swing.text.BadLocationException
java.io.IOException
-
insertBeforeStart
public void insertBeforeStart(javax.swing.text.Element elem, java.lang.String htmlText) throws javax.swing.text.BadLocationException, java.io.IOException
- Overrides:
insertBeforeStart
in classjavax.swing.text.html.HTMLDocument
- Throws:
javax.swing.text.BadLocationException
java.io.IOException
-
replaceHTML
public void replaceHTML(javax.swing.text.Element firstElement, int number, java.lang.String htmlText) throws javax.swing.text.BadLocationException, java.io.IOException
- Throws:
javax.swing.text.BadLocationException
java.io.IOException
-
startCompoundEdit
public void startCompoundEdit()
-
endCompoundEdit
public void endCompoundEdit()
-
fireUndoableEditUpdate
protected void fireUndoableEditUpdate(javax.swing.event.UndoableEditEvent e)
- Overrides:
fireUndoableEditUpdate
in classjavax.swing.text.html.HTMLDocument
-
setDocumentTitle
public void setDocumentTitle(java.lang.String title)
set the title of this SHTMLDocument- Parameters:
title
- the title this document shall have
-
getDocumentTitle
public java.lang.String 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
public java.lang.String 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
public javax.swing.text.html.HTMLEditorKit.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.- Overrides:
getReader
in classjavax.swing.text.html.HTMLDocument
-
getParagraphElement
public javax.swing.text.Element getParagraphElement(int pos)
- Specified by:
getParagraphElement
in interfacejavax.swing.text.StyledDocument
- Overrides:
getParagraphElement
in classjavax.swing.text.DefaultStyledDocument
-
getParagraphElement
public javax.swing.text.Element getParagraphElement(int pos, boolean noPImplied)
Gets the current paragraph element, retracing out of p-implied if the parameter noImplied is true.- See Also:
DefaultStyledDocument.getParagraphElement(int)
-
getLastDocumentPosition
public int getLastDocumentPosition()
-
setParagraphAttributes
public void setParagraphAttributes(int offset, int length, javax.swing.text.AttributeSet s, boolean replace)
- Specified by:
setParagraphAttributes
in interfacejavax.swing.text.StyledDocument
- Overrides:
setParagraphAttributes
in classjavax.swing.text.html.HTMLDocument
-
removeParagraphAttributes
public void removeParagraphAttributes(int offset, int length)
-
getBase
public java.net.URL getBase()
- Overrides:
getBase
in classjavax.swing.text.html.HTMLDocument
-
setBase
public void setBase(java.net.URL u)
- Overrides:
setBase
in classjavax.swing.text.html.HTMLDocument
-
-