コード例 #1
0
ファイル: AMLtoPNML.java プロジェクト: CaoAo/BeehiveZ
 public static EPCResult traverseAML(
     EPCResult partialResult,
     Node currentNode,
     Object parent,
     HashMap ObjDef_Name,
     HashMap ObjDef_LinkId,
     HashMap modelid_net,
     HashMap function_LinkId)
     throws Exception {
   if (currentNode.hasChildNodes()) {
     for (int i = 0; i < currentNode.getChildNodes().getLength(); i++) {
       Node currentChild = currentNode.getChildNodes().item(i);
       if (currentChild.getNodeName().equals("Group")) {
         String id = currentChild.getAttributes().getNamedItem("Group.ID").getNodeValue();
         String GroupName = "";
         if (currentChild.hasChildNodes()) {
           NodeList currentChildren = currentChild.getChildNodes();
           for (int j = 0; j < currentChildren.getLength(); j++) {
             Node Child = currentChildren.item(j);
             if (!(Child.getNodeName().equals("AttrDef"))) {
               continue;
             }
             if (Child.getAttributes()
                 .getNamedItem("AttrDef.Type")
                 .getNodeValue()
                 .equals("AT_NAME")) {
               if (Child.hasChildNodes()) {
                 for (int l = 0; l < Child.getChildNodes().getLength(); l++) {
                   if (!(Child.getChildNodes().item(l).getNodeName().equals("AttrValue"))) {
                     continue;
                   } else {
                     GroupName = getTextContent(Child.getChildNodes().item(l));
                   }
                 }
                 break;
               }
             }
           }
           if (GroupName.equals("")) {
             GroupName = id;
           }
         }
         ModelHierarchyDirectory dir = new ModelHierarchyDirectory(id, GroupName);
         partialResult.addInHierarchy(dir, parent, GroupName);
         partialResult =
             traverseAML(
                 partialResult,
                 currentChild,
                 dir,
                 ObjDef_Name,
                 ObjDef_LinkId,
                 modelid_net,
                 function_LinkId);
       }
       if (currentChild.getNodeName().equals("Model")
           && currentChild
               .getAttributes()
               .getNamedItem("Model.Type")
               .getNodeValue()
               .equals("MT_EEPC")) {
         String ModelName = "gaga";
         if (currentChild.hasChildNodes()) {
           NodeList currentChildren = currentChild.getChildNodes();
           for (int j = 0; j < currentChildren.getLength(); j++) {
             Node Child = currentChildren.item(j);
             if (!(Child.getNodeName().equals("AttrDef"))) {
               continue;
             }
             if (Child.getAttributes()
                 .getNamedItem("AttrDef.Type")
                 .getNodeValue()
                 .equals("AT_NAME")) {
               if (Child.hasChildNodes()) {
                 for (int l = 0; l < Child.getChildNodes().getLength(); l++) {
                   if (!(Child.getChildNodes().item(l).getNodeName().equals("AttrValue"))) {
                     continue;
                   } else {
                     ModelName = getTextContent(Child.getChildNodes().item(l));
                   }
                 }
               }
               break;
             }
           }
         }
         try {
           ModelName = ModelName.replaceAll("\n", " ");
           EPC net = read(currentChild, ObjDef_Name, ObjDef_LinkId, function_LinkId, ModelName);
           partialResult.addInHierarchy(net, parent, ModelName);
           modelid_net.put(
               currentChild.getAttributes().getNamedItem("Model.ID").getNodeValue(), net);
         } catch (Throwable x) {
           Message.add(x.getClass().getName());
           // throw new IOException(x.getMessage());
         }
       }
     }
   }
   return partialResult;
 }