@@ -65,6 +65,7 @@ protected XML() { }
6565 * Begin parsing XML data passed in from a PApplet. This code
6666 * wraps exception handling, for more advanced exception handling,
6767 * use the constructor that takes a Reader or InputStream.
68+ *
6869 * @throws SAXException
6970 * @throws ParserConfigurationException
7071 * @throws IOException
@@ -176,12 +177,17 @@ public boolean save(PrintWriter output) {
176177 /**
177178 * Returns the parent element. This method returns null for the root
178179 * element.
180+ *
181+ * @webref xml:method
182+ * @brief Gets a copy of the element's parent
179183 */
180184 public XML getParent () {
181185 return this .parent ;
182186 }
183187
184-
188+ /**
189+ * Internal function; not included in reference.
190+ */
185191 protected Node getNode () {
186192 return node ;
187193 }
@@ -190,13 +196,19 @@ protected Node getNode() {
190196 /**
191197 * Returns the full name (i.e. the name including an eventual namespace
192198 * prefix) of the element.
199+ *
200+ * @webref xml:method
201+ * @brief Gets the element's full name
193202 * @return the name, or null if the element only contains #PCDATA.
194203 */
195204 public String getName () {
196205 return name ;
197206 }
198207
199-
208+ /**
209+ * @webref xml:method
210+ * @brief Sets the element's name
211+ */
200212 public void setName (String newName ) {
201213 Document document = node .getOwnerDocument ();
202214 node = document .renameNode (node , null , newName );
@@ -206,6 +218,9 @@ public void setName(String newName) {
206218
207219 /**
208220 * Returns the name of the element (without namespace prefix).
221+ *
222+ * @webref xml:method
223+ * @brief Gets the element's name
209224 * @return the name, or null if the element only contains #PCDATA.
210225 */
211226 public String getLocalName () {
@@ -215,6 +230,8 @@ public String getLocalName() {
215230
216231 /**
217232 * Honey, can you just check on the kids? Thanks.
233+ *
234+ * Internal function; not included in reference.
218235 */
219236 protected void checkChildren () {
220237 if (children == null ) {
@@ -230,6 +247,9 @@ protected void checkChildren() {
230247
231248 /**
232249 * Returns the number of children.
250+ *
251+ * @webref xml:method
252+ * @brief Returns the element's number of children
233253 * @return the count.
234254 */
235255 public int getChildCount () {
@@ -238,6 +258,12 @@ public int getChildCount() {
238258 }
239259
240260
261+ /**
262+ * Returns a boolean of whether or not there are children.
263+ *
264+ * @webref xml:method
265+ * @brief Checks whether or not an element has any children
266+ */
241267 public boolean hasChildren () {
242268 checkChildren ();
243269 return children .length > 0 ;
@@ -247,6 +273,9 @@ public boolean hasChildren() {
247273 /**
248274 * Put the names of all children into an array. Same as looping through
249275 * each child and calling getName() on each XMLElement.
276+ *
277+ * @webref xml:method
278+ * @brief Returns the names of all children as an array
250279 */
251280 public String [] listChildren () {
252281// NodeList children = node.getChildNodes();
@@ -269,6 +298,9 @@ public String[] listChildren() {
269298
270299 /**
271300 * Returns an array containing all the child elements.
301+ *
302+ * @webref xml:method
303+ * @brief Returns an array containing all child elements
272304 */
273305 public XML [] getChildren () {
274306// NodeList children = node.getChildNodes();
@@ -286,7 +318,9 @@ public XML[] getChildren() {
286318
287319 /**
288320 * Quick accessor for an element at a particular index.
289- * @author processing.org
321+ *
322+ * @webref xml:method
323+ * @brief Returns the child element with the specified index value or path
290324 */
291325 public XML getChild (int index ) {
292326 checkChildren ();
@@ -296,6 +330,7 @@ public XML getChild(int index) {
296330
297331 /**
298332 * Get a child by its name or path.
333+ *
299334 * @param name element name or path/to/element
300335 * @return the first matching element
301336 */
@@ -317,6 +352,7 @@ public XML getChild(String name) {
317352
318353 /**
319354 * Internal helper function for getChild(String).
355+ *
320356 * @param items result of splitting the query on slashes
321357 * @param offset where in the items[] array we're currently looking
322358 * @return matching element or null if no match
@@ -351,6 +387,7 @@ protected XML getChildRecursive(String[] items, int offset) {
351387 /**
352388 * Get any children that match this name or path. Similar to getChild(),
353389 * but will grab multiple matches rather than only the first.
390+ *
354391 * @param name element name or path/to/element
355392 * @return array of child elements that match
356393 * @author processing.org
@@ -392,6 +429,10 @@ protected XML[] getChildrenRecursive(String[] items, int offset) {
392429 }
393430
394431
432+ /**
433+ * @webref xml:method
434+ * @brief Appends a new child to the element
435+ */
395436 public XML addChild (String tag ) {
396437 Document document = node .getOwnerDocument ();
397438 Node newChild = document .createElement (tag );
@@ -417,6 +458,10 @@ protected XML appendChild(Node newNode) {
417458 }
418459
419460
461+ /**
462+ * @webref xml:method
463+ * @brief Removes the specified child
464+ */
420465 public void removeChild (XML kid ) {
421466 node .removeChild (kid .node );
422467 children = null ; // TODO not efficient
@@ -457,6 +502,9 @@ public void trim() {
457502
458503 /**
459504 * Returns the number of attributes.
505+ *
506+ * @webref xml:method
507+ * @brief Counts the specified element's number of attributes
460508 */
461509 public int getAttributeCount () {
462510 return node .getAttributes ().getLength ();
@@ -465,6 +513,9 @@ public int getAttributeCount() {
465513
466514 /**
467515 * Get a list of the names for all of the attributes for this node.
516+ *
517+ * @webref xml:method
518+ * @brief Returns a list of names of all attributes as an array
468519 */
469520 public String [] listAttributes () {
470521 NamedNodeMap nnm = node .getAttributes ();
@@ -477,6 +528,9 @@ public String[] listAttributes() {
477528
478529 /**
479530 * Returns whether an attribute exists.
531+ *
532+ * @webref xml:method
533+ * @brief Checks whether or not an element has the specified attribute
480534 */
481535 public boolean hasAttribute (String name ) {
482536 return (node .getAttributes ().getNamedItem (name ) != null );
@@ -485,6 +539,7 @@ public boolean hasAttribute(String name) {
485539
486540 /**
487541 * Returns the value of an attribute.
542+ *
488543 * @param name the non-null name of the attribute.
489544 * @return the value, or null if the attribute does not exist.
490545 */
@@ -498,7 +553,6 @@ public boolean hasAttribute(String name) {
498553 *
499554 * @param name the non-null full name of the attribute.
500555 * @param defaultValue the default value of the attribute.
501- *
502556 * @return the value, or defaultValue if the attribute does not exist.
503557 */
504558// public String getAttribute(String name, String defaultValue) {
@@ -507,6 +561,10 @@ public boolean hasAttribute(String name) {
507561// }
508562
509563
564+ /**
565+ * @webref xml:method
566+ * @brief Gets the content of an element as a String
567+ */
510568 public String getString (String name ) {
511569 return getString (name , null );
512570 }
@@ -518,16 +576,28 @@ public String getString(String name, String defaultValue) {
518576 }
519577
520578
579+ /**
580+ * @webref xml:method
581+ * @brief Sets the content of an element as a String
582+ */
521583 public void setString (String name , String value ) {
522584 ((Element ) node ).setAttribute (name , value );
523585 }
524586
525587
588+ /**
589+ * @webref xml:method
590+ * @brief Gets the content of an element as an int
591+ */
526592 public int getInt (String name ) {
527593 return getInt (name , 0 );
528594 }
529595
530596
597+ /**
598+ * @webref xml:method
599+ * @brief Sets the content of an element as an int
600+ */
531601 public void setInt (String name , int value ) {
532602 setString (name , String .valueOf (value ));
533603 }
@@ -538,7 +608,6 @@ public void setInt(String name, int value) {
538608 *
539609 * @param name the non-null full name of the attribute.
540610 * @param defaultValue the default value of the attribute.
541- *
542611 * @return the value, or defaultValue if the attribute does not exist.
543612 */
544613 public int getInt (String name , int defaultValue ) {
@@ -549,6 +618,9 @@ public int getInt(String name, int defaultValue) {
549618
550619 /**
551620 * Returns the value of an attribute, or zero if not present.
621+ *
622+ * @webref xml:method
623+ * @brief Gets the content of an element as a float
552624 */
553625 public float getFloat (String name ) {
554626 return getFloat (name , 0 );
@@ -560,7 +632,6 @@ public float getFloat(String name) {
560632 *
561633 * @param name the non-null full name of the attribute.
562634 * @param defaultValue the default value of the attribute.
563- *
564635 * @return the value, or defaultValue if the attribute does not exist.
565636 */
566637 public float getFloat (String name , float defaultValue ) {
@@ -569,6 +640,10 @@ public float getFloat(String name, float defaultValue) {
569640 }
570641
571642
643+ /**
644+ * @webref xml:method
645+ * @brief Sets the content of an element as a float
646+ */
572647 public void setFloat (String name , float value ) {
573648 setString (name , String .valueOf (value ));
574649 }
@@ -604,13 +679,19 @@ public void setDouble(String name, double value) {
604679 * sections can be retrieved as unnamed child objects. In this case,
605680 * this method returns null.
606681 *
682+ * @webref xml:method
683+ * @brief Gets the content of an element
607684 * @return the content.
608685 */
609686 public String getContent () {
610687 return node .getTextContent ();
611688 }
612689
613690
691+ /**
692+ * @webref xml:method
693+ * @brief Sets the content of an element
694+ */
614695 public void setContent (String text ) {
615696 node .setTextContent (text );
616697 }
0 commit comments