Skip to content

Commit 3496a24

Browse files
committed
improved jdoc
1 parent 8c3d1d4 commit 3496a24

7 files changed

Lines changed: 188 additions & 120 deletions

File tree

src/main/java/org/htmlunit/javascript/host/xml/FormData.java

Lines changed: 43 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,13 @@
4141
import org.htmlunit.util.StringUtils;
4242

4343
/**
44-
* A JavaScript object for {@code FormData}.
44+
* JavaScript host object for {@code FormData}.
4545
*
4646
* @author Ahmed Ashour
4747
* @author Ronald Brill
4848
* @author Thorsten Wendelmuth
49+
*
50+
* @see <a href="https://developer.mozilla.org/en-US/docs/Web/API/FormData">MDN Documentation</a>
4951
*/
5052
@JsxClass
5153
public class FormData extends HtmlUnitScriptable {
@@ -56,7 +58,7 @@ public class FormData extends HtmlUnitScriptable {
5658
private final List<NameValuePair> requestParameters_ = new ArrayList<>();
5759

5860
/**
59-
* FormDate iterator support.
61+
* Iterator support for {@code FormData}.
6062
*/
6163
public static final class FormDataIterator extends ES6Iterator {
6264
private static final ClassDescriptor DESCRIPTOR =
@@ -70,7 +72,7 @@ enum Type { KEYS, VALUES, BOTH }
7072
private int index_;
7173

7274
/**
73-
* JS initializer.
75+
* Initializes the iterator prototype.
7476
*
7577
* @param cx the {@link Context}
7678
* @param scope the scope
@@ -82,7 +84,7 @@ public static void init(final Context cx, final TopLevel scope, final String cla
8284
}
8385

8486
/**
85-
* Ctor.
87+
* Creates an instance with an empty list (used for prototype initialization).
8688
*
8789
* @param className the class name
8890
*/
@@ -96,12 +98,12 @@ public FormDataIterator(final String className) {
9698
}
9799

98100
/**
99-
* Ctor.
101+
* Creates an instance for iterating over the given list of name-value pairs.
100102
*
101103
* @param scope the scope
102104
* @param className the class name
103-
* @param type the type
104-
* @param nameValuePairList the list of name value pairs
105+
* @param type the iteration type (keys, values, or both)
106+
* @param nameValuePairList the list of name-value pairs to iterate
105107
*/
106108
public FormDataIterator(final VarScope scope, final String className, final Type type,
107109
final List<NameValuePair> nameValuePairList) {
@@ -148,8 +150,9 @@ protected Object nextValue(final Context cx, final VarScope scope) {
148150
}
149151

150152
/**
151-
* Constructor.
152-
* @param formObj a form
153+
* Creates an instance of this object, optionally pre-populated from the given form.
154+
*
155+
* @param formObj an {@link HTMLFormElement} to initialize the data from, or {@code undefined}
153156
*/
154157
@JsxConstructor
155158
public void jsConstructor(final Object formObj) {
@@ -159,9 +162,9 @@ public void jsConstructor(final Object formObj) {
159162
}
160163

161164
/**
162-
* Appends a new value onto an existing key inside a {@code FormData} object,
163-
* or adds the key if it does not already exist.
164-
* @param name the name of the field whose data is contained in {@code value}
165+
* Appends a new value for an existing key, or adds the key if it does not already exist.
166+
*
167+
* @param name the name of the field
165168
* @param value the field's value
166169
* @param filename the filename reported to the server (optional)
167170
*/
@@ -182,7 +185,8 @@ public void append(final String name, final Object value, final Object filename)
182185
}
183186

184187
/**
185-
* Removes the entry (if exists).
188+
* Removes the entry with the given name, if it exists.
189+
*
186190
* @param name the name of the field to remove
187191
*/
188192
@JsxFunction(functionName = "delete")
@@ -195,8 +199,10 @@ public void delete_js(final String name) {
195199
}
196200

197201
/**
198-
* @param name the name of the field to check
199-
* @return the first value found for the give name
202+
* Returns the first value associated with the given name.
203+
*
204+
* @param name the name of the field to retrieve
205+
* @return the first value found, or {@code null} if not found
200206
*/
201207
@JsxFunction
202208
public String get(final String name) {
@@ -213,8 +219,10 @@ public String get(final String name) {
213219
}
214220

215221
/**
216-
* @param name the name of the field to check
217-
* @return the values found for the give name
222+
* Returns all values associated with the given name.
223+
*
224+
* @param name the name of the field to retrieve
225+
* @return an array of all values found for the given name
218226
*/
219227
@JsxFunction
220228
public Scriptable getAll(final String name) {
@@ -234,8 +242,10 @@ public Scriptable getAll(final String name) {
234242
}
235243

236244
/**
245+
* Returns whether an entry with the given name exists.
246+
*
237247
* @param name the name of the field to check
238-
* @return true if the name exists
248+
* @return {@code true} if the name exists, {@code false} otherwise
239249
*/
240250
@JsxFunction
241251
public boolean has(final String name) {
@@ -252,9 +262,10 @@ public boolean has(final String name) {
252262
}
253263

254264
/**
255-
* Sets a new value for an existing key inside a {@code FormData} object,
265+
* Sets a new value for an existing key, replacing all existing values for that key,
256266
* or adds the key if it does not already exist.
257-
* @param name the name of the field whose data is contained in {@code value}
267+
*
268+
* @param name the name of the field
258269
* @param value the field's value
259270
* @param filename the filename reported to the server (optional)
260271
*/
@@ -299,7 +310,9 @@ public void set(final String name, final Object value, final Object filename) {
299310
}
300311

301312
/**
302-
* @return An Iterator that contains all the requestParameters name[0] and value[1]
313+
* Returns an iterator over all name/value pairs contained in this {@code FormData}.
314+
*
315+
* @return an iterator of {@code [name, value]} arrays
303316
*/
304317
@JsxFunction
305318
@JsxSymbol(symbolName = "iterator")
@@ -309,7 +322,8 @@ public Scriptable entries() {
309322
}
310323

311324
/**
312-
* Sets the specified request with the parameters in this {@code FormData}.
325+
* Populates the given {@link WebRequest} with the parameters from this {@code FormData}.
326+
*
313327
* @param webRequest the web request to fill
314328
*/
315329
public void fillRequest(final WebRequest webRequest) {
@@ -318,9 +332,9 @@ public void fillRequest(final WebRequest webRequest) {
318332
}
319333

320334
/**
321-
* The FormData.forEach() method allows iteration through
322-
* all key/value pairs contained in this object via a callback function.
323-
* @param callback Function to execute on each key/value pairs
335+
* Iterates over all key/value pairs in this {@code FormData}, calling the given callback for each.
336+
*
337+
* @param callback the function to execute for each key/value pair
324338
*/
325339
@JsxFunction
326340
public void forEach(final Object callback) {
@@ -342,10 +356,9 @@ public void forEach(final Object callback) {
342356
}
343357

344358
/**
345-
* The FormData.keys() method returns an iterator allowing to go through
346-
* all keys contained in this object. The keys are USVString objects.
359+
* Returns an iterator over all keys in this {@code FormData}.
347360
*
348-
* @return an iterator.
361+
* @return an iterator of key strings
349362
*/
350363
@JsxFunction
351364
public FormDataIterator keys() {
@@ -354,10 +367,9 @@ public FormDataIterator keys() {
354367
}
355368

356369
/**
357-
* The URLSearchParams.values() method returns an iterator allowing to go through
358-
* all values contained in this object. The values are USVString objects.
370+
* Returns an iterator over all values in this {@code FormData}.
359371
*
360-
* @return an iterator.
372+
* @return an iterator of value strings
361373
*/
362374
@JsxFunction
363375
public FormDataIterator values() {

src/main/java/org/htmlunit/javascript/host/xml/XMLDocument.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
import org.htmlunit.xml.XmlPage;
4242

4343
/**
44-
* A JavaScript object for {@code XMLDocument}.
44+
* JavaScript host object for {@code XMLDocument}.
4545
*
4646
* @author Ahmed Ashour
4747
* @author Marc Guillemot
@@ -50,6 +50,8 @@
5050
* @author Chuck Dumont
5151
* @author Frank Danek
5252
* @author Sven Strickroth
53+
*
54+
* @see <a href="https://developer.mozilla.org/en-US/docs/Web/API/XMLDocument">MDN Documentation</a>
5355
*/
5456
@JsxClass
5557
public class XMLDocument extends Document {
@@ -64,7 +66,7 @@ public XMLDocument() {
6466
}
6567

6668
/**
67-
* JavaScript constructor.
69+
* Creates an instance of this object.
6870
*/
6971
@Override
7072
@JsxConstructor
@@ -73,8 +75,9 @@ public void jsConstructor() {
7375
}
7476

7577
/**
76-
* Creates a new instance, with associated XmlPage.
77-
* @param enclosingWindow the window
78+
* Creates a new instance with an associated {@link XmlPage}.
79+
*
80+
* @param enclosingWindow the enclosing window
7881
*/
7982
public XMLDocument(final WebWindow enclosingWindow) {
8083
super();
@@ -91,11 +94,11 @@ public XMLDocument(final WebWindow enclosingWindow) {
9194
}
9295

9396
/**
94-
* Loads an XML document using the supplied string.
97+
* Loads an XML document from the supplied string.
9598
*
96-
* @param strXML A string containing the XML string to load into this XML document object
97-
* This string can contain an entire XML document or a well-formed fragment.
98-
* @return true if the load succeeded; false if the load failed
99+
* @param strXML a string containing the XML to load into this document;
100+
* this string can contain an entire XML document or a well-formed fragment
101+
* @return {@code true} if the load succeeded; {@code false} if the load failed
99102
*/
100103
public boolean loadXML(final String strXML) {
101104
final WebWindow webWindow = getWindow().getWebWindow();

0 commit comments

Comments
 (0)