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
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
* @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
* 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