com.inet.html
Class InetHtmlDocument

java.lang.Object
  extended by javax.swing.text.AbstractDocument
      extended by javax.swing.text.DefaultStyledDocument
          extended by javax.swing.text.html.HTMLDocument
              extended by com.inet.html.InetHtmlDocument
All Implemented Interfaces:
CssDocument, java.io.Serializable, javax.swing.text.Document, javax.swing.text.StyledDocument

public class InetHtmlDocument
extends javax.swing.text.html.HTMLDocument
implements CssDocument

The document is the controller component of the JWebEngine model. It provides access to the element tree and the text content and provides updates to the view in case the model gets modified.
Another purpose of the document is to store additional information about the current content an how to process this content. Since the model of the JEditorPane prevents a direct access to the current parser, writer and view any property has to be set in the current document instance.

See Also:
Serialized Form

Nested Class Summary
 class InetHtmlDocument.ExtendedDocuementEvent
          Extends the DefaultDocumentEvent to support the update events by grouping the changes by paragraph element.
 class InetHtmlDocument.ImpliedElement
          This is the implementation for an implied bloc element.
 class InetHtmlDocument.StyleSheetClearEdit
          Undoable edit to replace stylesheets.
 
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
 
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
static java.lang.Object BREAK_MODE_OVERFLOW
          This mode is standard for HTML, it will never break within a word
static java.lang.Object BREAK_MODE_WORDBREAK
          This mode allows words to be broken, if they are wider than their block.
static java.lang.Object BREAK_MODE_WORDBREAKINLINE
          This mode allows words to be broken, if they are wider than their block.
static int DOCTYPE_FRAMESET
           
static int DOCTYPE_HTML
           
static int DOCTYPE_STRICT
           
static int DOCTYPE_TRANSIENT
           
static int DOCTYPE_UNKNOWN
           
static int DOCTYPE_XHTML
           
static java.lang.Object FLAG_INIT
          An Element-Attribute key.
static int MAJOR_VERSION
           
static java.lang.String MEDIA_PRINT
          The media target print.
static java.lang.String MEDIA_SCREEN
           
static java.lang.Object PROPERTY_BREAK_MODE
          This is a hint for the rendering device how to handle words which are wider than their block
static java.lang.Object PROPERTY_CONFIGURATION
          A Document property key, expected Type: com.inet.html.InetHtmlConfiguration, the Document configuration
static java.lang.Object PROPERTY_DEFAULT_FONT
          A Document property key, expected Type: java.awt.Font, the default font for empty documents
static java.lang.Object PROPERTY_DROP_UNKNOWN_STYLES
          A Document property key, expected Type: Boolean, if true unknown styles will not be stored in the document
static java.lang.Object PROPERTY_IGNORE_NAMESPACES
          Some applications define their own namespace to add additional informations to an XHTML document.
static java.lang.Object PROPERTY_INDENT_SPACE
          A Document property key.
static java.lang.Object PROPERTY_MEDIA
          Sets the type of media, this document will render to.
static java.lang.Object PROPERTY_PERSISTENT_STYLES
          A Document property key, expected Type: com.inet.html.Styles, these style information will be used as default styles whenever the document is created or cleared.
static java.lang.Object PROPERTY_TAB_WIDTH
          If this property is set and has an integer value greater zero, tab stops will be enabled.
static java.lang.Object PROPERTY_TIMEOUT
          Defines the timeout for the renderer.
static java.lang.Object PROPERTY_USE_FONT_FALLBACK
          If there are characters which cannot be displayed with a certain font, which has been set to and element, JWebEngine can use a fallback and search all known font for one, which can display the character.
static java.lang.Object PROPERTY_WRITE_HIERARCHY
          A Document property key.
 
Fields inherited from class javax.swing.text.html.HTMLDocument
AdditionalComments
 
Fields inherited from class javax.swing.text.DefaultStyledDocument
BUFFER_SIZE_DEFAULT
 
Fields inherited from class javax.swing.text.AbstractDocument
BidiElementName, ContentElementName, ElementNameAttribute, ParagraphElementName, SectionElementName
 
Fields inherited from interface javax.swing.text.Document
StreamDescriptionProperty, TitleProperty
 
Constructor Summary
InetHtmlDocument()
          Creates an empty document and creates the default empty structure of an HTML Document
 
