-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
8, 25
-
generic
-
generic
A DESCRIPTION OF THE PROBLEM :
The HTMLDocument.getIterator(HTML.Tag) method contains incomplete implementation for block-level elements. When called with any block-level tag (where tag.isBlock() returns true), the method immediately returns null due to a "TBD" (To Be Done) comment in the source code, rather than providing the expected iterator functionality.
public Iterator getIterator(HTML.Tag t) {
if (t.isBlock()) {
// TBD
return null;
}
return new LeafIterator(t, this);
}
---------- BEGIN SOURCE ----------
import javax.swing.JTextPane;
import javax.swing.text.html.HTML;
import javax.swing.text.html.HTMLDocument;
public class IteratorTest {
private static JTextPane editor;
public static void main(String[] args) {
editor = new JTextPane();
editor.setContentType("text/html");
HTMLDocument doc = (HTMLDocument) editor.getDocument();
HTMLDocument.Iterator bodyIt = doc.getIterator(HTML.Tag.BODY);
if (bodyIt == null) {
throw new RuntimeException("Test Failed: Iterator for BODY tag is null");
}
}
}
---------- END SOURCE ----------
The HTMLDocument.getIterator(HTML.Tag) method contains incomplete implementation for block-level elements. When called with any block-level tag (where tag.isBlock() returns true), the method immediately returns null due to a "TBD" (To Be Done) comment in the source code, rather than providing the expected iterator functionality.
public Iterator getIterator(HTML.Tag t) {
if (t.isBlock()) {
// TBD
return null;
}
return new LeafIterator(t, this);
}
---------- BEGIN SOURCE ----------
import javax.swing.JTextPane;
import javax.swing.text.html.HTML;
import javax.swing.text.html.HTMLDocument;
public class IteratorTest {
private static JTextPane editor;
public static void main(String[] args) {
editor = new JTextPane();
editor.setContentType("text/html");
HTMLDocument doc = (HTMLDocument) editor.getDocument();
HTMLDocument.Iterator bodyIt = doc.getIterator(HTML.Tag.BODY);
if (bodyIt == null) {
throw new RuntimeException("Test Failed: Iterator for BODY tag is null");
}
}
}
---------- END SOURCE ----------
- duplicates
-
JDK-8049347 HTMLDocument.getIterator throws NPE for Block Tag
-
- Open
-