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