Method Summary
 void addAttribute(javax.swing.text.AttributeSet attrs, java.lang.Object name, java.lang.Object value)
          Adds the value to the attribute set if the value is not null
 void changeIndent(int step, int offset, int length, boolean increase)
          Modifies the indet of a paragraph or list item.
 void changeListStatus(int offset, int length, boolean numberedList)
          This functions performs, what on may expect when clicking on a list button.
 void checkInit(javax.swing.text.Element elem)
          Checks whether the attributes for this view already were set and if not, sets them.
 javax.swing.text.AbstractDocument.BranchElement createAnnonymousElement(javax.swing.text.Element parent)
          Creates a implied paragraph element.
 int findNextBlank(int startOffset, boolean directionForward)
          Tries to find the next space or line break in the specified direction
 java.awt.Color getBackground(javax.swing.text.Element elem)
          Returns the background color of an element
 java.net.URL getBase()
          
 int getBlockStart(int pos)
          Returns the position where the content block at this position starts.
static java.lang.String getCachedString(java.lang.String value)
          This function guarantees to return always the same object for a string.
 javax.swing.text.Element getCharacterElement(int pos)
          
 InetHtmlConfiguration getConfiguration()
          Returns the currently used configuration.
 java.util.Dictionary<java.lang.Object,java.lang.Object> getDocumentProperties()
          
 com.inet.html.utils.EmbeddedImage[] getEmbeddedImages()
          Returns a list with the reference to all images used in IMG-Tags in this document.
static java.awt.Font getFont(javax.swing.text.Element elem)
          Returns the font of an element
NOTE: This function is for model-purpose ONLY!
static java.awt.Font getFont(javax.swing.text.Element elem, float size)
          Returns the font of an element.
static float getFontSize(javax.swing.text.Element elem)
          Returns the font size of an element
 java.awt.Color getForeground(javax.swing.text.Element elem)
          Returns the foreground color of an element
 float getHtmlVersion()
          Returns the HTML version of this document depending on the defined version and variant
 javax.swing.text.html.HTMLDocument.Iterator getIterator(javax.swing.text.html.HTML.Tag t)
          
 int getLength()
          Returns the last possible offset in this document
 int getLowerContentBoundary(int pos, javax.swing.text.Element topLevelParagraph)
          Find the next paragraph change in negative direction.
 int getModelLength()
          This is the length spanned by the model.
 javax.swing.text.Element getNextParagraphElement(int pos, javax.swing.text.Element root)
          Gets the paragraph element at the offset pos.
 javax.swing.text.Element getParagraphElement(int pos)
          
 javax.swing.text.Element getParagraphElement(int pos, javax.swing.text.Element root)
          Gets the paragraph element at the offset pos.
 int getRevision()
          The revision increases with every change, that causes an update event.}
 int getSiteCount()
          The site counter is increased every time the model is cleared.}
 java.util.Enumeration<?> getStyleNames()
          Fetches a list of the currently used styles.
 StyleResolver getStyleResolver()
          Returns the style resolver, which is bound to this document to resolve the CSS styles
 Styles getStyleSheet(java.lang.String nm)
          Returns the style with the given name.
 int getUpperContentBoundary(int pos, javax.swing.text.Element topLevelParagraph)
          Find the next paragraph change in positive direction.
 java.net.URL getURLwithReferrer(java.net.URL url)
          
 void 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 insertHRule(int pos)
          A horizontal rule is a very special object.
 void insertHTML(java.lang.String html, int position)
          Insert the content of a HTML formated string at the given position
 void insertImage(java.awt.Image image, int pos, java.io.File location)
          Inserts an image, without requiring an URL.
 void insertImage(java.awt.Image image, int pos, java.lang.String alt, java.io.File location)
          Inserts an image, without requiring an URL.
 void insertString(int offs, java.lang.String str, javax.swing.text.AttributeSet a)
          
 boolean isAllowInternalImages()
          Returns whether pasted images will be accepted
 boolean isLocked()
          Check if there is a write lock.
