Exemple #1
0
 /**
  * Returns an array containing all the child elements.
  *
  * @webref xml:method
  * @brief Returns an array containing all child elements
  */
 public XML[] getChildren() {
   //    NodeList children = node.getChildNodes();
   //    int childCount = children.getLength();
   //    XMLElement[] kids = new XMLElement[childCount];
   //    for (int i = 0; i < childCount; i++) {
   //      Node kid = children.item(i);
   //      kids[i] = new XMLElement(this, kid);
   //    }
   //    return kids;
   checkChildren();
   return children;
 }
Exemple #2
0
 /**
  * Put the names of all children into an array. Same as looping through each child and calling
  * getName() on each XMLElement.
  *
  * @webref xml:method
  * @brief Returns the names of all children as an array
  */
 public String[] listChildren() {
   //    NodeList children = node.getChildNodes();
   //    int childCount = children.getLength();
   //    String[] outgoing = new String[childCount];
   //    for (int i = 0; i < childCount; i++) {
   //      Node kid = children.item(i);
   //      if (kid.getNodeType() == Node.ELEMENT_NODE) {
   //        outgoing[i] = kid.getNodeName();
   //      } // otherwise just leave him null
   //    }
   checkChildren();
   String[] outgoing = new String[children.length];
   for (int i = 0; i < children.length; i++) {
     outgoing[i] = children[i].getName();
   }
   return outgoing;
 }
Exemple #3
0
 /**
  * Quick accessor for an element at a particular index.
  *
  * @webref xml:method
  * @brief Returns the child element with the specified index value or path
  */
 public XML getChild(int index) {
   checkChildren();
   return children[index];
 }
Exemple #4
0
 /**
  * Returns a boolean of whether or not there are children.
  *
  * @webref xml:method
  * @brief Checks whether or not an element has any children
  */
 public boolean hasChildren() {
   checkChildren();
   return children.length > 0;
 }
Exemple #5
0
 /**
  * Returns the number of children.
  *
  * @webref xml:method
  * @brief Returns the element's number of children
  * @return the count.
  */
 public int getChildCount() {
   checkChildren();
   return children.length;
 }