HTMLDocument.java revision 3261
871N/A * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. 871N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 871N/A * This code is free software; you can redistribute it and/or modify it 871N/A * under the terms of the GNU General Public License version 2 only, as 871N/A * published by the Free Software Foundation. Oracle designates this 871N/A * particular file as subject to the "Classpath" exception as provided 871N/A * by Oracle in the LICENSE file that accompanied this code. 871N/A * This code is distributed in the hope that it will be useful, but WITHOUT 871N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 871N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 871N/A * version 2 for more details (a copy is included in the LICENSE file that 871N/A * accompanied this code). 871N/A * You should have received a copy of the GNU General Public License version 871N/A * 2 along with this work; if not, write to the Free Software Foundation, 873N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 871N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 871N/A * or visit www.oracle.com if you need additional information or have any 3832N/A * A document that models HTML. The purpose of this model is to 3832N/A * support both browsing and editing. As a result, the structure 3832N/A * described by an HTML document is not exactly replicated by default. 871N/A * The element structure that is modeled by default, is built by the 871N/A * <code>HTMLEditorKit.ParserCallback</code> protocol that the parser 3832N/A * expects. To change the structure one can subclass 3832N/A * <code>HTMLReader</code>, and reimplement the method {@link 3832N/A * #getReader(int)} to return the new reader implementation. The 927N/A * documentation for <code>HTMLReader</code> should be consulted for 3832N/A * the details of the default structure created. The intent is that 3832N/A * the document be non-lossy (although reproducing the HTML format may 3832N/A * result in a different format). 871N/A * <p>The document models only HTML, and makes no attempt to store 3832N/A * view attributes in it. The elements are identified by the 3832N/A * <code>StyleContext.NameAttribute</code> attribute, which should 3832N/A * always have a value of type <code>HTML.Tag</code> that identifies 3832N/A * the kind of element. Some of the elements (such as comments) are 900N/A * synthesized. The <code>HTMLFactory</code> uses this attribute to 3832N/A * determine what kind of view to build.</p> 964N/A * <p>This document supports incremental loading. The 3832N/A * <code>TokenThreshold</code> property controls how much of the parse 3832N/A * is buffered before trying to update the element structure of the 3832N/A * document. This property is set by the <code>EditorKit</code> so 3832N/A * that subclasses can disable it.</p> 1835N/A * <p>The <code>Base</code> property determines the URL against which 3832N/A * relative URLs are resolved. By default, this will be the 1835N/A * <code>Document.StreamDescriptionProperty</code> if the value of the 1835N/A * property is a URL. If a <BASE> tag is encountered, the base 1835N/A * will become the URL specified by that tag. Because the base URL is 1835N/A * a property, it can of course be set directly.</p> 4458N/A * <p>The default content storage mechanism for this document is a gap 4458N/A * buffer (<code>GapContent</code>). Alternatives can be supplied by 4458N/A * using the constructor that takes a <code>Content</code> 3832N/A * <h2>Modifying HTMLDocument</h2> 3832N/A * <p>In addition to the methods provided by Document and 3832N/A * StyledDocument for mutating an HTMLDocument, HTMLDocument provides 4458N/A * a number of convenience methods. The following methods can be used 4458N/A * to insert HTML content into an existing document.</p> 4458N/A * <li>{@link #setInnerHTML(Element, String)}</li> 4458N/A * <li>{@link #setOuterHTML(Element, String)}</li> 3832N/A * <li>{@link #insertBeforeStart(Element, String)}</li> 3832N/A * <li>{@link #insertAfterStart(Element, String)}</li> 3832N/A * <li>{@link #insertBeforeEnd(Element, String)}</li> 3832N/A * <li>{@link #insertAfterEnd(Element, String)}</li> 3832N/A * <p>The following examples illustrate using these methods. Each 3832N/A * example assumes the HTML document is initialized in the following 3832N/A * JEditorPane p = new JEditorPane(); 3832N/A * p.setText("..."); // Document text is provided below. 3832N/A * HTMLDocument d = (HTMLDocument) p.getDocument(); 3832N/A * <p>With the following HTML content:</p> 3832N/A * <title>An example HTMLDocument</title> 3832N/A * div { background-color: silver; } 3832N/A * <p>All the methods for modifying an HTML document require an {@link 3832N/A * Element}. Elements can be obtained from an HTML document by using 4458N/A * the method {@link #getElement(Element e, Object attribute, Object 3832N/A * value)}. It returns the first descendant element that contains the 3832N/A * specified attribute with the given value, in depth-first order. 3832N/A * For example, <code>d.getElement(d.getDefaultRootElement(), 3832N/A * StyleConstants.NameAttribute, HTML.Tag.P)</code> returns the first 3832N/A * <p>A convenient shortcut for locating elements is the method {@link 3832N/A * #getElement(String)}; returns an element whose <code>ID</code> 3832N/A * attribute matches the specified value. For example, 3832N/A * <code>d.getElement("BOX")</code> returns the <code>DIV</code> 3832N/A * <p>The {@link #getIterator(HTML.Tag t)} method can also be used for 3832N/A * finding all occurrences of the specified HTML tag in the 3832N/A * <h3>Inserting elements</h3> 3832N/A * <p>Elements can be inserted before or after the existing children 1835N/A * of any non-leaf element by using the methods 3832N/A * <code>insertAfterStart</code> and <code>insertBeforeEnd</code>. 3832N/A * For example, if <code>e</code> is the <code>DIV</code> element, 3832N/A * <code>d.insertAfterStart(e, "<ul><li>List 1835N/A * Item</li></ul>")</code> inserts the list before the first 4458N/A * paragraph, and <code>d.insertBeforeEnd(e, "<ul><li>List 1835N/A * Item</li></ul>")</code> inserts the list after the last 1835N/A * paragraph. The <code>DIV</code> block becomes the parent of the 1835N/A * newly inserted elements.</p> 1835N/A * <p>Sibling elements can be inserted before or after any element by 3832N/A * using the methods <code>insertBeforeStart</code> and 3832N/A * <code>insertAfterEnd</code>. For example, if <code>e</code> is the 3832N/A * <code>DIV</code> element, <code>d.insertBeforeStart(e, 1835N/A * "<ul><li>List Item</li></ul>")</code> inserts the list 3832N/A * before the <code>DIV</code> element, and <code>d.insertAfterEnd(e, 1835N/A * "<ul><li>List Item</li></ul>")</code> inserts the list 1835N/A * after the <code>DIV</code> element. The newly inserted elements 3832N/A * become siblings of the <code>DIV</code> element.</p> 3832N/A * <h3>Replacing elements</h3> 4458N/A * <p>Elements and all their descendants can be replaced by using the 4458N/A * methods <code>setInnerHTML</code> and <code>setOuterHTML</code>. 4458N/A * For example, if <code>e</code> is the <code>DIV</code> element, 4458N/A * <code>d.setInnerHTML(e, "<ul><li>List 4458N/A * Item</li></ul>")</code> replaces all children paragraphs with 4458N/A * the list, and <code>d.setOuterHTML(e, "<ul><li>List 4458N/A * Item</li></ul>")</code> replaces the <code>DIV</code> element 4458N/A * itself. In latter case the parent of the list is the 4458N/A * <code>BODY</code> element. 4458N/A * <p>The following table shows the example document and the results 4458N/A * of various methods described above.</p> 4458N/A * <table border=1 cellspacing=0> 4495N/A * <th><code>insertAfterStart</code></th> 4458N/A * <th><code>insertBeforeEnd</code></th> 4458N/A * <th><code>insertBeforeStart</code></th> 4458N/A * <th><code>insertAfterEnd</code></th> 4458N/A * <th><code>setInnerHTML</code></th> 4458N/A * <th><code>setOuterHTML</code></th> 4458N/A * <div style="background-color: silver;"> 4458N/A * <div style="background-color: silver;"> 4495N/A * <div style="background-color: silver;"> 4495N/A * <div style="background-color: silver;"> 3832N/A * <div style="background-color: silver;"> 3832N/A * <div style="background-color: silver;"> 3832N/A * <p><strong>Warning:</strong> Serialized objects of this class will 3832N/A * not be compatible with future Swing releases. The current 3832N/A * serialization support is appropriate for short term storage or RMI 3832N/A * between applications running the same version of Swing. As of 1.4, 3832N/A * support for long term storage of all JavaBeans<sup><font 3832N/A * size="-2">TM</font></sup> has been added to the 3832N/A * <code>java.beans</code> package. Please see {@link 3832N/A * Constructs an HTML document using the default buffer size 3832N/A * and a default <code>StyleSheet</code>. This is a convenience 2175N/A * method for the constructor 3832N/A * <code>HTMLDocument(Content, StyleSheet)</code>. 3832N/A * Constructs an HTML document with the default content 3832N/A * storage mechanism. This is a convenience method for the 3832N/A * <code>HTMLDocument(Content, StyleSheet)</code>. 3832N/A * Constructs an HTML document with the given content 3832N/A * @param c the container for the content 3832N/A * Fetches the reader for the parser to use when loading the document 3832N/A * with HTML. This is implemented to return an instance of 871N/A * Subclasses can reimplement this 871N/A * method to change how the document gets structured if desired. 3832N/A * (For example, to handle custom tags, or structurally represent character 3832N/A * @param pos the starting position 4458N/A * @return the reader used by the parser to load the document 3832N/A * Returns the reader for the parser to use to load the document 3832N/A * with HTML. This is implemented to return an instance of 3832N/A * Subclasses can reimplement this 3832N/A * method to change how the document gets structured if desired. 3832N/A * (For example, to handle custom tags, or structurally represent character 3832N/A * <p>This is a convenience method for 3832N/A * <code>getReader(int, int, int, HTML.Tag, TRUE)</code>. 4458N/A * @param popDepth the number of <code>ElementSpec.EndTagTypes</code> 4458N/A * to generate before inserting 4458N/A * @param pushDepth the number of <code>ElementSpec.StartTagTypes</code> 4458N/A * with a direction of <code>ElementSpec.JoinNextDirection</code> 4458N/A * that should be generated before inserting, 4458N/A * but after the end tags have been generated 3832N/A * @param insertTag the first tag to start inserting into document 3832N/A * @return the reader used by the parser to load the document 3832N/A * Fetches the reader for the parser to use to load the document 3832N/A * with HTML. This is implemented to return an instance of 3832N/A * method to change how the document get structured if desired 871N/A * (e.g. to handle custom tags, structurally represent character 3832N/A * @param popDepth the number of <code>ElementSpec.EndTagTypes</code> 3832N/A * to generate before inserting 2175N/A * @param pushDepth the number of <code>ElementSpec.StartTagTypes</code> 3832N/A * with a direction of <code>ElementSpec.JoinNextDirection</code> 3832N/A * that should be generated before inserting, 3832N/A * but after the end tags have been generated 3832N/A * @param insertTag the first tag to start inserting into document 3832N/A * @param insertInsertTag false if all the Elements after insertTag should 2175N/A * be inserted; otherwise insertTag will be inserted 1445N/A * @return the reader used by the parser to load the document 4458N/A * Returns the location to resolve relative URLs against. By 4458N/A * default this will be the document's URL if the document 4458N/A * was loaded from a URL. If a base tag is found and 3832N/A * can be parsed, it will be used as the base location. 4458N/A * @return the base location 3832N/A * Sets the location to resolve relative URLs against. By 3832N/A * default this will be the document's URL if the document 3832N/A * was loaded from a URL. If a base tag is found and 4458N/A * can be parsed, it will be used as the base location. 4458N/A * <p>This also sets the base of the <code>StyleSheet</code> 4458N/A * to be <code>u</code> as well as the base of the document. 3832N/A * @param u the desired base URL 4458N/A * Inserts new elements in bulk. This is how elements get created 3832N/A * in the document. The parsing determines what structure is needed 3832N/A * and creates the specification as a set of tokens that describe the 3832N/A * edit while leaving the document free of a write-lock. This method 3832N/A * can then be called in bursts by the reader to acquire a write-lock 4458N/A * for a shorter duration (i.e. while the document is actually being 1209N/A * @param offset the starting offset 3832N/A * @param data the element data 3832N/A * @exception BadLocationException if the given position does not 3832N/A * represent a valid location in the associated document. 3832N/A * Updates document structure as a result of text insertion. This 2062N/A * will happen within a write lock. This implementation simply 871N/A * parses the inserted content for line breaks and builds up a set * of instructions for the element buffer. * @param chng a description of the document change * @param attr the attributes // If this is the composed text element, merge the content attribute to it * Replaces the contents of the document with the given * element specifications. This is called before insert if * the loading is done in bursts. This is the only method called * if loading the document entirely in one burst. * @param data the new contents of the document * Sets attributes for a paragraph. * This method is thread safe, although most Swing methods * to Use Threads</A> for more information. * @param offset the offset into the paragraph (must be at least 0) * @param length the number of characters affected (must be at least 0) * @param s the attributes * @param replace whether to replace existing attributes, or merge them // Make sure we send out a change for the length of the paragraph. * Fetches the <code>StyleSheet</code> with the document-specific display * rules (CSS) that were specified in the HTML document itself. * @return the <code>StyleSheet</code> * Fetches an iterator for the specified HTML tag. * This can be used for things like iterating over the * set of anchors contained, or iterating over the input * @param t the requested <code>HTML.Tag</code> * @return the <code>Iterator</code> for the given HTML tag * Creates a document leaf element that directly represents * text (doesn't have any children). This is implemented * to return an element of type * <code>HTMLDocument.RunElement</code>. * @param parent the parent element * @param a the attributes for the element * @param p0 the beginning of the range (must be at least 0) * @param p1 the end of the range (must be at least p0) * @return the new element * Creates a document branch element, that can contain other elements. * This is implemented to return an element of type * <code>HTMLDocument.BlockElement</code>. * @param parent the parent element * @param a the attributes * Creates the root element to be used to represent the * default document structure. * @return the element base // grabs a write-lock for this initialization and // abandon it during initialization so in normal // operation we can detect an illegitimate attempt * Sets the number of tokens to buffer before trying to update * the documents element structure. * @param n the number of tokens to buffer * Gets the number of tokens to buffer before trying to update * the documents element structure. The default value is * <code>Integer.MAX_VALUE</code>. * @return the number of tokens to buffer * Determines how unknown tags are handled by the parser. * If set to true, unknown * tags are put in the model, otherwise they are dropped. * @param preservesTags true if unknown tags should be * saved in the model, otherwise tags are dropped * Returns the behavior the parser observes when encountering * @return true if unknown tags are to be preserved when parsing * Processes <code>HyperlinkEvents</code> that * are generated by documents in an HTML frame. * The <code>HyperlinkEvent</code> type, as the parameter suggests, * is <code>HTMLFrameHyperlinkEvent</code>. * In addition to the typical information contained in a * <code>HyperlinkEvent</code>, * this event contains the element that corresponds to the frame in * which the click happened (the source element) and the * target name. The target name has 4 possible values: * If target is _self, the action is to change the value of the * <code>HTML.Attribute.SRC</code> attribute and fires a * <code>ChangedUpdate</code> event. * If the target is _parent, then it deletes the parent element, * which is a <FRAMESET> element, and inserts a new <FRAME> * element, and sets its <code>HTML.Attribute.SRC</code> attribute * to have a value equal to the destination URL and fire a * <code>RemovedUpdate</code> and <code>InsertUpdate</code>. * If the target is _top, this method does nothing. In the implementation * of the view for a frame, namely the <code>FrameView</code>, * the processing of _top is handled. Given that _top implies * replacing the entire document, it made sense to handle this outside * of the document that it will replace. * If the target is a named frame, then the element hierarchy is searched * for an element with a name equal to the target, its * <code>HTML.Attribute.SRC</code> attribute is updated and a * <code>ChangedUpdate</code> event is fired. The source and destination elements The destination is the parent of the frame. * Searches the element hierarchy for an FRAME element * that has its name attribute equal to the <code>frameName</code>. * @return the element whose NAME attribute has a value of * <code>frameName</code>; returns <code>null</code> * Returns true if <code>StyleConstants.NameAttribute</code> is * equal to the tag that is passed in as a parameter. * @param attr the attributes to be matched * @param tag the value to be matched * @return true if there is a match, false otherwise * Replaces a frameset branch Element with a frame leaf element. * @param element the frameset element to remove * @param url the value for the SRC attribute for the * new frame that will replace the frameset // Should handle this better // Should handle this better * Updates the Frame elements <code>HTML.Attribute.SRC attribute</code> * and fires a <code>ChangedUpdate</code> event. * @param element a FRAME element whose SRC attribute will be updated * @param url a string specifying the new value for the SRC attribute * Returns true if the document will be viewed in a frame. * @return true if document will be viewed in a frame, otherwise false * Sets a boolean state about whether the document will be * @param frameDoc true if the document will be viewed in a frame, * Adds the specified map, this will remove a Map that has been * previously registered with the same name. * @param map the <code>Map</code> to be registered * Removes a previously registered map. * @param map the <code>Map</code> to be removed * Returns the Map associated with the given name. * @param name the name of the desired <code>Map</code> * @return the <code>Map</code> or <code>null</code> if it can't * be found, or if <code>name</code> is <code>null</code> * Returns an <code>Enumeration</code> of the possible Maps. * @return the enumerated list of maps, or <code>null</code> * if the maps are not an instance of <code>Hashtable</code> * Sets the content type language used for style sheets that do not * explicitly specify the type. The default is text/css. * @param contentType the content type language for the style sheets * Returns the content type language used for style sheets. The default * @return the content type language used for the style sheets * Sets the parser that is used by the methods that insert html * into the existing document, such as <code>setInnerHTML</code>, * and <code>setOuterHTML</code>. * <code>HTMLEditorKit.createDefaultDocument</code> will set the parser * for you. If you create an <code>HTMLDocument</code> by hand, * be sure and set the parser accordingly. * @param parser the parser to be used for text insertion * Returns the parser that is used when inserting HTML into the existing * @return the parser used for text insertion * Replaces the children of the given element with the contents * specified as an HTML string. * <p>This will be seen as at least two events, n inserts followed by * <p>Consider the following structure (the <code>elem</code> * parameter is <b>in bold</b>).</p> * <p>Invoking <code>setInnerHTML(elem, "<ul><li>")</code> * results in the following structure (new elements are <font * color="red">in red</font>).</p> * <font color="red"><ul></font> * <font color="red"><li></font> * <p>Parameter <code>elem</code> must not be a leaf element, * otherwise an <code>IllegalArgumentException</code> is thrown. * If either <code>elem</code> or <code>htmlText</code> parameter * is <code>null</code>, no changes are made to the document.</p> * <p>For this to work correcty, the document must have an * <code>HTMLEditorKit.Parser</code> set. This will be the case * if the document was created from an HTMLEditorKit via the * <code>createDefaultDocument</code> method.</p> * @param elem the branch element whose children will be replaced * @param htmlText the string to be parsed and assigned to <code>elem</code> * @throws IllegalArgumentException if <code>elem</code> is a leaf * @throws IllegalStateException if an <code>HTMLEditorKit.Parser</code> (
"Can not set inner HTML of a leaf");
// Elements were inserted, do the cleanup. * Replaces the given element in the parent with the contents * specified as an HTML string. * <p>This will be seen as at least two events, n inserts followed by * <p>When replacing a leaf this will attempt to make sure there is * a newline present if one is needed. This may result in an additional * element being inserted. Consider, if you were to replace a character * element that contained a newline with <img> this would create * two elements, one for the image, ane one for the newline.</p> * <p>If you try to replace the element at length you will most * likely end up with two elements, eg * <code>setOuterHTML(getCharacterElement (getLength()), * "blah")</code> will result in two leaf elements at the end, one * representing 'blah', and the other representing the end * <p>Consider the following structure (the <code>elem</code> * parameter is <b>in bold</b>).</p> * <p>Invoking <code>setOuterHTML(elem, "<ul><li>")</code> * results in the following structure (new elements are <font * color="red">in red</font>).</p> * <font color="red"><ul></font> * <font color="red"><li></font> * <p>If either <code>elem</code> or <code>htmlText</code> * parameter is <code>null</code>, no changes are made to the * <p>For this to work correcty, the document must have an * HTMLEditorKit.Parser set. This will be the case if the document * was created from an HTMLEditorKit via the * <code>createDefaultDocument</code> method.</p> * @param elem the element to replace * @param htmlText the string to be parsed and inserted in place of <code>elem</code> * @throws IllegalStateException if an HTMLEditorKit.Parser has not // We don't want a newline if elem is a leaf, and doesn't contain * Inserts the HTML specified as a string at the start * <p>Consider the following structure (the <code>elem</code> * parameter is <b>in bold</b>).</p> * <p>Invoking <code>insertAfterStart(elem, * "<ul><li>")</code> results in the following structure * (new elements are <font color="red">in red</font>).</p> * <font color="red"><ul></font> <p> <p> * <font color="red"><li></font> * <p>Unlike the <code>insertBeforeStart</code> method, new * elements become <em>children</em> of the specified element, * <p>Parameter <code>elem</code> must not be a leaf element, * otherwise an <code>IllegalArgumentException</code> is thrown. * If either <code>elem</code> or <code>htmlText</code> parameter * is <code>null</code>, no changes are made to the document.</p> * <p>For this to work correcty, the document must have an * <code>HTMLEditorKit.Parser</code> set. This will be the case * if the document was created from an HTMLEditorKit via the * <code>createDefaultDocument</code> method.</p> * @param elem the branch element to be the root for the new text * @param htmlText the string to be parsed and assigned to <code>elem</code> * @throws IllegalArgumentException if <code>elem</code> is a leaf * @throws IllegalStateException if an HTMLEditorKit.Parser has not * been set on the document (
"Can not insert HTML after start of a leaf");
* Inserts the HTML specified as a string at the end of * <p> If <code>elem</code>'s children are leaves, and the * character at a <code>elem.getEndOffset() - 1</code> is a newline, * this will insert before the newline so that there isn't text after * <p>Consider the following structure (the <code>elem</code> * parameter is <b>in bold</b>).</p> * <p>Invoking <code>insertBeforeEnd(elem, "<ul><li>")</code> * results in the following structure (new elements are <font * color="red">in red</font>).</p> * <p> <p> <font color="red"><ul></font> * <font color="red"><li></font> * <p>Unlike the <code>insertAfterEnd</code> method, new elements * become <em>children</em> of the specified element, not * <p>Parameter <code>elem</code> must not be a leaf element, * otherwise an <code>IllegalArgumentException</code> is thrown. * If either <code>elem</code> or <code>htmlText</code> parameter * is <code>null</code>, no changes are made to the document.</p> * <p>For this to work correcty, the document must have an * <code>HTMLEditorKit.Parser</code> set. This will be the case * if the document was created from an HTMLEditorKit via the * <code>createDefaultDocument</code> method.</p> * @param elem the element to be the root for the new text * @param htmlText the string to be parsed and assigned to <code>elem</code> * @throws IllegalArgumentException if <code>elem</code> is a leaf * @throws IllegalStateException if an HTMLEditorKit.Parser has not * been set on the document (
"Can not set inner HTML before end of leaf");
* Inserts the HTML specified as a string before the start of * <p>Consider the following structure (the <code>elem</code> * parameter is <b>in bold</b>).</p> * <p>Invoking <code>insertBeforeStart(elem, * "<ul><li>")</code> results in the following structure * (new elements are <font color="red">in red</font>).</p> * <font color="red"><ul></font> <b><div></b> * <font color="red"><li></font> <p> <p> * <p>Unlike the <code>insertAfterStart</code> method, new * elements become <em>siblings</em> of the specified element, not * <p>If either <code>elem</code> or <code>htmlText</code> * parameter is <code>null</code>, no changes are made to the * <p>For this to work correcty, the document must have an * <code>HTMLEditorKit.Parser</code> set. This will be the case * if the document was created from an HTMLEditorKit via the * <code>createDefaultDocument</code> method.</p> * @param elem the element the content is inserted before * @param htmlText the string to be parsed and inserted before <code>elem</code> * @throws IllegalStateException if an HTMLEditorKit.Parser has not * been set on the document * Inserts the HTML specified as a string after the the end of the * <p>Consider the following structure (the <code>elem</code> * parameter is <b>in bold</b>).</p> * <p>Invoking <code>insertAfterEnd(elem, "<ul><li>")</code> * results in the following structure (new elements are <font * color="red">in red</font>).</p> * <b><div></b> <font color="red"><ul></font> * <p> <p> <font color="red"><li></font> * <p>Unlike the <code>insertBeforeEnd</code> method, new elements * become <em>siblings</em> of the specified element, not * <p>If either <code>elem</code> or <code>htmlText</code> * parameter is <code>null</code>, no changes are made to the * <p>For this to work correcty, the document must have an * <code>HTMLEditorKit.Parser</code> set. This will be the case * if the document was created from an HTMLEditorKit via the * <code>createDefaultDocument</code> method.</p> * @param elem the element the content is inserted after * @param htmlText the string to be parsed and inserted after <code>elem</code> * @throws IllegalStateException if an HTMLEditorKit.Parser has not * been set on the document * Returns the element that has the given id <code>Attribute</code>. * If the element can't be found, <code>null</code> is returned. * Note that this method works on an <code>Attribute</code>, * <i>not</i> a character tag. In the following HTML snippet: * <code><a id="HelloThere"></code> the attribute is * 'id' and the character tag is 'a'. * This is a convenience method for * <code>getElement(RootElement, HTML.Attribute.id, id)</code>. * This is not thread-safe. * @param id the string representing the desired <code>Attribute</code> * @return the element with the specified <code>Attribute</code> * or <code>null</code> if it can't be found, * or <code>null</code> if <code>id</code> is <code>null</code> * Returns the child element of <code>e</code> that contains the * attribute, <code>attribute</code> with value <code>value</code>, or * <code>null</code> if one isn't found. This is not thread-safe. * @param e the root element where the search begins * @param attribute the desired <code>Attribute</code> * @param value the values for the specified <code>Attribute</code> * @return the element with the specified <code>Attribute</code> * and the specified <code>value</code>, or <code>null</code> * Returns the child element of <code>e</code> that contains the * attribute, <code>attribute</code> with value <code>value</code>, or * <code>null</code> if one isn't found. This is not thread-safe. * If <code>searchLeafAttributes</code> is true, and <code>e</code> is * a leaf, any attributes that are instances of <code>HTML.Tag</code> * with a value that is an <code>AttributeSet</code> will also be checked. * @param e the root element where the search begins * @param attribute the desired <code>Attribute</code> * @param value the values for the specified <code>Attribute</code> * @return the element with the specified <code>Attribute</code> * and the specified <code>value</code>, or <code>null</code> // For some leaf elements we store the actual attributes inside // the AttributeSet of the Element (such as anchors). * Verifies the document has an <code>HTMLEditorKit.Parser</code> set. * If <code>getParser</code> returns <code>null</code>, this will throw an * @throws IllegalStateException if the document does not have a Parser * Installs a default Parser if one has not been installed yet. * Inserts a string of HTML into the document at the given position. * <code>parent</code> is used to identify the location to insert the * <code>html</code>. If <code>parent</code> is a leaf this can have // Found it, do the insert. * Removes child Elements of the passed in Element <code>e</code>. This * will do the necessary cleanup to ensure the element representing the * end character is correctly created. * <p>This is not a general purpose method, it assumes that <code>e</code> * will still have at least one child after the remove, and it assumes * the character at <code>e.getStartOffset() - 1</code> is a newline and * Called to remove child elements of <code>e</code> when one of the * elements to remove is representing the end character. * <p>Since the Content will not allow a removal to the end character * this will do a remove from <code>start - 1</code> to <code>end</code>. * The end Element(s) will be removed, and the element representing * <code>start - 1</code> to <code>start</code> will be recreated. This * Element has to be recreated as after the content removal its offsets * become <code>start - 1</code> to <code>start - 1</code>. // index must be > 0 otherwise no insert would have happened. // e.getElement(index - 1) should represent the newline. // The hiearchies don't match, we'll have to manually // recreate the leaf at e.getElement(index - 1) // The hierarchies for the end Element and // e.getElement(index - 1), match, we can safely remove // the Elements and the end content will be aligned // Not a leaf, descend until we find the leaf representing // start - 1 and remove it. * This is used by <code>removeElementsAtEnd</code>, it removes * <code>count</code> elements starting at <code>start</code> from * <code>e</code>. If <code>remove</code> is true text of length * <code>start - 1</code> to <code>end - 1</code> is removed. If * <code>create</code> is true a new leaf is created of length 1. * Called to remove child Elements when the end is not touched. // These two are provided for inner class access. The are named different // than the super class as the super class implementations are final. // Provided for inner class access. * Notifies all listeners that have registered interest for * notification on this event type. The event instance * is lazily created using the parameters passed into * Notifies all listeners that have registered interest for * notification on this event type. The event instance * is lazily created using the parameters passed into * state defines whether the document is a frame document * Used to store button groups for radio buttons in * Document property for the number of tokens to buffer * before building an element subtree to represent them. * Document property key value. The value for the key will be a Vector * of Strings that are comments not found in the body. * Document property key value. The value for the key will be a * String indicating the default type of stylesheet links. * The location to resolve relative URLs against. By * default this will be the document's URL if the document * was loaded from a URL. If a base tag is found and * can be parsed, it will be used as the base location. * does the document have base tag * BASE tag's TARGET attribute value * The parser that is used when inserting html into the existing * Used for inserts when a null AttributeSet is supplied. * Property Maps are registered under, will be a Hashtable. * @see AbstractDocument#I18NProperty * An iterator to iterate over a particular type of * tag. The iterator is not thread safe. If reliable * access to the document is not already ensured by * the context under which the iterator is being used, * its use should be performed under the protection of * Return the attributes for this tag. * @return the <code>AttributeSet</code> for this tag, or * <code>null</code> if none can be found * Returns the start of the range for which the current occurrence of * the tag is defined and has the same attributes. * @return the start of the range, or -1 if it can't be found * Returns the end of the range for which the current occurrence of * the tag is defined and has the same attributes. * @return the end of the range * Move the iterator forward to the next occurrence * of the tag it represents. public abstract void next();
* Indicates if the iterator is currently * representing an occurrence of a tag. If * false there are no more tags for this iterator. * @return true if the iterator is currently representing an * occurrence of a tag, otherwise returns false * Type of tag this iterator represents. * An iterator to iterate over a particular type of tag. * Returns the attributes for this tag. * @return the <code>AttributeSet</code> for this tag, * or <code>null</code> if none can be found * Returns the start of the range for which the current occurrence of * the tag is defined and has the same attributes. * @return the start of the range, or -1 if it can't be found * Returns the end of the range for which the current occurrence of * the tag is defined and has the same attributes. * @return the end of the range * Moves the iterator forward to the next occurrence * of the tag it represents. * Returns the type of tag this iterator represents. * @return the <code>HTML.Tag</code> that this iterator represents. * Returns true if the current position is not <code>null</code>. * @return true if current position is not <code>null</code>, * otherwise returns false * Moves the given iterator to the next leaf element. * @param iter the iterator to be scanned * Marches a cloned iterator forward to locate the end * of the run. This sets the value of <code>endOffset</code>. * An HTML reader to load an HTML document with an HTML * element structure. This is a set of callbacks from * the parser, implemented to create a set of elements * tagged with attributes. The parse builds up tokens * (ElementSpec) that describe the element subtree desired, * and burst it into the document under the protection of * a write lock using the insert method on the document * The reader can be configured by registering actions * that describe how to handle the action. The idea behind * the actions provided is that the most natural text editing * operations can be provided if the element structure boils * down to paragraphs with runs of some kind of style * in them. Some things are more naturally specified * structurally, so arbitrary structure should be allowed * above the paragraphs, but will need to be edited with structural * actions. The implication of this is that some of the * HTML elements specified in the stream being parsed will * be collapsed into attributes, and in some cases paragraphs * will be synthesized. When HTML elements have been * converted to attributes, the attribute key will be of * type HTML.Tag, and the value will be of type AttributeSet * so that no information is lost. This enables many of the * existing actions to work so that the user can type input, * hit the return key, backspace, delete, etc and have a * reasonable result. Selections can be created, and attributes * applied or removed, etc. With this in mind, the work done * by the reader can be categorized into the following kinds * <dd>Build the structure like it's specified in the stream. * This produces elements that contain other elements. * <dd>Like block except that it's expected that the element * will be used with a paragraph view so a paragraph element * won't need to be synthesized. * <dd>Contribute the element as an attribute that will start * and stop at arbitrary text locations. This will ultimately * be mixed into a run of text, with all of the currently * flattened HTML character elements. * <dd>Produce an embedded graphical element. * <dd>Produce an element that is like the embedded graphical * element, except that it also has a component model associated * <dd>Create an element that is hidden from view when the * document is being viewed read-only, and visible when the * document is being edited. This is useful to keep the * model from losing information, and used to store things * like comments and unrecognized tags. * Currently, <APPLET>, <PARAM>, <MAP>, <AREA>, <LINK>, * <SCRIPT> and <STYLE> are unsupported. * The assignment of the actions described is shown in the * following table for the tags defined in <code>HTML.Tag</code>.<P> * <table border=1 summary="HTML tags and assigned actions"> * <tr><th>Tag</th><th>Action</th></tr> * <tr><td><code>HTML.Tag.A</code> <td>CharacterAction * <tr><td><code>HTML.Tag.ADDRESS</code> <td>CharacterAction * <tr><td><code>HTML.Tag.APPLET</code> <td>HiddenAction * <tr><td><code>HTML.Tag.AREA</code> <td>AreaAction * <tr><td><code>HTML.Tag.B</code> <td>CharacterAction * <tr><td><code>HTML.Tag.BASE</code> <td>BaseAction * <tr><td><code>HTML.Tag.BASEFONT</code> <td>CharacterAction * <tr><td><code>HTML.Tag.BIG</code> <td>CharacterAction * <tr><td><code>HTML.Tag.BLOCKQUOTE</code><td>BlockAction * <tr><td><code>HTML.Tag.BODY</code> <td>BlockAction * <tr><td><code>HTML.Tag.BR</code> <td>SpecialAction * <tr><td><code>HTML.Tag.CAPTION</code> <td>BlockAction * <tr><td><code>HTML.Tag.CENTER</code> <td>BlockAction * <tr><td><code>HTML.Tag.CITE</code> <td>CharacterAction * <tr><td><code>HTML.Tag.CODE</code> <td>CharacterAction * <tr><td><code>HTML.Tag.DD</code> <td>BlockAction * <tr><td><code>HTML.Tag.DFN</code> <td>CharacterAction * <tr><td><code>HTML.Tag.DIR</code> <td>BlockAction * <tr><td><code>HTML.Tag.DIV</code> <td>BlockAction * <tr><td><code>HTML.Tag.DL</code> <td>BlockAction * <tr><td><code>HTML.Tag.DT</code> <td>ParagraphAction * <tr><td><code>HTML.Tag.EM</code> <td>CharacterAction * <tr><td><code>HTML.Tag.FONT</code> <td>CharacterAction * <tr><td><code>HTML.Tag.FORM</code> <td>As of 1.4 a BlockAction * <tr><td><code>HTML.Tag.FRAME</code> <td>SpecialAction * <tr><td><code>HTML.Tag.FRAMESET</code> <td>BlockAction * <tr><td><code>HTML.Tag.H1</code> <td>ParagraphAction * <tr><td><code>HTML.Tag.H2</code> <td>ParagraphAction * <tr><td><code>HTML.Tag.H3</code> <td>ParagraphAction * <tr><td><code>HTML.Tag.H4</code> <td>ParagraphAction * <tr><td><code>HTML.Tag.H5</code> <td>ParagraphAction * <tr><td><code>HTML.Tag.H6</code> <td>ParagraphAction * <tr><td><code>HTML.Tag.HEAD</code> <td>HeadAction * <tr><td><code>HTML.Tag.HR</code> <td>SpecialAction * <tr><td><code>HTML.Tag.I</code> <td>CharacterAction * <tr><td><code>HTML.Tag.IMG</code> <td>SpecialAction * <tr><td><code>HTML.Tag.INPUT</code> <td>FormAction * <tr><td><code>HTML.Tag.ISINDEX</code> <td>IsndexAction * <tr><td><code>HTML.Tag.KBD</code> <td>CharacterAction * <tr><td><code>HTML.Tag.LI</code> <td>BlockAction * <tr><td><code>HTML.Tag.LINK</code> <td>LinkAction * <tr><td><code>HTML.Tag.MAP</code> <td>MapAction * <tr><td><code>HTML.Tag.MENU</code> <td>BlockAction * <tr><td><code>HTML.Tag.META</code> <td>MetaAction * <tr><td><code>HTML.Tag.NOFRAMES</code> <td>BlockAction * <tr><td><code>HTML.Tag.OBJECT</code> <td>SpecialAction * <tr><td><code>HTML.Tag.OL</code> <td>BlockAction * <tr><td><code>HTML.Tag.OPTION</code> <td>FormAction * <tr><td><code>HTML.Tag.P</code> <td>ParagraphAction * <tr><td><code>HTML.Tag.PARAM</code> <td>HiddenAction * <tr><td><code>HTML.Tag.PRE</code> <td>PreAction * <tr><td><code>HTML.Tag.SAMP</code> <td>CharacterAction * <tr><td><code>HTML.Tag.SCRIPT</code> <td>HiddenAction * <tr><td><code>HTML.Tag.SELECT</code> <td>FormAction * <tr><td><code>HTML.Tag.SMALL</code> <td>CharacterAction * <tr><td><code>HTML.Tag.STRIKE</code> <td>CharacterAction * <tr><td><code>HTML.Tag.S</code> <td>CharacterAction * <tr><td><code>HTML.Tag.STRONG</code> <td>CharacterAction * <tr><td><code>HTML.Tag.STYLE</code> <td>StyleAction * <tr><td><code>HTML.Tag.SUB</code> <td>CharacterAction * <tr><td><code>HTML.Tag.SUP</code> <td>CharacterAction * <tr><td><code>HTML.Tag.TABLE</code> <td>BlockAction * <tr><td><code>HTML.Tag.TD</code> <td>BlockAction * <tr><td><code>HTML.Tag.TEXTAREA</code> <td>FormAction * <tr><td><code>HTML.Tag.TH</code> <td>BlockAction * <tr><td><code>HTML.Tag.TITLE</code> <td>TitleAction * <tr><td><code>HTML.Tag.TR</code> <td>BlockAction * <tr><td><code>HTML.Tag.TT</code> <td>CharacterAction * <tr><td><code>HTML.Tag.U</code> <td>CharacterAction * <tr><td><code>HTML.Tag.UL</code> <td>BlockAction * <tr><td><code>HTML.Tag.VAR</code> <td>CharacterAction * Once </html> is encountered, the Actions are no longer notified. * Generates a RuntimeException (will eventually generate * a BadLocationException when API changes are alloced) if inserting * into non empty document, <code>insertTag</code> is * non-<code>null</code>, and <code>offset</code> is not in the body. // PENDING(sky): Add throws BadLocationException and remove // register handlers for the well known tags * This block initializes the <code>inParagraph</code> flag. * It is left in <code>false</code> value automatically * if the target document is empty or future inserts * were positioned into the 'body' tag. /* Going up by the left document structure path */ for (
int i =
0; i <=
this.
popDepth; i++) {
/* Going down by the right document structure path */ * Generates an initial batch of end <code>ElementSpecs</code> * in parseBuffer to position future inserts into the body. // Previous isn't in body, but current is. Have to // do some end specs, followed by join next. // Insert a newline, if necessary. // Should never throw, but will catch anyway. // We should probably throw an exception if (count == -1) // Or look for the body and reset the offset. * @return number of parents to reach the child at offset. * @return number of parents of the leaf at <code>offset</code> * until a parent with name, <code>name</code> has been * found. -1 indicates no matching parent with * This will make sure there aren't two BODYs (the second is * typically created when you do a remove all, and then an insert). // Remove the fake second body. // Insert a new element to represent the end that the // second body was representing. // We now have two \n's, one part of the Document. // Mark the edit as done. // -- HTMLEditorKit.ParserCallback methods -------------------- * The last method called on the reader. It allows * any pending changes to be flushed into the document. * Since this is currently loading synchronously, the entire * set of changes are pushed in at this point. * Called by the parser to indicate a block of text was // see if complex glyph layout support is needed // if a default direction of right-to-left has been specified, // we want complex layout even if the text is all left to right. // Assume content should be added. * Callback from the parser. Route to the appropriate // Increment inBlock since we know we are in the body, // this is needed incase an implied-p is needed. If // inBlock isn't incremented, and an implied-p is // encountered, addContent won't be called! // Map the style attributes. // Comment outside of body, will not be able to show it, // but can add it as a property on the Document. * Adds the comment <code>comment</code> to the set of comments * maintained outside of the scope of elements. // No place to put comment. * Callback from the parser. Route to the appropriate * Callback from the parser. Route to the appropriate // Map the style attributes. // unknown tag, only add if should preserve it. * This is invoked after the stream has been parsed, but before * <code>flush</code>. <code>eol</code> will be one of \n, \r * or \r\n, which ever is encountered the most in parsing the // ---- tag handling support ------------------------------ * Registers a handler for the given tag. By default * all of the well-known tags will have been registered. * This can be used to change the handling of a particular * tag or to add support for custom tags. * An action to be performed in response * to parsing a tag. This allows customization * of how each tag is handled and avoids a large * Called when a start tag is seen for the * type of tag this action was registered * to. The tag argument indicates the actual * tag for those actions that are shared across * many tags. By default this does nothing and * completely ignores the tag. * Called when an end tag is seen for the * type of tag this action was registered * to. The tag argument indicates the actual * tag for those actions that are shared across * many tags. By default this does nothing and * completely ignores the tag. * Action used for the actual element form tag. This is named such * as there was already a public class named FormAction. // initialize a ButtonGroupsMap when // FORM tag is encountered. This will // be used for any radio buttons that // might be defined in the FORM. // for new group new ButtonGroup will be created (fix for 4529702) // group name is a key in radioButtonGroupsMap // reset the button group to null since * Subclass of HiddenAction to set the content type for style sheets, * and to set the name of the default style sheet. * End if overridden to create the necessary stylesheets that * are referenced via the link tag. It is done in this manner * as the meta tag can be used to specify an alternate style sheet, * and is not guaranteed to come before the link tags. // This check of the insertTag is put in to avoid considering // the implied-p that is generated for the head. This allows // inserts for HR to work correctly. // See if there is a StyleSheet to link to. // First element gives type. // Select link if rel==stylesheet. // Otherwise if rel==alternate stylesheet and // title matches default style. * A subclass to add the AttributeSet to styles if the * attributes contains an attribute for 'rel' with value * 'stylesheet' or 'alternate stylesheet'. // set inPre to false after closing, so that if a newline // is added it won't generate a blockOpen. // Note that the third argument should really be based off // inParagraph and impliedP. If we're wrong (that is // insertTagDepthDelta shouldn't be changed), we'll end up // removing an extra EndSpec, which won't matter anyway. * mappings that have a corresponding StyleConstants * and CSS mapping. The conversion is to CSS attributes. // Note that the third argument should really be based off // inParagraph and impliedP. If we're wrong (that is // insertTagDepthDelta shouldn't be changed), we'll end up // removing an extra EndSpec, which won't matter anyway. // We also need to add attr, otherwise we lose custom // attributes, including class/id for style lookups, and // further confuse style lookup (doesn't have tag). // set flag to catch empty anchors // if the anchor was empty it was probably a // named anchor point and we don't want to throw char[]
one =
new char[
1];
* Action to support forms by building all of the elements * used to represent form controls. This will process * the <INPUT>, <TEXTAREA>, <SELECT>, * and <OPTION> tags. The element created by * this action is expected to have the attribute * <code>StyleConstants.ModelAttribute</code> set to * the model that holds the state for the form control. * This enables multiple views, and allows document to * be iterated over picking up the data of the form. * The following are the model assignments for the * various type of form elements. * <table summary="model assignments for the various types of form elements"> * <td>{@link DefaultButtonModel} * <td>input, type checkbox * <td>{@link javax.swing.JToggleButton.ToggleButtonModel} * <td>{@link DefaultButtonModel} * <td>input, type password * <td>{@link PlainDocument} * <td>{@link javax.swing.JToggleButton.ToggleButtonModel} * <td>{@link DefaultButtonModel} * <td>{@link DefaultButtonModel} * <td>input, type text or type is null. * <td>{@link PlainDocument} * <td>{@link DefaultComboBoxModel} or an {@link DefaultListModel}, with an item type of Option * <td>{@link PlainDocument} * if type is not defined teh default is // build the element, unless this is an option. /* Now that the textarea has ended, * store the entire initial text * of the text area. This will * enable us to restore the initial * state if a reset is requested. * If a <SELECT> tag is being processed, this * model will be a reference to the model being filled * with the <OPTION> elements (which produce * objects of type <code>Option</code>. // --- utility methods used by the reader ------------------ * Pushes the current character style on a stack in preparation * for forming a new nested character style. * Pops a previously pushed character style off the stack * to return to a previous style. * Adds the given content to the textarea document. * This method gets called when we are in a textarea * context. Therefore all text that is seen belongs * to the text area and is hence added to the * TextAreaDocument associated with the text area. // Should do something reasonable * Adds the given content that was encountered in a * PRE element. This synthesizes lines to hold the * runs of text, and makes calls to addContent to * Adds an instruction to the parse buffer to create a * block element with the given attributes. * Adds an instruction to the parse buffer to close out * a block element of the given type. // Add a new line, if the last character wasn't one. This is // needed for proper positioning of the cursor. addContent // with true will force an implied paragraph to be generated if // there isn't one. This may result in a rather bogus structure // (perhaps a table with a child pargraph), but the paragraph // is needed for proper positioning and display. // an open/close with no content will be removed, so we // add a space of content to keep the element being formed. char[]
one =
new char[
1];
* Adds some text with the current character attributes. * @param data the content to add * @param offs the initial offset * @param length the length * Adds some text with the current character attributes. * @param data the content to add * @param offs the initial offset * @param length the length * @param generateImpliedPIfNecessary whether to generate implied * Adds content that is basically specified entirely char[]
one =
new char[
1];
// Set this to avoid generating a newline for frames, frames // shouldn't have any content, and shouldn't need a newline. * Flushes the current parse buffer into the document. * @param endOfStream true if there is no more content to parser * This will be invoked for the last flush, if <code>insertTag</code> // When inserting via an insertTag, the depths (of the tree // being read in, and existing hiearchy) may not match up. // This attemps to clean it up. // If this starts with content (or popDepth > 0 && // pushDepth > 0) and ends with EndTagTypes, make sure // the last content isn't a \n, otherwise will end up with // an extra \n in the middle of content. // Make sure there is in fact a newline * Adds the CSS rules in <code>rules</code>. * Adds the CSS stylesheet at <code>href</code> to the known list * Returns true if can insert starting at <code>t</code>. This * will return false if the insert tag is set, and hasn't been found * If insertTag == null then just proceed to * foundInsertTag() call below and return true. * Proceed to foundInsertTag() call... // Allow the insert if t matches the insert tag, or // insertAfterImplied is true and the element is implied. // Need to insert a newline. // Determine if we can use JoinPrevious, we can't // if the Element has some attributes that are // not meant to be duplicated. // If not joining with the previous element, be // sure and set the name (otherwise it will be // A start spec will be added (for this tag), so we account // An implied paragraph close (end spec) is going to be added, // so we account for it here. * This is set to true when and end is invoked for <html>. /** Number of times <code>flushBuffer</code> has been invoked. */ /** If true, behavior is similiar to insertTag, but instead of * waiting for insertTag will wait for first Element without * an 'implied' attribute and begin inserting then. */ /** This is only used if insertAfterImplied is true. If false, only * inserting content, and there is a trailing newline it is removed. */ /** True if (!emptyDocument && insertTag == null), this is used so /** True when the body has been encountered. */ /** If non null, gives parent Tag that insert is to happen at. */ /** If true, the insertTag is inserted, otherwise elements after * the insertTag is found are inserted. */ /** Set to true when insertTag has been found. */ /** When foundInsertTag is set to true, this will be updated to * reflect the delta between the two structures. That is, it * will be the depth the inserts are happening at minus the * depth of the tags being passed in. A value of 0 (the common * case) indicates the structures match, a value greater than 0 indicates * the insert is happening at a deeper depth than the stream is * parsing, and a value less than 0 indicates the insert is happening earlier * in the tree that the parser thinks and that we will need to remove * EndTagType specs in the flushBuffer method. /** How many parents to ascend before insert new elements. */ /** How many parents to descend (relative to popDepth) before /** Last Map that was encountered. */ /** Set to true when a style element is encountered. */ /** Name of style to use. Obtained from Meta tag. */ /** Vector describing styles that should be include. Will consist * of a bunch of HTML.Tags, which will either be: * <p>LINK: in which case it is followed by an AttributeSet * <p>STYLE: in which case the following element is a String * indicating the type (may be null), and the elements following * it until the next HTML.Tag are the rules as Strings. /** True if inside the head tag. */ /** Set to true if the style language is text/css. Since this is * used alot, it is cached. */ /** True if inserting into an empty document. */ /** Attributes from a style Attribute. */ * Current option, if in an option element (needed to * This attribute is sometimes used to refer to next tag * to be handled after p-implied when the latter is * the current tag which is being handled. * Used by StyleSheet to determine when to avoid removing HTML.Tags * matching StyleConstants. * An element that represents a chunk of text that has * a set of HTML character level attributes assigned to * Constructs an element that represents content within the * document (has no children). * @param parent the parent element * @param a the element attributes * @param offs0 the start offset (must be at least 0) * @param offs1 the end offset (must be at least offs0) * Gets the name of the element. * @return the name, null if none * Gets the resolving parent. HTML attributes are not inherited * at the model level so we override this to return null. * @return null, there are none * @see AttributeSet#getResolveParent * An element that represents a structural <em>block</em> of * Constructs a composite element that initially contains * @param parent the parent element * @param a the attributes for the element * Gets the name of the element. * @return the name, null if none * Gets the resolving parent. HTML attributes are not inherited * at the model level so we override this to return null. * @return null, there are none * @see AttributeSet#getResolveParent * Document that allows you to set the maximum length of the text.