static boolean isReady()
          Checks for external preconditions
 void parse(java.io.Reader in, int pos)
          Parses the content read from in and stores the generated model into the the document doc starting at position pos
 void pasteHTML(java.lang.String html, int start, int end)
          Paste a HTML content into a given selection range.
 void pasteHTML(java.lang.String html, int start, int end, java.lang.Object sourceID)
          Paste a HTML content into a given selection range.
 void performParagraphBreak(int pos)
          This function does what is in most cases expected if you press return.
 boolean readStylesOfVirtualTags()
          This flag modifies the the behavior of the default StyleResolver.
 void remove(int offs, int len)
          
 void removeElement(javax.swing.text.AttributeSet selector, int start, int end, boolean keepStyles)
          Removes the first element found int the tree which matches the selector attributes.
 void removeImpl(int offs, int len, com.inet.html.InetHtmlDocument.EventList list)
          Implentation of remove, holds no WriteLock, fires no events, just doe's it's job
 void replace(int offset, int length, java.lang.String text, javax.swing.text.AttributeSet attrs)
          
 void setAllowInternalImages(boolean allowInternalImages)
          Set to false to block pasted images.
 void setBase(java.net.URL base)
          
 void setCharacterAttributes(int offset, int length, javax.swing.text.AttributeSet s, boolean replace)
          Sets the attributes for characters.
 void setCharacterAttributes(int offset, int length, javax.swing.text.AttributeSet s, boolean replace, boolean forceStacking)
          Sets the attributes for characters.
 void setDocType(int docType)
          Set the document type
 void setDocumentProperties(java.util.Dictionary<java.lang.Object,java.lang.Object> x)
          
 void setDocumentProperty(java.lang.Object key, java.lang.Object value)
          Adds or sets a document property
 void setDocVariant(int docVariant)
          Sets the variant of this document
 void setDocVersion(float docVersion)
          Sets the document version, typically 3.2 or 4.01
 void setParagraphAttributes(int offset, int length, javax.swing.text.AttributeSet s, boolean replace)
          Sets attributes for a paragraph.
 
Methods inherited from class javax.swing.text.html.HTMLDocument
getElement, getElement, getParser, getPreservesUnknownTags, getReader, getReader, getStyleSheet, getTokenThreshold, processHTMLFrameHyperlinkEvent, setInnerHTML, setOuterHTML, setParser, setPreservesUnknownTags, setTokenThreshold
 
Methods inherited from class javax.swing.text.DefaultStyledDocument
addDocumentListener, addStyle, getBackground, getDefaultRootElement, getFont, getForeground, getLogicalStyle, getStyle, removeDocumentListener, removeStyle, setLogicalStyle
 
Methods inherited from class javax.swing.text.AbstractDocument
addUndoableEditListener, createPosition, dump, getAsynchronousLoadPriority, getBidiRootElement, getDocumentFilter, getDocumentListeners, getEndPosition, getListeners, getProperty, getRootElements, getStartPosition, getText, getText, getUndoableEditListeners, putProperty, readLock, readUnlock, removeUndoableEditListener, render, setAsynchronousLoadPriority, setDocumentFilter
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.swing.text.Document
addDocumentListener, addUndoableEditListener, createPosition, getDefaultRootElement, getEndPosition, getProperty, getRootElements, getStartPosition, getText, getText, putProperty, removeDocumentListener, removeUndoableEditListener, render
 

Field Detail

MAJOR_VERSION

public static final int MAJOR_VERSION
See Also:
Constant Field Values

FLAG_INIT

public static final java.lang.Object FLAG_INIT
An Element-Attribute key. If an attribute with this name is present, the temporary style informations for this element are supposed to be set and valid. If it is not set, it is recommended to call fillAttributes on this element before reading it's styles.


DOCTYPE_UNKNOWN

public static final int DOCTYPE_UNKNOWN
See Also:
Constant Field Values

DOCTYPE_HTML

public static final int DOCTYPE_HTML
See Also:
Constant Field Values

DOCTYPE_XHTML

public static final int DOCTYPE_XHTML
See Also:
Constant Field Values

DOCTYPE_STRICT

public static final int DOCTYPE_STRICT
See Also:
Constant Field Values

DOCTYPE_TRANSIENT

public static final int DOCTYPE_TRANSIENT
See Also:
Constant Field Values

DOCTYPE_FRAMESET

public static final int DOCTYPE_FRAMESET
See Also:
Constant Field Values

PROPERTY_INDENT_SPACE

public static final java.lang.Object PROPERTY_INDENT_SPACE
A Document property key. The value must be an java.lang.Integer. On writting the document it specify how many spaces an indent maps to. When indentation takes place, the indent level is multiplied by this mapping. The default is 2. With a value of 0 also no formating newlines are added.


PROPERTY_WRITE_HIERARCHY

public static final java.lang.Object PROPERTY_WRITE_HIERARCHY
A Document property key. The value must be an java.lang.Boolean. On writting the partial document it specify if the hierachy around the mark document is written. The default is false.


PROPERTY_CONFIGURATION

public static final java.lang.Object PROPERTY_CONFIGURATION
A Document property key, expected Type: com.inet.html.InetHtmlConfiguration, the Document configuration


