コード例 #1
0
ファイル: XmlDataset.java プロジェクト: nhauser/cdma
 public void printHierarchy() {
   System.out.print("-------------------------- HIERARCHY ---------------------------------\n");
   if (mRootGroup != null) {
     ((XmlGroup) mRootGroup).printHierarchy(0);
   } else {
     System.out.print("Root is null");
   }
 }
コード例 #2
0
ファイル: XmlDataset.java プロジェクト: nhauser/cdma
  private void loadChildNodes(Node node, XmlGroup parentContainer) throws Exception {
    if (node.hasChildNodes()) {
      NodeList childNodes = node.getChildNodes();
      int groupIndex = 0, itemIndex = 0;
      for (int index = 0; index < childNodes.getLength(); ++index) {
        Node currentChild = childNodes.item(index);
        if (XmlUtils.isAFakeNode(currentChild)) {
          continue;
        }
        String currentChildType = currentChild.getNodeName().trim();

        // Add data item when a text value is available
        String data = currentChild.getNodeValue();
        if (data != null && !data.trim().isEmpty()) {
          XmlDataItem item =
              new XmlDataItem(mFactoryName, "data_item", itemIndex, this, parentContainer);
          item.setCachedData(new XmlArray(mFactoryName, data), false);
          parentContainer.addContainer(item);
          itemIndex++;
        }
        // The node is a group
        else {
          XmlGroup container = null;
          if (parentContainer instanceof IGroup) {
            container =
                new XmlGroup(mFactoryName, currentChildType, groupIndex, this, parentContainer);
            loadChildNodes(currentChild, container);
            groupIndex++;
          }

          if (parentContainer != null && parentContainer instanceof XmlGroup) {
            parentContainer.addContainer(container);
          }
          loadAttributes(currentChild, container);
        }
      }
    }
  }