]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/global/SurfaceAreaQuery.java
Fix EDKT191.
[mirror_edk2.git] / Tools / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / platform / ui / global / SurfaceAreaQuery.java
index 11a278326a8f35114d3339233f655a40995f5c05..7e709706f4b71c87be9a9ef5e082db6166d969c7 100644 (file)
@@ -21,6 +21,7 @@ import java.util.List;
 import java.util.Map;\r
 import java.util.Set;\r
 import java.util.Stack;\r
+import java.util.Vector;\r
 import java.util.regex.Matcher;\r
 import java.util.regex.Pattern;\r
 \r
@@ -37,6 +38,7 @@ import org.tianocore.LibrariesDocument;
 import org.tianocore.LibraryClassDeclarationsDocument;\r
 import org.tianocore.LibraryClassDocument;\r
 import org.tianocore.ModuleSADocument;\r
+import org.tianocore.ModuleSurfaceAreaDocument;\r
 import org.tianocore.ModuleTypeDef;\r
 import org.tianocore.MsaFilesDocument;\r
 import org.tianocore.MsaHeaderDocument;\r
@@ -341,22 +343,22 @@ public class SurfaceAreaQuery {
         * @returns package name list if elements are found at the known xpath\r
         * @returns null if nothing is there\r
         */\r
-       public static PackageIdentification[] getDependencePkg(String arch) {\r
-               String[] xPath;\r
+\r
+       public static PackageIdentification[] getDependencePkg(String arch, ModuleIdentification mi) throws Exception{\r
+               \r
                String packageGuid = null;\r
                String packageVersion = null;\r
 \r
-               if (arch == null || arch.equals("")) {\r
-                       xPath = new String[] { "/PackageDependencies/Package" };\r
-               } else {\r
-                       xPath = new String[] { "/PackageDependencies/Package[not(@SupArchList) or @SupArchList='"\r
-                                       + arch + "']" };\r
-               }\r
+        ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = (ModuleSurfaceAreaDocument.ModuleSurfaceArea) GlobalData.getModuleXmlObject(mi);\r
+        if (msa.getPackageDependencies() == null) {\r
+            return new PackageIdentification[0];\r
+        }\r
+        int size = msa.getPackageDependencies().getPackageList().size();\r
+        XmlObject[] returns = new XmlObject[size];\r
+        for (int i = 0; i < size; ++i) {\r
+            returns[i] = msa.getPackageDependencies().getPackageList().get(i);\r
+        }\r
 \r
-               XmlObject[] returns = get("ModuleSurfaceArea", xPath);\r
-               if (returns == null) {\r
-                       return new PackageIdentification[0];\r
-               }\r
                PackageIdentification[] packageIdList = new PackageIdentification[returns.length];\r
                for (int i = 0; i < returns.length; i++) {\r
                        PackageDependenciesDocument.PackageDependencies.Package item = (PackageDependenciesDocument.PackageDependencies.Package) returns[i];\r
@@ -401,25 +403,22 @@ public class SurfaceAreaQuery {
         *          xpath\r
         * @returns null if nothing is there\r
         */\r
-       public static String[] getLibraryClasses(String usage) {\r
-               String[] xPath;\r
-\r
-               if (usage == null || usage.equals("")) {\r
-                       xPath = new String[] { "/LibraryClass" };\r
-               } else {\r
-                       xPath = new String[] { "/LibraryClass[@Usage='" + usage + "']" };\r
-               }\r
-\r
-               XmlObject[] returns = get("LibraryClassDefinitions", xPath);\r
-               if (returns == null || returns.length == 0) {\r
-                       return new String[0];\r
-               }\r
-\r
-               LibraryClassDocument.LibraryClass[] libraryClassList = (LibraryClassDocument.LibraryClass[]) returns;\r
-               String[] libraryClassName = new String[libraryClassList.length];\r
-               for (int i = 0; i < libraryClassList.length; i++) {\r
-                       libraryClassName[i] = libraryClassList[i].getKeyword();\r
+       public static Vector<String> getLibraryClasses(String usage, ModuleIdentification mi) throws Exception{\r
+        ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = (ModuleSurfaceAreaDocument.ModuleSurfaceArea)GlobalData.getModuleXmlObject(mi);\r
+        Vector<String> libraryClassName = new Vector<String>();\r
+        if (msa.getLibraryClassDefinitions() == null) {\r
+            return libraryClassName;\r
+        }\r
+        \r
+        int size = msa.getLibraryClassDefinitions().getLibraryClassList().size();\r
+               \r
+               for (int i = 0; i < size; i++) {\r
+            LibraryClassDocument.LibraryClass libClass = msa.getLibraryClassDefinitions().getLibraryClassList().get(i);\r
+            if (usage.equals(libClass.getUsage().toString())) {\r
+                libraryClassName.add(libClass.getKeyword());\r
+            }\r
                }\r
+        \r
                return libraryClassName;\r
        }\r
 \r