PROPERTY_DEFAULT_FONT

public static final java.lang.Object PROPERTY_DEFAULT_FONT
A Document property key, expected Type: java.awt.Font, the default font for empty documents


PROPERTY_DROP_UNKNOWN_STYLES

public static final java.lang.Object PROPERTY_DROP_UNKNOWN_STYLES
A Document property key, expected Type: Boolean, if true unknown styles will not be stored in the document


PROPERTY_MEDIA

public static final java.lang.Object PROPERTY_MEDIA
Sets the type of media, this document will render to. Any 'editable' media like the screen will tend to use threaded resource loading. Print media will cause the renderer to load all resources before the rendering will take place. Currentyl supported are 'screen' and 'print'.

See Also:
http://www.w3.org/TR/CSS21/media.html

MEDIA_SCREEN

public static final java.lang.String MEDIA_SCREEN
See Also:
Constant Field Values

MEDIA_PRINT

public static final java.lang.String MEDIA_PRINT
The media target print. Print media is treated differently in case of overflow for instance. Since print media cannot scroll and has a fixed clip, the content may be broken within words to always fit to boxes.
NOTE: Print Media rendering causes a single threaded layout/paint flow

See Also:
Constant Field Values

PROPERTY_PERSISTENT_STYLES

public static final java.lang.Object PROPERTY_PERSISTENT_STYLES
A Document property key, expected Type: com.inet.html.Styles, these style information will be used as default styles whenever the document is created or cleared. Unlike the default or user agent styles, these styles will be printed to the document!
NOTE: Changing this property has only an effect on the next clear of the document!


PROPERTY_IGNORE_NAMESPACES

public static final java.lang.Object PROPERTY_IGNORE_NAMESPACES
Some applications define their own namespace to add additional informations to an XHTML document. Since we cannot display or interpret these elements, the document parser will drop them. To prevent the parser from doing so, set this property to Boolean.FALSE


PROPERTY_TIMEOUT

public static final java.lang.Object PROPERTY_TIMEOUT
Defines the timeout for the renderer. If paint is called, this timeout can be used to interrupt the process after the given time has passed. Please note, that the timeout cannot be guaranteed it's only an approximation.
Required Value: Number(fractions will be ignored), Unit: milliseconds


PROPERTY_TAB_WIDTH

public static final java.lang.Object PROPERTY_TAB_WIDTH
If this property is set and has an integer value greater zero, tab stops will be enabled. Tab stops are always relative to the current line start! Please keep in mind, that the line justification is performed after the tabs had been sized. So any text-align will move the tab positions as well. If you want to achieve a table structure use a table instead! This value is in PX.


PROPERTY_BREAK_MODE

public static final java.lang.Object PROPERTY_BREAK_MODE
This is a hint for the rendering device how to handle words which are wider than their block


BREAK_MODE_OVERFLOW

public static final java.lang.Object BREAK_MODE_OVERFLOW
This mode is standard for HTML, it will never break within a word


BREAK_MODE_WORDBREAK

public static final java.lang.Object BREAK_MODE_WORDBREAK
This mode allows words to be broken, if they are wider than their block. The word will start on a new line


BREAK_MODE_WORDBREAKINLINE

public static final java.lang.Object BREAK_MODE_WORDBREAKINLINE
This mode allows words to be broken, if they are wider than their block. The word will start at it's current location


PROPERTY_USE_FONT_FALLBACK

public static final java.lang.Object PROPERTY_USE_FONT_FALLBACK
If there are characters which cannot be displayed with a certain font, which has been set to and element, JWebEngine can use a fallback and search all known font for one, which can display the character. To disable this fallback, set this property to Boolean.FALSE. By default it is active.

Constructor Detail

InetHtmlDocument

public InetHtmlDocument()
Creates an empty document and creates the default empty structure of an HTML Document

Method Detail

isReady

public static final boolean isReady()
Checks for external preconditions

Returns:
true, if the preconditions are fulfilled

getStyleResolver

public StyleResolver getStyleResolver()
Returns the style resolver, which is bound to this document to resolve the CSS styles

Specified by:
getStyleResolver in interface CssDocument
Returns:
the style resolver of this document

isLocked

public boolean isLocked()
Check if there is a write lock. This means the parsing is in process.

Returns:
true if there is a write lock

parse

public void parse(java.io.Reader in,
                  int pos)
           throws java.io.IOException,
                  javax.swing.text.BadLocationException
Parses the content read from in and stores the generated model into the the document doc starting at position pos

