]> git.proxmox.com Git - mirror_edk2.git/blame - Tools/Source/GenBuild/org/tianocore/build/global/SurfaceAreaQuery.java
update ModuleSA PCD editor.
[mirror_edk2.git] / Tools / Source / GenBuild / org / tianocore / build / global / SurfaceAreaQuery.java
CommitLineData
878ddf1f 1/** @file\r
2 This file is for surface area information retrieval.\r
3\r
4 Copyright (c) 2006, Intel Corporation\r
5 All rights reserved. This program and the accompanying materials\r
6 are licensed and made available under the terms and conditions of the BSD License\r
7 which accompanies this distribution. The full text of the license may be found at\r
8 http://opensource.org/licenses/bsd-license.php\r
9\r
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13 **/\r
14package org.tianocore.build.global;\r
15\r
16import java.util.ArrayList;\r
a29c47e0 17import java.util.HashMap;\r
878ddf1f 18import java.util.Iterator;\r
a29c47e0 19import java.util.LinkedHashMap;\r
878ddf1f 20import java.util.List;\r
21import java.util.Map;\r
22import java.util.Stack;\r
23import java.util.regex.Matcher;\r
24import java.util.regex.Pattern;\r
25\r
878ddf1f 26import org.apache.xmlbeans.XmlObject;\r
27import org.apache.xmlbeans.XmlString;\r
de4bb9f6 28import org.tianocore.BuildOptionsDocument;\r
29import org.tianocore.CNameType;\r
de4bb9f6 30import org.tianocore.ExternsDocument;\r
31import org.tianocore.FileNameConvention;\r
de4bb9f6 32import org.tianocore.FvImagesDocument;\r
de4bb9f6 33import org.tianocore.GuidDeclarationsDocument;\r
34import org.tianocore.GuidsDocument;\r
35import org.tianocore.LibrariesDocument;\r
36import org.tianocore.LibraryClassDeclarationsDocument;\r
37import org.tianocore.LibraryClassDocument;\r
38import org.tianocore.ModuleDefinitionsDocument;\r
39import org.tianocore.ModuleSADocument;\r
40import org.tianocore.ModuleSaBuildOptionsDocument;\r
41import org.tianocore.ModuleTypeDef;\r
42import org.tianocore.MsaFilesDocument;\r
43import org.tianocore.MsaHeaderDocument;\r
44import org.tianocore.OptionDocument;\r
45import org.tianocore.PPIsDocument;\r
46import org.tianocore.PackageDependenciesDocument;\r
47import org.tianocore.PackageHeadersDocument;\r
48import org.tianocore.PcdCodedDocument;\r
49import org.tianocore.PlatformDefinitionsDocument;\r
50import org.tianocore.PlatformHeaderDocument;\r
51import org.tianocore.PpiDeclarationsDocument;\r
52import org.tianocore.ProtocolDeclarationsDocument;\r
53import org.tianocore.Sentence;\r
54import org.tianocore.SpdHeaderDocument;\r
8031d48d 55import org.tianocore.UserExtensionsDocument;\r
a29c47e0 56import org.tianocore.FilenameDocument.Filename;\r
250258de 57import org.tianocore.MsaHeaderDocument.MsaHeader;\r
a29c47e0 58import org.tianocore.ProtocolsDocument.Protocols.Protocol;\r
59import org.tianocore.ProtocolsDocument.Protocols.ProtocolNotify;\r
a29c47e0 60import org.tianocore.build.id.FpdModuleIdentification;\r
61import org.tianocore.build.id.ModuleIdentification;\r
62import org.tianocore.build.id.PackageIdentification;\r
63import org.tianocore.build.id.PlatformIdentification;\r
64import org.tianocore.build.toolchain.ToolChainInfo;\r
136adffc 65import org.tianocore.logger.EdkLog;\r
8031d48d 66import org.w3c.dom.Node;\r
878ddf1f 67\r
68/**\r
a29c47e0 69 * SurfaceAreaQuery class is used to query Surface Area information from msa,\r
70 * mbd, spd and fpd files.\r
71 * \r
72 * This class should not instantiated. All the public interfaces is static.\r
73 * \r
74 * @since GenBuild 1.0\r
75 */\r
878ddf1f 76public class SurfaceAreaQuery {\r
a29c47e0 77\r
78 public static String prefix = "http://www.TianoCore.org/2006/Edk2.0";\r
79\r
80 // /\r
81 // / Contains name/value pairs of Surface Area document object. The name is\r
82 // / always the top level element name.\r
83 // /\r
878ddf1f 84 private static Map<String, XmlObject> map = null;\r
a29c47e0 85\r
86 // /\r
87 // / mapStack is used to do nested query\r
88 // /\r
89 private static Stack<Map<String, XmlObject>> mapStack = new Stack<Map<String, XmlObject>>();\r
90\r
91 // /\r
92 // / prefix of name space\r
93 // /\r
878ddf1f 94 private static String nsPrefix = "sans";\r
a29c47e0 95\r
96 // /\r
97 // / xmlbeans needs a name space for each Xpath element\r
98 // /\r
878ddf1f 99 private static String ns = null;\r
a29c47e0 100\r
101 // /\r
102 // / keep the namep declaration for xmlbeans Xpath query\r
103 // /\r
878ddf1f 104 private static String queryDeclaration = null;\r
105\r
106 /**\r
a29c47e0 107 * Set a Surface Area document for query later\r
108 * \r
109 * @param map\r
110 * A Surface Area document in TopLevelElementName/XmlObject\r
111 * format.\r
112 */\r
878ddf1f 113 public static void setDoc(Map<String, XmlObject> map) {\r
a29c47e0 114 ns = prefix;\r
878ddf1f 115 queryDeclaration = "declare namespace " + nsPrefix + "='" + ns + "'; ";\r
116 SurfaceAreaQuery.map = map;\r
117 }\r
118\r
119 /**\r
a29c47e0 120 * Push current used Surface Area document into query stack. The given new\r
121 * document will be used for any immediately followed getXXX() callings,\r
122 * untill pop() is called.\r
123 * \r
124 * @param newMap\r
125 * The TopLevelElementName/XmlObject format of a Surface Area\r
126 * document.\r
127 */\r
878ddf1f 128 public static void push(Map<String, XmlObject> newMap) {\r
129 mapStack.push(SurfaceAreaQuery.map);\r
130 SurfaceAreaQuery.map = newMap;\r
131 }\r
a29c47e0 132\r
878ddf1f 133 /**\r
a29c47e0 134 * Discard current used Surface Area document and use the top document in\r
135 * stack instead.\r
136 */\r
878ddf1f 137 public static void pop() {\r
138 SurfaceAreaQuery.map = mapStack.pop();\r
139 }\r
a29c47e0 140\r
141 // /\r
142 // / Convert xPath to be namespace qualified, which is necessary for\r
143 // XmlBeans\r
144 // / selectPath(). For example, converting /MsaHeader/ModuleType to\r
145 // / /ns:MsaHeader/ns:ModuleType\r
146 // /\r
878ddf1f 147 private static String normalizeQueryString(String[] exp, String from) {\r
148 StringBuffer normQueryString = new StringBuffer(4096);\r
149\r
150 int i = 0;\r
151 while (i < exp.length) {\r
152 String newExp = from + exp[i];\r
153 Pattern pattern = Pattern.compile("([^/]*)(/|//)([^/]+)");\r
154 Matcher matcher = pattern.matcher(newExp);\r
155\r
156 while (matcher.find()) {\r
a29c47e0 157 String starter = newExp.substring(matcher.start(1), matcher\r
158 .end(1));\r
159 String seperator = newExp.substring(matcher.start(2), matcher\r
160 .end(2));\r
161 String token = newExp.substring(matcher.start(3), matcher\r
162 .end(3));\r
163\r
878ddf1f 164 normQueryString.append(starter);\r
165 normQueryString.append(seperator);\r
166 normQueryString.append(nsPrefix);\r
167 normQueryString.append(":");\r
168 normQueryString.append(token);\r
169 }\r
170\r
171 ++i;\r
172 if (i < exp.length) {\r
173 normQueryString.append(" | ");\r
174 }\r
175 }\r
176\r
177 return normQueryString.toString();\r
178 }\r
179\r
180 /**\r
a29c47e0 181 * Search all XML documents stored in "map" for the specified xPath, using\r
182 * relative path (starting with '$this')\r
183 * \r
184 * @param xPath\r
185 * xpath query string array\r
186 * @returns An array of XmlObject if elements are found at the specified\r
187 * xpath\r
188 * @returns NULL if nothing is at the specified xpath\r
189 */\r
190 public static Object[] get(String[] xPath) {\r
878ddf1f 191 if (map == null) {\r
192 return null;\r
193 }\r
a29c47e0 194\r
878ddf1f 195 String[] keys = (String[]) map.keySet().toArray(new String[map.size()]);\r
a29c47e0 196 List<Object> result = new ArrayList<Object>();\r
878ddf1f 197 for (int i = 0; i < keys.length; ++i) {\r
198 XmlObject rootNode = (XmlObject) map.get(keys[i]);\r
199 if (rootNode == null) {\r
200 continue;\r
201 }\r
a29c47e0 202\r
203 String query = queryDeclaration\r
204 + normalizeQueryString(xPath, "$this/" + keys[i]);\r
878ddf1f 205 XmlObject[] tmp = rootNode.selectPath(query);\r
206 for (int j = 0; j < tmp.length; ++j) {\r
a29c47e0 207 result.add((Object)tmp[j]);\r
878ddf1f 208 }\r
209 }\r
a29c47e0 210\r
878ddf1f 211 int size = result.size();\r
212 if (size <= 0) {\r
213 return null;\r
214 }\r
a29c47e0 215\r
216 return (Object[]) result.toArray(new Object[size]);\r
878ddf1f 217 }\r
218\r
219 /**\r
a29c47e0 220 * Search XML documents named by "rootName" for the given xPath, using\r
221 * relative path (starting with '$this')\r
222 * \r
223 * @param rootName\r
224 * The top level element name\r
225 * @param xPath\r
226 * The xpath query string array\r
227 * @returns An array of XmlObject if elements are found at the given xpath\r
228 * @returns NULL if nothing is found at the given xpath\r
229 */\r
230 public static Object[] get(String rootName, String[] xPath) {\r
878ddf1f 231 if (map == null) {\r
232 return null;\r
233 }\r
a29c47e0 234\r
878ddf1f 235 XmlObject root = (XmlObject) map.get(rootName);\r
236 if (root == null) {\r
237 return null;\r
238 }\r
239\r
a29c47e0 240 String query = queryDeclaration\r
241 + normalizeQueryString(xPath, "$this/" + rootName);\r
878ddf1f 242 XmlObject[] result = root.selectPath(query);\r
243 if (result.length > 0) {\r
a29c47e0 244 return (Object[])result;\r
878ddf1f 245 }\r
246\r
247 query = queryDeclaration + normalizeQueryString(xPath, "/" + rootName);\r
248 result = root.selectPath(query);\r
249 if (result.length > 0) {\r
a29c47e0 250 return (Object[])result;\r
878ddf1f 251 }\r
252\r
253 return null;\r
254 }\r
255\r
256 /**\r
a29c47e0 257 * Retrieve SourceFiles/Filename for specified ARCH type\r
258 * \r
259 * @param arch\r
260 * architecture name\r
261 * @returns An 2 dimension string array if elements are found at the known\r
262 * xpath\r
263 * @returns NULL if nothing is found at the known xpath\r
264 */\r
265 public static String[][] getSourceFiles(String arch) {\r
878ddf1f 266 String[] xPath;\r
a29c47e0 267 Object[] returns;\r
878ddf1f 268\r
25832ed3 269 xPath = new String[] { "/Filename" };\r
878ddf1f 270\r
a29c47e0 271 returns = get("SourceFiles", xPath);\r
878ddf1f 272\r
a29c47e0 273 if (returns == null || returns.length == 0) {\r
274 return new String[0][0];\r
878ddf1f 275 }\r
276\r
a29c47e0 277 Filename[] sourceFileNames = (Filename[]) returns;\r
25832ed3 278 List<String[]> outputList = new ArrayList<String[]>();\r
a29c47e0 279 for (int i = 0; i < sourceFileNames.length; i++) {\r
78d0508a 280 @SuppressWarnings("unchecked")\r
25832ed3 281 List<String> archList = sourceFileNames[i].getSupArchList();\r
282 if (arch == null || arch.equalsIgnoreCase("") || archList == null || archList.contains(arch)) {\r
283 outputList.add(new String[] {sourceFileNames[i].getToolCode(),sourceFileNames[i].getStringValue()});\r
284 }\r
285 }\r
286 \r
287 String[][] outputString = new String[outputList.size()][2];\r
288 for (int index = 0; index < outputList.size(); index++) {\r
289 outputString[index][0] = outputList.get(index)[0];\r
290 outputString[index][1] = outputList.get(index)[1];\r
a29c47e0 291 }\r
292 return outputString;\r
878ddf1f 293 }\r
294\r
295 /**\r
a29c47e0 296 * Retrieve /PlatformDefinitions/OutputDirectory from FPD\r
297 * \r
298 * @returns Directory names array if elements are found at the known xpath\r
299 * @returns Empty if nothing is found at the known xpath\r
300 */\r
301 public static String getFpdOutputDirectory() {\r
302 String[] xPath = new String[] { "/PlatformDefinitions" };\r
303\r
304 Object[] returns = get("PlatformSurfaceArea", xPath);\r
305 if (returns == null || returns.length == 0) {\r
306 return null;\r
307 }\r
308 PlatformDefinitionsDocument.PlatformDefinitions item = (PlatformDefinitionsDocument.PlatformDefinitions)returns[0];\r
309 return item.getOutputDirectory();\r
310 }\r
878ddf1f 311\r
a29c47e0 312 public static String getFpdIntermediateDirectories() {\r
313 String[] xPath = new String[] { "/PlatformDefinitions" };\r
878ddf1f 314\r
a29c47e0 315 Object[] returns = get("PlatformSurfaceArea", xPath);\r
316 if (returns == null || returns.length == 0) {\r
317 return "UNIFIED";\r
318 }\r
319 PlatformDefinitionsDocument.PlatformDefinitions item = (PlatformDefinitionsDocument.PlatformDefinitions)returns[0];\r
320 if(item.getIntermediateDirectories() == null) {\r
321 return null; \r
322 }\r
323 else {\r
324 return item.getIntermediateDirectories().toString();\r
325 }\r
326 }\r
878ddf1f 327\r
a29c47e0 328 public static String getModuleFfsKeyword() {\r
329 String[] xPath = new String[] { "/" };\r
878ddf1f 330\r
a29c47e0 331 Object[] returns = get("ModuleSaBuildOptions", xPath);\r
332 if (returns == null || returns.length == 0) {\r
333 return null;\r
878ddf1f 334 }\r
a29c47e0 335 ModuleSaBuildOptionsDocument.ModuleSaBuildOptions item = (ModuleSaBuildOptionsDocument.ModuleSaBuildOptions)returns[0];\r
336 return item.getFfsFormatKey();\r
337 }\r
338 \r
339 public static String getModuleFvBindingKeyword() {\r
340 String[] xPath = new String[] { "/" };\r
878ddf1f 341\r
a29c47e0 342 Object[] returns = get("ModuleSaBuildOptions", xPath);\r
343 if (returns == null || returns.length == 0) {\r
344 return null;\r
345 }\r
346 ModuleSaBuildOptionsDocument.ModuleSaBuildOptions item = (ModuleSaBuildOptionsDocument.ModuleSaBuildOptions)returns[0];\r
347 return item.getFvBinding();\r
348 }\r
349 \r
350 public static List getModuleSupportedArchs() {\r
351 String[] xPath = new String[] { "/" };\r
352\r
353 Object[] returns = get("ModuleDefinitions", xPath);\r
354 if (returns == null || returns.length == 0) {\r
355 return null;\r
356 }\r
357 ModuleDefinitionsDocument.ModuleDefinitions item = (ModuleDefinitionsDocument.ModuleDefinitions)returns[0];\r
358 return item.getSupportedArchitectures();\r
359 }\r
360 \r
361 public static BuildOptionsDocument.BuildOptions.Ffs[] getFpdFfs() {\r
362 String[] xPath = new String[] {"/Ffs"};\r
363 \r
364 Object[] returns = get("BuildOptions", xPath);\r
365 if (returns == null || returns.length == 0) {\r
366 return new BuildOptionsDocument.BuildOptions.Ffs[0];\r
367 }\r
368 return (BuildOptionsDocument.BuildOptions.Ffs[])returns;\r
878ddf1f 369 }\r
a29c47e0 370 \r
371 public static String getModuleOutputFileBasename() {\r
372 String[] xPath = new String[] { "/" };\r
878ddf1f 373\r
a29c47e0 374 Object[] returns = get("ModuleDefinitions", xPath);\r
375 if (returns == null || returns.length == 0) {\r
376 return null;\r
377 }\r
378 ModuleDefinitionsDocument.ModuleDefinitions item = (ModuleDefinitionsDocument.ModuleDefinitions)returns[0];\r
379 return item.getOutputFileBasename();\r
380 }\r
381 \r
878ddf1f 382 /**\r
a29c47e0 383 * Retrieve BuildOptions/Option or Arch/Option\r
384 * \r
385 * @param toolChainFamilyFlag\r
386 * if true, retrieve options for toolchain family; otherwise for\r
387 * toolchain\r
388 * \r
389 * @returns String[][5] name, target, toolchain, arch, coommand of options\r
390 * if elements are found at the known xpath. String[0][] if dont\r
391 * find element.\r
392 * \r
393 * @returns Empty array if nothing is there\r
394 */\r
395 public static String[][] getOptions(String from, String[] xPath, boolean toolChainFamilyFlag) {\r
396 String target = null;\r
397 String toolchain = null;\r
398 String toolchainFamily = null;\r
399 List<String> archList = null;\r
400 String cmd = null;\r
401 String targetName = null;\r
402 String optionName = null;\r
403\r
404 Object[] returns = get(from, xPath);\r
405 if (returns == null) {\r
406 return new String[0][5];\r
407 }\r
878ddf1f 408\r
a29c47e0 409 List<String[]> optionList = new ArrayList<String[]>();\r
410 OptionDocument.Option option;\r
878ddf1f 411\r
a29c47e0 412 for (int i = 0; i < returns.length; i++) {\r
413 option = (OptionDocument.Option) returns[i];\r
878ddf1f 414\r
a29c47e0 415 //\r
416 // Get Target, ToolChain(Family), Arch, Cmd, and Option from Option,\r
417 // then\r
418 // put to result[][5] array in above order.\r
419 //\r
420 String[] targetList;\r
421 if (option.getBuildTargets() == null) {\r
422 target = null;\r
423 }\r
424 else {\r
425 target = option.getBuildTargets().toString();\r
426 }\r
427 if (target != null) {\r
428 targetList = target.split(" ");\r
429 } else {\r
430 targetList = new String[1];\r
431 targetList[0] = null;\r
432 }\r
878ddf1f 433\r
a29c47e0 434 if (toolChainFamilyFlag) {\r
435 toolchainFamily = option.getToolChainFamily();\r
436 if (toolchainFamily != null) {\r
437 toolchain = toolchainFamily.toString();\r
438 } else {\r
439 toolchain = null;\r
440 }\r
878ddf1f 441 } else {\r
a29c47e0 442 toolchain = option.getTagName();\r
878ddf1f 443 }\r
a29c47e0 444\r
445 archList = new ArrayList<String>();\r
78d0508a 446 @SuppressWarnings("unchecked")\r
a29c47e0 447 List<String> archEnumList = option.getSupArchList(); \r
448 if (archEnumList == null) {\r
449 archList.add(null);\r
450 } else {\r
451 archList.addAll(archEnumList);\r
452 /*\r
453 Iterator it = archEnumList.iterator();\r
454 while (it.hasNext()) {\r
455 System.out.println(it.next().getClass().getName());\r
456 SupportedArchitectures.Enum archType = it.next();\r
457 archList.add(archType.toString());\r
458 }\r
459 */\r
460 }\r
461\r
462 cmd = option.getToolCode();\r
463\r
464 optionName = option.getStringValue();\r
465 for (int t = 0; t < targetList.length; t++) {\r
466 for (int j = 0; j < archList.size(); j++) {\r
467 optionList.add(new String[] { targetList[t],\r
468 toolchain, archList.get(j), cmd, optionName});\r
878ddf1f 469 }\r
470 }\r
878ddf1f 471 }\r
472\r
a29c47e0 473 String[][] result = new String[optionList.size()][5];\r
474 for (int i = 0; i < optionList.size(); i++) {\r
475 result[i][0] = optionList.get(i)[0];\r
476 result[i][1] = optionList.get(i)[1];\r
477 result[i][2] = optionList.get(i)[2];\r
478 result[i][3] = optionList.get(i)[3];\r
479 result[i][4] = optionList.get(i)[4];\r
480 }\r
878ddf1f 481 return result;\r
482 }\r
a29c47e0 483\r
484 public static String[][] getModuleBuildOptions(boolean toolChainFamilyFlag) {\r
485 String[] xPath;\r
486 \r
487 if (toolChainFamilyFlag == true) {\r
488 xPath = new String[] {\r
489 "/Options/Option[not(@ToolChainFamily) and not(@TagName)]",\r
490 "/Options/Option[@ToolChainFamily]", };\r
491 } else {\r
492 xPath = new String[] {\r
493 "/Options/Option[not(@ToolChainFamily) and not(@TagName)]",\r
494 "/Options/Option[@TagName]", };\r
495 }\r
496 return getOptions("ModuleSaBuildOptions", xPath, toolChainFamilyFlag);\r
497 } \r
878ddf1f 498 \r
a29c47e0 499 public static String[][] getPlatformBuildOptions(boolean toolChainFamilyFlag) {\r
500 String[] xPath;\r
250258de 501\r
a29c47e0 502 if (toolChainFamilyFlag == true) {\r
503 xPath = new String[] {\r
504 "/BuildOptions/Options/Option[not(@ToolChainFamily) and not(@TagName)]",\r
505 "/BuildOptions/Options/Option[@ToolChainFamily]", };\r
506 } else {\r
507 xPath = new String[] {\r
508 "/BuildOptions/Options/Option[not(@ToolChainFamily) and not(@TagName)]",\r
509 "/BuildOptions/Options/Option[@TagName]", };\r
250258de 510 }\r
511\r
a29c47e0 512 return getOptions("PlatformSurfaceArea", xPath, toolChainFamilyFlag);\r
250258de 513 }\r
514\r
a29c47e0 515 public static ToolChainInfo getFpdToolChainInfo() {\r
516 String[] xPath = new String[] { "/PlatformDefinitions" };\r
878ddf1f 517\r
a29c47e0 518 Object[] returns = get("PlatformSurfaceArea", xPath);\r
519 if (returns == null || returns.length == 0) {\r
520 return null;\r
878ddf1f 521 }\r
a29c47e0 522 \r
523 PlatformDefinitionsDocument.PlatformDefinitions item = (PlatformDefinitionsDocument.PlatformDefinitions)returns[0];\r
524 ToolChainInfo toolChainInfo = new ToolChainInfo();\r
525 toolChainInfo.addTargets(item.getBuildTargets().toString());\r
526 toolChainInfo.addArchs(item.getSupportedArchitectures().toString());\r
527 toolChainInfo.addTagnames((String)null);\r
528 return toolChainInfo;\r
878ddf1f 529 }\r
530\r
531 /**\r
a29c47e0 532 * Retrieve <xxxHeader>/ModuleType\r
533 * \r
534 * @returns The module type name if elements are found at the known xpath\r
535 * @returns null if nothing is there\r
536 */\r
537 public static String getModuleType() {\r
538 String[] xPath = new String[] { "/ModuleType" };\r
539\r
540 Object[] returns = get(xPath);\r
878ddf1f 541 if (returns != null && returns.length > 0) {\r
a29c47e0 542 ModuleTypeDef type = (ModuleTypeDef) returns[0];\r
878ddf1f 543 return type.enumValue().toString();\r
544 }\r
545\r
546 return null;\r
547 }\r
548\r
549 /**\r
a29c47e0 550 * Retrieve PackageDependencies/Package\r
551 * \r
552 * @param arch\r
553 * Architecture name\r
554 * \r
555 * @returns package name list if elements are found at the known xpath\r
556 * @returns null if nothing is there\r
557 */\r
558 public static PackageIdentification[] getDependencePkg(String arch) {\r
878ddf1f 559 String[] xPath;\r
a29c47e0 560 String packageGuid = null;\r
561 String packageVersion = null;\r
878ddf1f 562\r
25832ed3 563 \r
564 xPath = new String[] { "/Package" };\r
565 \r
a29c47e0 566 Object[] returns = get("PackageDependencies", xPath);\r
567 if (returns == null) {\r
568 return new PackageIdentification[0];\r
878ddf1f 569 }\r
a84091c4 570\r
571 //\r
572 // Get packageIdentification \r
573 // \r
574 List<PackageIdentification> packageIdList = new ArrayList<PackageIdentification>();\r
a29c47e0 575 for (int i = 0; i < returns.length; i++) {\r
576 PackageDependenciesDocument.PackageDependencies.Package item = (PackageDependenciesDocument.PackageDependencies.Package) returns[i];\r
78d0508a 577 @SuppressWarnings("unchecked")\r
25832ed3 578 List<String> archList = item.getSupArchList();\r
579 if (arch == null || archList == null || archList.contains(arch)) {\r
580 packageGuid = item.getPackageGuid();\r
581 packageVersion = item.getPackageVersion();\r
a84091c4 582 packageIdList.add(new PackageIdentification(null, packageGuid,\r
a29c47e0 583 packageVersion));\r
25832ed3 584 }\r
a29c47e0 585 }\r
a84091c4 586\r
587 //\r
588 // transfer packageIdentification list to array.\r
589 // \r
590 PackageIdentification[] packageIdArray = new PackageIdentification[packageIdList.size()];\r
591 for (int i = 0; i < packageIdList.size(); i++) {\r
592 packageIdArray[i] = new PackageIdentification(null, packageIdList.get(i).getGuid(),packageIdList.get(i).getVersion());\r
593 }\r
594 return packageIdArray;\r
878ddf1f 595 }\r
596\r
597 /**\r
a29c47e0 598 * Retrieve LibraryClassDefinitions/LibraryClass for specified usage\r
599 * \r
600 * @param usage\r
601 * Library class usage\r
602 * \r
603 * @returns LibraryClass objects list if elements are found at the known\r
604 * xpath\r
605 * @returns null if nothing is there\r
606 */\r
607 public static String[] getLibraryClasses(String usage) {\r
878ddf1f 608 String[] xPath;\r
609\r
610 if (usage == null || usage.equals("")) {\r
a29c47e0 611 xPath = new String[] { "/LibraryClass" };\r
878ddf1f 612 } else {\r
a29c47e0 613 xPath = new String[] { "/LibraryClass[@Usage='" + usage + "']" };\r
878ddf1f 614 }\r
615\r
a29c47e0 616 Object[] returns = get("LibraryClassDefinitions", xPath);\r
617 if (returns == null || returns.length == 0) {\r
618 return new String[0];\r
878ddf1f 619 }\r
620\r
a29c47e0 621 LibraryClassDocument.LibraryClass[] libraryClassList = (LibraryClassDocument.LibraryClass[]) returns;\r
622 String[] libraryClassName = new String[libraryClassList.length];\r
623 for (int i = 0; i < libraryClassList.length; i++) {\r
624 libraryClassName[i] = libraryClassList[i].getKeyword();\r
625 }\r
626 return libraryClassName;\r
878ddf1f 627 }\r
628\r
629 /**\r
a29c47e0 630 * Retrieve ModuleEntryPoint names\r
631 * \r
632 * @returns ModuleEntryPoint name list if elements are found at the known\r
633 * xpath\r
634 * @returns null if nothing is there\r
635 */\r
878ddf1f 636 public static String[] getModuleEntryPointArray() {\r
637 String[] xPath = new String[] { "/Extern/ModuleEntryPoint" };\r
638\r
a29c47e0 639 Object[] returns = get("Externs", xPath);\r
878ddf1f 640\r
641 if (returns != null && returns.length > 0) {\r
642 String[] entryPoints = new String[returns.length];\r
643\r
644 for (int i = 0; i < returns.length; ++i) {\r
136adffc 645 entryPoints[i] = ((CNameType) returns[i]).getStringValue();\r
878ddf1f 646 }\r
647\r
648 return entryPoints;\r
649 }\r
650\r
651 return null;\r
652 }\r
653\r
654 /**\r
a29c47e0 655 * retrieve Protocol for specified usage\r
656 * \r
657 * @param usage\r
658 * Protocol usage arch Architecture\r
659 * \r
660 * @returns Protocol String list if elements are found at the known xpath\r
661 * @returns String[0] if nothing is there\r
662 */\r
663 public static String[] getProtocolArray(String arch, String usage) {\r
664 String[] xPath;\r
665 String usageXpath = "";\r
666 String archXpath = "";\r
878ddf1f 667\r
a29c47e0 668 if (arch == null || arch.equals("")) {\r
669 return new String[0];\r
670 } else {\r
25832ed3 671 archXpath = "/Protocol";\r
a29c47e0 672 if (usage != null && !usage.equals("")) {\r
673 usageXpath = "/Protocol[@Usage='" + usage + "']";\r
674 xPath = new String[] { usageXpath, archXpath };\r
675 } else {\r
676 return getProtocolArray(arch);\r
250258de 677 }\r
a29c47e0 678\r
250258de 679 }\r
680\r
a29c47e0 681 Object[] returns = get("Protocols", xPath);\r
682 if (returns == null) {\r
683 return new String[0];\r
684 }\r
685 Protocol[] protocolList = (Protocol[]) returns;\r
686\r
687 String[] protocolArray = new String[returns.length];\r
688 for (int i = 0; i < returns.length; i++) {\r
689 protocolArray[i] = protocolList[i].getProtocolCName();\r
690 }\r
691 return protocolArray;\r
250258de 692 }\r
693\r
694 /**\r
a29c47e0 695 * retrieve Protocol for specified usage\r
696 * \r
697 * @param arch\r
698 * Architecture\r
699 * \r
700 * @returns Protocol String list if elements are found at the known xpath\r
701 * @returns String[0] if nothing is there\r
702 */\r
703 public static String[] getProtocolArray(String arch) {\r
704 String[] xPath;\r
705\r
706 if (arch == null || arch.equals("")) {\r
707 return new String[0];\r
708 } else {\r
136adffc 709 xPath = new String[] { "/Protocol" };\r
a29c47e0 710 }\r
250258de 711\r
a29c47e0 712 Object[] returns = get("Protocols", xPath);\r
713 if (returns == null) {\r
714 return new String[0];\r
878ddf1f 715 }\r
25832ed3 716 Protocol[] returnlList = (Protocol[]) returns;\r
878ddf1f 717\r
25832ed3 718 List<String> protocolList = new ArrayList<String>();\r
719 \r
a29c47e0 720 for (int i = 0; i < returns.length; i++) {\r
78d0508a 721 @SuppressWarnings("unchecked")\r
25832ed3 722 List<String> archList = returnlList[i].getSupArchList();\r
136adffc 723 if (archList == null || archList.contains(arch)){\r
25832ed3 724 protocolList.add(returnlList[i].getProtocolCName());\r
136adffc 725 }\r
a29c47e0 726 }\r
25832ed3 727 String[] protocolArray = new String[protocolList.size()];\r
728 for (int i = 0; i < protocolList.size(); i++) {\r
729 protocolArray[i] = protocolList.get(i);\r
730 }\r
a29c47e0 731 return protocolArray;\r
878ddf1f 732 }\r
733\r
734 /**\r
a29c47e0 735 * Retrieve ProtocolNotify for specified usage\r
736 * \r
737 * @param usage\r
738 * ProtocolNotify usage\r
739 * \r
740 * @returns String[] if elements are found at the known xpath\r
741 * @returns String[0] if nothing is there\r
742 */\r
743 public static String[] getProtocolNotifyArray(String arch) {\r
878ddf1f 744 String[] xPath;\r
745\r
a29c47e0 746 if (arch == null || arch.equals("")) {\r
747 return new String[0];\r
878ddf1f 748 } else {\r
136adffc 749 xPath = new String[] { "/ProtocolNotify" };\r
878ddf1f 750 }\r
751\r
a29c47e0 752 Object[] returns = get("Protocols", xPath);\r
753 if (returns == null) {\r
754 return new String[0];\r
878ddf1f 755 }\r
756\r
25832ed3 757 List<String> protocolNotifyList = new ArrayList<String>();\r
758 \r
a29c47e0 759 for (int i = 0; i < returns.length; i++) {\r
78d0508a 760 @SuppressWarnings("unchecked")\r
136adffc 761 List<String> archList = ((ProtocolNotify) returns[i]).getSupArchList();\r
762 if (archList == null || archList.contains(arch)){\r
25832ed3 763 protocolNotifyList.add(((ProtocolNotify) returns[i]).getProtocolNotifyCName());\r
136adffc 764 }\r
765 \r
a29c47e0 766 }\r
25832ed3 767 String[] protocolNotifyArray = new String[protocolNotifyList.size()];\r
768 for (int i = 0; i < protocolNotifyList.size(); i++) {\r
769 protocolNotifyArray[i] = protocolNotifyList.get(i);\r
770 }\r
771 return protocolNotifyArray;\r
878ddf1f 772 }\r
773\r
774 /**\r
a29c47e0 775 * Retrieve ProtocolNotify for specified usage\r
776 * \r
777 * @param usage\r
778 * ProtocolNotify usage\r
779 * \r
780 * @returns String[] if elements are found at the known xpath\r
781 * @returns String[0] if nothing is there\r
782 */\r
783 public static String[] getProtocolNotifyArray(String arch, String usage) {\r
878ddf1f 784\r
878ddf1f 785 String[] xPath;\r
a29c47e0 786 String usageXpath;\r
787 String archXpath;\r
878ddf1f 788\r
a29c47e0 789 if (arch == null || arch.equals("")) {\r
790 return new String[0];\r
878ddf1f 791 } else {\r
25832ed3 792 archXpath = "/ProtocolNotify";\r
a29c47e0 793 if (usage != null && !usage.equals("")) {\r
794 usageXpath = "/ProtocolNotify[@Usage='" + arch + "']";\r
795 xPath = new String[] { archXpath, usageXpath };\r
796 } else {\r
797 return getProtocolNotifyArray(arch);\r
798 }\r
878ddf1f 799 }\r
800\r
a29c47e0 801 Object[] returns = get("Protocols", xPath);\r
802 if (returns == null) {\r
803 return new String[0];\r
878ddf1f 804 }\r
805\r
a29c47e0 806 String[] protocolNotifyList = new String[returns.length];\r
807\r
808 for (int i = 0; i < returns.length; i++) {\r
809 protocolNotifyList[i] = ((ProtocolNotify) returns[i]).getProtocolNotifyCName();\r
810 }\r
811 return protocolNotifyList;\r
878ddf1f 812 }\r
813\r
814 /**\r
a29c47e0 815 * Retrieve ModuleUnloadImage names\r
816 * \r
817 * @returns ModuleUnloadImage name list if elements are found at the known\r
818 * xpath\r
819 * @returns null if nothing is there\r
820 */\r
878ddf1f 821 public static String[] getModuleUnloadImageArray() {\r
822 String[] xPath = new String[] { "/Extern/ModuleUnloadImage" };\r
823\r
a29c47e0 824 Object[] returns = get("Externs", xPath);\r
878ddf1f 825 if (returns != null && returns.length > 0) {\r
826 String[] stringArray = new String[returns.length];\r
136adffc 827 CNameType[] doc = (CNameType[]) returns;\r
878ddf1f 828\r
829 for (int i = 0; i < returns.length; ++i) {\r
830 stringArray[i] = doc[i].getStringValue();\r
831 }\r
832\r
833 return stringArray;\r
834 }\r
835\r
836 return null;\r
837 }\r
838\r
839 /**\r
a29c47e0 840 * Retrieve Extern\r
841 * \r
842 * @returns Extern objects list if elements are found at the known xpath\r
843 * @returns null if nothing is there\r
844 */\r
878ddf1f 845 public static ExternsDocument.Externs.Extern[] getExternArray() {\r
846 String[] xPath = new String[] { "/Extern" };\r
847\r
a29c47e0 848 Object[] returns = get("Externs", xPath);\r
878ddf1f 849 if (returns != null && returns.length > 0) {\r
850 return (ExternsDocument.Externs.Extern[]) returns;\r
851 }\r
852\r
853 return null;\r
854 }\r
855\r
856 /**\r
a29c47e0 857 * Retrieve PpiNotify for specified arch\r
858 * \r
859 * @param arch\r
860 * PpiNotify arch\r
861 * \r
862 * @returns String[] if elements are found at the known xpath\r
863 * @returns String[0] if nothing is there\r
864 */\r
865 public static String[] getPpiNotifyArray(String arch) {\r
878ddf1f 866 String[] xPath;\r
867\r
a29c47e0 868 if (arch == null || arch.equals("")) {\r
869 return new String[0];\r
878ddf1f 870 } else {\r
136adffc 871 xPath = new String[] { "/PpiNotify" };\r
878ddf1f 872 }\r
873\r
a29c47e0 874 Object[] returns = get("PPIs", xPath);\r
875 if (returns == null) {\r
876 return new String[0];\r
878ddf1f 877 }\r
878\r
25832ed3 879 \r
880 List<String> ppiNotifyList = new ArrayList<String>();\r
a29c47e0 881 for (int i = 0; i < returns.length; i++) {\r
78d0508a 882 @SuppressWarnings("unchecked")\r
136adffc 883 List<String> archList = ((PPIsDocument.PPIs.PpiNotify) returns[i]).getSupArchList();\r
884 if (archList == null || archList.contains(arch)){\r
25832ed3 885 ppiNotifyList.add(((PPIsDocument.PPIs.PpiNotify) returns[i]).getPpiNotifyCName()); \r
136adffc 886 }\r
887 \r
a29c47e0 888 }\r
25832ed3 889 String[] ppiNotifyArray = new String[ppiNotifyList.size()];\r
890 for (int i = 0; i < ppiNotifyList.size(); i++) {\r
891 ppiNotifyArray[i] = ppiNotifyList.get(i);\r
892 }\r
a29c47e0 893\r
25832ed3 894 return ppiNotifyArray;\r
878ddf1f 895 }\r
896\r
897 /**\r
a29c47e0 898 * Retrieve PpiNotify for specified usage and arch\r
899 * \r
900 * @param arch\r
901 * PpiNotify arch usage PpiNotify usage\r
902 * \r
903 * \r
904 * @returns String[] if elements are found at the known xpath\r
905 * @returns String[0] if nothing is there\r
906 */\r
907 public static String[] getPpiNotifyArray(String arch, String usage) {\r
878ddf1f 908\r
878ddf1f 909 String[] xPath;\r
a29c47e0 910 String usageXpath;\r
911 String archXpath;\r
878ddf1f 912\r
a29c47e0 913 if (arch == null || arch.equals("")) {\r
914 return new String[0];\r
878ddf1f 915 } else {\r
136adffc 916 archXpath = "/PpiNotify";\r
a29c47e0 917 if (usage != null && !usage.equals("")) {\r
918 usageXpath = "/PpiNotify[@Usage='" + arch + "']";\r
919 xPath = new String[] { archXpath, usageXpath };\r
920 } else {\r
921 return getProtocolNotifyArray(arch);\r
922 }\r
878ddf1f 923 }\r
924\r
a29c47e0 925 Object[] returns = get("PPIs", xPath);\r
926 if (returns == null) {\r
927 return new String[0];\r
878ddf1f 928 }\r
929\r
a29c47e0 930 String[] ppiNotifyList = new String[returns.length];\r
931\r
932 for (int i = 0; i < returns.length; i++) {\r
933 ppiNotifyList[i] = ((PPIsDocument.PPIs.PpiNotify) returns[i]).getPpiNotifyCName();\r
934 }\r
935 return ppiNotifyList;\r
878ddf1f 936 }\r
937\r
938 /**\r
a29c47e0 939 * Retrieve Ppi for specified arch\r
940 * \r
941 * @param arch\r
942 * Ppi arch\r
943 * \r
944 * @returns String[] if elements are found at the known xpath\r
945 * @returns String[0] if nothing is there\r
946 */\r
947 public static String[] getPpiArray(String arch) {\r
948 String[] xPath;\r
949\r
950 if (arch == null || arch.equals("")) {\r
951 return new String[0];\r
952 } else {\r
136adffc 953 xPath = new String[] { "/Ppi" };\r
a29c47e0 954 }\r
955\r
956 Object[] returns = get("PPIs", xPath);\r
957 if (returns == null) {\r
958 return new String[0];\r
959 }\r
960\r
25832ed3 961 List<String> ppiList = new ArrayList<String>();\r
a29c47e0 962 for (int i = 0; i < returns.length; i++) {\r
78d0508a 963 @SuppressWarnings("unchecked")\r
136adffc 964 List<String> archList = ((PPIsDocument.PPIs.Ppi) returns[i]).getSupArchList();\r
965 if (archList == null || archList.contains(arch)){\r
25832ed3 966 ppiList.add(((PPIsDocument.PPIs.Ppi) returns[i]).getPpiCName()); \r
136adffc 967 }\r
968 \r
a29c47e0 969 }\r
25832ed3 970 String[] ppiArray = new String[ppiList.size()];\r
971 for (int i = 0; i < ppiList.size(); i++) {\r
972 ppiArray[i] = ppiList.get(i);\r
973 }\r
974 return ppiArray;\r
a29c47e0 975 }\r
878ddf1f 976\r
a29c47e0 977 /**\r
978 * Retrieve PpiNotify for specified usage and arch\r
979 * \r
980 * @param arch\r
981 * PpiNotify arch usage PpiNotify usage\r
982 * \r
983 * \r
984 * @returns String[] if elements are found at the known xpath\r
985 * @returns String[0] if nothing is there\r
986 */\r
987 public static String[] getPpiArray(String arch, String usage) {\r
878ddf1f 988\r
878ddf1f 989 String[] xPath;\r
a29c47e0 990 String usageXpath;\r
991 String archXpath;\r
878ddf1f 992\r
a29c47e0 993 if (arch == null || arch.equals("")) {\r
994 return new String[0];\r
878ddf1f 995 } else {\r
136adffc 996 archXpath = "/Ppi";\r
a29c47e0 997 if (usage != null && !usage.equals("")) {\r
998 usageXpath = "/Ppi[@Usage='" + arch + "']";\r
999 xPath = new String[] { archXpath, usageXpath };\r
1000 } else {\r
1001 return getProtocolNotifyArray(arch);\r
1002 }\r
878ddf1f 1003 }\r
1004\r
a29c47e0 1005 Object[] returns = get("PPIs", xPath);\r
1006 if (returns == null) {\r
1007 return new String[0];\r
878ddf1f 1008 }\r
1009\r
a29c47e0 1010 String[] ppiList = new String[returns.length];\r
1011\r
1012 for (int i = 0; i < returns.length; i++) {\r
1013 ppiList[i] = ((PPIsDocument.PPIs.Ppi) returns[i]).getPpiCName();\r
1014 }\r
1015 return ppiList;\r
878ddf1f 1016 }\r
1017\r
1018 /**\r
a29c47e0 1019 * Retrieve GuidEntry information for specified usage\r
1020 * \r
1021 * @param arch\r
1022 * GuidEntry arch\r
1023 * \r
1024 * @returns GuidEntry objects list if elements are found at the known xpath\r
1025 * @returns null if nothing is there\r
1026 */\r
1027 public static String[] getGuidEntryArray(String arch) {\r
1028 String[] xPath;\r
1029\r
1030 if (arch == null || arch.equals("")) {\r
136adffc 1031 xPath = new String[] { "/GuidCNames" };\r
a29c47e0 1032 } else {\r
136adffc 1033 xPath = new String[] { "/GuidCNames" };\r
a29c47e0 1034 }\r
1035\r
1036 Object[] returns = get("Guids", xPath);\r
1037 if (returns == null) {\r
1038 return new String[0];\r
1039 }\r
25832ed3 1040\r
1041 List<String> guidList = new ArrayList<String>();\r
a29c47e0 1042 for (int i = 0; i < returns.length; i++) {\r
78d0508a 1043 @SuppressWarnings("unchecked")\r
136adffc 1044 List<String> archList = ((GuidsDocument.Guids.GuidCNames) returns[i]).getSupArchList();\r
1045 if (archList == null || archList.contains(arch)){\r
25832ed3 1046 guidList.add(((GuidsDocument.Guids.GuidCNames) returns[i]).getGuidCName()); \r
136adffc 1047 }\r
1048 \r
a29c47e0 1049 }\r
25832ed3 1050 String[] guidArray = new String[guidList.size()];\r
1051 for (int i = 0; i < guidList.size(); i++) {\r
1052 guidArray[i] = guidList.get(i);\r
1053 }\r
1054 return guidArray;\r
878ddf1f 1055\r
a29c47e0 1056 }\r
878ddf1f 1057\r
a29c47e0 1058 /**\r
1059 * Retrieve GuidEntry information for specified usage\r
1060 * \r
1061 * @param arch\r
1062 * GuidEntry arch usage GuidEntry usage\r
1063 * \r
1064 * @returns GuidEntry objects list if elements are found at the known xpath\r
1065 * @returns null if nothing is there\r
1066 */\r
1067 public static String[] getGuidEntryArray(String arch, String usage) {\r
878ddf1f 1068 String[] xPath;\r
a29c47e0 1069 String archXpath;\r
1070 String usageXpath;\r
878ddf1f 1071\r
a29c47e0 1072 if (arch == null || arch.equals("")) {\r
1073 return new String[0];\r
1074 } else {\r
136adffc 1075 archXpath = "/GuidEntry";\r
a29c47e0 1076 if (usage != null && !usage.equals("")) {\r
1077 usageXpath = "/GuidEntry[@Usage='" + arch + "']";\r
1078 xPath = new String[] { archXpath, usageXpath };\r
878ddf1f 1079 } else {\r
a29c47e0 1080 return getProtocolNotifyArray(arch);\r
878ddf1f 1081 }\r
1082 }\r
878ddf1f 1083\r
a29c47e0 1084 Object[] returns = get("Guids", xPath);\r
1085 if (returns == null) {\r
1086 return new String[0];\r
878ddf1f 1087 }\r
a29c47e0 1088\r
1089 String[] guidList = new String[returns.length];\r
1090\r
1091 for (int i = 0; i < returns.length; i++) {\r
1092 guidList[i] = ((GuidsDocument.Guids.GuidCNames) returns[i]).getGuidCName();\r
1093 }\r
1094 return guidList;\r
1095 }\r
1096\r
1097 /**\r
1098 * Retrieve Library instance information\r
1099 * \r
1100 * @param arch\r
1101 * Architecture name\r
1102 * @param usage\r
1103 * Library instance usage\r
1104 * \r
1105 * @returns library instance name list if elements are found at the known\r
1106 * xpath\r
1107 * @returns null if nothing is there\r
1108 */\r
1109 public static ModuleIdentification[] getLibraryInstance(String arch) {\r
1110 String[] xPath;\r
1111 String saGuid = null;\r
1112 String saVersion = null;\r
1113 String pkgGuid = null;\r
1114 String pkgVersion = null;\r
1115\r
1116 if (arch == null || arch.equalsIgnoreCase("")) {\r
1117 xPath = new String[] { "/Instance" };\r
1118 } else {\r
25832ed3 1119 //\r
1120 // Since Schema don't have SupArchList now, so the follow Xpath is \r
1121 // equal to "/Instance" and [not(@SupArchList) or @SupArchList= arch]\r
1122 // don't have effect.\r
1123 //\r
a29c47e0 1124 xPath = new String[] { "/Instance[not(@SupArchList) or @SupArchList='"\r
1125 + arch + "']" };\r
878ddf1f 1126 }\r
1127\r
a29c47e0 1128 Object[] returns = get("Libraries", xPath);\r
1129 if (returns == null || returns.length == 0) {\r
1130 return new ModuleIdentification[0];\r
1131 }\r
1132\r
1133 ModuleIdentification[] saIdList = new ModuleIdentification[returns.length];\r
1134 for (int i = 0; i < returns.length; i++) {\r
1135 LibrariesDocument.Libraries.Instance library = (LibrariesDocument.Libraries.Instance) returns[i];\r
1136 saGuid = library.getModuleGuid();\r
1137 saVersion = library.getModuleVersion();\r
1138\r
1139 pkgGuid = library.getPackageGuid();\r
1140 pkgVersion = library.getPackageVersion();\r
1141\r
1142 ModuleIdentification saId = new ModuleIdentification(null, saGuid,\r
1143 saVersion);\r
1144 PackageIdentification pkgId = new PackageIdentification(null,\r
1145 pkgGuid, pkgVersion);\r
1146 saId.setPackage(pkgId);\r
1147\r
1148 saIdList[i] = saId;\r
1149\r
1150 }\r
1151 return saIdList;\r
878ddf1f 1152 }\r
1153\r
a29c47e0 1154 // /\r
1155 // / This method is used for retrieving the elements information which has\r
1156 // / CName sub-element\r
1157 // /\r
878ddf1f 1158 private static String[] getCNames(String from, String xPath[]) {\r
a29c47e0 1159 Object[] returns = get(from, xPath);\r
878ddf1f 1160 if (returns == null || returns.length == 0) {\r
1161 return null;\r
1162 }\r
a29c47e0 1163\r
878ddf1f 1164 String[] strings = new String[returns.length];\r
1165 for (int i = 0; i < returns.length; ++i) {\r
a29c47e0 1166 // TBD\r
136adffc 1167 strings[i] = ((CNameType) returns[i]).getStringValue();\r
878ddf1f 1168 }\r
a29c47e0 1169\r
1170 return strings;\r
878ddf1f 1171 }\r
878ddf1f 1172\r
a29c47e0 1173 /**\r
1174 * Retrive library's constructor name\r
1175 * \r
1176 * @returns constructor name list if elements are found at the known xpath\r
1177 * @returns null if nothing is there\r
1178 */\r
878ddf1f 1179 public static String getLibConstructorName() {\r
a29c47e0 1180 String[] xPath = new String[] { "/Extern/Constructor" };\r
878ddf1f 1181\r
a29c47e0 1182 Object[] returns = get("Externs", xPath);\r
878ddf1f 1183 if (returns != null && returns.length > 0) {\r
136adffc 1184 CNameType constructor = ((CNameType) returns[0]);\r
1185 return constructor.getStringValue();\r
878ddf1f 1186 }\r
1187\r
1188 return null;\r
1189 }\r
1190\r
1191 /**\r
a29c47e0 1192 * Retrive library's destructor name\r
1193 * \r
1194 * @returns destructor name list if elements are found at the known xpath\r
1195 * @returns null if nothing is there\r
1196 */\r
878ddf1f 1197 public static String getLibDestructorName() {\r
a29c47e0 1198 String[] xPath = new String[] { "/Extern/Destructor" };\r
878ddf1f 1199\r
a29c47e0 1200 Object[] returns = get("Externs", xPath);\r
878ddf1f 1201 if (returns != null && returns.length > 0) {\r
136adffc 1202 //\r
1203 // Only support one Destructor function.\r
1204 //\r
1205 CNameType destructor = (CNameType) returns[0];\r
1206 return destructor.getStringValue();\r
878ddf1f 1207 }\r
1208\r
1209 return null;\r
1210 }\r
878ddf1f 1211\r
a29c47e0 1212 /**\r
1213 * Retrive DriverBinding names\r
1214 * \r
1215 * @returns DriverBinding name list if elements are found at the known xpath\r
1216 * @returns null if nothing is there\r
1217 */\r
878ddf1f 1218 public static String[] getDriverBindingArray() {\r
a29c47e0 1219 String[] xPath = new String[] { "/Extern/DriverBinding" };\r
878ddf1f 1220 return getCNames("Externs", xPath);\r
1221 }\r
878ddf1f 1222\r
a29c47e0 1223 /**\r
1224 * Retrive ComponentName names\r
1225 * \r
1226 * @returns ComponentName name list if elements are found at the known xpath\r
1227 * @returns null if nothing is there\r
1228 */\r
878ddf1f 1229 public static String[] getComponentNameArray() {\r
a29c47e0 1230 String[] xPath = new String[] { "/Extern/ComponentName" };\r
878ddf1f 1231 return getCNames("Externs", xPath);\r
1232 }\r
878ddf1f 1233\r
a29c47e0 1234 /**\r
1235 * Retrive DriverConfig names\r
1236 * \r
1237 * @returns DriverConfig name list if elements are found at the known xpath\r
1238 * @returns null if nothing is there\r
1239 */\r
878ddf1f 1240 public static String[] getDriverConfigArray() {\r
a29c47e0 1241 String[] xPath = new String[] { "/Extern/DriverConfig" };\r
878ddf1f 1242 return getCNames("Externs", xPath);\r
1243 }\r
878ddf1f 1244\r
a29c47e0 1245 /**\r
1246 * Retrive DriverDiag names\r
1247 * \r
1248 * @returns DriverDiag name list if elements are found at the known xpath\r
1249 * @returns null if nothing is there\r
1250 */\r
878ddf1f 1251 public static String[] getDriverDiagArray() {\r
a29c47e0 1252 String[] xPath = new String[] { "/Extern/DriverDiag" };\r
878ddf1f 1253 return getCNames("Externs", xPath);\r
1254 }\r
1255\r
1256 /**\r
a29c47e0 1257 * Retrive SetVirtualAddressMapCallBack names\r
1258 * \r
1259 * @returns SetVirtualAddressMapCallBack name list if elements are found at\r
1260 * the known xpath\r
1261 * @returns null if nothing is there\r
1262 */\r
878ddf1f 1263 public static String[] getSetVirtualAddressMapCallBackArray() {\r
a29c47e0 1264 String[] xPath = new String[] { "/Extern/SetVirtualAddressMapCallBack" };\r
878ddf1f 1265 return getCNames("Externs", xPath);\r
1266 }\r
878ddf1f 1267\r
a29c47e0 1268 /**\r
1269 * Retrive ExitBootServicesCallBack names\r
1270 * \r
1271 * @returns ExitBootServicesCallBack name list if elements are found at the\r
1272 * known xpath\r
1273 * @returns null if nothing is there\r
1274 */\r
878ddf1f 1275 public static String[] getExitBootServicesCallBackArray() {\r
a29c47e0 1276 String[] xPath = new String[] { "/Extern/ExitBootServicesCallBack" };\r
878ddf1f 1277 return getCNames("Externs", xPath);\r
1278 }\r
1279\r
1280 /**\r
a29c47e0 1281 * Retrieve module surface area file information\r
1282 * \r
1283 * @returns ModuleSA objects list if elements are found at the known xpath\r
1284 * @returns Empty ModuleSA list if nothing is there\r
1285 */\r
1286 public static Map<FpdModuleIdentification, Map<String, XmlObject>> getFpdModules() {\r
1287 String[] xPath = new String[] { "/FrameworkModules/ModuleSA" };\r
1288 Object[] result = get("PlatformSurfaceArea", xPath);\r
1289 String arch = null;\r
1290 String fvBinding = null;\r
1291 String saGuid = null;\r
1292 String saVersion = null;\r
1293 String pkgGuid = null;\r
1294 String pkgVersion = null;\r
1295\r
1296 Map<FpdModuleIdentification, Map<String, XmlObject>> fpdModuleMap = new LinkedHashMap<FpdModuleIdentification, Map<String, XmlObject>>();\r
878ddf1f 1297\r
878ddf1f 1298 if (result == null) {\r
a29c47e0 1299 return fpdModuleMap;\r
1300 }\r
1301\r
1302 for (int i = 0; i < result.length; i++) {\r
1303 //\r
1304 // Get Fpd SA Module element node and add to ObjectMap.\r
1305 //\r
1306 Map<String, XmlObject> ObjectMap = new HashMap<String, XmlObject>();\r
1307 ModuleSADocument.ModuleSA moduleSA = (ModuleSADocument.ModuleSA) result[i];\r
1308 if (((ModuleSADocument.ModuleSA) result[i]).getLibraries() != null) {\r
1309 ObjectMap.put("Libraries", moduleSA.getLibraries());\r
1310 }\r
1311 if (((ModuleSADocument.ModuleSA) result[i]).getPcdBuildDefinition() != null) {\r
1312 ObjectMap.put("PcdBuildDefinition", moduleSA\r
1313 .getPcdBuildDefinition());\r
1314 }\r
1315 if (((ModuleSADocument.ModuleSA) result[i])\r
1316 .getModuleSaBuildOptions() != null) {\r
1317 ObjectMap.put("ModuleSaBuildOptions", moduleSA\r
1318 .getModuleSaBuildOptions());\r
1319 }\r
1320\r
1321 //\r
1322 // Get Fpd SA Module attribute and create FpdMoudleIdentification.\r
1323 //\r
1324 arch = moduleSA.getSupArchList().toString();\r
1325\r
1326 // TBD\r
1327 fvBinding = null;\r
1328 saVersion = ((ModuleSADocument.ModuleSA) result[i])\r
1329 .getModuleVersion();\r
1330\r
1331 saGuid = moduleSA.getModuleGuid();\r
1332 pkgGuid = moduleSA.getPackageGuid();\r
1333 pkgVersion = moduleSA.getPackageVersion();\r
1334\r
1335 //\r
1336 // Create Module Identification which have class member of package\r
1337 // identification.\r
1338 //\r
1339 PackageIdentification pkgId = new PackageIdentification(null,\r
1340 pkgGuid, pkgVersion);\r
1341 ModuleIdentification saId = new ModuleIdentification(null, saGuid,\r
1342 saVersion);\r
1343\r
1344 saId.setPackage(pkgId);\r
1345\r
1346 //\r
1347 // Create FpdModule Identification which have class member of module\r
1348 // identification\r
1349 //\r
1350 if (arch != null) {\r
1351 String[] archList = arch.split(" ");\r
1352 for (int j = 0; j < archList.length; j++) {\r
1353 FpdModuleIdentification fpdSaId = new FpdModuleIdentification(saId, archList[j]);\r
1354 \r
1355 if (fvBinding != null) {\r
1356 fpdSaId.setFvBinding(fvBinding);\r
1357 }\r
1358 \r
1359 //\r
1360 // Put element to Map<FpdModuleIdentification, Map<String,\r
1361 // Object>>.\r
1362 //\r
1363 fpdModuleMap.put(fpdSaId, ObjectMap);\r
1364 }\r
250258de 1365 }\r
878ddf1f 1366 }\r
a29c47e0 1367 return fpdModuleMap;\r
1368 }\r
878ddf1f 1369\r
a29c47e0 1370 /**\r
1371 * Retrieve valid image names\r
1372 * \r
1373 * @returns valid iamges name list if elements are found at the known xpath\r
1374 * @returns empty list if nothing is there\r
1375 */\r
1376 public static String[] getFpdValidImageNames() {\r
1377 String[] xPath = new String[] { "/Flash/FvImages/FvImage[@Type='ImageName']/FvImageNames" };\r
1378\r
1379 Object[] queryResult = get("PlatformSurfaceArea", xPath);\r
1380 if (queryResult == null) {\r
1381 return new String[0];\r
1382 }\r
1383\r
1384 String[] result = new String[queryResult.length];\r
1385 for (int i = 0; i < queryResult.length; i++) {\r
1386 result[i] = ((XmlString) queryResult[i]).getStringValue();\r
1387 }\r
1388\r
1389 return result;\r
1390 }\r
1391 \r
8031d48d 1392 public static Node getFpdUserExtension() {\r
e0f8d087 1393 String[] xPath = new String[] { "/UserExtensions[@UserID='TianoCore']" }; \r
a29c47e0 1394\r
1395 Object[] queryResult = get("PlatformSurfaceArea", xPath);\r
80785fd5 1396 if (queryResult == null || queryResult.length == 0) {\r
a29c47e0 1397 return null;\r
1398 }\r
8031d48d 1399 UserExtensionsDocument.UserExtensions a = (UserExtensionsDocument.UserExtensions)queryResult[0];\r
1400 \r
1401 return a.getDomNode();\r
878ddf1f 1402 }\r
1403\r
03b1a72d 1404 /**\r
a29c47e0 1405 * Retrieve FV image option information\r
1406 * \r
1407 * @param fvName\r
1408 * FV image name\r
1409 * \r
1410 * @returns option name/value list if elements are found at the known xpath\r
1411 * @returns empty list if nothing is there\r
1412 */\r
1413 public static String[][] getFpdOptions(String fvName) {\r
1414 String[] xPath = new String[] { "/Flash/FvImages/FvImage[@Type='Options' and ./FvImageNames='"\r
1415 + fvName.toUpperCase() + "']/FvImageOptions" };\r
1416 Object[] queryResult = get("PlatformSurfaceArea", xPath);\r
1417 if (queryResult == null) {\r
1418 return new String[0][];\r
1419 }\r
1420 ArrayList<String[]> list = new ArrayList<String[]>();\r
1421 for (int i = 0; i < queryResult.length; i++) {\r
1422 FvImagesDocument.FvImages.FvImage.FvImageOptions item = (FvImagesDocument.FvImages.FvImage.FvImageOptions) queryResult[i];\r
1423 List<FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue> namevalues = item\r
1424 .getNameValueList();\r
1425 Iterator iter = namevalues.iterator();\r
1426 while (iter.hasNext()) {\r
1427 FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue nvItem = (FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue) iter\r
1428 .next();\r
1429 list.add(new String[] { nvItem.getName(), nvItem.getValue() });\r
1430 }\r
1431 }\r
1432 String[][] result = new String[list.size()][2];\r
1433 for (int i = 0; i < list.size(); i++) {\r
1434 result[i][0] = list.get(i)[0];\r
1435 result[i][1] = list.get(i)[1];\r
1436 }\r
1437 return result;\r
03b1a72d 1438\r
a29c47e0 1439 }\r
03b1a72d 1440\r
a29c47e0 1441 public static XmlObject getFpdBuildOptions() {\r
1442 String[] xPath = new String[] { "/BuildOptions" };\r
1443\r
1444 Object[] queryResult = get("PlatformSurfaceArea", xPath);\r
1445\r
1446 if (queryResult == null || queryResult.length == 0) {\r
1447 return null;\r
03b1a72d 1448 }\r
a29c47e0 1449 return (XmlObject)queryResult[0];\r
1450 }\r
1451\r
1452 public static PlatformIdentification getFpdHeader() {\r
1453 String[] xPath = new String[] { "/PlatformHeader" };\r
1454\r
1455 Object[] returns = get("PlatformSurfaceArea", xPath);\r
1456\r
1457 if (returns == null || returns.length == 0) {\r
1458 return null;\r
1459 }\r
1460 PlatformHeaderDocument.PlatformHeader header = (PlatformHeaderDocument.PlatformHeader) returns[0];\r
1461\r
1462 String name = header.getPlatformName();\r
1463\r
1464 String guid = header.getGuidValue();\r
1465\r
1466 String version = header.getVersion();\r
1467\r
1468 return new PlatformIdentification(name, guid, version);\r
03b1a72d 1469 }\r
1470\r
878ddf1f 1471 /**\r
a29c47e0 1472 * Retrieve FV image attributes information\r
1473 * \r
1474 * @param fvName\r
1475 * FV image name\r
1476 * \r
1477 * @returns attribute name/value list if elements are found at the known\r
1478 * xpath\r
1479 * @returns empty list if nothing is there\r
1480 */\r
1481 public static String[][] getFpdAttributes(String fvName) {\r
1482 String[] xPath = new String[] { "/Flash/FvImages/FvImage[@Type='Attributes' and ./FvImageNames='"\r
1483 + fvName.toUpperCase() + "']/FvImageOptions" };\r
1484 Object[] queryResult = get("PlatformSurfaceArea", xPath);\r
1485 if (queryResult == null) {\r
1486 return new String[0][];\r
1487 }\r
1488 ArrayList<String[]> list = new ArrayList<String[]>();\r
1489 for (int i = 0; i < queryResult.length; i++) {\r
1490 \r
1491 FvImagesDocument.FvImages.FvImage.FvImageOptions item = (FvImagesDocument.FvImages.FvImage.FvImageOptions) queryResult[i];\r
1492 List<FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue> namevalues = item.getNameValueList();\r
1493 Iterator iter = namevalues.iterator();\r
1494 while (iter.hasNext()) {\r
1495 FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue nvItem = (FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue) iter\r
1496 .next();\r
1497 list.add(new String[] { nvItem.getName(), nvItem.getValue() });\r
1498 }\r
1499 }\r
1500 String[][] result = new String[list.size()][2];\r
1501 for (int i = 0; i < list.size(); i++) {\r
1502 result[i][0] = list.get(i)[0];\r
1503 result[i][1] = list.get(i)[1];\r
1504 }\r
1505 return result;\r
1506 }\r
1507\r
1508 /**\r
1509 * Retrieve flash definition file name\r
1510 * \r
1511 * @returns file name if elements are found at the known xpath\r
1512 * @returns null if nothing is there\r
1513 */\r
1514 public static String getFlashDefinitionFile() {\r
1515 String[] xPath = new String[] { "/PlatformDefinitions/FlashDeviceDefinitions/FlashDefinitionFile" };\r
1516\r
1517 Object[] queryResult = get("PlatformSurfaceArea", xPath);\r
1518 if (queryResult == null || queryResult.length == 0) {\r
1519 return null;\r
1520 }\r
1521\r
1522 FileNameConvention filename = (FileNameConvention) queryResult[queryResult.length - 1];\r
1523 return filename.getStringValue();\r
1524 }\r
878ddf1f 1525\r
878ddf1f 1526 public static String[][] getFpdGlobalVariable() {\r
1527 String[] xPath = new String[] { "/Flash/FvImages/NameValue" };\r
a29c47e0 1528 Object[] queryResult = get("PlatformSurfaceArea", xPath);\r
878ddf1f 1529 if (queryResult == null) {\r
1530 return new String[0][];\r
1531 }\r
1532\r
1533 String[][] result = new String[queryResult.length][2];\r
a29c47e0 1534 \r
1535 for (int i = 0; i < queryResult.length; i++) {\r
1536 FvImagesDocument.FvImages.NameValue item = (FvImagesDocument.FvImages.NameValue)queryResult[i];\r
1537 result[i][0] = item.getName();\r
1538 result[i][1] = item.getValue();\r
878ddf1f 1539 }\r
a29c47e0 1540 return result; \r
878ddf1f 1541 }\r
1542 \r
1543 /**\r
a29c47e0 1544 * Retrieve FV image component options\r
1545 * \r
1546 * @param fvName\r
1547 * FV image name\r
1548 * \r
1549 * @returns name/value pairs list if elements are found at the known xpath\r
1550 * @returns empty list if nothing is there\r
1551 */\r
1552 public static String[][] getFpdComponents(String fvName) {\r
1553 String[] xPath = new String[] { "/Flash/FvImages/FvImage[@Type='Components' and ./FvImageNames='"+ fvName.toUpperCase() + "']/FvImageOptions" };\r
1554 Object[] queryResult = get("PlatformSurfaceArea", xPath);\r
878ddf1f 1555 if (queryResult == null) {\r
a29c47e0 1556 return new String[0][];\r
878ddf1f 1557 }\r
1558\r
a29c47e0 1559 ArrayList<String[]> list = new ArrayList<String[]>();\r
1560 for (int i = 0; i < queryResult.length; i++) {\r
1561 FvImagesDocument.FvImages.FvImage.FvImageOptions item = (FvImagesDocument.FvImages.FvImage.FvImageOptions) queryResult[i];\r
1562 List<FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue> namevalues = item.getNameValueList();\r
1563 Iterator iter = namevalues.iterator();\r
1564 while (iter.hasNext()) {\r
1565 FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue nvItem = (FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue) iter\r
1566 .next();\r
1567 list.add(new String[] { nvItem.getName(), nvItem.getValue() });\r
1568 }\r
1569 }\r
1570 String[][] result = new String[list.size()][2];\r
1571 for (int i = 0; i < list.size(); i++) {\r
1572 result[i][0] = list.get(i)[0];\r
1573 result[i][1] = list.get(i)[1];\r
878ddf1f 1574 }\r
a29c47e0 1575 return result; \r
1576 }\r
878ddf1f 1577\r
a29c47e0 1578 /**\r
1579 * Retrieve PCD tokens\r
1580 * \r
1581 * @returns CName/ItemType pairs list if elements are found at the known\r
1582 * xpath\r
1583 * @returns null if nothing is there\r
1584 */\r
1585 public static String[][] getPcdTokenArray() {\r
1586 String[] xPath = new String[] { "/PcdData" };\r
1587\r
1588 Object[] returns = get("PCDs", xPath);\r
1589 if (returns == null || returns.length == 0) {\r
1590 return null;\r
1591 }\r
1592\r
1593 // PcdCoded.PcdData[] pcds = (PcdCoded.PcdData[]) returns;\r
1594 // String[][] result = new String[pcds.length][2];\r
1595 // for (int i = 0; i < returns.length; ++i) {\r
1596 // if (pcds[i].getItemType() != null) {\r
1597 // result[i][1] = pcds[i].getItemType().toString();\r
1598 // } else {\r
1599 // result[i][1] = null;\r
1600 // }\r
1601 // result[i][0] = pcds[i].getCName();\r
1602 // }\r
1603\r
1604 return null;\r
878ddf1f 1605 }\r
1606\r
1607 /**\r
a29c47e0 1608 * Get the PcdToken array from module's surface area document. The array\r
1609 * should contains following data:\r
1610 * <p>\r
1611 * -------------------------------------------------------------------\r
1612 * </p>\r
1613 * <p>\r
1614 * CName | ItemType | TokenspaceName | DefaultValue | Usage | HelpText\r
1615 * </p>\r
1616 * <p>\r
1617 * -------------------------------------------------------------------\r
1618 * </p>\r
1619 * <p>\r
1620 * Note: Until new schema applying, now we can only get CName, ItemType,\r
1621 * </p>\r
1622 * \r
1623 * @return 2-array table contains all information of PCD token retrieved\r
1624 * from MSA.\r
1625 */\r
1626 public static Object[][] etModulePCDTokenArray() {\r
1627 return null;\r
1628 // int index;\r
1629 // Object[][] result;\r
1630 // PCDs.PcdData[] pcds;\r
1631 // String[] xPath = new String[] { "/PcdData" };\r
1632 // Object[] returns = get("PCDs", xPath);\r
1633 //\r
1634 // if ((returns == null) || (returns.length == 0)) {\r
1635 // return null;\r
1636 // }\r
1637 //\r
1638 // pcds = (PCDs.PcdData[]) returns;\r
1639 // result = new Object[pcds.length][6];\r
1640 // for (index = 0; index < pcds.length; index++) {\r
1641 // //\r
1642 // // Get CName\r
1643 // //\r
1644 // result[index][0] = pcds[index].getCName();\r
1645 // //\r
1646 // // Get ItemType: FEATURE_FLAG, FIXED_AT_BUILD, PATCHABLE_IN_MODLE,\r
1647 // // DYNAMIC, DYNAMIC_EX\r
1648 // //\r
1649 // if (pcds[index].getItemType() != null) {\r
1650 // result[index][1] = pcds[index].getItemType().toString();\r
1651 // } else {\r
1652 // result[index][1] = null;\r
1653 // }\r
1654 //\r
1655 // //\r
1656 // // BUGBUG: following field can *not* be got from current MSA until\r
1657 // // schema changed.\r
1658 // //\r
1659 // // result [index][2] = pcds[index].getTokenSpaceName();\r
1660 // result[index][2] = null;\r
1661 // result[index][3] = pcds[index].getDefaultValue();\r
1662 // // result [index][4] = pcds[index].getUsage ();\r
1663 // result[index][4] = null;\r
1664 // // result [index][5] = pcds[index].getHelpText ();\r
1665 // result[index][5] = null;\r
1666 // }\r
1667 // return result;\r
1668 }\r
1669\r
1670 /**\r
1671 * Retrieve MAS header\r
1672 * \r
1673 * @return\r
1674 * @return\r
1675 */\r
1676 public static ModuleIdentification getMsaHeader() {\r
1677 String[] xPath = new String[] { "/" };\r
1678 Object[] returns = get("MsaHeader", xPath);\r
1679\r
1680 if (returns == null || returns.length == 0) {\r
1681 return null;\r
1682 }\r
1683\r
1684 MsaHeader msaHeader = (MsaHeader) returns[0];\r
1685 //\r
1686 // Get BaseName, ModuleType, GuidValue, Version\r
1687 // which in MsaHeader.\r
1688 //\r
1689 String name = msaHeader.getModuleName();\r
1690 String moduleType = msaHeader.getModuleType().toString();\r
1691 String guid = msaHeader.getGuidValue();\r
1692 String version = msaHeader.getVersion();\r
878ddf1f 1693\r
a29c47e0 1694 ModuleIdentification moduleId = new ModuleIdentification(name, guid,\r
1695 version);\r
878ddf1f 1696\r
a29c47e0 1697 moduleId.setModuleType(moduleType);\r
1698\r
1699 return moduleId;\r
1700 }\r
878ddf1f 1701\r
a29c47e0 1702 /**\r
1703 * Retrieve Extern Specification\r
1704 * \r
1705 * @param\r
1706 * \r
1707 * @return String[] If have specification element in the <extern> String[0]\r
1708 * If no specification element in the <extern>\r
1709 * \r
1710 */\r
1711\r
1712 public static String[] getExternSpecificaiton() {\r
1713 String[] xPath = new String[] { "/Specification" };\r
1714\r
1715 Object[] queryResult = get("Externs", xPath);\r
878ddf1f 1716 if (queryResult == null) {\r
a29c47e0 1717 return new String[0];\r
878ddf1f 1718 }\r
1719\r
a29c47e0 1720 String[] specificationList = new String[queryResult.length];\r
1721 for (int i = 0; i < queryResult.length; i++) {\r
136adffc 1722 specificationList[i] = ((Sentence)queryResult[i])\r
1723 .getStringValue();\r
878ddf1f 1724 }\r
a29c47e0 1725 return specificationList;\r
1726 }\r
878ddf1f 1727\r
a29c47e0 1728 /**\r
1729 * Retreive MsaFile which in SPD\r
1730 * \r
1731 * @param\r
1732 * @return String[][3] The string sequence is ModuleName, ModuleGuid,\r
1733 * ModuleVersion, MsaFile String[0][] If no msafile in SPD\r
1734 */\r
1735 public static String[] getSpdMsaFile() {\r
1736 String[] xPath = new String[] { "/MsaFiles" };\r
1737\r
1738 Object[] returns = get("PackageSurfaceArea", xPath);\r
1739 if (returns == null) {\r
1740 return new String[0];\r
1741 }\r
1742\r
1743 List<String> filenameList = ((MsaFilesDocument.MsaFiles) returns[0])\r
1744 .getFilenameList();\r
1745 return filenameList.toArray(new String[filenameList.size()]);\r
878ddf1f 1746 }\r
a29c47e0 1747\r
878ddf1f 1748 /**\r
a29c47e0 1749 * Reteive\r
1750 */\r
1751 public static Map<String, String[]> getSpdLibraryClasses() {\r
1752 String[] xPath = new String[] { "/LibraryClassDeclarations/LibraryClass" };\r
878ddf1f 1753\r
a29c47e0 1754 Object[] returns = get("PackageSurfaceArea", xPath);\r
878ddf1f 1755\r
a29c47e0 1756 //\r
1757 // Create Map, Key - LibraryClass, String[] - LibraryClass Header file.\r
1758 //\r
1759 Map<String, String[]> libClassHeaderMap = new HashMap<String, String[]>();\r
878ddf1f 1760\r
a29c47e0 1761 if (returns == null) {\r
1762 return libClassHeaderMap;\r
878ddf1f 1763 }\r
1764\r
a29c47e0 1765 for (int i = 0; i < returns.length; i++) {\r
1766 LibraryClassDeclarationsDocument.LibraryClassDeclarations.LibraryClass library = (LibraryClassDeclarationsDocument.LibraryClassDeclarations.LibraryClass) returns[i];\r
1767 libClassHeaderMap.put(library.getName(), new String[] { library\r
1768 .getIncludeHeader() });\r
1769 }\r
1770 return libClassHeaderMap;\r
1771 }\r
878ddf1f 1772\r
a29c47e0 1773 /**\r
1774 * Reteive\r
1775 */\r
1776 public static Map<String, String> getSpdPackageHeaderFiles() {\r
1777 String[] xPath = new String[] { "/PackageHeaders/IncludePkgHeader" };\r
878ddf1f 1778\r
a29c47e0 1779 Object[] returns = get("PackageSurfaceArea", xPath);\r
878ddf1f 1780\r
a29c47e0 1781 //\r
1782 // Create Map, Key - ModuleType, String - PackageInclude Header file.\r
1783 //\r
1784 Map<String, String> packageIncludeMap = new HashMap<String, String>();\r
1785\r
1786 if (returns == null) {\r
1787 return packageIncludeMap;\r
878ddf1f 1788 }\r
a29c47e0 1789// GlobalData.log.info("" + returns[0].getClass().getName());\r
1790 for (int i = 0; i < returns.length; i++) {\r
1791 PackageHeadersDocument.PackageHeaders.IncludePkgHeader includeHeader = (PackageHeadersDocument.PackageHeaders.IncludePkgHeader) returns[i];\r
1792 packageIncludeMap.put(includeHeader.getModuleType().toString(),\r
1793 includeHeader.getStringValue());\r
1794 }\r
1795 return packageIncludeMap;\r
1796 }\r
878ddf1f 1797\r
a29c47e0 1798 public static PackageIdentification getSpdHeader() {\r
1799 String[] xPath = new String[] { "/SpdHeader" };\r
1800\r
1801 Object[] returns = get("PackageSurfaceArea", xPath);\r
1802\r
1803 if (returns == null || returns.length == 0) {\r
1804 return null;\r
878ddf1f 1805 }\r
1806\r
a29c47e0 1807 SpdHeaderDocument.SpdHeader header = (SpdHeaderDocument.SpdHeader) returns[0];\r
1808\r
1809 String name = header.getPackageName();\r
1810\r
1811 String guid = header.getGuidValue();\r
1812\r
1813 String version = header.getVersion();\r
1814\r
1815 return new PackageIdentification(name, guid, version);\r
878ddf1f 1816 }\r
a29c47e0 1817\r
878ddf1f 1818 /**\r
a29c47e0 1819 * Reteive\r
1820 */\r
1821 public static Map<String, String[]> getSpdGuid() {\r
1822 String[] xPath = new String[] { "/GuidDeclarations/Entry" };\r
878ddf1f 1823\r
a29c47e0 1824 Object[] returns = get("PackageSurfaceArea", xPath);\r
878ddf1f 1825\r
a29c47e0 1826 //\r
1827 // Create Map, Key - GuidName, String[] - C_NAME & GUID value.\r
1828 //\r
1829 Map<String, String[]> guidDeclMap = new HashMap<String, String[]>();\r
1830 if (returns == null) {\r
1831 return guidDeclMap;\r
878ddf1f 1832 }\r
1833\r
a29c47e0 1834 for (int i = 0; i < returns.length; i++) {\r
1835 GuidDeclarationsDocument.GuidDeclarations.Entry entry = (GuidDeclarationsDocument.GuidDeclarations.Entry) returns[i];\r
1836 String[] guidPair = new String[2];\r
1837 guidPair[0] = entry.getCName();\r
1838 guidPair[1] = entry.getGuidValue();\r
1839 guidDeclMap.put(entry.getName(), guidPair);\r
136adffc 1840 EdkLog.log(EdkLog.EDK_VERBOSE, entry.getName());\r
1841 EdkLog.log(EdkLog.EDK_VERBOSE, guidPair[0]);\r
1842 EdkLog.log(EdkLog.EDK_VERBOSE, guidPair[1]);\r
a29c47e0 1843 }\r
1844 return guidDeclMap;\r
878ddf1f 1845 }\r
a29c47e0 1846\r
878ddf1f 1847 /**\r
a29c47e0 1848 * Reteive\r
1849 */\r
1850 public static Map<String, String[]> getSpdProtocol() {\r
1851 String[] xPath = new String[] { "/ProtocolDeclarations/Entry" };\r
878ddf1f 1852\r
a29c47e0 1853 Object[] returns = get("PackageSurfaceArea", xPath);\r
878ddf1f 1854\r
a29c47e0 1855 //\r
1856 // Create Map, Key - protocolName, String[] - C_NAME & GUID value.\r
1857 //\r
1858 Map<String, String[]> protoclMap = new HashMap<String, String[]>();\r
878ddf1f 1859\r
a29c47e0 1860 if (returns == null) {\r
1861 return protoclMap;\r
878ddf1f 1862 }\r
1863\r
a29c47e0 1864 for (int i = 0; i < returns.length; i++) {\r
1865 ProtocolDeclarationsDocument.ProtocolDeclarations.Entry entry = (ProtocolDeclarationsDocument.ProtocolDeclarations.Entry) returns[i];\r
1866 String[] protocolPair = new String[2];\r
878ddf1f 1867\r
a29c47e0 1868 protocolPair[0] = entry.getCName();\r
1869 protocolPair[1] = entry.getGuidValue();\r
1870 protoclMap.put(entry.getName(), protocolPair);\r
136adffc 1871 EdkLog.log(EdkLog.EDK_VERBOSE, entry.getName());\r
1872 EdkLog.log(EdkLog.EDK_VERBOSE, protocolPair[0]);\r
1873 EdkLog.log(EdkLog.EDK_VERBOSE, protocolPair[1]);\r
a29c47e0 1874 }\r
1875 return protoclMap;\r
1876 }\r
878ddf1f 1877\r
a29c47e0 1878 /**\r
1879 * getSpdPpi() Retrieve the SPD PPI Entry\r
1880 * \r
1881 * @param\r
1882 * @return Map<String, String[2]> if get the PPI entry from SPD. Key - PPI\r
1883 * Name String[0] - PPI CNAME String[1] - PPI Guid Null if no PPI\r
1884 * entry in SPD.\r
1885 */\r
1886 public static Map<String, String[]> getSpdPpi() {\r
1887 String[] xPath = new String[] { "/PpiDeclarations/Entry" };\r
1888\r
1889 Object[] returns = get("PackageSurfaceArea", xPath);\r
1890\r
1891 //\r
1892 // Create Map, Key - protocolName, String[] - C_NAME & GUID value.\r
1893 //\r
1894 Map<String, String[]> ppiMap = new HashMap<String, String[]>();\r
878ddf1f 1895\r
a29c47e0 1896 if (returns == null) {\r
1897 return ppiMap;\r
878ddf1f 1898 }\r
1899\r
a29c47e0 1900 for (int i = 0; i < returns.length; i++) {\r
1901 PpiDeclarationsDocument.PpiDeclarations.Entry entry = (PpiDeclarationsDocument.PpiDeclarations.Entry) returns[i];\r
1902 String[] ppiPair = new String[2];\r
1903 ppiPair[0] = entry.getCName();\r
1904 ppiPair[1] = entry.getGuidValue();\r
1905 ppiMap.put(entry.getName(), ppiPair);\r
878ddf1f 1906 }\r
a29c47e0 1907 return ppiMap;\r
878ddf1f 1908 }\r
a29c47e0 1909\r
878ddf1f 1910 /**\r
a29c47e0 1911 * getToolChainFamily\r
1912 * \r
1913 * This function is to retrieve ToolChainFamily attribute of FPD\r
1914 * <BuildOptions>\r
1915 * \r
1916 * @param\r
1917 * @return toolChainFamily If find toolChainFamily attribute in\r
1918 * <BuildOptions> Null If don't have toolChainFamily in\r
1919 * <BuildOptions>.\r
1920 */\r
1921 public String getToolChainFamily() {\r
1922 String toolChainFamily;\r
1923 String[] xPath = new String[] { "/BuildOptions" };\r
1924\r
1925 Object[] result = get("PlatformSurfaceArea", xPath);\r
1926 if (result == null) {\r
878ddf1f 1927 return null;\r
1928 }\r
a29c47e0 1929 // toolChainFamily =\r
1930 // ((BuildOptionsDocument.BuildOptions)result[0]).getToolChainFamilies();\r
1931 // return toolChainFamily;\r
1932 return null;\r
1933 }\r
878ddf1f 1934\r
a29c47e0 1935 /**\r
1936 * Retrieve module Guid string\r
1937 * \r
1938 * @returns GUILD string if elements are found at the known xpath\r
1939 * @returns null if nothing is there\r
1940 */\r
1941 public static String getModuleGuid() {\r
1942 String[] xPath = new String[] { "" };\r
1943\r
1944 Object[] returns = get("MsaHeader", xPath);\r
1945 if (returns != null && returns.length > 0) {\r
1946 String guid = ((MsaHeaderDocument.MsaHeader) returns[0])\r
1947 .getGuidValue();\r
1948 return guid;\r
ad82307c 1949 }\r
a29c47e0 1950\r
1951 return null;\r
1952 }\r
1953\r
1954 //\r
1955 // For new Pcd\r
1956 //\r
1957 public static ModuleSADocument.ModuleSA[] getFpdModuleSAs() {\r
1958 String[] xPath = new String[] { "/FrameworkModules/ModuleSA" };\r
1959 Object[] result = get("PlatformSurfaceArea", xPath);\r
1960 if (result != null) {\r
1961 return (ModuleSADocument.ModuleSA[]) result;\r
1962 }\r
1963 return new ModuleSADocument.ModuleSA[0];\r
1964\r
878ddf1f 1965 }\r
136adffc 1966 /**\r
1967 Get name array of PCD in a module. In one module, token space\r
1968 is same, and token name should not be conflicted.\r
1969 \r
1970 @return String[]\r
1971 **/\r
1972 public static String[] getModulePcdEntryNameArray() {\r
1973 PcdCodedDocument.PcdCoded.PcdEntry[] pcdEntries = null;\r
1974 String[] results;\r
1975 int index;\r
1976 String[] xPath = new String[] {"/PcdEntry"};\r
1977 Object[] returns = get ("PcdCoded", xPath);\r
1978 \r
1979 if (returns == null) {\r
1980 return new String[0];\r
1981 }\r
1982 \r
1983 pcdEntries = (PcdCodedDocument.PcdCoded.PcdEntry[])returns;\r
1984 results = new String[pcdEntries.length];\r
1985 \r
1986 for (index = 0; index < pcdEntries.length; index ++) {\r
1987 results[index] = pcdEntries[index].getCName();\r
1988 }\r
1989 return results;\r
1990 }\r
878ddf1f 1991}\r