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