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