Пример #1
0
  private void processFamilyNode(Leaf node, Node parent) {

    // Required
    String familyName = node.getProperty("Dfamily");
    String familyVendor = node.getProperty("Dvendor");

    String va[] = familyVendor.split("[:]");

    Node vendorNode = addUniqueVendor(parent, va[0], va[1]);

    Node familyNode = Node.addUniqueChild(vendorNode, Type.FAMILY, familyName);

    // The last encountered value one will be preserved
    // TODO: update vendor name from vendor id based on a conversion table
    familyNode.putProperty(Property.VENDOR_NAME, va[0]);
    familyNode.putProperty(Property.VENDOR_ID, va[1]);

    // Store all details to identify the pack where the device family
    // was defined.
    familyNode.putProperty(Property.PACK_VENDOR, fVendorName);
    familyNode.putProperty(Property.PACK_NAME, fPackName);
    familyNode.putProperty(Property.PACK_VERSION, fVersion);

    if (node.hasChildren()) {
      for (Leaf child : ((Node) node).getChildren()) {
        if (child.isType("subFamily")) {
          processSubFamilyNode(child, familyNode);
        } else if (child.isType("device")) {
          processDeviceNode(child, familyNode);
        } else {
          processDevicePropertiesGroup(child, familyNode);
        }
      }
    }
  }
Пример #2
0
  private void processBoardNode(Leaf node, Node parent) {

    // Required
    String boardVendor = node.getProperty("vendor");
    String boardName = node.getProperty("name");

    // Optional
    String boardRevision = node.getProperty("revision");

    Node vendorNode = Node.addUniqueChild(parent, Type.VENDOR, boardVendor);

    Node boardNode = Node.addNewChild(vendorNode, Type.BOARD);

    boardNode.setName(boardName);

    boardNode.putNonEmptyProperty(Property.BOARD_REVISION, boardRevision);
    boardNode.putNonEmptyProperty(Property.VENDOR_NAME, boardVendor);

    // Store all details to identify the pack where the board
    // was defined.
    boardNode.putProperty(Property.PACK_VENDOR, fVendorName);
    boardNode.putProperty(Property.PACK_NAME, fPackName);
    boardNode.putProperty(Property.PACK_VERSION, fVersion);

    // Count the encountered boards
    fCount++;

    if (node.hasChildren()) {
      for (Leaf child : ((Node) node).getChildren()) {
        if (child.isType("mountedDevice")) {
          // Required
          String Dvendor = child.getProperty("Dvendor");

          // Optional
          String Dname = child.getProperty("Dname");

          if (Dname.length() > 0) {
            Node deviceNode = Node.addNewChild(boardNode, Type.DEVICE);
            deviceNode.setName(Dname);

            String va[] = Dvendor.split(":");
            deviceNode.putProperty(Property.VENDOR_NAME, va[0]);
            deviceNode.putProperty(Property.VENDOR_ID, va[1]);
          }
        } else if (child.isType("feature")) {
          processFeatureNode(child, boardNode);
        } else if (child.isType("book")) {
          processBookNode(child, boardNode);
        }
      }
    }

    // Clock can be set by processFeatureNode()
    String clock = boardNode.getProperty(Property.CLOCK);
    if (clock.length() > 0) {
      // Also add a property with the clcock value
      boardNode.putProperty(Property.CLOCK, clock);
    }
  }
Пример #3
0
  // Parse for boards, add them to parent node
  public int parseBoards(Node node, Node parent) {

    if (!checkValid(node)) {
      return 0;
    }

    fCount = 0;

    fVendorName = "";
    fPackName = "";
    fVersion = "";

    Leaf packageNode = node.getFirstChild();

    if (!packageNode.isType("package")) {
      return 0;
    }

    fVendorName = packageNode.getProperty("vendor");
    fPackName = packageNode.getProperty("name");

    if (packageNode.hasChildren()) {
      for (Leaf child : ((Node) packageNode).getChildren()) {

        if (child.isType("boards") && child.hasChildren()) {
          for (Leaf grandchild : ((Node) child).getChildren()) {
            if (grandchild.isType("board")) {
              processBoardNode(grandchild, parent);
            }
          }
        } else if (child.isType("releases") && child.hasChildren()) {

          Leaf versionNode = ((Node) child).getFirstChild();
          fVersion = versionNode.getProperty("version");
        }
      }
    }

    return fCount;
  }
Пример #4
0
  private void processSubFamilyNode(Leaf node, Node parent) {

    String subFamilyName = node.getProperty("DsubFamily");

    Node subFamilyNode = Node.addUniqueChild(parent, Type.SUBFAMILY, subFamilyName);

    if (node.hasChildren()) {
      for (Leaf child : ((Node) node).getChildren()) {
        if (child.isType("device")) {
          processDeviceNode(child, subFamilyNode);
        } else {
          processDevicePropertiesGroup(child, subFamilyNode);
        }
      }
    }
  }
Пример #5
0
  private void processDeviceNode(Leaf node, Node parent) {

    // Required
    String deviceName = node.getProperty("Dname");

    Node deviceNode = Node.addUniqueChild(parent, Type.DEVICE, deviceName);
    int saveCount = fCount;

    if (node.hasChildren()) {
      for (Leaf child : ((Node) node).getChildren()) {
        processDevicePropertiesGroup(child, deviceNode);
      }
    }

    if (fCount == saveCount) {
      fCount++; // If there were no variants, count this device
    }
  }