Parameters:
in - The HTML input
pos - The position within the document to start inserting the elements
Throws:
java.io.IOException - Thrown the the input reader
javax.swing.text.BadLocationException - Will be thrown if pos is not within the content range

getForeground

public java.awt.Color getForeground(javax.swing.text.Element elem)
Returns the foreground color of an element

Parameters:
elem - the element to check
Returns:
the foreground color of an element

getBackground

public java.awt.Color getBackground(javax.swing.text.Element elem)
Returns the background color of an element

Parameters:
elem - the element to check
Returns:
the background color of an element

getFontSize

public static float getFontSize(javax.swing.text.Element elem)
Returns the font size of an element

Parameters:
elem - The element to query
Returns:
The font size for elem in pixel

getFont

public static java.awt.Font getFont(javax.swing.text.Element elem)
Returns the font of an element
NOTE: This function is for model-purpose ONLY! If the returned font is to be used in some render context, use the functions of the HtmlRootView instead!

Parameters:
elem - The element to query
Returns:
The font object for elem

getFont

public static java.awt.Font getFont(javax.swing.text.Element elem,
                                    float size)
Returns the font of an element.
NOTE: This function is for model-purpose ONLY! If the returned font is to be used in some render context, use the functions of the HtmlRootView instead!

Parameters:
elem - The element to query
size - The font size of this element
Returns:
The font object for elem

createAnnonymousElement

public javax.swing.text.AbstractDocument.BranchElement createAnnonymousElement(javax.swing.text.Element parent)
Creates a implied paragraph element.
NOTE: Does not change the document model and doesn't need a write lock

Specified by:
createAnnonymousElement in interface CssDocument
Parameters:
parent - the parent for the generated element
Returns:
a new anonymous branch element

insertAfterEnd

public void insertAfterEnd(javax.swing.text.Element elem,
                           java.lang.String htmlText)
                    throws javax.swing.text.BadLocationException,
                           java.io.IOException

Overrides:
insertAfterEnd in class javax.swing.text.html.HTMLDocument
Throws:
javax.swing.text.BadLocationException
java.io.IOException

insertHTML

public void insertHTML(java.lang.String html,
                       int position)
Insert the content of a HTML formated string at the given position

Parameters:
html - The content to insert
position - insert offset

pasteHTML

public void pasteHTML(java.lang.String html,
                      int start,
                      int end)
Paste a HTML content into a given selection range. This algorithm tries to find the common paragraph of the start and end position and pastes the HTML to this paragraph. Any content in between will be replaced. If start equals end, this is an insert.

Parameters:
html - the content to insert
start - the start offset
end - the end offset

pasteHTML

public void pasteHTML(java.lang.String html,
                      int start,
                      int end,
                      java.lang.Object sourceID)
Paste a HTML content into a given selection range. This algorithm tries to find the common paragraph of the start and end position and pastes the HTML to this paragraph. Any content in between will be replaced. If start equals end, this is an insert.

Parameters:
html - the content to insert
start - the start offset
end - the end offset
sourceID - the sourceID can be any object or null. The sourceID will be used to relate the content with it's global CSS. So, if there are several paste from the same source, it's global CSS can be reused.

insertAfterStart

public void insertAfterStart(javax.swing.text.Element elem,
                             java.lang.String htmlText)
                      throws javax.swing.text.BadLocationException,
                             java.io.IOException

Overrides:
insertAfterStart in class javax.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 class javax.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 class javax.swing.text.html.HTMLDocument
Throws:
javax.swing.text.BadLocationException
java.io.IOException

insertString

public void insertString(int offs,
                         java.lang.String str,
                         javax.swing.text.AttributeSet a)
                  throws javax.swing.text.BadLocationException

Specified by:
insertString in interface javax.swing.text.Document
Overrides:
insertString in class javax.swing.text.AbstractDocument
Throws:
javax.swing.text.BadLocationException

performParagraphBreak

public void performParagraphBreak(int pos)
This function does what is in most cases expected if you press return. It starts new paragraphs or list items or splits these elements if required.
This does obviously not work within table cells!

Parameters:
pos - the position to use for this split action

insertHRule

public void insertHRule(int pos)
A horizontal rule is a very special object. It is a monolitic block element, which splits the surrounding paragraph. If there is no paragraph, the content at this position has to be wrapped into a P.

Parameters:
pos - the position, to insert the HR

getLowerContentBoundary

public int getLowerContentBoundary(int pos,
                                   javax.swing.text.Element topLevelParagraph)
