# 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`

public class SHTMLDocument extends HTMLDocument
Extends `HTMLDocument` by a custom reader which supports the SPAN tag.

See Also:
  - Serialized Form

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`static interface`
`SHTMLDocument.ThrowingRunnable<T extends Exception>`

### Nested classes/interfaces inherited from class HTMLDocument

`HTMLDocument.BlockElement, HTMLDocument.HTMLReader, HTMLDocument.Iterator, HTMLDocument.RunElement`

### Nested classes/interfaces inherited from class DefaultStyledDocument

`DefaultStyledDocument.AttributeUndoableEdit, DefaultStyledDocument.ElementBuffer, DefaultStyledDocument.ElementSpec, DefaultStyledDocument.SectionElement`

### Nested classes/interfaces inherited from class AbstractDocument

`AbstractDocument.AbstractElement, AbstractDocument.AttributeContext, AbstractDocument.BranchElement, AbstractDocument.Content, AbstractDocument.DefaultDocumentEvent, AbstractDocument.ElementEdit, AbstractDocument.LeafElement`

## Field Summary

Fields
Modifier and Type
Field
Description
`static final String`
`SUFFIX`

### Fields inherited from class HTMLDocument

`AdditionalComments`

### Fields inherited from class DefaultStyledDocument

`buffer, BUFFER_SIZE_DEFAULT`

### Fields inherited from class AbstractDocument

`BAD_LOCATION, BidiElementName, ContentElementName, ElementNameAttribute, listenerList, ParagraphElementName, SectionElementName`

### Fields inherited from interface Document

`StreamDescriptionProperty, TitleProperty`

## Constructor Summary

Constructors
Constructor
Description
`SHTMLDocument()`
Constructs 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 Type
Method
Description
`void`
`addAttributes(Element e, AttributeSet a)`
apply a set of attributes to a given document element
`<T extends Exception>
void`
`copyingExternalImages(CopiedImageSources copiedExternalImagesSources, SHTMLDocument.ThrowingRunnable<T> runnable)`
`protected AbstractDocument.AbstractElement`
`createDefaultRoot()`
Creates the root element to be used to represent the default document structure.
`void`
`endCompoundEdit()`
`protected void`
`fireUndoableEditUpdate(UndoableEditEvent e)`
`String`
`getDocumentTitle()`
get the title of this SHTMLDocument
`File`
`getImageDirectory()`
`static File`
`getImageDirectory(URL base)`
`String`
`getImageDirectoryName()`
`static String`
`getImageDirectoryName(URL documentUrl)`
`int`
`getLastDocumentPosition()`
`Element`
`getParagraphElement(int pos)`
`Element`
`getParagraphElement(int pos, boolean noPImplied)`
Gets the current paragraph element, retracing out of p-implied if the parameter noImplied is true.
`String`
`getStyleRef()`
get the style sheet reference of the document in this `DocumentPane`.
`boolean`
`hasStyleRef()`
check whether or not this SHTMLDocument has an explicit style sheet reference
`protected void`
`insert(int offset, DefaultStyledDocument.ElementSpec[] data)`
`void`
`insertAfterEnd(Element elem, String htmlText)`
`void`
`insertAfterStart(Element elem, String htmlText)`
`void`
`insertBeforeEnd(Element elem, String htmlText)`
`void`
`insertBeforeStart(Element elem, String htmlText)`
`void`
`insertStyleRef()`
insert a style sheet reference into the head of this SHTMLDocument
`void`
`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`
`setDocumentTitle(String title)`
set the title of this SHTMLDocument
`void`
`setOuterHTML(Element paragraphElement, String htmlText)`
`void`
`setParagraphAttributes(int offset, int length, AttributeSet s, boolean replace)`
`void`
`startCompoundEdit()`

### Methods inherited from class HTMLDocument

`create, createBranchElement, createLeafElement, fireChangedUpdate, getBase, getElement, getElement, getIterator, getParser, getPreservesUnknownTags, getReader, getReader, getStyleSheet, getTokenThreshold, insertUpdate, processHTMLFrameHyperlinkEvent, setBase, setInnerHTML, setParser, setPreservesUnknownTags, setTokenThreshold`

