Package com.inet.html
Class InetHtmlDocument
java.lang.Object
javax.swing.text.AbstractDocument
javax.swing.text.DefaultStyledDocument
javax.swing.text.html.HTMLDocument
com.inet.html.InetHtmlDocument
- All Implemented Interfaces:
CssDocument,Serializable,Document,StyledDocument
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
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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classExtension of the java.text way to store the adds and removes in two arrays.classExtends the DefaultDocumentEvent to support the update events by grouping the changes by paragraph element.classThis is the implementation for an implied bloc element.classUndoable edit to replace stylesheets.static interfaceA value for thePROPERTY_CONNECTION_TIMEOUTproperty to dynamically determine the connection timeout per destination.Nested 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
FieldsModifier and TypeFieldDescriptionstatic final ObjectThis mode is standard for HTML, it will never break within a wordstatic final ObjectThis mode allows words to be broken, if they are wider than their block.static final ObjectThis mode allows words to be broken, if they are wider than their block.static final intDeprecated.static final intDeprecated.As of JWebEngine 1.05, usegetDocType()insteadstatic final intDeprecated.As of JWebEngine 1.05, usegetDocType()insteadstatic final intDeprecated.As of JWebEngine 1.05, usegetDocType()insteadstatic final intDeprecated.As of JWebEngine 1.05, usegetDocType()insteadstatic final intDeprecated.As of JWebEngine 1.05, usegetDocType()insteadstatic final ObjectAn Element-Attribute key.static final intThe major version of i-net JWebEnginestatic final StringThe media target 'print'.static final StringThe media target 'screen'.static final ObjectThis is a hint for the rendering device how to handle words which are wider than their blockstatic final ObjectA Document property key, expected Type: com.inet.html.InetHtmlConfiguration, the Document configurationstatic final ObjectThis property sets the connection timeout (in milliseconds) for all connections of a document.static final ObjectA Document property key, expected Type: java.awt.Font, the default font for empty documentsstatic final ObjectA Document property key, expected Type:StringIf set, this string will be set as style class for all elements created by jWebEngine, except BR.static final ObjectA Document property key, expected Type: Boolean, if true unknown styles will not be stored in the documentstatic final ObjectSome applications define their own namespace to add additional informations to an XHTML document.static final ObjectA Document property key.static final ObjectSets the type of media, this document will render to.static final ObjectA Document property key, expected Type:Styles, these style information will be used as default styles whenever the document is created or cleared.static final ObjectIf this property is set and has an integer value greater zero, tab stops will be enabled.static final ObjectDefines the timeout for the renderer.static final ObjectIf 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 final ObjectA Document property key.static final intThe value forPROPERTY_CONNECTION_TIMEOUTto indicate that the default timeout has to be usedFields 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
ConstructorsConstructorDescriptionCreates an empty document and creates the default empty structure of an HTML Document -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAttribute(AttributeSet attrs, Object name, Object value) Adds the value to the attribute set if the value is not null.
NOTE: This method does not fire document events.voidchangeIndent(int step, int offset, int length, boolean increase) Modifies the indent of a paragraph or list item.voidchangeListStatus(int offset, int length, boolean numberedList) This functions performs, what on may expect when clicking on a list button.voidChecks whether the attributes for this view already were set and if not, sets them.createAnnonymousElement(Element parent) Creates a implied paragraph element.
NOTE: Does not change the document model and doesn't need a write lockprotected com.inet.html.InetHtmlDocument.BoxElementcreateBranchElement(Element parent, Object name) Create a branch element of the given typeprotected com.inet.html.InetHtmlDocument.BoxElementcreateBranchElement(Element parent, AttributeSet a) protected ElementcreateCopy(Element from, int limitLeft, int limitRight, Element newParent) Copies all children fromfromwhich match the limits.protected ElementcreateCopy(Element from, Element to, int limitLeft, int limitRight) Copies all children fromfromtotowhich match the limits.protected ElementcreateCopy(Element from, Element to, int limitLeft, int limitRight, int insertIndex) Copies all children fromfromtotowhich match the limits.protected AbstractDocument.AbstractElementprotected com.inet.html.InetHtmlDocument.ContentElementcreateLeafElement(Element parent, Object name, int startOffs, int endOffs) Creates a leafInetHtmlDocument.ContentElementprotected com.inet.html.InetHtmlDocument.ContentElementcreateLeafElement(Element parent, AttributeSet a, int startOffs, int endOffs) protected voidfillAttributes(Element root) Recursive descending function to get all attributes.intfindNextBlank(int startOffset, boolean directionForward) Tries to find the next space or line break in the specified directionprotected voidprotected voidprotected voidgetBackground(Element elem) Returns the background color of an elementgetBase()intgetBlockStart(int pos) Returns the position where the content block at this position starts.static StringgetCachedString(String value) This function guarantees to return always the same object for a string.
May be used to hash class or id valuesgetCharacterElement(int pos) Returns the currently used configuration.intgetConnectionTimeout(URL url) Deprecated.as of JWebEngine 1.12 - useprotected final AbstractDocument.ContentRedirect the call of getContent().com.inet.html.parser.DocTypeReturns the document type definition for the current documentReturns a list with the reference to all images used in IMG-Tags in this document.static StringgetEncoding(ChangedCharSetException charSetEx) Tries to find the charset name in a html header field.static FontReturns 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 theHtmlRootViewinstead!static FontReturns 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 theHtmlRootViewinstead!static floatgetFontSize(Element elem) Returns the font size of an elementgetForeground(Element elem) Returns the foreground color of an elementfloatDeprecated.As of JWebEngine 1.05 - UsegetDocType()and the methods ifDocTypeinsteadintReturns the last possible offset in this documentintgetLowerContentBoundary(int pos, Element topLevelParagraph) Find the next paragraph change in negative direction.intThis is the length spanned by the model.getNextParagraphElement(int pos, Element root) Gets the paragraph element at the offsetpos.getParagraphElement(int pos) getParagraphElement(int pos, Element root, boolean deepSearch) Gets the paragraph element at the offsetpos.intThe revision increases with every change, that causes an update event.
Required, if model changes and layout/painting will run in different threads!intThe site counter is increased every time the model is cleared.Enumeration<?>Fetches a list of the currently used styles.com.inet.html.css.StyleResolverReturns the style resolver, which is bound to this document to resolve the CSS stylescom.inet.html.css.StylesgetStyleSheet(String nm) Returns the style with the given name.Returns the timeout provider to be used for outgoing connections of this document.intgetUpperContentBoundary(int pos, Element topLevelParagraph) Find the next paragraph change in positive direction.getURLwithReferrer(URL url) Returns an URL with the referrer set.voidinsertAfterEnd(Element elem, String htmlText) voidinsertAfterStart(Element elem, String htmlText) voidinsertBeforeEnd(Element elem, String htmlText) voidinsertBeforeStart(Element elem, String htmlText) voidinsertHRule(int pos) A horizontal rule is a very special object.voidinsertHTML(String html, int position) Insert the content of a HTML formated string at the given positionvoidinsertImage(Image image, int pos, File location) Inserts an image, without requiring an URL.voidinsertImage(Image image, int pos, String alt, File location) Inserts an image, without requiring an URL.voidinsertString(int offs, String str, AttributeSet a) booleanReturns whether pasted images will be acceptedbooleanisLocked()Check if there is a write lock.static final booleanisReady()Checks for external preconditionsvoidParses the content read frominand stores the generated model into the the documentdocstarting at positionposvoidPaste a HTML content into a given selection range.voidPaste a HTML content into a given selection range.voidperformParagraphBreak(int pos) This function does what is in most cases expected if you pressreturn.booleanThis flag modifies the the behavior of the defaultStyleResolver.
If it returns true, theStyleResolverwill read the styles of the virtual elements CONTENT and IMPLIED as well.voidremove(int offs, int len) voidremoveElement(AttributeSet selector, int start, int end, boolean keepStyles) Removes the first element found in the tree which matches the selector attributes.voidremoveImpl(int offs, int len, com.inet.html.InetHtmlDocument.EventList list) Implementation of remove, holds no WriteLock, fires no events, just doe's it's jobvoidreplace(int offset, int length, String text, AttributeSet attrs) voidsetAllowInternalImages(boolean allowInternalImages) Set to false to block pasted images.voidvoidsetCharacterAttributes(int offset, int length, AttributeSet s, boolean replace) Sets the attributes for characters.
This function tries to set the attributes, which influence the inline content.voidsetCharacterAttributes(int offset, int length, AttributeSet s, boolean replace, boolean forceStacking) Sets the attributes for characters.
This function tries to set the attributes, which influence the inline content.voidsetDocType(int docType) Deprecated.As of JWebEngine 1.05 - UsegetDocType()and the methods ifDocTypeinsteadvoidvoidsetDocumentProperty(Object key, Object value) Adds or sets a document propertyvoidsetDocVariant(int docVariant) Deprecated.As of JWebEngine 1.05 - UsegetDocType()and the methods ifDocTypeinsteadvoidsetDocVersion(float docVersion) Deprecated.As of JWebEngine 1.05 - UsegetDocType()and the methods ifDocTypeinsteadvoidsetElementAttributes(Element elem, AttributeSet attributes, boolean replace) Directly modifies the attributes of an element an fires the required event for the viewsvoidsetParagraphAttributes(int offset, int length, 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.Methods inherited from class javax.swing.text.html.HTMLDocument
create, fireUndoableEditUpdate, getElement, getElement, getParser, getPreservesUnknownTags, getReader, getReader, getStyleSheet, getTokenThreshold, insert, insertUpdate, processHTMLFrameHyperlinkEvent, setInnerHTML, setOuterHTML, setParser, setPreservesUnknownTags, setTokenThresholdMethods inherited from class javax.swing.text.DefaultStyledDocument
addDocumentListener, addStyle, getBackground, getDefaultRootElement, getFont, getForeground, getLogicalStyle, getStyle, removeDocumentListener, removeElement, removeStyle, removeUpdate, setLogicalStyle, styleChangedMethods inherited from class javax.swing.text.AbstractDocument
addUndoableEditListener, createPosition, dump, getAsynchronousLoadPriority, getAttributeContext, getBidiRootElement, getContent, getCurrentWriter, getDocumentFilter, getDocumentListeners, getEndPosition, getListeners, getProperty, getRootElements, getStartPosition, getText, getText, getUndoableEditListeners, postRemoveUpdate, putProperty, readLock, readUnlock, removeUndoableEditListener, render, setAsynchronousLoadPriority, setDocumentFilter, 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
addDocumentListener, addUndoableEditListener, createPosition, getDefaultRootElement, getEndPosition, getProperty, getRootElements, getStartPosition, getText, getText, putProperty, removeDocumentListener, removeUndoableEditListener, render
-
Field Details
-
MAJOR_VERSION
public static final int MAJOR_VERSIONThe major version of i-net JWebEngine- See Also:
-
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 callfillAttributeson this element before reading it's styles. -
DOCTYPE_UNKNOWN
Deprecated.As of JWebEngine 1.05, usegetDocType()insteadReturn value ofgetHtmlVersion()- See Also:
-
DOCTYPE_HTML
Deprecated.As of JWebEngine 1.05, usegetDocType()insteadReturn value ofgetHtmlVersion()- See Also:
-
DOCTYPE_XHTML
Deprecated.As of JWebEngine 1.05, usegetDocType()insteadReturn value ofgetHtmlVersion()- See Also:
-
DOCTYPE_STRICT
Deprecated.As of JWebEngine 1.05, usegetDocType()insteadReturn value ofgetHtmlVersion()- See Also:
-
DOCTYPE_TRANSIENT
Deprecated.As of JWebEngine 1.05, usegetDocType()insteadReturn value ofgetHtmlVersion()- See Also:
-
DOCTYPE_FRAMESET
Deprecated.As of JWebEngine 1.05, usegetDocType()insteadReturn value ofgetHtmlVersion()- See Also:
-
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 formatting newlines are added. -
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
A Document property key, expected Type: com.inet.html.InetHtmlConfiguration, the Document configuration -
PROPERTY_DEFAULT_FONT
A Document property key, expected Type: java.awt.Font, the default font for empty documents -
PROPERTY_DROP_UNKNOWN_STYLES
A Document property key, expected Type: Boolean, if true unknown styles will not be stored in the document -
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. Currently supported are 'screen' and 'print'.- See Also:
-
MEDIA_SCREEN
The media target 'screen'. Renders like a normal web browser, enables lazy-loading of images.- See Also:
-
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:
-
PROPERTY_PERSISTENT_STYLES
A Document property key, expected Type: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_DEFAULT_STYLE_CLASS
A Document property key, expected Type:StringIf set, this string will be set as style class for all elements created by jWebEngine, except BR. This can be used combined with the default styles to create a unique styling for all elements created by the user. -
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
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
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
This is a hint for the rendering device how to handle words which are wider than their block -
BREAK_MODE_OVERFLOW
This mode is standard for HTML, it will never break within a word -
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
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
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 toBoolean.FALSE. By default it is active. -
PROPERTY_CONNECTION_TIMEOUT
This property sets the connection timeout (in milliseconds) for all connections of a document. So it primarily affects the referenced style sheets, since these are read during the parser cycle. Images are loaded asynchronously by the image cache, so their loading does not effect the time until the document is displayed. For images the value is only relevant when printing.
Allowed value types are numericString,NumberorInetHtmlDocument.TimeoutProvider
In case of numeric values:- values > 0 - will be used as timeout in milliseconds
- value == 0 - will set an infinite timeout
- value == null or value ==
VALUE_CONNECTION_TIMEOUT_DEFAULT- do no set any timeout, use connection default - values < 0 - will DISABLE all connections
- Since:
- 1.10
-
VALUE_CONNECTION_TIMEOUT_DEFAULT
public static final int VALUE_CONNECTION_TIMEOUT_DEFAULTThe value forPROPERTY_CONNECTION_TIMEOUTto indicate that the default timeout has to be used- See Also:
-
-
Constructor Details
-
InetHtmlDocument
public InetHtmlDocument()Creates an empty document and creates the default empty structure of an HTML Document- Since:
- 1.05
-
-
Method Details
-
isReady
public static final boolean isReady()Checks for external preconditions- Returns:
- true, if the preconditions are fulfilled
- Since:
- 1.05
-
getStyleResolver
public com.inet.html.css.StyleResolver getStyleResolver()Returns the style resolver, which is bound to this document to resolve the CSS styles- Specified by:
getStyleResolverin interfaceCssDocument- 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
- Since:
- 1.05
-
parse
Parses the content read frominand stores the generated model into the the documentdocstarting at positionpos- Parameters:
in- The HTML inputpos- The position within the document to start inserting the elements- Throws:
IOException- Thrown the the input readerBadLocationException- Will be thrown ifposis not within the content range- Since:
- 1.05
-
getContentImpl
Redirect the call of getContent().- Returns:
- the content implementation of this document
- Since:
- 1.05
-
getForeground
Returns the foreground color of an element- Parameters:
elem- the element to check- Returns:
- the foreground color of an element
- Since:
- 1.05
-
getBackground
Returns the background color of an element- Parameters:
elem- the element to check- Returns:
- the background color of an element
- Since:
- 1.05
-
getFontSize
Returns the font size of an element- Parameters:
elem- The element to query- Returns:
- The font size for
elemin pixel - Since:
- 1.05
-
getFont
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 theHtmlRootViewinstead!- Parameters:
elem- The element to query- Returns:
- The font object for
elem - Since:
- 1.05
-
getFont
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 theHtmlRootViewinstead!- Parameters:
elem- The element to querysize- The font size of this element- Returns:
- The font object for
elem - Since:
- 1.05
-
createBranchElement
protected com.inet.html.InetHtmlDocument.BoxElement createBranchElement(Element parent, AttributeSet a) - Overrides:
createBranchElementin classHTMLDocument
-
createBranchElement
protected com.inet.html.InetHtmlDocument.BoxElement createBranchElement(Element parent, Object name) throws IllegalArgumentException Create a branch element of the given type- Parameters:
parent- the parent element of the created elementname- the HTML Tag of the element- Returns:
- a fresh, new branch element
- Throws:
IllegalArgumentException- Thrown in case there is no parent and the element to generate does not have the nameHTML.Tag.HTML- Since:
- 1.05
-
createLeafElement
protected com.inet.html.InetHtmlDocument.ContentElement createLeafElement(Element parent, AttributeSet a, int startOffs, int endOffs) - Overrides:
createLeafElementin classHTMLDocument
-
createLeafElement
protected com.inet.html.InetHtmlDocument.ContentElement createLeafElement(Element parent, Object name, int startOffs, int endOffs) Creates a leafInetHtmlDocument.ContentElement- Parameters:
parent- the parent element, must not benullname- the name of the element, recommended to be anHTML.TagstartOffs- the start offsetendOffs- the end offset, must be > startOffs- Returns:
- the element, never
null - Throws:
IllegalArgumentException- in case the parent is null AND the name is not HTML in that case- Since:
- 1.09
-
createAnnonymousElement
Creates a implied paragraph element.
NOTE: Does not change the document model and doesn't need a write lock- Specified by:
createAnnonymousElementin interfaceCssDocument- Parameters:
parent- the parent for the generated element- Returns:
- a new anonymous branch element
-
insertAfterEnd
- Overrides:
insertAfterEndin classHTMLDocument- Throws:
BadLocationExceptionIOException
-
insertHTML
Insert the content of a HTML formated string at the given position- Parameters:
html- The content to insertposition- insert offset- Since:
- 1.05
-
pasteHTML
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 insertstart- the start offsetend- the end offset- Since:
- 1.05
-
pasteHTML
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 insertstart- the start offsetend- the end offsetsourceID- 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. If this parameter is null, the inserted HTML will be regarded as document internal - in that case no additional edit-line will be inserted after the last block element of the insert.- Since:
- 1.05
-
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
-
insertString
- Specified by:
insertStringin interfaceDocument- Overrides:
insertStringin classAbstractDocument- Throws:
BadLocationException
-
performParagraphBreak
public void performParagraphBreak(int pos) This function does what is in most cases expected if you pressreturn. 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- Since:
- 1.05
-
insertHRule
public void insertHRule(int pos) A horizontal rule is a very special object. It is a monolithic 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- Since:
- 1.05
-
getLowerContentBoundary
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 offsettopLevelParagraph- the paragraph at the start position- Returns:
- the position of the next paragraph change
- Since:
- 1.05
-
getUpperContentBoundary
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 offsettopLevelParagraph- the paragraph at the start position- Returns:
- the position of the next paragraph change
- Since:
- 1.05
-
createCopy
Copies all children fromfromwhich match the limits. Children which cross one of the limits will be cropped. The function will be called recursively for all children which are branch elements to ensure a complete copy of the structure.
NOTE: This function requires an enclosing write lock!- Parameters:
from- Element to copy fromlimitLeft- the lower positon limit for childrenlimitRight- the upper position limit for childrennewParent- The parent of the newly created element(cannot be changed later on!)- Returns:
- returns the copy of the element
- Since:
- 1.05
-
createCopy
Copies all children fromfromtotowhich match the limits. Children which cross one of the limits will be cropped. The function will be called recursively for all children which are branch elements to ensure a complete copy of the structure.- Parameters:
from- Element to copy fromto- Element to copy tolimitLeft- the lower positon limit for childrenlimitRight- the upper position limit for children- Returns:
- returns the
toelement to support inline create© - Since:
- 1.05
-
createCopy
protected Element createCopy(Element from, Element to, int limitLeft, int limitRight, int insertIndex) Copies all children fromfromtotowhich match the limits. Children which cross one of the limits will be cropped. The function will be called recursively for all children which are branch elements to ensure a complete copy of the structure.
NOTE: This function also works for exisitingtoelements with children. The copied elements will be inserted at the specified index.
This function does not change the content! The indices of the copied elements will still be the same!- Parameters:
from- Element to copy fromto- Element to copy tolimitLeft- the lower positon limit for childrenlimitRight- the upper position limit for childreninsertIndex- The index where to insert the copied elements.- Returns:
- returns the
toelement to support inline create© - Since:
- 1.05
-
remove
- Specified by:
removein interfaceDocument- Overrides:
removein classAbstractDocument- Throws:
BadLocationException
-
removeImpl
public void removeImpl(int offs, int len, com.inet.html.InetHtmlDocument.EventList list) throws BadLocationException Implementation of remove, holds no WriteLock, fires no events, just doe's it's job- Parameters:
offs- start offset of the removallen- length of the removallist- the event list to register the changes- Throws:
BadLocationException- thrown if the range leaves the content range- Since:
- 1.05
-
getCharacterElement
- Specified by:
getCharacterElementin interfaceStyledDocument- Overrides:
getCharacterElementin classDefaultStyledDocument
-
getLength
public int getLength()Returns the last possible offset in this document- Specified by:
getLengthin interfaceDocument- Overrides:
getLengthin classAbstractDocument- Returns:
- Returns the last possible offset in this document
- Since:
- 1.05
-
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
- Since:
- 1.05
-
removeElement
Removes the first element found in 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 matchedstart- start offset of the remove areaend- end offset of the remove areakeepStyles- if set to true, the document will try to keep all font-formatting styles, which are attached directly the remove element. Every special attribute will be dropped like HREF or NAME for instance.
NOTE: May have unexpected side effects, if combined with an element, which spans a block- Since:
- 1.05
-
replace
public void replace(int offset, int length, String text, AttributeSet attrs) throws BadLocationException - Overrides:
replacein classAbstractDocument- Throws:
BadLocationException
-
createDefaultRoot
- Overrides:
createDefaultRootin classHTMLDocument
-
setBase
- Overrides:
setBasein classHTMLDocument
-
getBase
- Overrides:
getBasein classHTMLDocument
-
fillAttributes
Recursive descending function to get all attributes. This function is public so it may be called by the views to fill generated/splitted content-elements as well- Parameters:
root- The root element to get the attributes- Since:
- 1.05
-
checkInit
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.- Since:
- 1.05
-
addAttribute
Adds the value to the attribute set if the value is not null.
NOTE: This method does not fire document events. Thats why it shouldn't be called on documents which are currently displayed in an editor since the changes will not be reflected by the GUI.- Parameters:
attrs- The attribute set to modifyname- The name of the attributevalue- The value of the attribute- Since:
- 1.05
-
setDocType
Deprecated.As of JWebEngine 1.05 - UsegetDocType()and the methods ifDocTypeinsteadSet the document type (Version/type constant)- Parameters:
docType- document type (Version/type constant)- Since:
- 1.0
-
setDocVersion
Deprecated.As of JWebEngine 1.05 - UsegetDocType()and the methods ifDocTypeinsteadSets the document version, typically 3.2 or 4.01- Parameters:
docVersion- the version and sub version- Since:
- 1.0
-
setDocVariant
Deprecated.As of JWebEngine 1.05 - UsegetDocType()and the methods ifDocTypeinsteadSets the variant of this document- Parameters:
docVariant- the variant constant- Since:
- 1.0
- See Also:
-
getHtmlVersion
Deprecated.As of JWebEngine 1.05 - UsegetDocType()and the methods ifDocTypeinsteadReturns the HTML version of this document depending on the defined version and variant- Returns:
- the html version and sub version
- Since:
- 1.0
-
getDocType
public com.inet.html.parser.DocType getDocType()Returns the document type definition for the current document- Returns:
- the document type definition for the current document, never null
- Since:
- 1.05
-
getParagraphElement
Gets the paragraph element at the offsetpos. 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 >= 0root- The element to start fromdeepSearch- iftruethe deepest block element will be returned, hence the first- Returns:
- the element
- Since:
- 1.05
-
getNextParagraphElement
Gets the paragraph element at the offsetpos. 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 >= 0root- The element to start from- Returns:
- the next paragraph or null, if there isn't any paragraph below
root - Since:
- 1.05
-
getParagraphElement
- Specified by:
getParagraphElementin interfaceStyledDocument- Overrides:
getParagraphElementin classDefaultStyledDocument
-
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 searching- Returns:
- the start offset of the current content parts
- Since:
- 1.05
-
setCharacterAttributes
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 changing attributes.- Specified by:
setCharacterAttributesin interfaceStyledDocument- Overrides:
setCharacterAttributesin classDefaultStyledDocument- Parameters:
offset- Where to start changing the attributeslength- Length of the area where to changes- A set of attributes which should be applied to the contentreplace- If set to true, any existing attribute of the same type will be replaced but only if it is COMPLETLY within the range of the change(to avoid side effects)- Since:
- 1.05
-
setCharacterAttributes
public void setCharacterAttributes(int offset, int length, 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 changing attributes.- Parameters:
offset- Where to start changing the attributeslength- Length of the area where to changes- A set of attributes which should be applied to the contentreplace- If set to true, any existing attribute of the same type will be replaced but only if it is COMPLETLY within the range of the change(to avoid side effects)forceStacking- if set to true, it overrides the inlineCompatibleMode and forces the method to create new inline elements on top of the existing ones instead of re-using elements. This may break inline-Boxes but is an efficient way to create new, unstyled inline elements.- Since:
- 1.05
-
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 startdirectionForward- true to search forward, false to search backwards- Returns:
- the offset of the next blank
- Since:
- 1.05
-
setParagraphAttributes
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:
setParagraphAttributesin interfaceStyledDocument- Overrides:
setParagraphAttributesin classHTMLDocument- 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 attributesreplace- whether to replace existing attributes, or merge them- Since:
- 1.05
-
setElementAttributes
Directly modifies the attributes of an element an fires the required event for the views- Parameters:
elem- the element to be modifiedattributes- the attributes to setreplace- if true, the old attributes will be removed- Since:
- 1.05
-
changeIndent
public void changeIndent(int step, int offset, int length, boolean increase) Modifies the indent 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 intersect the area from offset to offset+length.- Parameters:
step- The step size by which the margin-left will be modifiedoffset- The start position of the modificationlength- The length of the modificationincrease- true, if the indent is to be increased, false otherwise (required for lists)- Since:
- 1.05
-
changeListStatus
public void changeListStatus(int offset, int length, boolean numberedList) throws 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 offsetlength- Length of the selection, may be 0numberedList- Set to true, if a numbered list should be generated, false if a unordered list is to be generated.- Throws:
BadLocationException- possibly thrown on model errors- Since:
- 1.05
-
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. - Since:
- 1.05
-
insertImage
Inserts an image, without requiring an URL.- Parameters:
image- The image to insertpos- the position, to insert the image.location- the file location of the image (OPTIONAL)- Since:
- 1.05
-
insertImage
Inserts an image, without requiring an URL.- Parameters:
image- The image to insertpos- the position, to insert the image.alt- the ALT-Text, if anylocation- the file location of the image, if any (OPTIONAL)- Since:
- 1.05
-
fireChangedUpdate
- Overrides:
fireChangedUpdatein classHTMLDocument
-
fireInsertUpdate
- Overrides:
fireInsertUpdatein classAbstractDocument
-
fireRemoveUpdate
- Overrides:
fireRemoveUpdatein classAbstractDocument
-
setAllowInternalImages
public void setAllowInternalImages(boolean allowInternalImages) Set to false to block pasted images.- Parameters:
allowInternalImages- true to allow pasted images, false otherwise- Since:
- 1.05
-
isAllowInternalImages
public boolean isAllowInternalImages()Returns whether pasted images will be accepted- Returns:
- true if pasted images will be displayed, false otherwise
- Since:
- 1.05
-
getDocumentProperties
- Overrides:
getDocumentPropertiesin classAbstractDocument
-
setDocumentProperties
- Overrides:
setDocumentPropertiesin classAbstractDocument
-
setDocumentProperty
Adds or sets a document property- Parameters:
key- the key objectvalue- the value for this key- Since:
- 1.05
-
getConfiguration
Returns the currently used configuration.- Returns:
- Returns the currently used configuration.
- Since:
- 1.05
-
getCachedString
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
- Since:
- 1.05
-
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:
getStyleNamesin classDefaultStyledDocument- Returns:
- a list with the names of all used style tables
- Since:
- 1.0
-
getStyleSheet
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
- Since:
- 1.05
-
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:
getSiteCountin interfaceCssDocument- 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:
getRevisionin interfaceCssDocument- Returns:
- the current revision number
-
getIterator
- Overrides:
getIteratorin classHTMLDocument
-
getURLwithReferrer
Returns an URL with the referrer set. This is relevant for some website that block direct access to resource- Parameters:
url- the source URL- Returns:
- an equal URL with an additional referrer header field
- Since:
- 1.05
-
readStylesOfVirtualTags
public boolean readStylesOfVirtualTags()This flag modifies the the behavior of the defaultStyleResolver.
If it returns true, theStyleResolverwill 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 JavasStyledDocument)- Specified by:
readStylesOfVirtualTagsin interfaceCssDocument- Returns:
- true, if the styles of CONTENT and IMPLIED will be respected, if false they will be ignored
-
getEncoding
Tries to find the charset name in a html header field. You need to IgnoreCharsetDirective to prevent this exceptiondoc.putProperty( "IgnoreCharsetDirective", Boolean.TRUE );- Parameters:
charSetEx- exception that occur on parse(Reader)- Returns:
- the charset name
- Since:
- 1.09
-
getTimeoutProvider
Returns the timeout provider to be used for outgoing connections of this document.- Returns:
- the timeout provider to be used or
nullif there is no timeout defined. - Since:
- JWebEngine 1.12
-
getConnectionTimeout
Deprecated.as of JWebEngine 1.12 - useReturns the timeout to be used when connecting to an URL destination.- Parameters:
url- the URL to connect to- Returns:
- values > 0 -> the timeout in milliseconds
- value == 0 -> infinite timeout
- value == null or value ==
VALUE_CONNECTION_TIMEOUT_DEFAULT-> do no set any timeout, use connection default - values < 0 -> DO NOT CONNECT
-
getDocType()instead