Find the next paragraph change in negative direction. A change is where getParagraph() would return another element or where the current paragraph ends.

Parameters:
pos - Start offset
topLevelParagraph - the paragraph at the start position
Returns:
the position of the next paragraph change

getUpperContentBoundary

public int getUpperContentBoundary(int pos,
                                   javax.swing.text.Element topLevelParagraph)
Find the next paragraph change in positive direction. A change is where getParagraph() would return another element or where the current paragraph ends.

Parameters:
pos - Start offset
topLevelParagraph - the paragraph at the start position
Returns:
the position of the next paragraph change

remove

public void remove(int offs,
                   int len)
            throws javax.swing.text.BadLocationException

Specified by:
remove in interface javax.swing.text.Document
Overrides:
remove in class javax.swing.text.AbstractDocument
Throws:
javax.swing.text.BadLocationException

removeImpl

public void removeImpl(int offs,
                       int len,
                       com.inet.html.InetHtmlDocument.EventList list)
                throws javax.swing.text.BadLocationException
Implentation of remove, holds no WriteLock, fires no events, just doe's it's job

Parameters:
offs - start offset of the removal
len - length of the removal
list - the event list to register the changes
Throws:
javax.swing.text.BadLocationException - thrown if the range leaves the content range

getCharacterElement

public javax.swing.text.Element getCharacterElement(int pos)

Specified by:
getCharacterElement in interface javax.swing.text.StyledDocument
Overrides:
getCharacterElement in class javax.swing.text.DefaultStyledDocument

getLength

public int getLength()
Returns the last possible offset in this document

Specified by:
getLength in interface javax.swing.text.Document
Overrides:
getLength in class javax.swing.text.AbstractDocument
Returns:
Returns the last possible offset in this document

getModelLength

public int getModelLength()
This is the length spanned by the model. It's 1 more than the getLength value and one less than the content.getLength value

Returns:
the length of the model

removeElement

public void removeElement(javax.swing.text.AttributeSet selector,
                          int start,
                          int end,
                          boolean keepStyles)
Removes the first element found int the tree which matches the selector attributes. All children of this element will be moved one level up(to the parent of the element)

Parameters:
selector - the attributes which have to be matched
start - start offset of the remove area
end - end offset of the remove area
keepStyles - if set to true, the document will try to keep all font-formating styles, which are attached directly the remove element. Every special attribute will be dropped like HREF or NAME for instance.
NOTE: May have unexpected sideeffects, if combined with an element, which spans a block

replace

public void replace(int offset,
                    int length,
                    java.lang.String text,
                    javax.swing.text.AttributeSet attrs)
             throws javax.swing.text.BadLocationException

Overrides:
replace in class javax.swing.text.AbstractDocument
Throws:
javax.swing.text.BadLocationException

setBase

public void setBase(java.net.URL base)

Overrides:
setBase in class javax.swing.text.html.HTMLDocument

getBase

public java.net.URL getBase()

Overrides:
getBase in class javax.swing.text.html.HTMLDocument

checkInit

public void checkInit(javax.swing.text.Element elem)
Checks whether the attributes for this view already were set and if not, sets them. The Problem is setContentType create Views and elements without any content or parser action.

Parameters:
elem - The element to check.

addAttribute

public void addAttribute(javax.swing.text.AttributeSet attrs,
                         java.lang.Object name,
                         java.lang.Object value)
Adds the value to the attribute set if the value is not null

Parameters:
attrs - The attribute set to modify
name - The name of the attribute
value - The value of the attribute

setDocType

public void setDocType(int docType)
Set the document type

Parameters:
docType - document type

setDocVersion

public void setDocVersion(float docVersion)
Sets the document version, typically 3.2 or 4.01

Parameters:
docVersion - the version and sub version

setDocVariant

public void setDocVariant(int docVariant)
Sets the variant of this document

Parameters:
docVariant - the variant constant
See Also:
DOCTYPE_HTML, DOCTYPE_STRICT, DOCTYPE_TRANSIENT, DOCTYPE_FRAMESET, DOCTYPE_XHTML, DOCTYPE_UNKNOWN

getHtmlVersion

public float getHtmlVersion()
Returns the HTML version of this document depending on the defined version and variant

Returns:
the html version and sub version

getParagraphElement

public javax.swing.text.Element getParagraphElement(int pos,
                                                    javax.swing.text.Element root)
Gets the paragraph element at the offset pos. A paragraph consists of at least one child Element, which is usually a leaf. This method will search for the deepest paragraph element in the model tree!

