2 This file is for surface area information retrieval.
4 Copyright (c) 2006, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14 package org
.tianocore
.build
.global
;
16 import java
.util
.ArrayList
;
17 import java
.util
.HashMap
;
18 import java
.util
.Iterator
;
19 import java
.util
.LinkedHashMap
;
20 import java
.util
.List
;
22 import java
.util
.Stack
;
23 import java
.util
.regex
.Matcher
;
24 import java
.util
.regex
.Pattern
;
26 import org
.apache
.xmlbeans
.XmlNormalizedString
;
27 import org
.apache
.xmlbeans
.XmlObject
;
28 import org
.apache
.xmlbeans
.XmlString
;
29 import org
.tianocore
.BuildOptionsDocument
;
30 import org
.tianocore
.DataIdDocument
;
31 import org
.tianocore
.ExternsDocument
;
32 import org
.tianocore
.FileNameConvention
;
33 import org
.tianocore
.FvAttributeDocument
;
34 import org
.tianocore
.FvImagesDocument
;
35 import org
.tianocore
.FvOptionDocument
;
36 import org
.tianocore
.GuidDeclarationsDocument
;
37 import org
.tianocore
.GuidsDocument
;
38 import org
.tianocore
.LibrariesDocument
;
39 import org
.tianocore
.LibraryClassDeclarationsDocument
;
40 import org
.tianocore
.LibraryClassDocument
;
41 import org
.tianocore
.ModuleDefinitionsDocument
;
42 import org
.tianocore
.ModuleSADocument
;
43 import org
.tianocore
.ModuleSaBuildOptionsDocument
;
44 import org
.tianocore
.ModuleTypeDef
;
45 import org
.tianocore
.MsaFilesDocument
;
46 import org
.tianocore
.MsaHeaderDocument
;
47 import org
.tianocore
.OptionDocument
;
48 import org
.tianocore
.PPIsDocument
;
49 import org
.tianocore
.PackageDependenciesDocument
;
50 import org
.tianocore
.PackageHeadersDocument
;
51 import org
.tianocore
.PlatformDefinitionsDocument
;
52 import org
.tianocore
.PpiDeclarationsDocument
;
53 import org
.tianocore
.ProtocolDeclarationsDocument
;
54 import org
.tianocore
.SpdHeaderDocument
;
55 import org
.tianocore
.SupportedArchitectures
;
56 import org
.tianocore
.FilenameDocument
.Filename
;
57 import org
.tianocore
.MsaHeaderDocument
.MsaHeader
;
58 import org
.tianocore
.ProtocolsDocument
.Protocols
.Protocol
;
59 import org
.tianocore
.ProtocolsDocument
.Protocols
.ProtocolNotify
;
60 import org
.tianocore
.PlatformHeaderDocument
;
61 import org
.tianocore
.build
.id
.FpdModuleIdentification
;
62 import org
.tianocore
.build
.id
.ModuleIdentification
;
63 import org
.tianocore
.build
.id
.PackageIdentification
;
64 import org
.tianocore
.build
.id
.PlatformIdentification
;
65 import org
.tianocore
.build
.toolchain
.ToolChainInfo
;
68 * SurfaceAreaQuery class is used to query Surface Area information from msa,
69 * mbd, spd and fpd files.
71 * This class should not instantiated. All the public interfaces is static.
75 public class SurfaceAreaQuery
{
77 public static String prefix
= "http://www.TianoCore.org/2006/Edk2.0";
80 // / Contains name/value pairs of Surface Area document object. The name is
81 // / always the top level element name.
83 private static Map
<String
, XmlObject
> map
= null;
86 // / mapStack is used to do nested query
88 private static Stack
<Map
<String
, XmlObject
>> mapStack
= new Stack
<Map
<String
, XmlObject
>>();
91 // / prefix of name space
93 private static String nsPrefix
= "sans";
96 // / xmlbeans needs a name space for each Xpath element
98 private static String ns
= null;
101 // / keep the namep declaration for xmlbeans Xpath query
103 private static String queryDeclaration
= null;
106 * Set a Surface Area document for query later
109 * A Surface Area document in TopLevelElementName/XmlObject
112 public static void setDoc(Map
<String
, XmlObject
> map
) {
114 queryDeclaration
= "declare namespace " + nsPrefix
+ "='" + ns
+ "'; ";
115 SurfaceAreaQuery
.map
= map
;
119 * Push current used Surface Area document into query stack. The given new
120 * document will be used for any immediately followed getXXX() callings,
121 * untill pop() is called.
124 * The TopLevelElementName/XmlObject format of a Surface Area
127 public static void push(Map
<String
, XmlObject
> newMap
) {
128 mapStack
.push(SurfaceAreaQuery
.map
);
129 SurfaceAreaQuery
.map
= newMap
;
133 * Discard current used Surface Area document and use the top document in
136 public static void pop() {
137 SurfaceAreaQuery
.map
= mapStack
.pop();
141 // / Convert xPath to be namespace qualified, which is necessary for
143 // / selectPath(). For example, converting /MsaHeader/ModuleType to
144 // / /ns:MsaHeader/ns:ModuleType
146 private static String
normalizeQueryString(String
[] exp
, String from
) {
147 StringBuffer normQueryString
= new StringBuffer(4096);
150 while (i
< exp
.length
) {
151 String newExp
= from
+ exp
[i
];
152 Pattern pattern
= Pattern
.compile("([^/]*)(/|//)([^/]+)");
153 Matcher matcher
= pattern
.matcher(newExp
);
155 while (matcher
.find()) {
156 String starter
= newExp
.substring(matcher
.start(1), matcher
158 String seperator
= newExp
.substring(matcher
.start(2), matcher
160 String token
= newExp
.substring(matcher
.start(3), matcher
163 normQueryString
.append(starter
);
164 normQueryString
.append(seperator
);
165 normQueryString
.append(nsPrefix
);
166 normQueryString
.append(":");
167 normQueryString
.append(token
);
171 if (i
< exp
.length
) {
172 normQueryString
.append(" | ");
176 return normQueryString
.toString();
180 * Search all XML documents stored in "map" for the specified xPath, using
181 * relative path (starting with '$this')
184 * xpath query string array
185 * @returns An array of XmlObject if elements are found at the specified
187 * @returns NULL if nothing is at the specified xpath
189 public static Object
[] get(String
[] xPath
) {
194 String
[] keys
= (String
[]) map
.keySet().toArray(new String
[map
.size()]);
195 List
<Object
> result
= new ArrayList
<Object
>();
196 for (int i
= 0; i
< keys
.length
; ++i
) {
197 XmlObject rootNode
= (XmlObject
) map
.get(keys
[i
]);
198 if (rootNode
== null) {
202 String query
= queryDeclaration
203 + normalizeQueryString(xPath
, "$this/" + keys
[i
]);
204 XmlObject
[] tmp
= rootNode
.selectPath(query
);
205 for (int j
= 0; j
< tmp
.length
; ++j
) {
206 result
.add((Object
)tmp
[j
]);
210 int size
= result
.size();
215 return (Object
[]) result
.toArray(new Object
[size
]);
219 * Search XML documents named by "rootName" for the given xPath, using
220 * relative path (starting with '$this')
223 * The top level element name
225 * The xpath query string array
226 * @returns An array of XmlObject if elements are found at the given xpath
227 * @returns NULL if nothing is found at the given xpath
229 public static Object
[] get(String rootName
, String
[] xPath
) {
234 XmlObject root
= (XmlObject
) map
.get(rootName
);
239 String query
= queryDeclaration
240 + normalizeQueryString(xPath
, "$this/" + rootName
);
241 XmlObject
[] result
= root
.selectPath(query
);
242 if (result
.length
> 0) {
243 return (Object
[])result
;
246 query
= queryDeclaration
+ normalizeQueryString(xPath
, "/" + rootName
);
247 result
= root
.selectPath(query
);
248 if (result
.length
> 0) {
249 return (Object
[])result
;
256 * Retrieve SourceFiles/Filename for specified ARCH type
260 * @returns An 2 dimension string array if elements are found at the known
262 * @returns NULL if nothing is found at the known xpath
264 public static String
[][] getSourceFiles(String arch
) {
268 if (arch
== null || arch
.equals("")) {
269 xPath
= new String
[] { "/Filename" };
271 xPath
= new String
[] { "/Filename[not(@SupArchList) or @SupArchList='"
275 returns
= get("SourceFiles", xPath
);
277 if (returns
== null || returns
.length
== 0) {
278 return new String
[0][0];
281 Filename
[] sourceFileNames
= (Filename
[]) returns
;
282 String
[][] outputString
= new String
[sourceFileNames
.length
][2];
283 for (int i
= 0; i
< sourceFileNames
.length
; i
++) {
284 outputString
[i
][0] = sourceFileNames
[i
].getToolCode();
285 outputString
[i
][1] = sourceFileNames
[i
].getStringValue();
291 * Retrieve /PlatformDefinitions/OutputDirectory from FPD
293 * @returns Directory names array if elements are found at the known xpath
294 * @returns Empty if nothing is found at the known xpath
296 public static String
getFpdOutputDirectory() {
297 String
[] xPath
= new String
[] { "/PlatformDefinitions" };
299 Object
[] returns
= get("PlatformSurfaceArea", xPath
);
300 if (returns
== null || returns
.length
== 0) {
303 PlatformDefinitionsDocument
.PlatformDefinitions item
= (PlatformDefinitionsDocument
.PlatformDefinitions
)returns
[0];
304 return item
.getOutputDirectory();
307 public static String
getFpdIntermediateDirectories() {
308 String
[] xPath
= new String
[] { "/PlatformDefinitions" };
310 Object
[] returns
= get("PlatformSurfaceArea", xPath
);
311 if (returns
== null || returns
.length
== 0) {
314 PlatformDefinitionsDocument
.PlatformDefinitions item
= (PlatformDefinitionsDocument
.PlatformDefinitions
)returns
[0];
315 if(item
.getIntermediateDirectories() == null) {
319 return item
.getIntermediateDirectories().toString();
323 public static String
getModuleFfsKeyword() {
324 String
[] xPath
= new String
[] { "/" };
326 Object
[] returns
= get("ModuleSaBuildOptions", xPath
);
327 if (returns
== null || returns
.length
== 0) {
330 ModuleSaBuildOptionsDocument
.ModuleSaBuildOptions item
= (ModuleSaBuildOptionsDocument
.ModuleSaBuildOptions
)returns
[0];
331 return item
.getFfsFormatKey();
334 public static String
getModuleFvBindingKeyword() {
335 String
[] xPath
= new String
[] { "/" };
337 Object
[] returns
= get("ModuleSaBuildOptions", xPath
);
338 if (returns
== null || returns
.length
== 0) {
341 ModuleSaBuildOptionsDocument
.ModuleSaBuildOptions item
= (ModuleSaBuildOptionsDocument
.ModuleSaBuildOptions
)returns
[0];
342 return item
.getFvBinding();
345 public static List
getModuleSupportedArchs() {
346 String
[] xPath
= new String
[] { "/" };
348 Object
[] returns
= get("ModuleDefinitions", xPath
);
349 if (returns
== null || returns
.length
== 0) {
352 ModuleDefinitionsDocument
.ModuleDefinitions item
= (ModuleDefinitionsDocument
.ModuleDefinitions
)returns
[0];
353 return item
.getSupportedArchitectures();
356 public static BuildOptionsDocument
.BuildOptions
.Ffs
[] getFpdFfs() {
357 String
[] xPath
= new String
[] {"/Ffs"};
359 Object
[] returns
= get("BuildOptions", xPath
);
360 if (returns
== null || returns
.length
== 0) {
361 return new BuildOptionsDocument
.BuildOptions
.Ffs
[0];
363 return (BuildOptionsDocument
.BuildOptions
.Ffs
[])returns
;
366 public static String
getModuleOutputFileBasename() {
367 String
[] xPath
= new String
[] { "/" };
369 Object
[] returns
= get("ModuleDefinitions", xPath
);
370 if (returns
== null || returns
.length
== 0) {
373 ModuleDefinitionsDocument
.ModuleDefinitions item
= (ModuleDefinitionsDocument
.ModuleDefinitions
)returns
[0];
374 return item
.getOutputFileBasename();
378 * Retrieve BuildOptions/Option or Arch/Option
380 * @param toolChainFamilyFlag
381 * if true, retrieve options for toolchain family; otherwise for
384 * @returns String[][5] name, target, toolchain, arch, coommand of options
385 * if elements are found at the known xpath. String[0][] if dont
388 * @returns Empty array if nothing is there
390 public static String
[][] getOptions(String from
, String
[] xPath
, boolean toolChainFamilyFlag
) {
391 String target
= null;
392 String toolchain
= null;
393 String toolchainFamily
= null;
394 List
<String
> archList
= null;
396 String targetName
= null;
397 String optionName
= null;
399 Object
[] returns
= get(from
, xPath
);
400 if (returns
== null) {
401 return new String
[0][5];
404 List
<String
[]> optionList
= new ArrayList
<String
[]>();
405 OptionDocument
.Option option
;
407 for (int i
= 0; i
< returns
.length
; i
++) {
408 option
= (OptionDocument
.Option
) returns
[i
];
411 // Get Target, ToolChain(Family), Arch, Cmd, and Option from Option,
413 // put to result[][5] array in above order.
416 if (option
.getBuildTargets() == null) {
420 target
= option
.getBuildTargets().toString();
422 if (target
!= null) {
423 targetList
= target
.split(" ");
425 targetList
= new String
[1];
426 targetList
[0] = null;
429 if (toolChainFamilyFlag
) {
430 toolchainFamily
= option
.getToolChainFamily();
431 if (toolchainFamily
!= null) {
432 toolchain
= toolchainFamily
.toString();
437 toolchain
= option
.getTagName();
440 archList
= new ArrayList
<String
>();
441 List
<String
> archEnumList
= option
.getSupArchList();
442 if (archEnumList
== null) {
445 archList
.addAll(archEnumList
);
447 Iterator it = archEnumList.iterator();
448 while (it.hasNext()) {
449 System.out.println(it.next().getClass().getName());
450 SupportedArchitectures.Enum archType = it.next();
451 archList.add(archType.toString());
456 cmd
= option
.getToolCode();
458 optionName
= option
.getStringValue();
459 for (int t
= 0; t
< targetList
.length
; t
++) {
460 for (int j
= 0; j
< archList
.size(); j
++) {
461 optionList
.add(new String
[] { targetList
[t
],
462 toolchain
, archList
.get(j
), cmd
, optionName
});
467 String
[][] result
= new String
[optionList
.size()][5];
468 for (int i
= 0; i
< optionList
.size(); i
++) {
469 result
[i
][0] = optionList
.get(i
)[0];
470 result
[i
][1] = optionList
.get(i
)[1];
471 result
[i
][2] = optionList
.get(i
)[2];
472 result
[i
][3] = optionList
.get(i
)[3];
473 result
[i
][4] = optionList
.get(i
)[4];
478 public static String
[][] getModuleBuildOptions(boolean toolChainFamilyFlag
) {
481 if (toolChainFamilyFlag
== true) {
482 xPath
= new String
[] {
483 "/Options/Option[not(@ToolChainFamily) and not(@TagName)]",
484 "/Options/Option[@ToolChainFamily]", };
486 xPath
= new String
[] {
487 "/Options/Option[not(@ToolChainFamily) and not(@TagName)]",
488 "/Options/Option[@TagName]", };
490 return getOptions("ModuleSaBuildOptions", xPath
, toolChainFamilyFlag
);
493 public static String
[][] getPlatformBuildOptions(boolean toolChainFamilyFlag
) {
496 if (toolChainFamilyFlag
== true) {
497 xPath
= new String
[] {
498 "/BuildOptions/Options/Option[not(@ToolChainFamily) and not(@TagName)]",
499 "/BuildOptions/Options/Option[@ToolChainFamily]", };
501 xPath
= new String
[] {
502 "/BuildOptions/Options/Option[not(@ToolChainFamily) and not(@TagName)]",
503 "/BuildOptions/Options/Option[@TagName]", };
506 return getOptions("PlatformSurfaceArea", xPath
, toolChainFamilyFlag
);
509 public static ToolChainInfo
getFpdToolChainInfo() {
510 String
[] xPath
= new String
[] { "/PlatformDefinitions" };
512 Object
[] returns
= get("PlatformSurfaceArea", xPath
);
513 if (returns
== null || returns
.length
== 0) {
517 PlatformDefinitionsDocument
.PlatformDefinitions item
= (PlatformDefinitionsDocument
.PlatformDefinitions
)returns
[0];
518 ToolChainInfo toolChainInfo
= new ToolChainInfo();
519 toolChainInfo
.addTargets(item
.getBuildTargets().toString());
520 toolChainInfo
.addArchs(item
.getSupportedArchitectures().toString());
521 toolChainInfo
.addTagnames((String
)null);
522 return toolChainInfo
;
526 * Retrieve <xxxHeader>/ModuleType
528 * @returns The module type name if elements are found at the known xpath
529 * @returns null if nothing is there
531 public static String
getModuleType() {
532 String
[] xPath
= new String
[] { "/ModuleType" };
534 Object
[] returns
= get(xPath
);
535 if (returns
!= null && returns
.length
> 0) {
536 ModuleTypeDef type
= (ModuleTypeDef
) returns
[0];
537 return type
.enumValue().toString();
544 * Retrieve PackageDependencies/Package
549 * @returns package name list if elements are found at the known xpath
550 * @returns null if nothing is there
552 public static PackageIdentification
[] getDependencePkg(String arch
) {
554 String packageGuid
= null;
555 String packageVersion
= null;
557 if (arch
== null || arch
.equals("")) {
558 xPath
= new String
[] { "/Package" };
560 xPath
= new String
[] { "/Package[not(@SupArchList) or @SupArchList='"
564 Object
[] returns
= get("PackageDependencies", xPath
);
565 if (returns
== null) {
566 return new PackageIdentification
[0];
568 PackageIdentification
[] packageIdList
= new PackageIdentification
[returns
.length
];
569 for (int i
= 0; i
< returns
.length
; i
++) {
570 PackageDependenciesDocument
.PackageDependencies
.Package item
= (PackageDependenciesDocument
.PackageDependencies
.Package
) returns
[i
];
571 packageGuid
= item
.getPackageGuid();
572 packageVersion
= item
.getPackageVersion();
573 packageIdList
[i
] = (new PackageIdentification(null, packageGuid
,
576 return packageIdList
;
580 * Retrieve LibraryClassDefinitions/LibraryClass for specified usage
583 * Library class usage
585 * @returns LibraryClass objects list if elements are found at the known
587 * @returns null if nothing is there
589 public static String
[] getLibraryClasses(String usage
) {
592 if (usage
== null || usage
.equals("")) {
593 xPath
= new String
[] { "/LibraryClass" };
595 xPath
= new String
[] { "/LibraryClass[@Usage='" + usage
+ "']" };
598 Object
[] returns
= get("LibraryClassDefinitions", xPath
);
599 if (returns
== null || returns
.length
== 0) {
600 return new String
[0];
603 LibraryClassDocument
.LibraryClass
[] libraryClassList
= (LibraryClassDocument
.LibraryClass
[]) returns
;
604 String
[] libraryClassName
= new String
[libraryClassList
.length
];
605 for (int i
= 0; i
< libraryClassList
.length
; i
++) {
606 libraryClassName
[i
] = libraryClassList
[i
].getKeyword();
608 return libraryClassName
;
612 * Retrieve ModuleEntryPoint names
614 * @returns ModuleEntryPoint name list if elements are found at the known
616 * @returns null if nothing is there
618 public static String
[] getModuleEntryPointArray() {
619 String
[] xPath
= new String
[] { "/Extern/ModuleEntryPoint" };
621 Object
[] returns
= get("Externs", xPath
);
623 if (returns
!= null && returns
.length
> 0) {
624 String
[] entryPoints
= new String
[returns
.length
];
626 for (int i
= 0; i
< returns
.length
; ++i
) {
627 entryPoints
[i
] = ((XmlNormalizedString
) returns
[i
])
638 * retrieve Protocol for specified usage
641 * Protocol usage arch Architecture
643 * @returns Protocol String list if elements are found at the known xpath
644 * @returns String[0] if nothing is there
646 public static String
[] getProtocolArray(String arch
, String usage
) {
648 String usageXpath
= "";
649 String archXpath
= "";
651 if (arch
== null || arch
.equals("")) {
652 return new String
[0];
654 archXpath
= "/Protocol[@SupArchList='" + arch
+ "']";
655 if (usage
!= null && !usage
.equals("")) {
656 usageXpath
= "/Protocol[@Usage='" + usage
+ "']";
657 xPath
= new String
[] { usageXpath
, archXpath
};
659 return getProtocolArray(arch
);
664 Object
[] returns
= get("Protocols", xPath
);
665 if (returns
== null) {
666 return new String
[0];
668 Protocol
[] protocolList
= (Protocol
[]) returns
;
670 String
[] protocolArray
= new String
[returns
.length
];
671 for (int i
= 0; i
< returns
.length
; i
++) {
672 protocolArray
[i
] = protocolList
[i
].getProtocolCName();
674 return protocolArray
;
678 * retrieve Protocol for specified usage
683 * @returns Protocol String list if elements are found at the known xpath
684 * @returns String[0] if nothing is there
686 public static String
[] getProtocolArray(String arch
) {
689 if (arch
== null || arch
.equals("")) {
690 return new String
[0];
692 xPath
= new String
[] { "/Protocol[@SupArchList='" + arch
+ "']" };
695 Object
[] returns
= get("Protocols", xPath
);
696 if (returns
== null) {
697 return new String
[0];
699 Protocol
[] protocolList
= (Protocol
[]) returns
;
701 String
[] protocolArray
= new String
[returns
.length
];
702 for (int i
= 0; i
< returns
.length
; i
++) {
703 protocolArray
[i
] = protocolList
[i
].getProtocolCName();
705 return protocolArray
;
709 * Retrieve ProtocolNotify for specified usage
712 * ProtocolNotify usage
714 * @returns String[] if elements are found at the known xpath
715 * @returns String[0] if nothing is there
717 public static String
[] getProtocolNotifyArray(String arch
) {
720 if (arch
== null || arch
.equals("")) {
721 return new String
[0];
723 xPath
= new String
[] { "/ProtocolNotify[@SupArchList='" + arch
727 Object
[] returns
= get("Protocols", xPath
);
728 if (returns
== null) {
729 return new String
[0];
732 String
[] protocolNotifyList
= new String
[returns
.length
];
733 for (int i
= 0; i
< returns
.length
; i
++) {
734 protocolNotifyList
[i
] = ((ProtocolNotify
) returns
[i
]).getProtocolNotifyCName();
737 return protocolNotifyList
;
741 * Retrieve ProtocolNotify for specified usage
744 * ProtocolNotify usage
746 * @returns String[] if elements are found at the known xpath
747 * @returns String[0] if nothing is there
749 public static String
[] getProtocolNotifyArray(String arch
, String usage
) {
755 if (arch
== null || arch
.equals("")) {
756 return new String
[0];
758 archXpath
= "/ProtocolNotify[@SupArchList='" + arch
+ "']";
759 if (usage
!= null && !usage
.equals("")) {
760 usageXpath
= "/ProtocolNotify[@Usage='" + arch
+ "']";
761 xPath
= new String
[] { archXpath
, usageXpath
};
763 return getProtocolNotifyArray(arch
);
767 Object
[] returns
= get("Protocols", xPath
);
768 if (returns
== null) {
769 return new String
[0];
772 String
[] protocolNotifyList
= new String
[returns
.length
];
774 for (int i
= 0; i
< returns
.length
; i
++) {
775 protocolNotifyList
[i
] = ((ProtocolNotify
) returns
[i
]).getProtocolNotifyCName();
777 return protocolNotifyList
;
781 * Retrieve ModuleUnloadImage names
783 * @returns ModuleUnloadImage name list if elements are found at the known
785 * @returns null if nothing is there
787 public static String
[] getModuleUnloadImageArray() {
788 String
[] xPath
= new String
[] { "/Extern/ModuleUnloadImage" };
790 Object
[] returns
= get("Externs", xPath
);
791 if (returns
!= null && returns
.length
> 0) {
792 String
[] stringArray
= new String
[returns
.length
];
793 XmlNormalizedString
[] doc
= (XmlNormalizedString
[]) returns
;
795 for (int i
= 0; i
< returns
.length
; ++i
) {
796 stringArray
[i
] = doc
[i
].getStringValue();
808 * @returns Extern objects list if elements are found at the known xpath
809 * @returns null if nothing is there
811 public static ExternsDocument
.Externs
.Extern
[] getExternArray() {
812 String
[] xPath
= new String
[] { "/Extern" };
814 Object
[] returns
= get("Externs", xPath
);
815 if (returns
!= null && returns
.length
> 0) {
816 return (ExternsDocument
.Externs
.Extern
[]) returns
;
823 * Retrieve PpiNotify for specified arch
828 * @returns String[] if elements are found at the known xpath
829 * @returns String[0] if nothing is there
831 public static String
[] getPpiNotifyArray(String arch
) {
834 if (arch
== null || arch
.equals("")) {
835 return new String
[0];
837 xPath
= new String
[] { "/PpiNotify[@SupArchList='" + arch
+ "']" };
840 Object
[] returns
= get("PPIs", xPath
);
841 if (returns
== null) {
842 return new String
[0];
845 String
[] ppiNotifyList
= new String
[returns
.length
];
846 for (int i
= 0; i
< returns
.length
; i
++) {
847 ppiNotifyList
[i
] = ((PPIsDocument
.PPIs
.PpiNotify
) returns
[i
]).getPpiNotifyCName();
850 return ppiNotifyList
;
854 * Retrieve PpiNotify for specified usage and arch
857 * PpiNotify arch usage PpiNotify usage
860 * @returns String[] if elements are found at the known xpath
861 * @returns String[0] if nothing is there
863 public static String
[] getPpiNotifyArray(String arch
, String usage
) {
869 if (arch
== null || arch
.equals("")) {
870 return new String
[0];
872 archXpath
= "/PpiNotify[@SupArchList='" + arch
+ "']";
873 if (usage
!= null && !usage
.equals("")) {
874 usageXpath
= "/PpiNotify[@Usage='" + arch
+ "']";
875 xPath
= new String
[] { archXpath
, usageXpath
};
877 return getProtocolNotifyArray(arch
);
881 Object
[] returns
= get("PPIs", xPath
);
882 if (returns
== null) {
883 return new String
[0];
886 String
[] ppiNotifyList
= new String
[returns
.length
];
888 for (int i
= 0; i
< returns
.length
; i
++) {
889 ppiNotifyList
[i
] = ((PPIsDocument
.PPIs
.PpiNotify
) returns
[i
]).getPpiNotifyCName();
891 return ppiNotifyList
;
895 * Retrieve Ppi for specified arch
900 * @returns String[] if elements are found at the known xpath
901 * @returns String[0] if nothing is there
903 public static String
[] getPpiArray(String arch
) {
906 if (arch
== null || arch
.equals("")) {
907 return new String
[0];
909 xPath
= new String
[] { "/Ppi[@SupArchList='" + arch
+ "']" };
912 Object
[] returns
= get("PPIs", xPath
);
913 if (returns
== null) {
914 return new String
[0];
917 String
[] ppiList
= new String
[returns
.length
];
918 for (int i
= 0; i
< returns
.length
; i
++) {
919 ppiList
[i
] = ((PPIsDocument
.PPIs
.Ppi
) returns
[i
]).getPpiCName();
925 * Retrieve PpiNotify for specified usage and arch
928 * PpiNotify arch usage PpiNotify usage
931 * @returns String[] if elements are found at the known xpath
932 * @returns String[0] if nothing is there
934 public static String
[] getPpiArray(String arch
, String usage
) {
940 if (arch
== null || arch
.equals("")) {
941 return new String
[0];
943 archXpath
= "/Ppi[@SupArchList='" + arch
+ "']";
944 if (usage
!= null && !usage
.equals("")) {
945 usageXpath
= "/Ppi[@Usage='" + arch
+ "']";
946 xPath
= new String
[] { archXpath
, usageXpath
};
948 return getProtocolNotifyArray(arch
);
952 Object
[] returns
= get("PPIs", xPath
);
953 if (returns
== null) {
954 return new String
[0];
957 String
[] ppiList
= new String
[returns
.length
];
959 for (int i
= 0; i
< returns
.length
; i
++) {
960 ppiList
[i
] = ((PPIsDocument
.PPIs
.Ppi
) returns
[i
]).getPpiCName();
966 * Retrieve GuidEntry information for specified usage
971 * @returns GuidEntry objects list if elements are found at the known xpath
972 * @returns null if nothing is there
974 public static String
[] getGuidEntryArray(String arch
) {
977 if (arch
== null || arch
.equals("")) {
978 xPath
= new String
[] { "/GuidName" };
980 xPath
= new String
[] { "/GuidName[@SupArchList='" + arch
+ "']" };
983 Object
[] returns
= get("Guids", xPath
);
984 if (returns
== null) {
985 return new String
[0];
987 String
[] guidList
= new String
[returns
.length
];
988 for (int i
= 0; i
< returns
.length
; i
++) {
989 guidList
[i
] = ((GuidsDocument
.Guids
.GuidCNames
) returns
[i
]).getGuidCName();
996 * Retrieve GuidEntry information for specified usage
999 * GuidEntry arch usage GuidEntry usage
1001 * @returns GuidEntry objects list if elements are found at the known xpath
1002 * @returns null if nothing is there
1004 public static String
[] getGuidEntryArray(String arch
, String usage
) {
1009 if (arch
== null || arch
.equals("")) {
1010 return new String
[0];
1012 archXpath
= "/GuidEntry[@SupArchList='" + arch
+ "']";
1013 if (usage
!= null && !usage
.equals("")) {
1014 usageXpath
= "/GuidEntry[@Usage='" + arch
+ "']";
1015 xPath
= new String
[] { archXpath
, usageXpath
};
1017 return getProtocolNotifyArray(arch
);
1021 Object
[] returns
= get("Guids", xPath
);
1022 if (returns
== null) {
1023 return new String
[0];
1026 String
[] guidList
= new String
[returns
.length
];
1028 for (int i
= 0; i
< returns
.length
; i
++) {
1029 guidList
[i
] = ((GuidsDocument
.Guids
.GuidCNames
) returns
[i
]).getGuidCName();
1035 * Retrieve Library instance information
1040 * Library instance usage
1042 * @returns library instance name list if elements are found at the known
1044 * @returns null if nothing is there
1046 public static ModuleIdentification
[] getLibraryInstance(String arch
) {
1048 String saGuid
= null;
1049 String saVersion
= null;
1050 String pkgGuid
= null;
1051 String pkgVersion
= null;
1053 if (arch
== null || arch
.equalsIgnoreCase("")) {
1054 xPath
= new String
[] { "/Instance" };
1056 xPath
= new String
[] { "/Instance[not(@SupArchList) or @SupArchList='"
1060 Object
[] returns
= get("Libraries", xPath
);
1061 if (returns
== null || returns
.length
== 0) {
1062 return new ModuleIdentification
[0];
1065 ModuleIdentification
[] saIdList
= new ModuleIdentification
[returns
.length
];
1066 for (int i
= 0; i
< returns
.length
; i
++) {
1067 LibrariesDocument
.Libraries
.Instance library
= (LibrariesDocument
.Libraries
.Instance
) returns
[i
];
1068 saGuid
= library
.getModuleGuid();
1069 saVersion
= library
.getModuleVersion();
1071 pkgGuid
= library
.getPackageGuid();
1072 pkgVersion
= library
.getPackageVersion();
1074 ModuleIdentification saId
= new ModuleIdentification(null, saGuid
,
1076 PackageIdentification pkgId
= new PackageIdentification(null,
1077 pkgGuid
, pkgVersion
);
1078 saId
.setPackage(pkgId
);
1087 // / This method is used for retrieving the elements information which has
1088 // / CName sub-element
1090 private static String
[] getCNames(String from
, String xPath
[]) {
1091 Object
[] returns
= get(from
, xPath
);
1092 if (returns
== null || returns
.length
== 0) {
1096 String
[] strings
= new String
[returns
.length
];
1097 for (int i
= 0; i
< returns
.length
; ++i
) {
1099 // strings[i] = ((CName) returns[i]).getStringValue();
1106 * Retrive library's constructor name
1108 * @returns constructor name list if elements are found at the known xpath
1109 * @returns null if nothing is there
1111 public static String
getLibConstructorName() {
1112 String
[] xPath
= new String
[] { "/Extern/Constructor" };
1114 Object
[] returns
= get("Externs", xPath
);
1115 if (returns
!= null && returns
.length
> 0) {
1116 // CName constructor = (CName) returns[0];
1117 // return constructor.getStringValue();
1124 * Retrive library's destructor name
1126 * @returns destructor name list if elements are found at the known xpath
1127 * @returns null if nothing is there
1129 public static String
getLibDestructorName() {
1130 String
[] xPath
= new String
[] { "/Extern/Destructor" };
1132 Object
[] returns
= get("Externs", xPath
);
1133 if (returns
!= null && returns
.length
> 0) {
1134 // CName destructor = (CName) returns[0];
1135 // return destructor.getStringValue();
1142 * Retrive DriverBinding names
1144 * @returns DriverBinding name list if elements are found at the known xpath
1145 * @returns null if nothing is there
1147 public static String
[] getDriverBindingArray() {
1148 String
[] xPath
= new String
[] { "/Extern/DriverBinding" };
1149 return getCNames("Externs", xPath
);
1153 * Retrive ComponentName names
1155 * @returns ComponentName name list if elements are found at the known xpath
1156 * @returns null if nothing is there
1158 public static String
[] getComponentNameArray() {
1159 String
[] xPath
= new String
[] { "/Extern/ComponentName" };
1160 return getCNames("Externs", xPath
);
1164 * Retrive DriverConfig names
1166 * @returns DriverConfig name list if elements are found at the known xpath
1167 * @returns null if nothing is there
1169 public static String
[] getDriverConfigArray() {
1170 String
[] xPath
= new String
[] { "/Extern/DriverConfig" };
1171 return getCNames("Externs", xPath
);
1175 * Retrive DriverDiag names
1177 * @returns DriverDiag name list if elements are found at the known xpath
1178 * @returns null if nothing is there
1180 public static String
[] getDriverDiagArray() {
1181 String
[] xPath
= new String
[] { "/Extern/DriverDiag" };
1182 return getCNames("Externs", xPath
);
1186 * Retrive SetVirtualAddressMapCallBack names
1188 * @returns SetVirtualAddressMapCallBack name list if elements are found at
1190 * @returns null if nothing is there
1192 public static String
[] getSetVirtualAddressMapCallBackArray() {
1193 String
[] xPath
= new String
[] { "/Extern/SetVirtualAddressMapCallBack" };
1194 return getCNames("Externs", xPath
);
1198 * Retrive ExitBootServicesCallBack names
1200 * @returns ExitBootServicesCallBack name list if elements are found at the
1202 * @returns null if nothing is there
1204 public static String
[] getExitBootServicesCallBackArray() {
1205 String
[] xPath
= new String
[] { "/Extern/ExitBootServicesCallBack" };
1206 return getCNames("Externs", xPath
);
1210 * Retrieve module surface area file information
1212 * @returns ModuleSA objects list if elements are found at the known xpath
1213 * @returns Empty ModuleSA list if nothing is there
1215 public static Map
<FpdModuleIdentification
, Map
<String
, XmlObject
>> getFpdModules() {
1216 String
[] xPath
= new String
[] { "/FrameworkModules/ModuleSA" };
1217 Object
[] result
= get("PlatformSurfaceArea", xPath
);
1219 String fvBinding
= null;
1220 String saGuid
= null;
1221 String saVersion
= null;
1222 String pkgGuid
= null;
1223 String pkgVersion
= null;
1225 Map
<FpdModuleIdentification
, Map
<String
, XmlObject
>> fpdModuleMap
= new LinkedHashMap
<FpdModuleIdentification
, Map
<String
, XmlObject
>>();
1227 if (result
== null) {
1228 return fpdModuleMap
;
1231 for (int i
= 0; i
< result
.length
; i
++) {
1233 // Get Fpd SA Module element node and add to ObjectMap.
1235 Map
<String
, XmlObject
> ObjectMap
= new HashMap
<String
, XmlObject
>();
1236 ModuleSADocument
.ModuleSA moduleSA
= (ModuleSADocument
.ModuleSA
) result
[i
];
1237 if (((ModuleSADocument
.ModuleSA
) result
[i
]).getLibraries() != null) {
1238 ObjectMap
.put("Libraries", moduleSA
.getLibraries());
1240 if (((ModuleSADocument
.ModuleSA
) result
[i
]).getPcdBuildDefinition() != null) {
1241 ObjectMap
.put("PcdBuildDefinition", moduleSA
1242 .getPcdBuildDefinition());
1244 if (((ModuleSADocument
.ModuleSA
) result
[i
])
1245 .getModuleSaBuildOptions() != null) {
1246 ObjectMap
.put("ModuleSaBuildOptions", moduleSA
1247 .getModuleSaBuildOptions());
1251 // Get Fpd SA Module attribute and create FpdMoudleIdentification.
1253 arch
= moduleSA
.getSupArchList().toString();
1257 saVersion
= ((ModuleSADocument
.ModuleSA
) result
[i
])
1258 .getModuleVersion();
1260 saGuid
= moduleSA
.getModuleGuid();
1261 pkgGuid
= moduleSA
.getPackageGuid();
1262 pkgVersion
= moduleSA
.getPackageVersion();
1265 // Create Module Identification which have class member of package
1268 PackageIdentification pkgId
= new PackageIdentification(null,
1269 pkgGuid
, pkgVersion
);
1270 ModuleIdentification saId
= new ModuleIdentification(null, saGuid
,
1273 saId
.setPackage(pkgId
);
1276 // Create FpdModule Identification which have class member of module
1280 String
[] archList
= arch
.split(" ");
1281 for (int j
= 0; j
< archList
.length
; j
++) {
1282 FpdModuleIdentification fpdSaId
= new FpdModuleIdentification(saId
, archList
[j
]);
1284 if (fvBinding
!= null) {
1285 fpdSaId
.setFvBinding(fvBinding
);
1289 // Put element to Map<FpdModuleIdentification, Map<String,
1292 fpdModuleMap
.put(fpdSaId
, ObjectMap
);
1296 return fpdModuleMap
;
1300 * Retrieve valid image names
1302 * @returns valid iamges name list if elements are found at the known xpath
1303 * @returns empty list if nothing is there
1305 public static String
[] getFpdValidImageNames() {
1306 String
[] xPath
= new String
[] { "/Flash/FvImages/FvImage[@Type='ImageName']/FvImageNames" };
1308 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1309 if (queryResult
== null) {
1310 return new String
[0];
1313 String
[] result
= new String
[queryResult
.length
];
1314 for (int i
= 0; i
< queryResult
.length
; i
++) {
1315 result
[i
] = ((XmlString
) queryResult
[i
]).getStringValue();
1321 public static XmlObject
getFpdUserExtension() {
1322 String
[] xPath
= new String
[] { "" };
1324 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1325 if (queryResult
== null) {
1332 * Retrieve FV image option information
1337 * @returns option name/value list if elements are found at the known xpath
1338 * @returns empty list if nothing is there
1340 public static String
[][] getFpdOptions(String fvName
) {
1341 String
[] xPath
= new String
[] { "/Flash/FvImages/FvImage[@Type='Options' and ./FvImageNames='"
1342 + fvName
.toUpperCase() + "']/FvImageOptions" };
1343 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1344 if (queryResult
== null) {
1345 return new String
[0][];
1347 ArrayList
<String
[]> list
= new ArrayList
<String
[]>();
1348 for (int i
= 0; i
< queryResult
.length
; i
++) {
1349 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions item
= (FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
) queryResult
[i
];
1350 List
<FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
> namevalues
= item
1351 .getNameValueList();
1352 Iterator iter
= namevalues
.iterator();
1353 while (iter
.hasNext()) {
1354 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nvItem
= (FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
) iter
1356 list
.add(new String
[] { nvItem
.getName(), nvItem
.getValue() });
1359 String
[][] result
= new String
[list
.size()][2];
1360 for (int i
= 0; i
< list
.size(); i
++) {
1361 result
[i
][0] = list
.get(i
)[0];
1362 result
[i
][1] = list
.get(i
)[1];
1368 public static XmlObject
getFpdBuildOptions() {
1369 String
[] xPath
= new String
[] { "/BuildOptions" };
1371 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1373 if (queryResult
== null || queryResult
.length
== 0) {
1376 return (XmlObject
)queryResult
[0];
1379 public static PlatformIdentification
getFpdHeader() {
1380 String
[] xPath
= new String
[] { "/PlatformHeader" };
1382 Object
[] returns
= get("PlatformSurfaceArea", xPath
);
1384 if (returns
== null || returns
.length
== 0) {
1387 PlatformHeaderDocument
.PlatformHeader header
= (PlatformHeaderDocument
.PlatformHeader
) returns
[0];
1389 String name
= header
.getPlatformName();
1391 String guid
= header
.getGuidValue();
1393 String version
= header
.getVersion();
1395 return new PlatformIdentification(name
, guid
, version
);
1399 * Retrieve FV image attributes information
1404 * @returns attribute name/value list if elements are found at the known
1406 * @returns empty list if nothing is there
1408 public static String
[][] getFpdAttributes(String fvName
) {
1409 String
[] xPath
= new String
[] { "/Flash/FvImages/FvImage[@Type='Attributes' and ./FvImageNames='"
1410 + fvName
.toUpperCase() + "']/FvImageOptions" };
1411 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1412 if (queryResult
== null) {
1413 return new String
[0][];
1415 ArrayList
<String
[]> list
= new ArrayList
<String
[]>();
1416 for (int i
= 0; i
< queryResult
.length
; i
++) {
1418 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions item
= (FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
) queryResult
[i
];
1419 List
<FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
> namevalues
= item
.getNameValueList();
1420 Iterator iter
= namevalues
.iterator();
1421 while (iter
.hasNext()) {
1422 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nvItem
= (FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
) iter
1424 list
.add(new String
[] { nvItem
.getName(), nvItem
.getValue() });
1427 String
[][] result
= new String
[list
.size()][2];
1428 for (int i
= 0; i
< list
.size(); i
++) {
1429 result
[i
][0] = list
.get(i
)[0];
1430 result
[i
][1] = list
.get(i
)[1];
1436 * Retrieve flash definition file name
1438 * @returns file name if elements are found at the known xpath
1439 * @returns null if nothing is there
1441 public static String
getFlashDefinitionFile() {
1442 String
[] xPath
= new String
[] { "/PlatformDefinitions/FlashDeviceDefinitions/FlashDefinitionFile" };
1444 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1445 if (queryResult
== null || queryResult
.length
== 0) {
1449 FileNameConvention filename
= (FileNameConvention
) queryResult
[queryResult
.length
- 1];
1450 return filename
.getStringValue();
1453 public static String
[][] getFpdGlobalVariable() {
1454 String
[] xPath
= new String
[] { "/Flash/FvImages/NameValue" };
1455 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1456 if (queryResult
== null) {
1457 return new String
[0][];
1460 String
[][] result
= new String
[queryResult
.length
][2];
1462 for (int i
= 0; i
< queryResult
.length
; i
++) {
1463 FvImagesDocument
.FvImages
.NameValue item
= (FvImagesDocument
.FvImages
.NameValue
)queryResult
[i
];
1464 result
[i
][0] = item
.getName();
1465 result
[i
][1] = item
.getValue();
1471 * Retrieve FV image component options
1476 * @returns name/value pairs list if elements are found at the known xpath
1477 * @returns empty list if nothing is there
1479 public static String
[][] getFpdComponents(String fvName
) {
1480 String
[] xPath
= new String
[] { "/Flash/FvImages/FvImage[@Type='Components' and ./FvImageNames='"+ fvName
.toUpperCase() + "']/FvImageOptions" };
1481 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1482 if (queryResult
== null) {
1483 return new String
[0][];
1486 ArrayList
<String
[]> list
= new ArrayList
<String
[]>();
1487 for (int i
= 0; i
< queryResult
.length
; i
++) {
1488 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions item
= (FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
) queryResult
[i
];
1489 List
<FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
> namevalues
= item
.getNameValueList();
1490 Iterator iter
= namevalues
.iterator();
1491 while (iter
.hasNext()) {
1492 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nvItem
= (FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
) iter
1494 list
.add(new String
[] { nvItem
.getName(), nvItem
.getValue() });
1497 String
[][] result
= new String
[list
.size()][2];
1498 for (int i
= 0; i
< list
.size(); i
++) {
1499 result
[i
][0] = list
.get(i
)[0];
1500 result
[i
][1] = list
.get(i
)[1];
1506 * Retrieve PCD tokens
1508 * @returns CName/ItemType pairs list if elements are found at the known
1510 * @returns null if nothing is there
1512 public static String
[][] getPcdTokenArray() {
1513 String
[] xPath
= new String
[] { "/PcdData" };
1515 Object
[] returns
= get("PCDs", xPath
);
1516 if (returns
== null || returns
.length
== 0) {
1520 // PcdCoded.PcdData[] pcds = (PcdCoded.PcdData[]) returns;
1521 // String[][] result = new String[pcds.length][2];
1522 // for (int i = 0; i < returns.length; ++i) {
1523 // if (pcds[i].getItemType() != null) {
1524 // result[i][1] = pcds[i].getItemType().toString();
1526 // result[i][1] = null;
1528 // result[i][0] = pcds[i].getCName();
1535 * Get the PcdToken array from module's surface area document. The array
1536 * should contains following data:
1538 * -------------------------------------------------------------------
1541 * CName | ItemType | TokenspaceName | DefaultValue | Usage | HelpText
1544 * -------------------------------------------------------------------
1547 * Note: Until new schema applying, now we can only get CName, ItemType,
1550 * @return 2-array table contains all information of PCD token retrieved
1553 public static Object
[][] etModulePCDTokenArray() {
1556 // Object[][] result;
1557 // PCDs.PcdData[] pcds;
1558 // String[] xPath = new String[] { "/PcdData" };
1559 // Object[] returns = get("PCDs", xPath);
1561 // if ((returns == null) || (returns.length == 0)) {
1565 // pcds = (PCDs.PcdData[]) returns;
1566 // result = new Object[pcds.length][6];
1567 // for (index = 0; index < pcds.length; index++) {
1571 // result[index][0] = pcds[index].getCName();
1573 // // Get ItemType: FEATURE_FLAG, FIXED_AT_BUILD, PATCHABLE_IN_MODLE,
1574 // // DYNAMIC, DYNAMIC_EX
1576 // if (pcds[index].getItemType() != null) {
1577 // result[index][1] = pcds[index].getItemType().toString();
1579 // result[index][1] = null;
1583 // // BUGBUG: following field can *not* be got from current MSA until
1584 // // schema changed.
1586 // // result [index][2] = pcds[index].getTokenSpaceName();
1587 // result[index][2] = null;
1588 // result[index][3] = pcds[index].getDefaultValue();
1589 // // result [index][4] = pcds[index].getUsage ();
1590 // result[index][4] = null;
1591 // // result [index][5] = pcds[index].getHelpText ();
1592 // result[index][5] = null;
1598 * Retrieve MAS header
1603 public static ModuleIdentification
getMsaHeader() {
1604 String
[] xPath
= new String
[] { "/" };
1605 Object
[] returns
= get("MsaHeader", xPath
);
1607 if (returns
== null || returns
.length
== 0) {
1611 MsaHeader msaHeader
= (MsaHeader
) returns
[0];
1613 // Get BaseName, ModuleType, GuidValue, Version
1614 // which in MsaHeader.
1616 String name
= msaHeader
.getModuleName();
1617 String moduleType
= msaHeader
.getModuleType().toString();
1618 String guid
= msaHeader
.getGuidValue();
1619 String version
= msaHeader
.getVersion();
1621 ModuleIdentification moduleId
= new ModuleIdentification(name
, guid
,
1624 moduleId
.setModuleType(moduleType
);
1630 * Retrieve Extern Specification
1634 * @return String[] If have specification element in the <extern> String[0]
1635 * If no specification element in the <extern>
1639 public static String
[] getExternSpecificaiton() {
1640 String
[] xPath
= new String
[] { "/Specification" };
1642 Object
[] queryResult
= get("Externs", xPath
);
1643 if (queryResult
== null) {
1644 return new String
[0];
1647 String
[] specificationList
= new String
[queryResult
.length
];
1648 for (int i
= 0; i
< queryResult
.length
; i
++) {
1649 // specificationList[i] = ((SpecificationDocument.Specification)
1651 // .getStringValue();
1653 return specificationList
;
1657 * Retreive MsaFile which in SPD
1660 * @return String[][3] The string sequence is ModuleName, ModuleGuid,
1661 * ModuleVersion, MsaFile String[0][] If no msafile in SPD
1663 public static String
[] getSpdMsaFile() {
1664 String
[] xPath
= new String
[] { "/MsaFiles" };
1666 Object
[] returns
= get("PackageSurfaceArea", xPath
);
1667 if (returns
== null) {
1668 return new String
[0];
1671 List
<String
> filenameList
= ((MsaFilesDocument
.MsaFiles
) returns
[0])
1673 return filenameList
.toArray(new String
[filenameList
.size()]);
1679 public static Map
<String
, String
[]> getSpdLibraryClasses() {
1680 String
[] xPath
= new String
[] { "/LibraryClassDeclarations/LibraryClass" };
1682 Object
[] returns
= get("PackageSurfaceArea", xPath
);
1685 // Create Map, Key - LibraryClass, String[] - LibraryClass Header file.
1687 Map
<String
, String
[]> libClassHeaderMap
= new HashMap
<String
, String
[]>();
1689 if (returns
== null) {
1690 return libClassHeaderMap
;
1693 for (int i
= 0; i
< returns
.length
; i
++) {
1694 LibraryClassDeclarationsDocument
.LibraryClassDeclarations
.LibraryClass library
= (LibraryClassDeclarationsDocument
.LibraryClassDeclarations
.LibraryClass
) returns
[i
];
1695 libClassHeaderMap
.put(library
.getName(), new String
[] { library
1696 .getIncludeHeader() });
1698 return libClassHeaderMap
;
1704 public static Map
<String
, String
> getSpdPackageHeaderFiles() {
1705 String
[] xPath
= new String
[] { "/PackageHeaders/IncludePkgHeader" };
1707 Object
[] returns
= get("PackageSurfaceArea", xPath
);
1710 // Create Map, Key - ModuleType, String - PackageInclude Header file.
1712 Map
<String
, String
> packageIncludeMap
= new HashMap
<String
, String
>();
1714 if (returns
== null) {
1715 return packageIncludeMap
;
1717 // GlobalData.log.info("" + returns[0].getClass().getName());
1718 for (int i
= 0; i
< returns
.length
; i
++) {
1719 PackageHeadersDocument
.PackageHeaders
.IncludePkgHeader includeHeader
= (PackageHeadersDocument
.PackageHeaders
.IncludePkgHeader
) returns
[i
];
1720 packageIncludeMap
.put(includeHeader
.getModuleType().toString(),
1721 includeHeader
.getStringValue());
1723 return packageIncludeMap
;
1726 public static PackageIdentification
getSpdHeader() {
1727 String
[] xPath
= new String
[] { "/SpdHeader" };
1729 Object
[] returns
= get("PackageSurfaceArea", xPath
);
1731 if (returns
== null || returns
.length
== 0) {
1735 SpdHeaderDocument
.SpdHeader header
= (SpdHeaderDocument
.SpdHeader
) returns
[0];
1737 String name
= header
.getPackageName();
1739 String guid
= header
.getGuidValue();
1741 String version
= header
.getVersion();
1743 return new PackageIdentification(name
, guid
, version
);
1749 public static Map
<String
, String
[]> getSpdGuid() {
1750 String
[] xPath
= new String
[] { "/GuidDeclarations/Entry" };
1752 Object
[] returns
= get("PackageSurfaceArea", xPath
);
1755 // Create Map, Key - GuidName, String[] - C_NAME & GUID value.
1757 Map
<String
, String
[]> guidDeclMap
= new HashMap
<String
, String
[]>();
1758 if (returns
== null) {
1762 for (int i
= 0; i
< returns
.length
; i
++) {
1763 GuidDeclarationsDocument
.GuidDeclarations
.Entry entry
= (GuidDeclarationsDocument
.GuidDeclarations
.Entry
) returns
[i
];
1764 String
[] guidPair
= new String
[2];
1765 guidPair
[0] = entry
.getCName();
1766 guidPair
[1] = entry
.getGuidValue();
1767 guidDeclMap
.put(entry
.getName(), guidPair
);
1775 public static Map
<String
, String
[]> getSpdProtocol() {
1776 String
[] xPath
= new String
[] { "/ProtocolDeclarations/Entry" };
1778 Object
[] returns
= get("PackageSurfaceArea", xPath
);
1781 // Create Map, Key - protocolName, String[] - C_NAME & GUID value.
1783 Map
<String
, String
[]> protoclMap
= new HashMap
<String
, String
[]>();
1785 if (returns
== null) {
1789 for (int i
= 0; i
< returns
.length
; i
++) {
1790 ProtocolDeclarationsDocument
.ProtocolDeclarations
.Entry entry
= (ProtocolDeclarationsDocument
.ProtocolDeclarations
.Entry
) returns
[i
];
1791 String
[] protocolPair
= new String
[2];
1793 protocolPair
[0] = entry
.getCName();
1794 protocolPair
[1] = entry
.getGuidValue();
1795 protoclMap
.put(entry
.getName(), protocolPair
);
1801 * getSpdPpi() Retrieve the SPD PPI Entry
1804 * @return Map<String, String[2]> if get the PPI entry from SPD. Key - PPI
1805 * Name String[0] - PPI CNAME String[1] - PPI Guid Null if no PPI
1808 public static Map
<String
, String
[]> getSpdPpi() {
1809 String
[] xPath
= new String
[] { "/PpiDeclarations/Entry" };
1811 Object
[] returns
= get("PackageSurfaceArea", xPath
);
1814 // Create Map, Key - protocolName, String[] - C_NAME & GUID value.
1816 Map
<String
, String
[]> ppiMap
= new HashMap
<String
, String
[]>();
1818 if (returns
== null) {
1822 for (int i
= 0; i
< returns
.length
; i
++) {
1823 PpiDeclarationsDocument
.PpiDeclarations
.Entry entry
= (PpiDeclarationsDocument
.PpiDeclarations
.Entry
) returns
[i
];
1824 String
[] ppiPair
= new String
[2];
1825 ppiPair
[0] = entry
.getCName();
1826 ppiPair
[1] = entry
.getGuidValue();
1827 ppiMap
.put(entry
.getName(), ppiPair
);
1833 * getToolChainFamily
1835 * This function is to retrieve ToolChainFamily attribute of FPD
1839 * @return toolChainFamily If find toolChainFamily attribute in
1840 * <BuildOptions> Null If don't have toolChainFamily in
1843 public String
getToolChainFamily() {
1844 String toolChainFamily
;
1845 String
[] xPath
= new String
[] { "/BuildOptions" };
1847 Object
[] result
= get("PlatformSurfaceArea", xPath
);
1848 if (result
== null) {
1851 // toolChainFamily =
1852 // ((BuildOptionsDocument.BuildOptions)result[0]).getToolChainFamilies();
1853 // return toolChainFamily;
1858 * Retrieve module Guid string
1860 * @returns GUILD string if elements are found at the known xpath
1861 * @returns null if nothing is there
1863 public static String
getModuleGuid() {
1864 String
[] xPath
= new String
[] { "" };
1866 Object
[] returns
= get("MsaHeader", xPath
);
1867 if (returns
!= null && returns
.length
> 0) {
1868 String guid
= ((MsaHeaderDocument
.MsaHeader
) returns
[0])
1879 public static ModuleSADocument
.ModuleSA
[] getFpdModuleSAs() {
1880 String
[] xPath
= new String
[] { "/FrameworkModules/ModuleSA" };
1881 Object
[] result
= get("PlatformSurfaceArea", xPath
);
1882 if (result
!= null) {
1883 return (ModuleSADocument
.ModuleSA
[]) result
;
1885 return new ModuleSADocument
.ModuleSA
[0];