@@ -54,18 +54,23 @@ private void writeString(final String text) throws IOException {
5454 out .write (text .getBytes (charset ));
5555 }
5656
57- /*
58- * Recursive method to extract text from all nodes
59- * - This method processes TextNode and <br> tags, recursively
60- * extracting text from nested tags.
61- * For example: extract text from nested <span> tags
62- * - Appends newlines for <br> tags.
57+ // CHECKSTYLE:OFF checkstyle:JavadocStyle
58+ // checkstyle does not understand that span tags are inside a code block
59+ /**
60+ * <p>Recursive method to extract text from all nodes.</p>
61+ * <p>
62+ * This method processes {@link TextNode}s and {@code <br>} tags,
63+ * recursively extracting text from nested tags
64+ * (e.g. extracting text from nested {@code <span>} tags).
65+ * Newlines are added for {@code <br>} tags.
66+ * </p>
67+ * @param node the current node to process
68+ * @param text the {@link StringBuilder} to append the extracted text to
6369 */
6470 private void extractText (final Node node , final StringBuilder text ) {
65- if (node instanceof TextNode ) {
66- text .append (((TextNode ) node ).text ());
67- } else if (node instanceof Element ) {
68- final Element element = (Element ) node ;
71+ if (node instanceof TextNode textNode ) {
72+ text .append ((textNode ).text ());
73+ } else if (node instanceof Element element ) {
6974 // <br> is a self-closing HTML tag used to insert a line break.
7075 if (element .tagName ().equalsIgnoreCase ("br" )) {
7176 // Add a newline for <br> tags
@@ -77,6 +82,7 @@ private void extractText(final Node node, final StringBuilder text) {
7782 extractText (child , text );
7883 }
7984 }
85+ // CHECKSTYLE:ON
8086
8187 public void build (final SharpStream ttml ) throws IOException {
8288 /*
@@ -98,7 +104,7 @@ public void build(final SharpStream ttml) throws IOException {
98104 final Elements paragraphList = doc .select ("body > div > p" );
99105
100106 // check if has frames
101- if (paragraphList .size () < 1 ) {
107+ if (paragraphList .isEmpty () ) {
102108 return ;
103109 }
104110
0 commit comments