### Methods inherited from class DefaultStyledDocument

`addDocumentListener, addStyle, getBackground, getCharacterElement, getDefaultRootElement, getFont, getForeground, getLogicalStyle, getStyle, getStyleNames, removeDocumentListener, removeElement, removeStyle, removeUpdate, setCharacterAttributes, setLogicalStyle, styleChanged`

### Methods inherited from class 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 Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface Document

`addUndoableEditListener, createPosition, getEndPosition, getLength, getProperty, getRootElements, getStartPosition, getText, getText, insertString, putProperty, remove, removeUndoableEditListener, render`

## Field Details

### SUFFIX

public static final String SUFFIX

See Also:
  - Constant Field Values

## Constructor Details

### 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(AbstractDocument.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 Details

### createDefaultRoot

protected AbstractDocument.AbstractElement createDefaultRoot()
Creates the root element to be used to represent the default document structure.

Overrides:
  `createDefaultRoot` in class `HTMLDocument`
Returns:
  the element base

### 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

### removeElements

public void removeElements(Element element, int index, int count) throws BadLocationException
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
Throws:
  `BadLocationException`

### setOuterHTML

public void setOuterHTML(Element paragraphElement, String htmlText) throws BadLocationException, IOException

Overrides:
  `setOuterHTML` in class `HTMLDocument`
Throws:
  `BadLocationException`
  `IOException`

### insertAfterEnd

public void insertAfterEnd(Element elem, String htmlText) throws BadLocationException, IOException

Overrides:
  `insertAfterEnd` in class `HTMLDocument`
Throws:
  `BadLocationException`
  `IOException`

### insertAfterStart

public void insertAfterStart(Element elem, String htmlText) throws BadLocationException, IOException

Overrides:
  `insertAfterStart` in class `HTMLDocument`
Throws:
  `BadLocationException`
  `IOException`

### insertBeforeEnd

public void insertBeforeEnd(Element elem, String htmlText) throws BadLocationException, IOException

Overrides:
  `insertBeforeEnd` in class `HTMLDocument`
Throws:
  `BadLocationException`
  `IOException`

### insertBeforeStart

public void insertBeforeStart(Element elem, String htmlText) throws BadLocationException, IOException

Overrides:
  `insertBeforeStart` in class `HTMLDocument`
Throws:
  `BadLocationException`
  `IOException`

### copyingExternalImages

public <T extends Exception> void copyingExternalImages(CopiedImageSources copiedExternalImagesSources, SHTMLDocument.ThrowingRunnable<T> runnable) throws T

Throws:
  `T`

### insert

protected void insert(int offset, DefaultStyledDocument.ElementSpec[] data) throws BadLocationException

Overrides:
  `insert` in class `HTMLDocument`
Throws:
  `BadLocationException`

### 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

protected void fireUndoableEditUpdate(UndoableEditEvent e)

Overrides:
  `fireUndoableEditUpdate` in class `HTMLDocument`

### setDocumentTitle

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

Parameters:
  `title` - the title this document shall have

### getDocumentTitle

public 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 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

### getParagraphElement

public Element getParagraphElement(int pos)

Specified by:
  `getParagraphElement` in interface `StyledDocument`
Overrides:
  `getParagraphElement` in class `DefaultStyledDocument`

### 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:
  - `DefaultStyledDocument.getParagraphElement(int)`

### getLastDocumentPosition

public int getLastDocumentPosition()

### setParagraphAttributes

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

Specified by:
  `setParagraphAttributes` in interface `StyledDocument`
Overrides:
  `setParagraphAttributes` in class `HTMLDocument`

### removeParagraphAttributes

public void removeParagraphAttributes(int offset, int length)

### getImageDirectory

public File getImageDirectory()

### getImageDirectory

public static File getImageDirectory(URL base)

### getImageDirectoryName

public String getImageDirectoryName()

### getImageDirectoryName

public static String getImageDirectoryName(URL documentUrl)