Parameters:
pos - the starting offset >= 0
root - The element to start from
Returns:
the element

getNextParagraphElement

public javax.swing.text.Element getNextParagraphElement(int pos,
                                                        javax.swing.text.Element root)
Gets the paragraph element at the offset pos. A paragraph consists of at least one child Element, which is usually a leaf. This method will search for the next deeper paragraph in the model tree

Parameters:
pos - the starting offset >= 0
root - The element to start from
Returns:
the next paragraph or null, if there isn't any paragraph below root

getParagraphElement

public javax.swing.text.Element getParagraphElement(int pos)

Specified by:
getParagraphElement in interface javax.swing.text.StyledDocument
Overrides:
getParagraphElement in class javax.swing.text.DefaultStyledDocument

getBlockStart

public int getBlockStart(int pos)
Returns the position where the content block at this position starts. This can be the start of the implied at this position as well.

Parameters:
pos - the offset to start seaching
Returns:
the start offset of the current content parts

setCharacterAttributes

public void setCharacterAttributes(int offset,
                                   int length,
                                   javax.swing.text.AttributeSet s,
                                   boolean replace)
Sets the attributes for characters.
This function tries to set the attributes, which influence the inline content. For a HTML 4 conform type of document, this may result in a mix of inserting spans an changeing attributes.

Specified by:
setCharacterAttributes in interface javax.swing.text.StyledDocument
Overrides:
setCharacterAttributes in class javax.swing.text.DefaultStyledDocument
Parameters:
offset - Where to start changing the attributes
length - Length of the area where to change
s - A set of attributes which should be applied to the content
replace - If set to true, any existing attribute of the same type will be replaced but only if it is COMPLETLY withing the range of the change(to avoid sideeffects)

setCharacterAttributes

public void setCharacterAttributes(int offset,
                                   int length,
                                   javax.swing.text.AttributeSet s,
                                   boolean replace,
                                   boolean forceStacking)
Sets the attributes for characters.
This function tries to set the attributes, which influence the inline content. For a HTML 4 conform type of document, this may result in a mix of inserting spans an changeing attributes.

Parameters:
offset - Where to start changing the attributes
length - Length of the area where to change
s - A set of attributes which should be applied to the content
replace - If set to true, any existing attribute of the same type will be replaced but only if it is COMPLETLY withing the range of the change(to avoid sideeffects)
forceStacking - if set to true, it overrides the inlineCompatibleMode and forces the medthod to create new inline elements on top of the exisiting ones instead of re-using elements. This may break inline-Boxes but is an efficent way to create new, unstyled inline elements.

findNextBlank

public int findNextBlank(int startOffset,
                         boolean directionForward)
Tries to find the next space or line break in the specified direction

Parameters:
startOffset - where to start
directionForward - true to search foward, false to search backwards
Returns:
the offset of the next blank

setParagraphAttributes

public void setParagraphAttributes(int offset,
                                   int length,
                                   javax.swing.text.AttributeSet s,
                                   boolean replace)
Sets attributes for a paragraph.
Unless the original implementation this method tries to applie the new attributes too the deepest paragraph element in the document structure. If there are nested paragraphs at a given position this will apply to the nested ones!

Specified by:
setParagraphAttributes in interface javax.swing.text.StyledDocument
Overrides:
setParagraphAttributes in class javax.swing.text.html.HTMLDocument
Parameters:
offset - the offset into the paragraph (must be at least 0)
length - the number of characters affected (must be at least 0)
s - the attributes
replace - whether to replace existing attributes, or merge them

changeIndent

public void changeIndent(int step,
                         int offset,
                         int length,
                         boolean increase)
Modifies the indet of a paragraph or list item. For normal blocks this will modify the margin-left setting. List items will be moved to another list level, if possible.
NOTE: This method will operate on all block which interserct the area from offset to offset+length.

Parameters:
step - The stepsize by which the margin-left will be modified
offset - The start position of the modification
length - The length of the modification
increase - true, if the indent is to be increased, false otherwise (required for lists)

changeListStatus

public void changeListStatus(int offset,
                             int length,
                             boolean numberedList)
                      throws javax.swing.text.BadLocationException
This functions performs, what on may expect when clicking on a list button. It's behavior depends on the selection. If there is a normal paragraph, it will be changed to a list. If there is a list item of the specified type, it will be changed to a normal paragraph. If there is a List item of a different Type, it will be changed to the current type. This method works for selections as well.

