1717import java .io .IOException ;
1818
1919import org .htmlunit .SgmlPage ;
20+ import org .htmlunit .WebClient ;
2021import org .htmlunit .WebResponse ;
2122import org .htmlunit .html .DomNode ;
2223import org .htmlunit .html .ElementFactory ;
@@ -75,22 +76,61 @@ ElementFactory getElementFactory(SgmlPage page, String namespaceURI,
7576 * @param source the (X)HTML to be parsed
7677 * @throws SAXException if a SAX error occurs
7778 * @throws IOException if an IO error occurs
79+ *
80+ * @deprecated as of version 4.12.0; use
81+ * {@link #parseFragment(WebClient, DomNode, DomNode, String, boolean)} instead.
7882 */
79- void parseFragment (DomNode parent , String source ) throws SAXException , IOException ;
83+ @ Deprecated
84+ default void parseFragment (DomNode parent , String source ) throws SAXException , IOException {
85+ parseFragment (null , parent , parent , source , false );
86+ }
8087
8188 /**
8289 * Parses the HTML content from the given string into an object tree representation.
8390 *
91+ * @param webClient the {@link WebClient}
8492 * @param parent where the new parsed nodes will be added to
8593 * @param context the context to build the fragment context stack
8694 * @param source the (X)HTML to be parsed
8795 * @param createdByJavascript if true the (script) tag was created by javascript
8896 * @throws SAXException if a SAX error occurs
8997 * @throws IOException if an IO error occurs
9098 */
91- void parseFragment (DomNode parent , DomNode context , String source ,
99+ void parseFragment (WebClient webClient , DomNode parent , DomNode context , String source ,
92100 boolean createdByJavascript ) throws SAXException , IOException ;
93101
102+ /**
103+ * Parses the HTML content from the given string into an object tree representation.
104+ *
105+ * @param parent where the new parsed nodes will be added to
106+ * @param context the context to build the fragment context stack
107+ * @param source the (X)HTML to be parsed
108+ * @param createdByJavascript if true the (script) tag was created by javascript
109+ * @throws SAXException if a SAX error occurs
110+ * @throws IOException if an IO error occurs
111+ *
112+ * @deprecated as of version 4.12.0; use
113+ * {@link #parseFragment(WebClient, DomNode, DomNode, String, boolean)} instead.
114+ */
115+ @ Deprecated
116+ default void parseFragment (DomNode parent , DomNode context , String source ,
117+ boolean createdByJavascript ) throws SAXException , IOException {
118+ parseFragment (null , parent , context , source , createdByJavascript );
119+ }
120+
121+ /**
122+ * Parses the WebResponse into an object tree representation.
123+ *
124+ * @param webClient the {@link WebClient}
125+ * @param webResponse the response data
126+ * @param page the HtmlPage to add the nodes
127+ * @param xhtml if true use the XHtml parser
128+ * @param createdByJavascript if true the (script) tag was created by javascript
129+ * @throws IOException if there is an IO error
130+ */
131+ void parse (WebClient webClient , WebResponse webResponse , HtmlPage page ,
132+ boolean xhtml , boolean createdByJavascript ) throws IOException ;
133+
94134 /**
95135 * Parses the WebResponse into an object tree representation.
96136 *
@@ -99,6 +139,12 @@ void parseFragment(DomNode parent, DomNode context, String source,
99139 * @param xhtml if true use the XHtml parser
100140 * @param createdByJavascript if true the (script) tag was created by javascript
101141 * @throws IOException if there is an IO error
142+ *
143+ * @deprecated as of version 4.12.0; use
144+ * {@link #parse(WebClient, WebResponse, HtmlPage, boolean, boolean)} instead.
102145 */
103- void parse (WebResponse webResponse , HtmlPage page , boolean xhtml , boolean createdByJavascript ) throws IOException ;
146+ @ Deprecated
147+ default void parse (WebResponse webResponse , HtmlPage page , boolean xhtml , boolean createdByJavascript ) throws IOException {
148+ parse (null , webResponse , page , xhtml , createdByJavascript );
149+ }
104150}
0 commit comments