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