Parameters:
offset - Start offset
length - Length of the selection, may be 0
numberedList - Set to true, if a numbered list should be generated, false if a unordered list is to be generated.
Throws:
javax.swing.text.BadLocationException - possibly thrown on model errors

getEmbeddedImages

public com.inet.html.utils.EmbeddedImage[] getEmbeddedImages()
Returns a list with the reference to all images used in IMG-Tags in this document. Every embedded image will come with url=null on the first call, every linked image will have an URL set, but no image object.
NOTE: This method does not find background images!

Returns:
A list of all images used in this document of null, if none were used.

insertImage

public void insertImage(java.awt.Image image,
                        int pos,
                        java.io.File location)
Inserts an image, without requiring an URL.

Parameters:
image - The image to insert
pos - the position, to insert the image.
location - the file location of the image (OPTIONAL)

insertImage

public void insertImage(java.awt.Image image,
                        int pos,
                        java.lang.String alt,
                        java.io.File location)
Inserts an image, without requiring an URL.

Parameters:
image - The image to insert
pos - the position, to insert the image.
alt - the ALT-Text, if any
location - the file location of the image, if any (OPTIONAL)

setAllowInternalImages

public void setAllowInternalImages(boolean allowInternalImages)
Set to false to block pasted images.

Parameters:
allowInternalImages - true to allow pasted images, fals otherwise

isAllowInternalImages

public boolean isAllowInternalImages()
Returns whether pasted images will be accepted

Returns:
true if pasted images will be displayed, false otherwise

getDocumentProperties

public java.util.Dictionary<java.lang.Object,java.lang.Object> getDocumentProperties()

Overrides:
getDocumentProperties in class javax.swing.text.AbstractDocument

setDocumentProperties

public void setDocumentProperties(java.util.Dictionary<java.lang.Object,java.lang.Object> x)

Overrides:
setDocumentProperties in class javax.swing.text.AbstractDocument

setDocumentProperty

public void setDocumentProperty(java.lang.Object key,
                                java.lang.Object value)
Adds or sets a document property

Parameters:
key - the key object
value - the value for this key

getConfiguration

public InetHtmlConfiguration getConfiguration()
Returns the currently used configuration.

Returns:
Returns the currently used configuration.

getCachedString

public static java.lang.String getCachedString(java.lang.String value)
This function guarantees to return always the same object for a string.
May be used to hash class or id values

Parameters:
value - the string to find
Returns:
an object which is always the same for lexicaly equal strings

getStyleNames

public java.util.Enumeration<?> getStyleNames()
Fetches a list of the currently used styles. There are upt to three logical style-table names in use:
DEFAULT for the editors default values USERAGENT for the current user agent styles(which may override the defaults) INLINE for any style information described or linked by the current page

Overrides:
getStyleNames in class javax.swing.text.DefaultStyledDocument
Returns:
a list with the names of all used style tables

getStyleSheet

public Styles getStyleSheet(java.lang.String nm)
Returns the style with the given name. The name is the logical name of the styles table, not the name of any linked stylesheet.
NOTE: It is recommended not to change the DEFAULT-Table! Use USERAGENT instead.

Parameters:
nm - the name to find
Returns:
a styles table or null

getSiteCount

public int getSiteCount()
The site counter is increased every time the model is cleared. This happens, if a new page is set or the complete content has been replaced.
Required, if model changes and layout/painting will run in different threads!}

Specified by:
getSiteCount in interface CssDocument
Returns:
the current site number

getRevision

public int getRevision()
The revision increases with every change, that causes an update event.
Required, if model changes and layout/painting will run in different threads!}

Specified by:
getRevision in interface CssDocument
Returns:
the current revision number

getIterator

public javax.swing.text.html.HTMLDocument.Iterator getIterator(javax.swing.text.html.HTML.Tag t)

Overrides:
getIterator in class javax.swing.text.html.HTMLDocument

getURLwithReferrer

public java.net.URL getURLwithReferrer(java.net.URL url)


readStylesOfVirtualTags

public boolean readStylesOfVirtualTags()
This flag modifies the the behavior of the default StyleResolver.
If it returns true, the StyleResolver will read the styles of the virtual elements CONTENT and IMPLIED as well. If false is returned, the styles of these elements will be ignored and it's parents will be searched.
NOTE: This is important for document structures, which set the styles by the tree structure(like HTML) rather than by the leaf elements(like Javas StyledDocument)

Specified by:
readStylesOfVirtualTags in interface CssDocument
Returns:
true, if the styles of CONTENT and IMPLIED will be respected, if false they will be ignored