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
.tianocore
.ExternsDocument
.Externs
.Extern
;
27 import org
.apache
.xmlbeans
.XmlObject
;
28 import org
.apache
.xmlbeans
.XmlString
;
29 import org
.tianocore
.*;
30 import org
.tianocore
.FilenameDocument
.Filename
;
31 import org
.tianocore
.MsaHeaderDocument
.MsaHeader
;
32 import org
.tianocore
.ProtocolsDocument
.Protocols
.Protocol
;
33 import org
.tianocore
.ProtocolsDocument
.Protocols
.ProtocolNotify
;
34 import org
.tianocore
.build
.autogen
.CommonDefinition
;
35 import org
.tianocore
.build
.id
.FpdModuleIdentification
;
36 import org
.tianocore
.build
.id
.ModuleIdentification
;
37 import org
.tianocore
.build
.id
.PackageIdentification
;
38 import org
.tianocore
.build
.id
.PlatformIdentification
;
39 import org
.tianocore
.build
.toolchain
.ToolChainInfo
;
40 import org
.tianocore
.common
.exception
.EdkException
;
41 import org
.w3c
.dom
.Node
;
44 * SurfaceAreaQuery class is used to query Surface Area information from msa,
45 * mbd, spd and fpd files.
47 * This class should not instantiated. All the public interfaces is static.
51 public class SurfaceAreaQuery
{
53 public String prefix
= "http://www.TianoCore.org/2006/Edk2.0";
56 // Contains name/value pairs of Surface Area document object. The name is
57 // always the top level element name.
59 private Map
<String
, XmlObject
> map
= null;
62 // mapStack is used to do nested query
64 private Stack
<Map
<String
, XmlObject
>> mapStack
= new Stack
<Map
<String
, XmlObject
>>();
67 // prefix of name space
69 private String nsPrefix
= "sans";
72 // xmlbeans needs a name space for each Xpath element
74 private String ns
= null;
77 // keep the namep declaration for xmlbeans Xpath query
79 private String queryDeclaration
= null;
81 private StringBuffer normQueryString
= new StringBuffer(4096);
82 private Pattern xPathPattern
= Pattern
.compile("([^/]*)(/|//)([^/]+)");
85 * Set a Surface Area document for query later
88 * A Surface Area document in TopLevelElementName/XmlObject
91 public SurfaceAreaQuery(Map
<String
, XmlObject
> map
) {
93 queryDeclaration
= "declare namespace " + nsPrefix
+ "='" + ns
+ "'; ";
98 * Push current used Surface Area document into query stack. The given new
99 * document will be used for any immediately followed getXXX() callings,
100 * untill pop() is called.
103 * The TopLevelElementName/XmlObject format of a Surface Area
106 public void push(Map
<String
, XmlObject
> newMap
) {
107 mapStack
.push(this.map
);
112 * Discard current used Surface Area document and use the top document in
116 this.map
= mapStack
.pop();
120 // / Convert xPath to be namespace qualified, which is necessary for
122 // / selectPath(). For example, converting /MsaHeader/ModuleType to
123 // / /ns:MsaHeader/ns:ModuleType
125 private String
normalizeQueryString(String
[] exp
, String from
) {
126 normQueryString
.setLength(0);
129 while (i
< exp
.length
) {
130 String newExp
= from
+ exp
[i
];
131 Matcher matcher
= xPathPattern
.matcher(newExp
);
133 while (matcher
.find()) {
134 String starter
= newExp
.substring(matcher
.start(1), matcher
136 String seperator
= newExp
.substring(matcher
.start(2), matcher
138 String token
= newExp
.substring(matcher
.start(3), matcher
141 normQueryString
.append(starter
);
142 normQueryString
.append(seperator
);
143 normQueryString
.append(nsPrefix
);
144 normQueryString
.append(":");
145 normQueryString
.append(token
);
149 if (i
< exp
.length
) {
150 normQueryString
.append(" | ");
154 return normQueryString
.toString();
158 * Search all XML documents stored in "map" for the specified xPath, using
159 * relative path (starting with '$this')
162 * xpath query string array
163 * @returns An array of XmlObject if elements are found at the specified
165 * @returns NULL if nothing is at the specified xpath
167 public Object
[] get(String
[] xPath
) {
172 String
[] keys
= (String
[]) map
.keySet().toArray(new String
[map
.size()]);
173 List
<Object
> result
= new ArrayList
<Object
>();
174 for (int i
= 0; i
< keys
.length
; ++i
) {
175 XmlObject rootNode
= (XmlObject
) map
.get(keys
[i
]);
176 if (rootNode
== null) {
180 String query
= queryDeclaration
181 + normalizeQueryString(xPath
, "$this/" + keys
[i
]);
182 XmlObject
[] tmp
= rootNode
.selectPath(query
);
183 for (int j
= 0; j
< tmp
.length
; ++j
) {
184 result
.add((Object
)tmp
[j
]);
188 int size
= result
.size();
193 return (Object
[]) result
.toArray(new Object
[size
]);
197 * Search XML documents named by "rootName" for the given xPath, using
198 * relative path (starting with '$this')
201 * The top level element name
203 * The xpath query string array
204 * @returns An array of XmlObject if elements are found at the given xpath
205 * @returns NULL if nothing is found at the given xpath
207 public Object
[] get(String rootName
, String
[] xPath
) {
212 XmlObject root
= (XmlObject
) map
.get(rootName
);
217 String query
= queryDeclaration
218 + normalizeQueryString(xPath
, "$this/" + rootName
);
219 XmlObject
[] result
= root
.selectPath(query
);
220 if (result
.length
> 0) {
221 return (Object
[])result
;
224 query
= queryDeclaration
+ normalizeQueryString(xPath
, "/" + rootName
);
225 result
= root
.selectPath(query
);
226 if (result
.length
> 0) {
227 return (Object
[])result
;
234 * Retrieve SourceFiles/Filename for specified ARCH type
238 * @returns An 2 dimension string array if elements are found at the known
240 * @returns NULL if nothing is found at the known xpath
242 public String
[][] getSourceFiles(String arch
) {
246 xPath
= new String
[] { "/Filename" };
248 returns
= get("SourceFiles", xPath
);
250 if (returns
== null || returns
.length
== 0) {
251 return new String
[0][3];
254 Filename
[] sourceFileNames
= (Filename
[]) returns
;
255 List
<String
[]> outputList
= new ArrayList
<String
[]>();
256 for (int i
= 0; i
< sourceFileNames
.length
; i
++) {
257 List archList
= sourceFileNames
[i
].getSupArchList();
258 if (arch
== null || arch
.trim().equalsIgnoreCase("") || archList
== null || contains(archList
, arch
)) {
259 outputList
.add(new String
[] {sourceFileNames
[i
].getToolCode(), sourceFileNames
[i
].getStringValue(), sourceFileNames
[i
].getToolChainFamily()});
263 String
[][] outputString
= new String
[outputList
.size()][3];
264 for (int index
= 0; index
< outputList
.size(); index
++) {
266 // ToolCode (FileType)
268 outputString
[index
][0] = outputList
.get(index
)[0];
270 // File name (relative to MODULE_DIR)
272 outputString
[index
][1] = outputList
.get(index
)[1];
276 outputString
[index
][2] = outputList
.get(index
)[2];
282 * Retrieve /PlatformDefinitions/OutputDirectory from FPD
284 * @returns Directory names array if elements are found at the known xpath
285 * @returns Empty if nothing is found at the known xpath
287 public String
getFpdOutputDirectory() {
288 String
[] xPath
= new String
[] { "/PlatformDefinitions" };
290 Object
[] returns
= get("PlatformSurfaceArea", xPath
);
291 if (returns
== null || returns
.length
== 0) {
294 PlatformDefinitionsDocument
.PlatformDefinitions item
= (PlatformDefinitionsDocument
.PlatformDefinitions
)returns
[0];
295 return item
.getOutputDirectory();
298 public String
getFpdIntermediateDirectories() {
299 String
[] xPath
= new String
[] { "/PlatformDefinitions" };
301 Object
[] returns
= get("PlatformSurfaceArea", xPath
);
302 if (returns
== null || returns
.length
== 0) {
305 PlatformDefinitionsDocument
.PlatformDefinitions item
= (PlatformDefinitionsDocument
.PlatformDefinitions
)returns
[0];
306 if(item
.getIntermediateDirectories() == null) {
310 return item
.getIntermediateDirectories().toString();
314 public String
getModuleFfsKeyword() {
315 String
[] xPath
= new String
[] { "/" };
317 Object
[] returns
= get("ModuleSaBuildOptions", xPath
);
318 if (returns
== null || returns
.length
== 0) {
321 ModuleSaBuildOptionsDocument
.ModuleSaBuildOptions item
= (ModuleSaBuildOptionsDocument
.ModuleSaBuildOptions
)returns
[0];
322 return item
.getFfsFormatKey();
325 public String
getModuleFvBindingKeyword() {
326 String
[] xPath
= new String
[] { "/" };
328 Object
[] returns
= get("ModuleSaBuildOptions", xPath
);
329 if (returns
== null || returns
.length
== 0) {
332 ModuleSaBuildOptionsDocument
.ModuleSaBuildOptions item
= (ModuleSaBuildOptionsDocument
.ModuleSaBuildOptions
)returns
[0];
333 return item
.getFvBinding();
336 public List
getModuleSupportedArchs() {
337 String
[] xPath
= new String
[] { "/" };
339 Object
[] returns
= get("ModuleDefinitions", xPath
);
340 if (returns
== null || returns
.length
== 0) {
343 ModuleDefinitionsDocument
.ModuleDefinitions item
= (ModuleDefinitionsDocument
.ModuleDefinitions
)returns
[0];
344 return item
.getSupportedArchitectures();
347 public BuildOptionsDocument
.BuildOptions
.Ffs
[] getFpdFfs() {
348 String
[] xPath
= new String
[] {"/Ffs"};
350 Object
[] returns
= get("BuildOptions", xPath
);
351 if (returns
== null || returns
.length
== 0) {
352 return new BuildOptionsDocument
.BuildOptions
.Ffs
[0];
354 return (BuildOptionsDocument
.BuildOptions
.Ffs
[])returns
;
357 public String
getModuleOutputFileBasename() {
358 String
[] xPath
= new String
[] { "/" };
360 Object
[] returns
= get("ModuleDefinitions", xPath
);
361 if (returns
== null || returns
.length
== 0) {
364 ModuleDefinitionsDocument
.ModuleDefinitions item
= (ModuleDefinitionsDocument
.ModuleDefinitions
)returns
[0];
365 return item
.getOutputFileBasename();
369 * Retrieve BuildOptions/Option or Arch/Option
371 * @param toolChainFamilyFlag
372 * if true, retrieve options for toolchain family; otherwise for
375 * @returns String[][5] name, target, toolchain, arch, coommand of options
376 * if elements are found at the known xpath. String[0][] if dont
379 * @returns Empty array if nothing is there
381 public String
[][] getOptions(String from
, String
[] xPath
, boolean toolChainFamilyFlag
) {
382 String target
= null;
383 String toolchain
= null;
384 String toolchainFamily
= null;
385 List
<String
> archList
= null;
387 String optionName
= null;
389 Object
[] returns
= get(from
, xPath
);
390 if (returns
== null) {
391 return new String
[0][5];
394 List
<String
[]> optionList
= new ArrayList
<String
[]>();
395 OptionDocument
.Option option
;
397 for (int i
= 0; i
< returns
.length
; i
++) {
398 option
= (OptionDocument
.Option
) returns
[i
];
401 // Get Target, ToolChain(Family), Arch, Cmd, and Option from Option,
403 // put to result[][5] array in above order.
406 if (option
.getBuildTargets() == null) {
410 target
= option
.getBuildTargets().toString();
412 if (target
!= null) {
413 targetList
= target
.split(" ");
415 targetList
= new String
[1];
416 targetList
[0] = null;
419 if (toolChainFamilyFlag
) {
420 toolchainFamily
= option
.getToolChainFamily();
421 if (toolchainFamily
!= null) {
422 toolchain
= toolchainFamily
.toString();
427 toolchain
= option
.getTagName();
430 archList
= new ArrayList
<String
>();
431 List archEnumList
= option
.getSupArchList();
432 if (archEnumList
== null) {
435 //archList.addAll(archEnumList);
436 Iterator it
= archEnumList
.iterator();
437 while (it
.hasNext()) {
438 String archType
= (String
)it
.next();
439 archList
.add(archType
);
443 cmd
= option
.getToolCode();
445 optionName
= option
.getStringValue();
446 for (int t
= 0; t
< targetList
.length
; t
++) {
447 for (int j
= 0; j
< archList
.size(); j
++) {
448 optionList
.add(new String
[] { targetList
[t
],
449 toolchain
, archList
.get(j
), cmd
, optionName
});
454 String
[][] result
= new String
[optionList
.size()][5];
455 for (int i
= 0; i
< optionList
.size(); i
++) {
456 result
[i
][0] = optionList
.get(i
)[0];
457 result
[i
][1] = optionList
.get(i
)[1];
458 result
[i
][2] = optionList
.get(i
)[2];
459 result
[i
][3] = optionList
.get(i
)[3];
460 result
[i
][4] = optionList
.get(i
)[4];
465 public String
[][] getModuleBuildOptions(boolean toolChainFamilyFlag
) {
468 if (toolChainFamilyFlag
== true) {
469 xPath
= new String
[] {
470 "/Options/Option[not(@ToolChainFamily) and not(@TagName)]",
471 "/Options/Option[@ToolChainFamily]", };
473 xPath
= new String
[] {
474 "/Options/Option[not(@ToolChainFamily) and not(@TagName)]",
475 "/Options/Option[@TagName]", };
477 return getOptions("ModuleSaBuildOptions", xPath
, toolChainFamilyFlag
);
480 public String
[][] getPlatformBuildOptions(boolean toolChainFamilyFlag
) {
483 if (toolChainFamilyFlag
== true) {
484 xPath
= new String
[] {
485 "/BuildOptions/Options/Option[not(@ToolChainFamily) and not(@TagName)]",
486 "/BuildOptions/Options/Option[@ToolChainFamily]", };
488 xPath
= new String
[] {
489 "/BuildOptions/Options/Option[not(@ToolChainFamily) and not(@TagName)]",
490 "/BuildOptions/Options/Option[@TagName]", };
493 return getOptions("PlatformSurfaceArea", xPath
, toolChainFamilyFlag
);
496 public ToolChainInfo
getFpdToolChainInfo() {
497 String
[] xPath
= new String
[] { "/PlatformDefinitions" };
499 Object
[] returns
= get("PlatformSurfaceArea", xPath
);
500 if (returns
== null || returns
.length
== 0) {
504 PlatformDefinitionsDocument
.PlatformDefinitions item
= (PlatformDefinitionsDocument
.PlatformDefinitions
)returns
[0];
505 ToolChainInfo toolChainInfo
= new ToolChainInfo();
506 toolChainInfo
.addTargets(item
.getBuildTargets().toString());
507 toolChainInfo
.addArchs(item
.getSupportedArchitectures().toString());
508 toolChainInfo
.addTagnames((String
)null);
509 return toolChainInfo
;
513 * Retrieve <xxxHeader>/ModuleType
515 * @returns The module type name if elements are found at the known xpath
516 * @returns null if nothing is there
518 public String
getModuleType() {
519 String
[] xPath
= new String
[] { "/ModuleType" };
521 Object
[] returns
= get(xPath
);
522 if (returns
!= null && returns
.length
> 0) {
523 ModuleTypeDef type
= (ModuleTypeDef
) returns
[0];
524 return type
.enumValue().toString();
531 * Retrieve PackageDependencies/Package
536 * @returns package name list if elements are found at the known xpath
537 * @returns null if nothing is there
539 public PackageIdentification
[] getDependencePkg(String arch
) throws EdkException
{
541 String packageGuid
= null;
542 String packageVersion
= null;
545 xPath
= new String
[] { "/Package" };
547 Object
[] returns
= get("PackageDependencies", xPath
);
548 if (returns
== null) {
549 return new PackageIdentification
[0];
553 // Get packageIdentification
555 List
<PackageIdentification
> packageIdList
= new ArrayList
<PackageIdentification
>();
556 for (int i
= 0; i
< returns
.length
; i
++) {
557 PackageDependenciesDocument
.PackageDependencies
.Package item
= (PackageDependenciesDocument
.PackageDependencies
.Package
) returns
[i
];
558 List archList
= item
.getSupArchList();
559 if (arch
== null || archList
== null || contains(archList
, arch
)) {
560 packageGuid
= item
.getPackageGuid();
561 packageVersion
= item
.getPackageVersion();
562 PackageIdentification pkgId
= new PackageIdentification(null, packageGuid
, packageVersion
);
563 GlobalData
.refreshPackageIdentification(pkgId
);
564 packageIdList
.add(pkgId
);
568 return packageIdList
.toArray(new PackageIdentification
[packageIdList
.size()]);
572 * Retrieve LibraryClassDefinitions/LibraryClass for specified usage
575 * Library class usage
577 * @returns LibraryClass objects list if elements are found at the known
579 * @returns null if nothing is there
581 public String
[] getLibraryClasses(String usage
, String arch
) {
583 if (usage
== null || usage
.equals("")) {
584 xPath
= new String
[] { "/LibraryClass" };
586 xPath
= new String
[] { "/LibraryClass[@Usage='" + usage
+ "']" };
589 Object
[] returns
= get("LibraryClassDefinitions", xPath
);
590 if (returns
== null || returns
.length
== 0) {
591 return new String
[0];
594 LibraryClassDocument
.LibraryClass
[] libraryClassList
= (LibraryClassDocument
.LibraryClass
[]) returns
;
595 List
<String
> libraryClassName
= new ArrayList
<String
>();
596 for (int i
= 0; i
< libraryClassList
.length
; i
++) {
597 List archList
= libraryClassList
[i
].getSupArchList();
599 if (arch
== null || contains(archList
, arch
)) {
600 libraryClassName
.add(libraryClassList
[i
].getKeyword());
604 String
[] libraryArray
= new String
[libraryClassName
.size()];
605 libraryClassName
.toArray(libraryArray
);
610 * Retrieve ModuleEntryPoint names
612 * @returns ModuleEntryPoint name list if elements are found at the known
614 * @returns null if nothing is there
616 public String
[] getModuleEntryPointArray() {
617 String
[] xPath
= new String
[] { "/Extern/ModuleEntryPoint" };
619 Object
[] returns
= get("Externs", xPath
);
621 if (returns
!= null && returns
.length
> 0) {
622 String
[] entryPoints
= new String
[returns
.length
];
624 for (int i
= 0; i
< returns
.length
; ++i
) {
625 entryPoints
[i
] = ((CNameType
) returns
[i
]).getStringValue();
635 * retrieve Protocol for specified usage
638 * Protocol usage arch Architecture
640 * @returns Protocol String list if elements are found at the known xpath
641 * @returns String[0] if nothing is there
643 public String
[] getProtocolArray(String arch
, String usage
) {
645 String usageXpath
= "";
646 String archXpath
= "";
648 if (arch
== null || arch
.equals("")) {
649 return new String
[0];
651 archXpath
= "/Protocol";
652 if (usage
!= null && !usage
.equals("")) {
653 usageXpath
= "/Protocol[@Usage='" + usage
+ "']";
654 xPath
= new String
[] { usageXpath
, archXpath
};
656 return getProtocolArray(arch
);
661 Object
[] returns
= get("Protocols", xPath
);
662 if (returns
== null) {
663 return new String
[0];
665 Protocol
[] protocolList
= (Protocol
[]) returns
;
667 String
[] protocolArray
= new String
[returns
.length
];
668 for (int i
= 0; i
< returns
.length
; i
++) {
669 protocolArray
[i
] = protocolList
[i
].getProtocolCName();
671 return protocolArray
;
675 * retrieve Protocol for specified usage
680 * @returns Protocol String list if elements are found at the known xpath
681 * @returns String[0] if nothing is there
683 public String
[] getProtocolArray(String arch
) {
686 if (arch
== null || arch
.equals("")) {
687 return new String
[0];
689 xPath
= new String
[] { "/Protocol" };
692 Object
[] returns
= get("Protocols", xPath
);
693 if (returns
== null) {
694 return new String
[0];
696 Protocol
[] returnlList
= (Protocol
[]) returns
;
698 List
<String
> protocolList
= new ArrayList
<String
>();
700 for (int i
= 0; i
< returns
.length
; i
++) {
701 List archList
= returnlList
[i
].getSupArchList();
702 if (archList
== null || contains(archList
, arch
)){
703 protocolList
.add(returnlList
[i
].getProtocolCName());
706 String
[] protocolArray
= new String
[protocolList
.size()];
707 for (int i
= 0; i
< protocolList
.size(); i
++) {
708 protocolArray
[i
] = protocolList
.get(i
);
710 return protocolArray
;
714 * Retrieve ProtocolNotify for specified usage
717 * ProtocolNotify usage
719 * @returns String[] if elements are found at the known xpath
720 * @returns String[0] if nothing is there
722 public String
[] getProtocolNotifyArray(String arch
) {
725 if (arch
== null || arch
.equals("")) {
726 return new String
[0];
728 xPath
= new String
[] { "/ProtocolNotify" };
731 Object
[] returns
= get("Protocols", xPath
);
732 if (returns
== null) {
733 return new String
[0];
736 List
<String
> protocolNotifyList
= new ArrayList
<String
>();
738 for (int i
= 0; i
< returns
.length
; i
++) {
739 List archList
= ((ProtocolNotify
) returns
[i
]).getSupArchList();
740 if (archList
== null || contains(archList
, arch
)){
741 protocolNotifyList
.add(((ProtocolNotify
) returns
[i
]).getProtocolNotifyCName());
745 String
[] protocolNotifyArray
= new String
[protocolNotifyList
.size()];
746 for (int i
= 0; i
< protocolNotifyList
.size(); i
++) {
747 protocolNotifyArray
[i
] = protocolNotifyList
.get(i
);
749 return protocolNotifyArray
;
753 * Retrieve ProtocolNotify for specified usage
756 * ProtocolNotify usage
758 * @returns String[] if elements are found at the known xpath
759 * @returns String[0] if nothing is there
761 public String
[] getProtocolNotifyArray(String arch
, String usage
) {
767 if (arch
== null || arch
.equals("")) {
768 return new String
[0];
770 archXpath
= "/ProtocolNotify";
771 if (usage
!= null && !usage
.equals("")) {
772 usageXpath
= "/ProtocolNotify[@Usage='" + arch
+ "']";
773 xPath
= new String
[] { archXpath
, usageXpath
};
775 return getProtocolNotifyArray(arch
);
779 Object
[] returns
= get("Protocols", xPath
);
780 if (returns
== null) {
781 return new String
[0];
784 String
[] protocolNotifyList
= new String
[returns
.length
];
786 for (int i
= 0; i
< returns
.length
; i
++) {
787 protocolNotifyList
[i
] = ((ProtocolNotify
) returns
[i
]).getProtocolNotifyCName();
789 return protocolNotifyList
;
793 * Retrieve ModuleUnloadImage names
795 * @returns ModuleUnloadImage name list if elements are found at the known
797 * @returns null if nothing is there
799 public String
[] getModuleUnloadImageArray() {
800 String
[] xPath
= new String
[] { "/Extern/ModuleUnloadImage" };
802 Object
[] returns
= get("Externs", xPath
);
803 if (returns
!= null && returns
.length
> 0) {
804 String
[] stringArray
= new String
[returns
.length
];
805 CNameType
[] doc
= (CNameType
[]) returns
;
807 for (int i
= 0; i
< returns
.length
; ++i
) {
808 stringArray
[i
] = doc
[i
].getStringValue();
820 * @returns Extern objects list if elements are found at the known xpath
821 * @returns null if nothing is there
823 public ExternsDocument
.Externs
.Extern
[] getExternArray() {
824 String
[] xPath
= new String
[] { "/Extern" };
826 Object
[] returns
= get("Externs", xPath
);
827 if (returns
!= null && returns
.length
> 0) {
828 return (ExternsDocument
.Externs
.Extern
[]) returns
;
835 * Retrieve PpiNotify for specified arch
840 * @returns String[] if elements are found at the known xpath
841 * @returns String[0] if nothing is there
843 public String
[] getPpiNotifyArray(String arch
) {
846 if (arch
== null || arch
.equals("")) {
847 return new String
[0];
849 xPath
= new String
[] { "/PpiNotify" };
852 Object
[] returns
= get("PPIs", xPath
);
853 if (returns
== null) {
854 return new String
[0];
858 List
<String
> ppiNotifyList
= new ArrayList
<String
>();
859 for (int i
= 0; i
< returns
.length
; i
++) {
860 List archList
= ((PPIsDocument
.PPIs
.PpiNotify
) returns
[i
]).getSupArchList();
861 if (archList
== null || contains(archList
, arch
)){
862 ppiNotifyList
.add(((PPIsDocument
.PPIs
.PpiNotify
) returns
[i
]).getPpiNotifyCName());
866 String
[] ppiNotifyArray
= new String
[ppiNotifyList
.size()];
867 for (int i
= 0; i
< ppiNotifyList
.size(); i
++) {
868 ppiNotifyArray
[i
] = ppiNotifyList
.get(i
);
871 return ppiNotifyArray
;
875 * Retrieve PpiNotify for specified usage and arch
878 * PpiNotify arch usage PpiNotify usage
881 * @returns String[] if elements are found at the known xpath
882 * @returns String[0] if nothing is there
884 public String
[] getPpiNotifyArray(String arch
, String usage
) {
890 if (arch
== null || arch
.equals("")) {
891 return new String
[0];
893 archXpath
= "/PpiNotify";
894 if (usage
!= null && !usage
.equals("")) {
895 usageXpath
= "/PpiNotify[@Usage='" + arch
+ "']";
896 xPath
= new String
[] { archXpath
, usageXpath
};
898 return getProtocolNotifyArray(arch
);
902 Object
[] returns
= get("PPIs", xPath
);
903 if (returns
== null) {
904 return new String
[0];
907 String
[] ppiNotifyList
= new String
[returns
.length
];
909 for (int i
= 0; i
< returns
.length
; i
++) {
910 ppiNotifyList
[i
] = ((PPIsDocument
.PPIs
.PpiNotify
) returns
[i
]).getPpiNotifyCName();
912 return ppiNotifyList
;
916 * Retrieve Ppi for specified arch
921 * @returns String[] if elements are found at the known xpath
922 * @returns String[0] if nothing is there
924 public String
[] getPpiArray(String arch
) {
927 if (arch
== null || arch
.equals("")) {
928 return new String
[0];
930 xPath
= new String
[] { "/Ppi" };
933 Object
[] returns
= get("PPIs", xPath
);
934 if (returns
== null) {
935 return new String
[0];
938 List
<String
> ppiList
= new ArrayList
<String
>();
939 for (int i
= 0; i
< returns
.length
; i
++) {
940 List archList
= ((PPIsDocument
.PPIs
.Ppi
) returns
[i
]).getSupArchList();
941 if (archList
== null || contains(archList
, arch
)){
942 ppiList
.add(((PPIsDocument
.PPIs
.Ppi
) returns
[i
]).getPpiCName());
946 String
[] ppiArray
= new String
[ppiList
.size()];
947 for (int i
= 0; i
< ppiList
.size(); i
++) {
948 ppiArray
[i
] = ppiList
.get(i
);
954 * Retrieve PpiNotify for specified usage and arch
957 * PpiNotify arch usage PpiNotify usage
960 * @returns String[] if elements are found at the known xpath
961 * @returns String[0] if nothing is there
963 public String
[] getPpiArray(String arch
, String usage
) {
969 if (arch
== null || arch
.equals("")) {
970 return new String
[0];
973 if (usage
!= null && !usage
.equals("")) {
974 usageXpath
= "/Ppi[@Usage='" + arch
+ "']";
975 xPath
= new String
[] { archXpath
, usageXpath
};
977 return getProtocolNotifyArray(arch
);
981 Object
[] returns
= get("PPIs", xPath
);
982 if (returns
== null) {
983 return new String
[0];
986 String
[] ppiList
= new String
[returns
.length
];
988 for (int i
= 0; i
< returns
.length
; i
++) {
989 ppiList
[i
] = ((PPIsDocument
.PPIs
.Ppi
) returns
[i
]).getPpiCName();
995 * Retrieve GuidEntry information for specified usage
1000 * @returns GuidEntry objects list if elements are found at the known xpath
1001 * @returns null if nothing is there
1003 public String
[] getGuidEntryArray(String arch
) {
1006 if (arch
== null || arch
.equals("")) {
1007 xPath
= new String
[] { "/GuidCNames" };
1009 xPath
= new String
[] { "/GuidCNames" };
1012 Object
[] returns
= get("Guids", xPath
);
1013 if (returns
== null) {
1014 return new String
[0];
1017 List
<String
> guidList
= new ArrayList
<String
>();
1018 for (int i
= 0; i
< returns
.length
; i
++) {
1019 List archList
= ((GuidsDocument
.Guids
.GuidCNames
) returns
[i
]).getSupArchList();
1020 if (archList
== null || contains(archList
, arch
)){
1021 guidList
.add(((GuidsDocument
.Guids
.GuidCNames
) returns
[i
]).getGuidCName());
1025 String
[] guidArray
= new String
[guidList
.size()];
1026 for (int i
= 0; i
< guidList
.size(); i
++) {
1027 guidArray
[i
] = guidList
.get(i
);
1034 * Retrieve GuidEntry information for specified usage
1037 * GuidEntry arch usage GuidEntry usage
1039 * @returns GuidEntry objects list if elements are found at the known xpath
1040 * @returns null if nothing is there
1042 public String
[] getGuidEntryArray(String arch
, String usage
) {
1047 if (arch
== null || arch
.equals("")) {
1048 return new String
[0];
1050 archXpath
= "/GuidEntry";
1051 if (usage
!= null && !usage
.equals("")) {
1052 usageXpath
= "/GuidEntry[@Usage='" + arch
+ "']";
1053 xPath
= new String
[] { archXpath
, usageXpath
};
1055 return getProtocolNotifyArray(arch
);
1059 Object
[] returns
= get("Guids", xPath
);
1060 if (returns
== null) {
1061 return new String
[0];
1064 String
[] guidList
= new String
[returns
.length
];
1066 for (int i
= 0; i
< returns
.length
; i
++) {
1067 guidList
[i
] = ((GuidsDocument
.Guids
.GuidCNames
) returns
[i
]).getGuidCName();
1073 * Retrieve Library instance information
1078 * Library instance usage
1080 * @returns library instance name list if elements are found at the known
1082 * @returns null if nothing is there
1084 public ModuleIdentification
[] getLibraryInstance(String arch
) throws EdkException
{
1086 String saGuid
= null;
1087 String saVersion
= null;
1088 String pkgGuid
= null;
1089 String pkgVersion
= null;
1091 if (arch
== null || arch
.equalsIgnoreCase("")) {
1092 xPath
= new String
[] { "/Instance" };
1095 // Since Schema don't have SupArchList now, so the follow Xpath is
1096 // equal to "/Instance" and [not(@SupArchList) or @SupArchList= arch]
1097 // don't have effect.
1099 xPath
= new String
[] { "/Instance[not(@SupArchList) or @SupArchList='"
1103 Object
[] returns
= get("Libraries", xPath
);
1104 if (returns
== null || returns
.length
== 0) {
1105 return new ModuleIdentification
[0];
1108 ModuleIdentification
[] saIdList
= new ModuleIdentification
[returns
.length
];
1109 for (int i
= 0; i
< returns
.length
; i
++) {
1110 LibrariesDocument
.Libraries
.Instance library
= (LibrariesDocument
.Libraries
.Instance
) returns
[i
];
1111 saGuid
= library
.getModuleGuid();
1112 saVersion
= library
.getModuleVersion();
1114 pkgGuid
= library
.getPackageGuid();
1115 pkgVersion
= library
.getPackageVersion();
1117 ModuleIdentification saId
= new ModuleIdentification(null, saGuid
,
1119 PackageIdentification pkgId
= new PackageIdentification(null,
1120 pkgGuid
, pkgVersion
);
1121 GlobalData
.refreshPackageIdentification(pkgId
);
1122 saId
.setPackage(pkgId
);
1123 GlobalData
.refreshModuleIdentification(saId
);
1132 // / This method is used for retrieving the elements information which has
1133 // / CName sub-element
1135 private String
[] getCNames(String from
, String xPath
[]) {
1136 Object
[] returns
= get(from
, xPath
);
1137 if (returns
== null || returns
.length
== 0) {
1141 String
[] strings
= new String
[returns
.length
];
1142 for (int i
= 0; i
< returns
.length
; ++i
) {
1144 strings
[i
] = ((CNameType
) returns
[i
]).getStringValue();
1151 * Retrive library's constructor name
1153 * @returns constructor name list if elements are found at the known xpath
1154 * @returns null if nothing is there
1156 public String
getLibConstructorName() {
1157 String
[] xPath
= new String
[] { "/Extern/Constructor" };
1159 Object
[] returns
= get("Externs", xPath
);
1160 if (returns
!= null && returns
.length
> 0) {
1161 CNameType constructor
= ((CNameType
) returns
[0]);
1162 return constructor
.getStringValue();
1169 * Retrive library's destructor name
1171 * @returns destructor name list if elements are found at the known xpath
1172 * @returns null if nothing is there
1174 public String
getLibDestructorName() {
1175 String
[] xPath
= new String
[] { "/Extern/Destructor" };
1177 Object
[] returns
= get("Externs", xPath
);
1178 if (returns
!= null && returns
.length
> 0) {
1180 // Only support one Destructor function.
1182 CNameType destructor
= (CNameType
) returns
[0];
1183 return destructor
.getStringValue();
1190 * Retrive DriverBinding names
1192 * @returns DriverBinding name list if elements are found at the known xpath
1193 * @returns null if nothing is there
1195 public String
[] getDriverBindingArray() {
1196 String
[] xPath
= new String
[] { "/Extern/DriverBinding" };
1197 return getCNames("Externs", xPath
);
1201 * Retrive ComponentName names
1203 * @returns ComponentName name list if elements are found at the known xpath
1204 * @returns null if nothing is there
1206 public String
[] getComponentNameArray() {
1207 String
[] xPath
= new String
[] { "/Extern/ComponentName" };
1208 return getCNames("Externs", xPath
);
1212 * Retrive DriverConfig names
1214 * @returns DriverConfig name list if elements are found at the known xpath
1215 * @returns null if nothing is there
1217 public String
[] getDriverConfigArray() {
1218 String
[] xPath
= new String
[] { "/Extern/DriverConfig" };
1219 return getCNames("Externs", xPath
);
1223 * Retrive DriverDiag names
1225 * @returns DriverDiag name list if elements are found at the known xpath
1226 * @returns null if nothing is there
1228 public String
[] getDriverDiagArray() {
1229 String
[] xPath
= new String
[] { "/Extern/DriverDiag" };
1230 return getCNames("Externs", xPath
);
1234 * Retrive DriverBinding, ComponentName, DriverConfig,
1235 * DriverDiag group array
1237 * @returns DriverBinding group name list if elements are found
1238 * at the known xpath
1239 * @returns null if nothing is there
1241 public String
[][] getExternProtocolGroup() {
1242 String
[] xPath
= new String
[] {"/Extern"};
1243 Object
[] returns
= get("Externs",xPath
);
1245 if (returns
== null) {
1246 return new String
[0][4];
1248 List
<Extern
> externList
= new ArrayList
<Extern
>();
1249 for (int i
= 0; i
< returns
.length
; i
++) {
1250 org
.tianocore
.ExternsDocument
.Externs
.Extern extern
= (org
.tianocore
.ExternsDocument
.Externs
.Extern
)returns
[i
];
1251 if (extern
.getDriverBinding() != null) {
1252 externList
.add(extern
);
1256 String
[][] externGroup
= new String
[externList
.size()][4];
1257 for (int i
= 0; i
< externList
.size(); i
++) {
1258 String driverBindingStr
= externList
.get(i
).getDriverBinding();
1259 if ( driverBindingStr
!= null){
1260 externGroup
[i
][0] = driverBindingStr
;
1262 externGroup
[i
][0] = null;
1265 String componentNameStr
= externList
.get(i
).getComponentName();
1266 if (componentNameStr
!= null) {
1267 externGroup
[i
][1] = componentNameStr
;
1269 externGroup
[i
][1] = null;
1272 String driverConfigStr
= externList
.get(i
).getDriverConfig();
1273 if (driverConfigStr
!= null) {
1274 externGroup
[i
][2] = driverConfigStr
;
1276 externGroup
[i
][2] = null;
1279 String driverDiagStr
= externList
.get(i
).getDriverDiag();
1280 if (driverDiagStr
!= null) {
1281 externGroup
[i
][3] = driverDiagStr
;
1283 externGroup
[i
][3] = null;
1290 * Retrive SetVirtualAddressMapCallBack names
1292 * @returns SetVirtualAddressMapCallBack name list if elements are found at
1294 * @returns null if nothing is there
1296 public String
[] getSetVirtualAddressMapCallBackArray() {
1297 String
[] xPath
= new String
[] { "/Extern/SetVirtualAddressMapCallBack" };
1298 return getCNames("Externs", xPath
);
1302 * Retrive ExitBootServicesCallBack names
1304 * @returns ExitBootServicesCallBack name list if elements are found at the
1306 * @returns null if nothing is there
1308 public String
[] getExitBootServicesCallBackArray() {
1309 String
[] xPath
= new String
[] { "/Extern/ExitBootServicesCallBack" };
1310 return getCNames("Externs", xPath
);
1314 Judge whether current driver is PEI_PCD_DRIVER or DXE_PCD_DRIVER or
1317 @return CommonDefinition.PCD_DRIVER_TYPE the type of current driver
1319 public CommonDefinition
.PCD_DRIVER_TYPE
getPcdDriverType() {
1320 String
[] xPath
= new String
[] {"/PcdIsDriver"};
1321 Object
[] results
= get ("Externs", xPath
);
1323 if (results
!= null && results
.length
!= 0) {
1324 PcdDriverTypes type
= (PcdDriverTypes
) results
[0];
1325 String typeStr
= type
.enumValue().toString();
1326 if (typeStr
.equals(CommonDefinition
.PCD_DRIVER_TYPE
.PEI_PCD_DRIVER
.toString())) {
1327 return CommonDefinition
.PCD_DRIVER_TYPE
.PEI_PCD_DRIVER
;
1328 } else if (typeStr
.equals(CommonDefinition
.PCD_DRIVER_TYPE
.DXE_PCD_DRIVER
.toString())) {
1329 return CommonDefinition
.PCD_DRIVER_TYPE
.DXE_PCD_DRIVER
;
1331 return CommonDefinition
.PCD_DRIVER_TYPE
.UNKNOWN_PCD_DRIVER
;
1334 return CommonDefinition
.PCD_DRIVER_TYPE
.NOT_PCD_DRIVER
;
1338 * Retrieve module surface area file information
1340 * @returns ModuleSA objects list if elements are found at the known xpath
1341 * @returns Empty ModuleSA list if nothing is there
1343 public Map
<FpdModuleIdentification
, Map
<String
, XmlObject
>> getFpdModules() throws EdkException
{
1344 String
[] xPath
= new String
[] { "/FrameworkModules/ModuleSA" };
1345 Object
[] result
= get("PlatformSurfaceArea", xPath
);
1347 String fvBinding
= null;
1348 String saGuid
= null;
1349 String saVersion
= null;
1350 String pkgGuid
= null;
1351 String pkgVersion
= null;
1353 Map
<FpdModuleIdentification
, Map
<String
, XmlObject
>> fpdModuleMap
= new LinkedHashMap
<FpdModuleIdentification
, Map
<String
, XmlObject
>>();
1355 if (result
== null) {
1356 return fpdModuleMap
;
1359 for (int i
= 0; i
< result
.length
; i
++) {
1361 // Get Fpd SA Module element node and add to ObjectMap.
1363 Map
<String
, XmlObject
> ObjectMap
= new HashMap
<String
, XmlObject
>();
1364 ModuleSADocument
.ModuleSA moduleSA
= (ModuleSADocument
.ModuleSA
) result
[i
];
1365 if (((ModuleSADocument
.ModuleSA
) result
[i
]).getLibraries() != null) {
1366 ObjectMap
.put("Libraries", moduleSA
.getLibraries());
1368 if (((ModuleSADocument
.ModuleSA
) result
[i
]).getPcdBuildDefinition() != null) {
1369 ObjectMap
.put("PcdBuildDefinition", moduleSA
.getPcdBuildDefinition());
1371 if (((ModuleSADocument
.ModuleSA
) result
[i
]).getModuleSaBuildOptions() != null) {
1372 ObjectMap
.put("ModuleSaBuildOptions", moduleSA
.getModuleSaBuildOptions());
1376 // Get Fpd SA Module attribute and create FpdMoudleIdentification.
1378 if (moduleSA
.isSetSupArchList()) {
1379 arch
= moduleSA
.getSupArchList().toString();
1386 saVersion
= ((ModuleSADocument
.ModuleSA
) result
[i
]).getModuleVersion();
1388 saGuid
= moduleSA
.getModuleGuid();
1389 pkgGuid
= moduleSA
.getPackageGuid();
1390 pkgVersion
= moduleSA
.getPackageVersion();
1393 // Create Module Identification which have class member of package
1396 PackageIdentification pkgId
= new PackageIdentification(null, pkgGuid
, pkgVersion
);
1397 GlobalData
.refreshPackageIdentification(pkgId
);
1399 ModuleIdentification saId
= new ModuleIdentification(null, saGuid
, saVersion
);
1400 saId
.setPackage(pkgId
);
1401 GlobalData
.refreshModuleIdentification(saId
);
1406 // Create FpdModule Identification which have class member of module
1409 String
[] archList
= new String
[0];
1410 if (arch
== null || arch
.trim().length() == 0) {
1411 archList
= GlobalData
.getToolChainInfo().getArchs();
1413 archList
= arch
.split(" ");
1415 for (int j
= 0; j
< archList
.length
; j
++) {
1416 FpdModuleIdentification fpdSaId
= new FpdModuleIdentification(saId
, archList
[j
]);
1418 if (fvBinding
!= null) {
1419 fpdSaId
.setFvBinding(fvBinding
);
1423 // Put element to Map<FpdModuleIdentification, Map<String,
1426 fpdModuleMap
.put(fpdSaId
, ObjectMap
);
1429 return fpdModuleMap
;
1433 * Retrieve valid image names
1435 * @returns valid iamges name list if elements are found at the known xpath
1436 * @returns empty list if nothing is there
1438 public String
[] getFpdValidImageNames() {
1439 String
[] xPath
= new String
[] { "/Flash/FvImages/FvImage[@Type='ImageName']/FvImageNames" };
1441 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1442 if (queryResult
== null) {
1443 return new String
[0];
1446 String
[] result
= new String
[queryResult
.length
];
1447 for (int i
= 0; i
< queryResult
.length
; i
++) {
1448 result
[i
] = ((XmlString
) queryResult
[i
]).getStringValue();
1454 public Node
getFpdUserExtensionPreBuild() {
1455 String
[] xPath
= new String
[] { "/UserExtensions[@UserID='TianoCore' and @Identifier='0']" };
1457 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1458 if (queryResult
== null || queryResult
.length
== 0) {
1461 UserExtensionsDocument
.UserExtensions a
= (UserExtensionsDocument
.UserExtensions
)queryResult
[0];
1463 return a
.getDomNode();
1466 public Node
getFpdUserExtensionPostBuild() {
1467 String
[] xPath
= new String
[] { "/UserExtensions[@UserID='TianoCore' and @Identifier='1']" };
1469 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1470 if (queryResult
== null || queryResult
.length
== 0) {
1473 UserExtensionsDocument
.UserExtensions a
= (UserExtensionsDocument
.UserExtensions
)queryResult
[0];
1475 return a
.getDomNode();
1479 * Retrieve FV image option information
1484 * @returns option name/value list if elements are found at the known xpath
1485 * @returns empty list if nothing is there
1487 public String
[][] getFpdOptions(String fvName
) {
1488 String
[] xPath
= new String
[] { "/Flash/FvImages/FvImage[@Type='Options' and ./FvImageNames='"
1489 + fvName
+ "']/FvImageOptions" };
1490 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1491 if (queryResult
== null) {
1492 return new String
[0][];
1494 ArrayList
<String
[]> list
= new ArrayList
<String
[]>();
1495 for (int i
= 0; i
< queryResult
.length
; i
++) {
1496 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions item
= (FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
) queryResult
[i
];
1497 List
<FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
> namevalues
= item
1498 .getNameValueList();
1499 Iterator iter
= namevalues
.iterator();
1500 while (iter
.hasNext()) {
1501 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nvItem
= (FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
) iter
1503 list
.add(new String
[] { nvItem
.getName(), nvItem
.getValue() });
1506 String
[][] result
= new String
[list
.size()][2];
1507 for (int i
= 0; i
< list
.size(); i
++) {
1508 result
[i
][0] = list
.get(i
)[0];
1509 result
[i
][1] = list
.get(i
)[1];
1515 public XmlObject
getFpdBuildOptions() {
1516 String
[] xPath
= new String
[] { "/BuildOptions" };
1518 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1520 if (queryResult
== null || queryResult
.length
== 0) {
1523 return (XmlObject
)queryResult
[0];
1526 public PlatformIdentification
getFpdHeader() {
1527 String
[] xPath
= new String
[] { "/PlatformHeader" };
1529 Object
[] returns
= get("PlatformSurfaceArea", xPath
);
1531 if (returns
== null || returns
.length
== 0) {
1534 PlatformHeaderDocument
.PlatformHeader header
= (PlatformHeaderDocument
.PlatformHeader
) returns
[0];
1536 String name
= header
.getPlatformName();
1538 String guid
= header
.getGuidValue();
1540 String version
= header
.getVersion();
1542 return new PlatformIdentification(name
, guid
, version
);
1546 * Retrieve FV image attributes information
1551 * @returns attribute name/value list if elements are found at the known
1553 * @returns empty list if nothing is there
1555 public String
[][] getFpdAttributes(String fvName
) {
1556 String
[] xPath
= new String
[] { "/Flash/FvImages/FvImage[@Type='Attributes' and ./FvImageNames='"
1557 + fvName
+ "']/FvImageOptions" };
1558 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1559 if (queryResult
== null) {
1560 return new String
[0][];
1562 ArrayList
<String
[]> list
= new ArrayList
<String
[]>();
1563 for (int i
= 0; i
< queryResult
.length
; i
++) {
1565 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions item
= (FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
) queryResult
[i
];
1566 List
<FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
> namevalues
= item
.getNameValueList();
1567 Iterator iter
= namevalues
.iterator();
1568 while (iter
.hasNext()) {
1569 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nvItem
= (FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
) iter
1571 list
.add(new String
[] { nvItem
.getName(), nvItem
.getValue() });
1574 String
[][] result
= new String
[list
.size()][2];
1575 for (int i
= 0; i
< list
.size(); i
++) {
1576 result
[i
][0] = list
.get(i
)[0];
1577 result
[i
][1] = list
.get(i
)[1];
1583 * Retrieve flash definition file name
1585 * @returns file name if elements are found at the known xpath
1586 * @returns null if nothing is there
1588 public String
getFlashDefinitionFile() {
1589 String
[] xPath
= new String
[] { "/PlatformDefinitions/FlashDeviceDefinitions/FlashDefinitionFile" };
1591 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1592 if (queryResult
== null || queryResult
.length
== 0) {
1596 FileNameConvention filename
= (FileNameConvention
) queryResult
[queryResult
.length
- 1];
1597 return filename
.getStringValue();
1600 public String
[][] getFpdGlobalVariable() {
1601 String
[] xPath
= new String
[] { "/Flash/FvImages/NameValue" };
1602 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1603 if (queryResult
== null) {
1604 return new String
[0][];
1607 String
[][] result
= new String
[queryResult
.length
][2];
1609 for (int i
= 0; i
< queryResult
.length
; i
++) {
1610 FvImagesDocument
.FvImages
.NameValue item
= (FvImagesDocument
.FvImages
.NameValue
)queryResult
[i
];
1611 result
[i
][0] = item
.getName();
1612 result
[i
][1] = item
.getValue();
1618 * Retrieve FV image component options
1623 * @returns name/value pairs list if elements are found at the known xpath
1624 * @returns empty list if nothing is there
1626 public String
[][] getFpdComponents(String fvName
) {
1627 String
[] xPath
= new String
[] { "/Flash/FvImages/FvImage[@Type='Components' and ./FvImageNames='"+ fvName
+ "']/FvImageOptions" };
1628 Object
[] queryResult
= get("PlatformSurfaceArea", xPath
);
1629 if (queryResult
== null) {
1630 return new String
[0][];
1633 ArrayList
<String
[]> list
= new ArrayList
<String
[]>();
1634 for (int i
= 0; i
< queryResult
.length
; i
++) {
1635 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions item
= (FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
) queryResult
[i
];
1636 List
<FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
> namevalues
= item
.getNameValueList();
1637 Iterator iter
= namevalues
.iterator();
1638 while (iter
.hasNext()) {
1639 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nvItem
= (FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
) iter
1641 list
.add(new String
[] { nvItem
.getName(), nvItem
.getValue() });
1644 String
[][] result
= new String
[list
.size()][2];
1645 for (int i
= 0; i
< list
.size(); i
++) {
1646 result
[i
][0] = list
.get(i
)[0];
1647 result
[i
][1] = list
.get(i
)[1];
1653 * Retrieve PCD tokens
1655 * @returns CName/ItemType pairs list if elements are found at the known
1657 * @returns null if nothing is there
1659 public String
[][] getPcdTokenArray() {
1660 String
[] xPath
= new String
[] { "/PcdData" };
1662 Object
[] returns
= get("PCDs", xPath
);
1663 if (returns
== null || returns
.length
== 0) {
1671 * Retrieve MAS header
1676 public ModuleIdentification
getMsaHeader() {
1677 String
[] xPath
= new String
[] { "/" };
1678 Object
[] returns
= get("MsaHeader", xPath
);
1680 if (returns
== null || returns
.length
== 0) {
1684 MsaHeader msaHeader
= (MsaHeader
) returns
[0];
1686 // Get BaseName, ModuleType, GuidValue, Version
1687 // which in MsaHeader.
1689 String name
= msaHeader
.getModuleName();
1690 String moduleType
= msaHeader
.getModuleType().toString();
1691 String guid
= msaHeader
.getGuidValue();
1692 String version
= msaHeader
.getVersion();
1694 ModuleIdentification moduleId
= new ModuleIdentification(name
, guid
,
1697 moduleId
.setModuleType(moduleType
);
1703 * Retrieve Extern Specification
1707 * @return String[] If have specification element in the <extern> String[0]
1708 * If no specification element in the <extern>
1712 public String
[] getExternSpecificaiton() {
1713 String
[] xPath
= new String
[] { "/Specification" };
1715 Object
[] queryResult
= get("Externs", xPath
);
1716 if (queryResult
== null) {
1717 return new String
[0];
1720 String
[] specificationList
= new String
[queryResult
.length
];
1721 for (int i
= 0; i
< queryResult
.length
; i
++) {
1722 specificationList
[i
] = ((Sentence
)queryResult
[i
])
1725 return specificationList
;
1729 * Retreive MsaFile which in SPD
1732 * @return String[][3] The string sequence is ModuleName, ModuleGuid,
1733 * ModuleVersion, MsaFile String[0][] If no msafile in SPD
1735 public String
[] getSpdMsaFile() {
1736 String
[] xPath
= new String
[] { "/MsaFiles" };
1738 Object
[] returns
= get("PackageSurfaceArea", xPath
);
1739 if (returns
== null) {
1740 return new String
[0];
1743 List
<String
> filenameList
= ((MsaFilesDocument
.MsaFiles
) returns
[0])
1745 return filenameList
.toArray(new String
[filenameList
.size()]);
1751 public Map
<String
, String
[]> getSpdLibraryClasses() {
1752 String
[] xPath
= new String
[] { "/LibraryClassDeclarations/LibraryClass" };
1754 Object
[] returns
= get("PackageSurfaceArea", xPath
);
1757 // Create Map, Key - LibraryClass, String[] - LibraryClass Header file.
1759 Map
<String
, String
[]> libClassHeaderMap
= new HashMap
<String
, String
[]>();
1761 if (returns
== null) {
1762 return libClassHeaderMap
;
1765 for (int i
= 0; i
< returns
.length
; i
++) {
1766 LibraryClassDeclarationsDocument
.LibraryClassDeclarations
.LibraryClass library
= (LibraryClassDeclarationsDocument
.LibraryClassDeclarations
.LibraryClass
) returns
[i
];
1767 libClassHeaderMap
.put(library
.getName(), new String
[] { library
1768 .getIncludeHeader() });
1770 return libClassHeaderMap
;
1776 public Map
<String
, String
> getSpdPackageHeaderFiles() {
1777 String
[] xPath
= new String
[] { "/PackageHeaders/IncludePkgHeader" };
1779 Object
[] returns
= get("PackageSurfaceArea", xPath
);
1782 // Create Map, Key - ModuleType, String - PackageInclude Header file.
1784 Map
<String
, String
> packageIncludeMap
= new HashMap
<String
, String
>();
1786 if (returns
== null) {
1787 return packageIncludeMap
;
1790 for (int i
= 0; i
< returns
.length
; i
++) {
1791 PackageHeadersDocument
.PackageHeaders
.IncludePkgHeader includeHeader
= (PackageHeadersDocument
.PackageHeaders
.IncludePkgHeader
) returns
[i
];
1792 packageIncludeMap
.put(includeHeader
.getModuleType().toString(),
1793 includeHeader
.getStringValue());
1795 return packageIncludeMap
;
1798 public PackageIdentification
getSpdHeader() {
1799 String
[] xPath
= new String
[] { "/SpdHeader" };
1801 Object
[] returns
= get("PackageSurfaceArea", xPath
);
1803 if (returns
== null || returns
.length
== 0) {
1807 SpdHeaderDocument
.SpdHeader header
= (SpdHeaderDocument
.SpdHeader
) returns
[0];
1809 String name
= header
.getPackageName();
1811 String guid
= header
.getGuidValue();
1813 String version
= header
.getVersion();
1815 return new PackageIdentification(name
, guid
, version
);
1821 public Map
<String
, String
[]> getSpdGuid() {
1822 String
[] xPath
= new String
[] { "/GuidDeclarations/Entry" };
1824 Object
[] returns
= get("PackageSurfaceArea", xPath
);
1827 // Create Map, Key - GuidName, String[] - C_NAME & GUID value.
1829 Map
<String
, String
[]> guidDeclMap
= new HashMap
<String
, String
[]>();
1830 if (returns
== null) {
1834 for (int i
= 0; i
< returns
.length
; i
++) {
1835 GuidDeclarationsDocument
.GuidDeclarations
.Entry entry
= (GuidDeclarationsDocument
.GuidDeclarations
.Entry
) returns
[i
];
1836 String
[] guidPair
= new String
[2];
1837 guidPair
[0] = entry
.getCName();
1838 guidPair
[1] = entry
.getGuidValue();
1839 guidDeclMap
.put(entry
.getCName(), guidPair
);
1847 public Map
<String
, String
[]> getSpdProtocol() {
1848 String
[] xPath
= new String
[] { "/ProtocolDeclarations/Entry" };
1850 Object
[] returns
= get("PackageSurfaceArea", xPath
);
1853 // Create Map, Key - protocolName, String[] - C_NAME & GUID value.
1855 Map
<String
, String
[]> protoclMap
= new HashMap
<String
, String
[]>();
1857 if (returns
== null) {
1861 for (int i
= 0; i
< returns
.length
; i
++) {
1862 ProtocolDeclarationsDocument
.ProtocolDeclarations
.Entry entry
= (ProtocolDeclarationsDocument
.ProtocolDeclarations
.Entry
) returns
[i
];
1863 String
[] protocolPair
= new String
[2];
1865 protocolPair
[0] = entry
.getCName();
1866 protocolPair
[1] = entry
.getGuidValue();
1867 protoclMap
.put(entry
.getCName(), protocolPair
);
1873 * getSpdPpi() Retrieve the SPD PPI Entry
1876 * @return Map<String, String[2]> if get the PPI entry from SPD. Key - PPI
1877 * Name String[0] - PPI CNAME String[1] - PPI Guid Null if no PPI
1880 public Map
<String
, String
[]> getSpdPpi() {
1881 String
[] xPath
= new String
[] { "/PpiDeclarations/Entry" };
1883 Object
[] returns
= get("PackageSurfaceArea", xPath
);
1886 // Create Map, Key - protocolName, String[] - C_NAME & GUID value.
1888 Map
<String
, String
[]> ppiMap
= new HashMap
<String
, String
[]>();
1890 if (returns
== null) {
1894 for (int i
= 0; i
< returns
.length
; i
++) {
1895 PpiDeclarationsDocument
.PpiDeclarations
.Entry entry
= (PpiDeclarationsDocument
.PpiDeclarations
.Entry
) returns
[i
];
1896 String
[] ppiPair
= new String
[2];
1897 ppiPair
[0] = entry
.getCName();
1898 ppiPair
[1] = entry
.getGuidValue();
1899 ppiMap
.put(entry
.getCName(), ppiPair
);
1905 * Retrieve module Guid string
1907 * @returns GUILD string if elements are found at the known xpath
1908 * @returns null if nothing is there
1910 public String
getModuleGuid() {
1911 String
[] xPath
= new String
[] { "" };
1913 Object
[] returns
= get("MsaHeader", xPath
);
1914 if (returns
!= null && returns
.length
> 0) {
1915 String guid
= ((MsaHeaderDocument
.MsaHeader
) returns
[0])
1926 public ModuleSADocument
.ModuleSA
[] getFpdModuleSAs() {
1927 String
[] xPath
= new String
[] { "/FrameworkModules/ModuleSA" };
1928 Object
[] result
= get("PlatformSurfaceArea", xPath
);
1929 if (result
!= null) {
1930 return (ModuleSADocument
.ModuleSA
[]) result
;
1932 return new ModuleSADocument
.ModuleSA
[0];
1936 Get name array of PCD in a module. In one module, token space
1937 is same, and token name should not be conflicted.
1941 public String
[] getModulePcdEntryNameArray() {
1942 PcdCodedDocument
.PcdCoded
.PcdEntry
[] pcdEntries
= null;
1945 String
[] xPath
= new String
[] {"/PcdEntry"};
1946 Object
[] returns
= get ("PcdCoded", xPath
);
1948 if (returns
== null) {
1949 return new String
[0];
1952 pcdEntries
= (PcdCodedDocument
.PcdCoded
.PcdEntry
[])returns
;
1953 results
= new String
[pcdEntries
.length
];
1955 for (index
= 0; index
< pcdEntries
.length
; index
++) {
1956 results
[index
] = pcdEntries
[index
].getCName();
1962 Search in a List for a given string
1966 public boolean contains(List list
, String str
) {
1967 if (list
== null || list
.size()== 0) {
1970 Iterator it
= list
.iterator();
1971 while (it
.hasNext()) {
1972 String s
= (String
)it
.next();
1973 if (s
.equalsIgnoreCase(str
)) {
1981 public boolean isHaveTianoR8FlashMap(){
1982 String
[] xPath
= new String
[] {"/"};
1983 Object
[] returns
= get ("Externs", xPath
);
1985 if (returns
== null) {
1989 ExternsDocument
.Externs ext
= (ExternsDocument
.Externs
)returns
[0];
1991 if (ext
.getTianoR8FlashMapH()){
1998 public Node
getFpdModuleSequence(String fvName
) {
1999 String
[] xPath
= new String
[] { "/BuildOptions/UserExtensions[@UserID='IMAGES' and @Identifier='1' and ./FvName='" + fvName
+ "']" };
2000 Object
[] result
= get("PlatformSurfaceArea", xPath
);
2002 if (result
== null || result
.length
== 0) {
2006 UserExtensionsDocument
.UserExtensions a
= (UserExtensionsDocument
.UserExtensions
)result
[0];
2008 return a
.getDomNode();