2 Java class FpdFileContents is used to parse fpd xml file.
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.
13 package org
.tianocore
.frameworkwizard
.platform
.ui
;
16 import java
.io
.IOException
;
17 import java
.math
.BigInteger
;
18 import java
.util
.ArrayList
;
19 import java
.util
.HashMap
;
20 import java
.util
.Iterator
;
21 import java
.util
.LinkedHashMap
;
22 import java
.util
.List
;
23 import java
.util
.ListIterator
;
26 import java
.util
.Vector
;
28 import javax
.xml
.namespace
.QName
;
30 import org
.apache
.xmlbeans
.XmlCursor
;
31 import org
.apache
.xmlbeans
.XmlObject
;
32 import org
.apache
.xmlbeans
.XmlOptions
;
33 import org
.tianocore
.AntTaskDocument
;
34 import org
.tianocore
.BuildOptionsDocument
;
35 import org
.tianocore
.DynamicPcdBuildDefinitionsDocument
;
36 import org
.tianocore
.EfiSectionType
;
37 import org
.tianocore
.FlashDefinitionFileDocument
;
38 import org
.tianocore
.FlashDocument
;
39 import org
.tianocore
.FrameworkModulesDocument
;
40 import org
.tianocore
.IntermediateOutputType
;
41 import org
.tianocore
.LibrariesDocument
;
42 import org
.tianocore
.ModuleSADocument
;
43 import org
.tianocore
.ModuleSaBuildOptionsDocument
;
44 import org
.tianocore
.ModuleSurfaceAreaDocument
;
45 import org
.tianocore
.OptionDocument
;
46 import org
.tianocore
.OptionsDocument
;
47 import org
.tianocore
.PcdBuildDefinitionDocument
;
48 import org
.tianocore
.PcdCodedDocument
;
49 import org
.tianocore
.PcdDataTypes
;
50 import org
.tianocore
.PcdDeclarationsDocument
;
51 import org
.tianocore
.PcdItemTypes
;
52 import org
.tianocore
.PlatformDefinitionsDocument
;
53 import org
.tianocore
.PlatformSurfaceAreaDocument
;
54 import org
.tianocore
.FvImageTypes
;
55 import org
.tianocore
.FvImagesDocument
;
56 import org
.tianocore
.LicenseDocument
;
57 import org
.tianocore
.PlatformHeaderDocument
;
58 import org
.tianocore
.SkuInfoDocument
;
59 import org
.tianocore
.UserDefinedAntTasksDocument
;
60 import org
.tianocore
.UserExtensionsDocument
;
61 import org
.tianocore
.frameworkwizard
.platform
.ui
.global
.WorkspaceProfile
;
62 import org
.tianocore
.frameworkwizard
.platform
.ui
.global
.SurfaceAreaQuery
;
63 import org
.tianocore
.frameworkwizard
.module
.Identifications
.ModuleIdentification
;
64 import org
.tianocore
.frameworkwizard
.packaging
.PackageIdentification
;
67 This class processes fpd file contents such as add remove xml elements.
68 @since PackageEditor 1.0
70 public class FpdFileContents
{
72 static final String xmlNs
= "http://www.TianoCore.org/2006/Edk2.0";
74 private PlatformSurfaceAreaDocument fpdd
= null;
76 private PlatformSurfaceAreaDocument
.PlatformSurfaceArea fpdRoot
= null;
78 private PlatformHeaderDocument
.PlatformHeader fpdHdr
= null;
80 private PlatformDefinitionsDocument
.PlatformDefinitions fpdPlatformDefs
= null;
82 private FlashDocument
.Flash fpdFlash
= null;
84 private BuildOptionsDocument
.BuildOptions fpdBuildOpts
= null;
86 private FrameworkModulesDocument
.FrameworkModules fpdFrameworkModules
= null;
88 private DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions fpdDynPcdBuildDefs
= null;
90 private HashMap
<String
, ArrayList
<String
>> dynPcdMap
= null;
92 private HashMap
<String
, String
> defaultPcdValue
= new HashMap
<String
, String
>();
95 * look through all pcd data in all ModuleSA, create pcd -> ModuleSA mappings.
97 public void initDynPcdMap() {
98 if (dynPcdMap
== null) {
99 dynPcdMap
= new HashMap
<String
, ArrayList
<String
>>();
100 List
<ModuleSADocument
.ModuleSA
> l
= getfpdFrameworkModules().getModuleSAList();
102 removeElement(getfpdFrameworkModules());
103 fpdFrameworkModules
= null;
106 ListIterator
<ModuleSADocument
.ModuleSA
> li
= l
.listIterator();
107 while (li
.hasNext()) {
108 ModuleSADocument
.ModuleSA moduleSa
= li
.next();
109 if (moduleSa
.getPcdBuildDefinition() == null || moduleSa
.getPcdBuildDefinition().getPcdDataList() == null) {
112 String ModuleInfo
= moduleSa
.getModuleGuid() + " " + moduleSa
.getModuleVersion() +
113 " " + moduleSa
.getPackageGuid() + " " + moduleSa
.getPackageVersion() + " " + listToString(moduleSa
.getSupArchList());
114 List
<PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
> lp
= moduleSa
.getPcdBuildDefinition().getPcdDataList();
115 ListIterator
<PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
> lpi
= lp
.listIterator();
116 while (lpi
.hasNext()) {
117 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= lpi
.next();
118 String pcdKey
= pcdData
.getCName() + " " + pcdData
.getTokenSpaceGuidCName();
119 if (dynPcdMap
.get(pcdKey
) == null) {
120 ArrayList
<String
> al
= new ArrayList
<String
>();
121 al
.add(ModuleInfo
+ " " + pcdData
.getItemType().toString());
122 dynPcdMap
.put(pcdKey
, al
);
125 dynPcdMap
.get(pcdKey
).add(ModuleInfo
+ " " + pcdData
.getItemType().toString());
132 public ArrayList
<String
> getDynPcdMapValue(String key
) {
133 return dynPcdMap
.get(key
);
136 Constructor to create a new spd file
138 public FpdFileContents() {
140 fpdd
= PlatformSurfaceAreaDocument
.Factory
.newInstance();
141 fpdRoot
= fpdd
.addNewPlatformSurfaceArea();
146 Constructor for existing document object
149 public FpdFileContents(PlatformSurfaceAreaDocument
.PlatformSurfaceArea fpd
) {
151 fpdHdr
= fpdRoot
.getPlatformHeader();
152 fpdPlatformDefs
= fpdRoot
.getPlatformDefinitions();
153 fpdBuildOpts
= fpdRoot
.getBuildOptions();
154 fpdFrameworkModules
= fpdRoot
.getFrameworkModules();
155 fpdDynPcdBuildDefs
= fpdRoot
.getDynamicPcdBuildDefinitions();
156 fpdFlash
= fpdRoot
.getFlash();
160 Constructor based on an existing spd file
162 @param f Existing spd file
164 public FpdFileContents(File f
) {
166 fpdd
= PlatformSurfaceAreaDocument
.Factory
.parse(f
);
167 fpdRoot
= fpdd
.getPlatformSurfaceArea();
168 } catch (Exception e
) {
169 System
.out
.println(e
.toString());
173 public DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
getfpdDynPcdBuildDefs() {
174 if (fpdDynPcdBuildDefs
== null){
175 fpdDynPcdBuildDefs
= fpdRoot
.addNewDynamicPcdBuildDefinitions();
177 return fpdDynPcdBuildDefs
;
180 public FrameworkModulesDocument
.FrameworkModules
getfpdFrameworkModules() {
181 if (fpdFrameworkModules
== null){
182 fpdFrameworkModules
= fpdRoot
.addNewFrameworkModules();
184 return fpdFrameworkModules
;
187 public int getFrameworkModulesCount() {
188 if (getfpdFrameworkModules().getModuleSAList() == null || getfpdFrameworkModules().getModuleSAList().size() == 0){
189 removeElement(getfpdFrameworkModules());
190 fpdFrameworkModules
= null;
193 return getfpdFrameworkModules().getModuleSAList().size();
196 public void getFrameworkModulesInfo(String
[][] saa
) {
197 if (getFrameworkModulesCount() == 0){
201 ListIterator li
= getfpdFrameworkModules().getModuleSAList().listIterator();
203 while(li
.hasNext()) {
204 ModuleSADocument
.ModuleSA msa
= (ModuleSADocument
.ModuleSA
)li
.next();
205 saa
[i
][0] = msa
.getModuleGuid();
206 saa
[i
][1] = msa
.getModuleVersion();
208 saa
[i
][2] = msa
.getPackageGuid();
209 saa
[i
][3] = msa
.getPackageVersion();
210 saa
[i
][4] = listToString(msa
.getSupArchList());
215 public void getFrameworkModuleInfo(int i
, String
[] sa
) {
216 ModuleSADocument
.ModuleSA msa
= getModuleSA(i
);
220 sa
[0] = msa
.getModuleGuid();
221 sa
[1] = msa
.getModuleVersion();
222 sa
[2] = msa
.getPackageGuid();
223 sa
[3] = msa
.getPackageVersion();
224 sa
[4] = listToString(msa
.getSupArchList());
227 public ModuleSADocument
.ModuleSA
getModuleSA(String key
) {
228 String
[] s
= key
.split(" ");
229 if (getfpdFrameworkModules().getModuleSAList() == null || getfpdFrameworkModules().getModuleSAList().size() == 0) {
230 removeElement(getfpdFrameworkModules());
231 fpdFrameworkModules
= null;
234 ListIterator li
= getfpdFrameworkModules().getModuleSAList().listIterator();
235 while(li
.hasNext()) {
236 ModuleSADocument
.ModuleSA moduleSa
= (ModuleSADocument
.ModuleSA
)li
.next();
237 if (moduleSa
.getModuleGuid().equalsIgnoreCase(s
[0]) && moduleSa
.getPackageGuid().equalsIgnoreCase(s
[2])) {
238 if (moduleSa
.getModuleVersion() != null) {
239 if (!moduleSa
.getModuleVersion().equals(s
[1])) {
243 if (moduleSa
.getPackageVersion() != null) {
244 if (!moduleSa
.getPackageVersion().equals(s
[3])) {
248 //ToDo add arch check for s[4]
249 if (moduleSa
.getSupArchList() != null) {
250 if (!listToString(moduleSa
.getSupArchList()).equals(s
[4])) {
260 private ModuleSADocument
.ModuleSA
getModuleSA(int i
) {
261 ModuleSADocument
.ModuleSA moduleSa
= null;
262 if (fpdRoot
.getFrameworkModules() == null) {
265 XmlCursor cursor
= fpdRoot
.getFrameworkModules().newCursor();
266 if (cursor
.toFirstChild()) {
267 for (int j
= 0; j
< i
; ++j
) {
268 cursor
.toNextSibling();
270 moduleSa
= (ModuleSADocument
.ModuleSA
)cursor
.getObject();
276 public void removeModuleSA(int i
) {
277 XmlObject o
= fpdRoot
.getFrameworkModules();
282 XmlCursor cursor
= o
.newCursor();
283 if (cursor
.toFirstChild()) {
284 for (int j
= 0; j
< i
; ++j
) {
285 cursor
.toNextSibling();
288 // remove pcd from dynPcdMap, if DynamicPcdBuildData exists, remove them too.
290 ModuleSADocument
.ModuleSA moduleSa
= (ModuleSADocument
.ModuleSA
)cursor
.getObject();
291 String moduleInfo
= moduleSa
.getModuleGuid() + " " + moduleSa
.getModuleVersion() + " " +
292 moduleSa
.getPackageGuid()+ " " + moduleSa
.getPackageVersion() + " " + listToString(moduleSa
.getSupArchList());
293 PcdBuildDefinitionDocument
.PcdBuildDefinition pcdBuildDef
= moduleSa
.getPcdBuildDefinition();
294 if (pcdBuildDef
!= null && pcdBuildDef
.getPcdDataList() != null) {
295 ListIterator
<PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
> li
= pcdBuildDef
.getPcdDataList().listIterator();
296 while(li
.hasNext()) {
297 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= li
.next();
298 maintainDynPcdMap(pcdData
.getCName() + " " + pcdData
.getTokenSpaceGuidCName(), moduleInfo
);
303 cursor
.toPrevToken();
304 if (cursor
.isComment()) {
309 if (getFrameworkModulesCount() == 0) {
317 public boolean adjustPcd (int seqModuleSa
) throws Exception
{
318 boolean dataModified
= false;
319 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(seqModuleSa
);
320 int pcdCount
= getPcdDataCount(seqModuleSa
);
321 String
[][] saaModuleSaPcd
= new String
[pcdCount
][7];
322 getPcdData(seqModuleSa
, saaModuleSaPcd
);
323 String mg
= moduleSa
.getModuleGuid();
324 String mv
= moduleSa
.getModuleVersion();
325 String pg
= moduleSa
.getPackageGuid();
326 String pv
= moduleSa
.getPackageVersion();
327 String arch
= listToString(moduleSa
.getSupArchList());
329 // delete pcd in ModuleSA but not in MSA files any longer.
331 String moduleKey
= mg
+ " " + mv
+ " " + pg
+ " " + pv
+ " " + arch
;
332 int libCount
= getLibraryInstancesCount(moduleKey
);
333 String
[][] saaLib
= new String
[libCount
][5];
334 getLibraryInstances(moduleKey
, saaLib
);
335 ModuleIdentification mi
= WorkspaceProfile
.getModuleId(moduleKey
);
336 Vector
<ModuleIdentification
> vMi
= new Vector
<ModuleIdentification
>();
339 nextPcd
:for (int i
= 0; i
< saaModuleSaPcd
.length
; ++i
) {
340 if (WorkspaceProfile
.pcdInMsa(saaModuleSaPcd
[i
][0], saaModuleSaPcd
[i
][1], mi
)){
343 for (int j
= 0; j
< saaLib
.length
; ++j
) {
344 String libKey
= saaLib
[j
][1] + " " + saaLib
[j
][2] + " " + saaLib
[j
][3] + " " + saaLib
[j
][4];
345 ModuleIdentification libMi
= WorkspaceProfile
.getModuleId(libKey
);
347 if (WorkspaceProfile
.pcdInMsa(saaModuleSaPcd
[i
][0], saaModuleSaPcd
[i
][1], libMi
)) {
351 removePcdData(seqModuleSa
, saaModuleSaPcd
[i
][0], saaModuleSaPcd
[i
][1]);
355 catch (Exception e
) {
359 // add new Pcd from MSA file to ModuleSA.
363 for (int i
= 0; i
< vMi
.size(); ++i
) {
364 ModuleSurfaceAreaDocument
.ModuleSurfaceArea msa
= (ModuleSurfaceAreaDocument
.ModuleSurfaceArea
) WorkspaceProfile
365 .getModuleXmlObject(vMi
367 if (msa
.getPcdCoded() == null || msa
.getPcdCoded().getPcdEntryList() == null) {
370 ListIterator li
= msa
.getPcdCoded().getPcdEntryList().listIterator();
371 msaPcdIter
:while (li
.hasNext()) {
372 PcdCodedDocument
.PcdCoded
.PcdEntry msaPcd
= (PcdCodedDocument
.PcdCoded
.PcdEntry
) li
.next();
373 ArrayList
<String
> al
= getDynPcdMapValue(msaPcd
.getCName() + " " + msaPcd
.getTokenSpaceGuidCName());
375 for (int j
= 0; j
< al
.size(); ++j
) {
376 if (al
.get(j
).contains(moduleKey
)) {
382 Map
<String
, XmlObject
> m
= new HashMap
<String
, XmlObject
>();
383 m
.put("ModuleSurfaceArea", msa
);
384 SurfaceAreaQuery
.setDoc(m
);
385 PackageIdentification
[] depPkgs
= SurfaceAreaQuery
.getDependencePkg(null, vMi
.get(i
));
386 PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry spdPcd
= LookupPcdDeclaration(msaPcd
, depPkgs
);
387 if (spdPcd
== null) {
391 throw new PcdDeclNotFound("No Declaration for PCD Entry " + msaPcd
.getCName() + " in Module "
395 // AddItem to ModuleSA PcdBuildDefinitions
397 String defaultVal
= msaPcd
.getDefaultValue() == null ? spdPcd
.getDefaultValue()
398 : msaPcd
.getDefaultValue();
400 genPcdData(msaPcd
.getCName(), spdPcd
.getToken(), msaPcd
.getTokenSpaceGuidCName(),
401 msaPcd
.getPcdItemType().toString(), spdPcd
.getDatumType() + "", defaultVal
, moduleSa
);
414 private void maintainDynPcdMap(String pcdKey
, String moduleInfo
) {
416 ArrayList
<String
> al
= dynPcdMap
.get(pcdKey
);
420 String
[] s
= moduleInfo
.split(" ");
421 for(int i
= 0; i
< al
.size(); ++i
){
422 String consumer
= al
.get(i
);
423 if (consumer
.contains(s
[0]) && consumer
.contains(s
[2])){
424 String
[] consumerPart
= consumer
.split(" ");
425 if (!consumerPart
[4].equals(s
[4])) {
433 if (al
.size() == 0) {
434 defaultPcdValue
.remove(pcdKey
);
435 dynPcdMap
.remove(pcdKey
);
436 String
[] s1
= pcdKey
.split(" ");
437 removeDynamicPcdBuildData(s1
[0], s1
[1]);
442 // key for ModuleSA : "ModuleGuid ModuleVer PackageGuid PackageVer Arch"
444 public int getPcdDataCount (int i
){
445 ModuleSADocument
.ModuleSA msa
= getModuleSA(i
);
447 if (msa
== null || msa
.getPcdBuildDefinition() == null || msa
.getPcdBuildDefinition().getPcdDataList() == null){
450 return msa
.getPcdBuildDefinition().getPcdDataList().size();
454 public void getPcdData (int i
, String
[][] saa
) {
455 ModuleSADocument
.ModuleSA msa
= getModuleSA(i
);
457 if (msa
== null || msa
.getPcdBuildDefinition() == null || msa
.getPcdBuildDefinition().getPcdDataList() == null){
460 ListIterator
<PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
>li
= msa
.getPcdBuildDefinition().getPcdDataList().listIterator();
461 for (int k
= 0; k
< saa
.length
; ++k
) {
462 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= li
.next();
463 saa
[k
][0] = pcdData
.getCName();
464 saa
[k
][1] = pcdData
.getTokenSpaceGuidCName();
465 saa
[k
][2] = pcdData
.getItemType()+"";
466 saa
[k
][3] = pcdData
.getToken().toString();
467 saa
[k
][4] = pcdData
.getMaxDatumSize()+"";
468 saa
[k
][5] = pcdData
.getDatumType()+"";
469 saa
[k
][6] = pcdData
.getValue();
474 public void removePcdData (int seqModuleSa
, String cName
, String tsGuid
) {
475 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(seqModuleSa
);
476 if (moduleSa
== null || moduleSa
.getPcdBuildDefinition() == null){
480 String mg
= moduleSa
.getModuleGuid();
481 String mv
= moduleSa
.getModuleVersion();
482 String pg
= moduleSa
.getPackageGuid();
483 String pv
= moduleSa
.getPackageVersion();
484 String arch
= listToString(moduleSa
.getSupArchList());
485 String moduleKey
= mg
+ " " + mv
+ " " + pg
+ " " + pv
+ " " + arch
;
487 XmlCursor cursor
= moduleSa
.getPcdBuildDefinition().newCursor();
488 if (cursor
.toFirstChild()){
491 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= (PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
)cursor
.getObject();
492 if (pcdData
.getCName().equals(cName
) && pcdData
.getTokenSpaceGuidCName().equals(tsGuid
)) {
493 maintainDynPcdMap(cName
+ " " + tsGuid
, moduleKey
);
494 if (getPcdDataCount(seqModuleSa
) == 1) {
501 while(cursor
.toNextSibling());
507 public void updatePcdData (String key
, String cName
, String tsGuid
, String itemType
, String maxSize
, String value
){
508 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(key
);
509 if (moduleSa
== null || moduleSa
.getPcdBuildDefinition() == null){
513 XmlCursor cursor
= moduleSa
.getPcdBuildDefinition().newCursor();
514 if (cursor
.toFirstChild()){
516 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= (PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
)cursor
.getObject();
517 if (pcdData
.getCName().equals(cName
) && pcdData
.getTokenSpaceGuidCName().equals(tsGuid
)) {
518 pcdData
.setItemType(PcdItemTypes
.Enum
.forString(itemType
));
519 if(pcdData
.getDatumType().equals("VOID*")) {
520 pcdData
.setMaxDatumSize(new Integer(maxSize
));
522 pcdData
.setValue(value
);
523 defaultPcdValue
.put(cName
+ " " + tsGuid
, value
);
527 while(cursor
.toNextSibling());
532 /**Get original Pcd info from MSA & SPD files.
533 * @param mi ModuleIdentification from which MSA & SPD come
534 * @param cName PCD cName
535 * @param sa Results: HelpText, Original item type.
538 public boolean getPcdBuildDataInfo(ModuleIdentification mi
, String cName
, String tsGuid
, String
[] sa
) throws Exception
{
541 ModuleSurfaceAreaDocument
.ModuleSurfaceArea msa
= (ModuleSurfaceAreaDocument
.ModuleSurfaceArea
)WorkspaceProfile
.getModuleXmlObject(mi
);
542 if (msa
.getPcdCoded() == null) {
546 Map
<String
, XmlObject
> m
= new HashMap
<String
, XmlObject
>();
547 m
.put("ModuleSurfaceArea", msa
);
548 SurfaceAreaQuery
.setDoc(m
);
549 PackageIdentification
[] depPkgs
= SurfaceAreaQuery
.getDependencePkg(null, mi
);
551 // First look through MSA pcd entries.
553 List
<PcdCodedDocument
.PcdCoded
.PcdEntry
> l
= msa
.getPcdCoded().getPcdEntryList();
554 ListIterator li
= l
.listIterator();
555 while(li
.hasNext()) {
556 PcdCodedDocument
.PcdCoded
.PcdEntry msaPcd
= (PcdCodedDocument
.PcdCoded
.PcdEntry
)li
.next();
557 if (!msaPcd
.getCName().equals(cName
)) {
560 if (!msaPcd
.getTokenSpaceGuidCName().equals(tsGuid
)) {
563 PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry spdPcd
= LookupPcdDeclaration(msaPcd
, depPkgs
);
564 if (spdPcd
== null) {
568 throw new PcdDeclNotFound(mi
.getName() + " " + msaPcd
.getCName());
571 // Get Pcd help text and original item type.
573 sa
[0] = spdPcd
.getHelpText() + msaPcd
.getHelpText();
574 sa
[1] = msaPcd
.getPcdItemType()+"";
588 /**Remove PCDBuildDefinition entries from ModuleSA
589 * @param moduleKey identifier of ModuleSA.
590 * @param consumer where these entries come from.
592 public void removePcdData(String moduleKey
, ModuleIdentification consumer
) {
594 ModuleSurfaceAreaDocument
.ModuleSurfaceArea msa
= (ModuleSurfaceAreaDocument
.ModuleSurfaceArea
)WorkspaceProfile
.getModuleXmlObject(consumer
);
595 if (msa
.getPcdCoded() == null) {
599 List
<PcdCodedDocument
.PcdCoded
.PcdEntry
> l
= msa
.getPcdCoded().getPcdEntryList();
600 ListIterator li
= l
.listIterator();
602 while(li
.hasNext()) {
603 PcdCodedDocument
.PcdCoded
.PcdEntry msaPcd
= (PcdCodedDocument
.PcdCoded
.PcdEntry
)li
.next();
604 ModuleSADocument
.ModuleSA moduleSA
= getModuleSA(moduleKey
);
605 if (moduleSA
.getPcdBuildDefinition() != null) {
606 XmlCursor cursor
= moduleSA
.getPcdBuildDefinition().newCursor();
607 if (cursor
.toFirstChild()) {
608 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= (PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
) cursor
610 if (msaPcd
.getCName().equals(pcdData
.getCName())
611 && msaPcd
.getTokenSpaceGuidCName().equals(pcdData
.getTokenSpaceGuidCName())) {
613 maintainDynPcdMap(pcdData
.getCName() + " " + pcdData
.getTokenSpaceGuidCName(), moduleKey
);
617 while (cursor
.toNextSibling()) {
618 pcdData
= (PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
) cursor
.getObject();
619 if (msaPcd
.getCName().equals(pcdData
.getCName())
620 && msaPcd
.getTokenSpaceGuidCName().equals(pcdData
.getTokenSpaceGuidCName())) {
621 maintainDynPcdMap(pcdData
.getCName() + " " + pcdData
.getTokenSpaceGuidCName(),
639 // key for ModuleSA : "ModuleGuid ModuleVer PackageGuid PackageVer Arch"
641 public int getLibraryInstancesCount(String key
) {
642 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
643 if (msa
== null || msa
.getLibraries() == null || msa
.getLibraries().getInstanceList() == null){
646 return msa
.getLibraries().getInstanceList().size();
649 public void getLibraryInstances(String key
, String
[][] saa
){
650 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
651 if (msa
== null || msa
.getLibraries() == null || msa
.getLibraries().getInstanceList() == null){
655 ListIterator
<LibrariesDocument
.Libraries
.Instance
> li
= msa
.getLibraries().getInstanceList().listIterator();
656 for (int i
= 0; i
< saa
.length
; ++i
) {
657 LibrariesDocument
.Libraries
.Instance instance
= li
.next();
658 saa
[i
][1] = instance
.getModuleGuid();
659 saa
[i
][2] = instance
.getModuleVersion();
660 saa
[i
][3] = instance
.getPackageGuid();
661 saa
[i
][4] = instance
.getPackageVersion();
665 public void removeLibraryInstance(String key
, int i
) {
666 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
667 if (msa
== null || msa
.getLibraries() == null){
671 XmlCursor cursor
= msa
.getLibraries().newCursor();
672 if (cursor
.toFirstChild()) {
673 for (int j
= 0; j
< i
; ++j
) {
674 cursor
.toNextSibling();
677 cursor
.toPrevToken();
678 if (cursor
.isComment()) {
683 if (getLibraryInstancesCount(key
) == 0) {
692 public void genLibraryInstance(ModuleIdentification libMi
, String key
) {
693 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
695 msa
= getfpdFrameworkModules().addNewModuleSA();
697 LibrariesDocument
.Libraries libs
= msa
.getLibraries();
699 libs
= msa
.addNewLibraries();
702 String mn
= libMi
.getName();
703 String mg
= libMi
.getGuid();
704 String mv
= libMi
.getVersion();
705 String pn
= libMi
.getPackageId().getName();
706 String pg
= libMi
.getPackageId().getGuid();
707 String pv
= libMi
.getPackageId().getVersion();
708 LibrariesDocument
.Libraries
.Instance instance
= libs
.addNewInstance();
709 XmlCursor cursor
= instance
.newCursor();
711 String comment
= "Pkg: " + pn
+ " Mod: " + mn
712 + " Path: " + libMi
.getPath().substring(System
.getenv("WORKSPACE").length() + 1);
713 cursor
.insertComment(comment
);
722 instance
.setModuleGuid(mg
);
723 instance
.setModuleVersion(mv
);
724 instance
.setPackageGuid(pg
);
725 instance
.setPackageVersion(pv
);
729 public String
getFvBinding(String moduleKey
){
730 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
731 if (msa
== null || msa
.getModuleSaBuildOptions() == null) {
734 return msa
.getModuleSaBuildOptions().getFvBinding();
737 public void setFvBinding(String moduleKey
, String fvBinding
){
738 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
742 if(msa
.getModuleSaBuildOptions() == null){
743 msa
.addNewModuleSaBuildOptions().setFvBinding(fvBinding
);
746 msa
.getModuleSaBuildOptions().setFvBinding(fvBinding
);
749 public String
getFfsFileNameGuid(String moduleKey
){
750 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
751 if (msa
== null || msa
.getModuleSaBuildOptions() == null) {
754 return msa
.getModuleSaBuildOptions().getFfsFileNameGuid();
757 public void setFfsFileNameGuid(String moduleKey
, String fileGuid
){
758 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
762 if(msa
.getModuleSaBuildOptions() == null){
763 msa
.addNewModuleSaBuildOptions();
766 ModuleSaBuildOptionsDocument
.ModuleSaBuildOptions msaBuildOpts
= msa
.getModuleSaBuildOptions();
767 if (fileGuid
!= null) {
768 msaBuildOpts
.setFfsFileNameGuid(fileGuid
);
771 XmlCursor cursor
= msaBuildOpts
.newCursor();
772 if (cursor
.toChild(xmlNs
, "FfsFileNameGuid")) {
780 public String
getFfsFormatKey(String moduleKey
){
781 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
782 if (msa
== null || msa
.getModuleSaBuildOptions() == null) {
785 return msa
.getModuleSaBuildOptions().getFfsFormatKey();
788 public void setFfsFormatKey(String moduleKey
, String ffsKey
){
789 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
793 if(msa
.getModuleSaBuildOptions() == null){
794 msa
.addNewModuleSaBuildOptions().setFfsFormatKey(ffsKey
);
797 msa
.getModuleSaBuildOptions().setFfsFormatKey(ffsKey
);
800 public void setModuleSAForceDebug(int i
, boolean dbgEnable
) {
801 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(i
);
802 moduleSa
.setForceDebug(dbgEnable
);
805 public boolean getModuleSAForceDebug (int i
) {
806 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(i
);
807 if (moduleSa
.getForceDebug() == true) {
813 public void getModuleSAOptions(String moduleKey
, String
[][] saa
) {
814 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
815 if (msa
== null || msa
.getModuleSaBuildOptions() == null || msa
.getModuleSaBuildOptions().getOptions() == null
816 || msa
.getModuleSaBuildOptions().getOptions().getOptionList() == null) {
820 List
<OptionDocument
.Option
> lOpt
= msa
.getModuleSaBuildOptions().getOptions().getOptionList();
821 ListIterator li
= lOpt
.listIterator();
823 while(li
.hasNext()) {
824 OptionDocument
.Option opt
= (OptionDocument
.Option
)li
.next();
825 if (opt
.getBuildTargets() != null) {
826 saa
[i
][0] = listToString(opt
.getBuildTargets());
828 saa
[i
][1] = opt
.getToolChainFamily();
829 saa
[i
][2] = opt
.getTagName();
830 saa
[i
][3] = opt
.getToolCode();
832 if (opt
.getSupArchList() != null){
833 saa
[i
][4] = listToString(opt
.getSupArchList());
837 saa
[i
][5] = opt
.getStringValue();
843 public int getModuleSAOptionsCount(String moduleKey
){
844 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
845 if (msa
== null || msa
.getModuleSaBuildOptions() == null || msa
.getModuleSaBuildOptions().getOptions() == null
846 || msa
.getModuleSaBuildOptions().getOptions().getOptionList() == null) {
849 return msa
.getModuleSaBuildOptions().getOptions().getOptionList().size();
852 public void genModuleSAOptionsOpt(String moduleKey
, Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
) {
853 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
854 if (msa
.getModuleSaBuildOptions() == null) {
855 msa
.addNewModuleSaBuildOptions();
857 if (msa
.getModuleSaBuildOptions().getOptions() == null){
858 msa
.getModuleSaBuildOptions().addNewOptions();
860 OptionDocument
.Option opt
= msa
.getModuleSaBuildOptions().getOptions().addNewOption();
861 setBuildOptionsOpt(buildTargets
, toolChain
, tagName
, toolCmd
, archList
, contents
, opt
);
864 public void removeModuleSAOptionsOpt(String moduleKey
, int i
) {
865 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
866 if (msa
.getModuleSaBuildOptions() == null || msa
.getModuleSaBuildOptions().getOptions() == null) {
869 OptionsDocument
.Options opts
= msa
.getModuleSaBuildOptions().getOptions();
870 XmlCursor cursor
= opts
.newCursor();
871 if (cursor
.toFirstChild()) {
872 for (int j
= 0; j
< i
; ++j
){
873 cursor
.toNextSibling();
880 public void updateModuleSAOptionsOpt(String moduleKey
, int i
, Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
) {
881 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
882 if (msa
.getModuleSaBuildOptions() == null || msa
.getModuleSaBuildOptions().getOptions() == null) {
885 OptionsDocument
.Options opts
= msa
.getModuleSaBuildOptions().getOptions();
886 XmlCursor cursor
= opts
.newCursor();
887 if (cursor
.toFirstChild()) {
888 for (int j
= 0; j
< i
; ++j
){
889 cursor
.toNextSibling();
891 OptionDocument
.Option opt
= (OptionDocument
.Option
)cursor
.getObject();
892 setBuildOptionsOpt(buildTargets
, toolChain
, tagName
, toolCmd
, archList
, contents
, opt
);
897 /**add pcd information of module mi to a ModuleSA.
899 * @param moduleSa if null, generate a new ModuleSA.
901 public void addFrameworkModulesPcdBuildDefs(ModuleIdentification mi
, String arch
, ModuleSADocument
.ModuleSA moduleSa
) throws Exception
{
902 //ToDo add Arch filter
905 if (moduleSa
== null) {
906 moduleSa
= genModuleSA(mi
, arch
);
909 ModuleSurfaceAreaDocument
.ModuleSurfaceArea msa
= (ModuleSurfaceAreaDocument
.ModuleSurfaceArea
)WorkspaceProfile
.getModuleXmlObject(mi
);
910 if (msa
.getPcdCoded() == null) {
914 Map
<String
, XmlObject
> m
= new HashMap
<String
, XmlObject
>();
915 m
.put("ModuleSurfaceArea", msa
);
916 SurfaceAreaQuery
.setDoc(m
);
917 PackageIdentification
[] depPkgs
= SurfaceAreaQuery
.getDependencePkg(null, mi
);
919 // Implementing InitializePlatformPcdBuildDefinitions
921 List
<PcdCodedDocument
.PcdCoded
.PcdEntry
> l
= msa
.getPcdCoded().getPcdEntryList();
922 ListIterator li
= l
.listIterator();
923 while(li
.hasNext()) {
924 PcdCodedDocument
.PcdCoded
.PcdEntry msaPcd
= (PcdCodedDocument
.PcdCoded
.PcdEntry
)li
.next();
925 PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry spdPcd
= LookupPcdDeclaration(msaPcd
, depPkgs
);
926 if (spdPcd
== null) {
930 throw new PcdDeclNotFound("No Declaration for PCD Entry " + msaPcd
.getCName() + " in Module " + mi
.getName());
933 // AddItem to ModuleSA PcdBuildDefinitions
935 String defaultVal
= msaPcd
.getDefaultValue() == null ? spdPcd
.getDefaultValue() : msaPcd
.getDefaultValue();
937 genPcdData(msaPcd
.getCName(), spdPcd
.getToken(), msaPcd
.getTokenSpaceGuidCName(), msaPcd
.getPcdItemType().toString(), spdPcd
.getDatumType()+"", defaultVal
, moduleSa
);
948 private PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry
LookupPcdDeclaration (PcdCodedDocument
.PcdCoded
.PcdEntry msaPcd
, PackageIdentification
[] depPkgs
) {
950 PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry spdPcd
= null;
951 for (int i
= 0; i
< depPkgs
.length
; ++i
) {
953 XmlObject
[] xo
= SurfaceAreaQuery
.getSpdPcdDeclarations(depPkgs
[i
]);
957 for (int j
= 0; j
< xo
.length
; ++j
) {
958 spdPcd
= (PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry
)xo
[j
];
959 if (msaPcd
.getTokenSpaceGuidCName() == null) {
960 if (spdPcd
.getCName().equals(msaPcd
.getCName())) {
965 if (spdPcd
.getCName().equals(msaPcd
.getCName()) && spdPcd
.getTokenSpaceGuidCName().equals(msaPcd
.getTokenSpaceGuidCName())) {
976 private ModuleSADocument
.ModuleSA
genModuleSA (ModuleIdentification mi
, String arch
) {
977 PackageIdentification pi
= WorkspaceProfile
.getPackageForModule(mi
);
978 ModuleSADocument
.ModuleSA msa
= getfpdFrameworkModules().addNewModuleSA();
979 XmlCursor cursor
= msa
.newCursor();
981 String comment
= "Mod: " + mi
.getName() + " Type: " + SurfaceAreaQuery
.getModuleType(mi
) + " Path: "
982 + mi
.getPath().substring(System
.getenv("WORKSPACE").length() + 1);
983 cursor
.insertComment(comment
);
991 msa
.setModuleGuid(mi
.getGuid());
992 msa
.setModuleVersion(mi
.getVersion());
993 msa
.setPackageGuid(pi
.getGuid());
994 msa
.setPackageVersion(pi
.getVersion());
996 Vector
<String
> v
= new Vector
<String
>();
998 msa
.setSupArchList(v
);
1004 private void genPcdData (String cName
, Object token
, String tsGuid
, String itemType
, String dataType
, String defaultVal
, ModuleSADocument
.ModuleSA moduleSa
)
1005 throws PcdItemTypeConflictException
, PcdValueMalFormed
{
1006 if (moduleSa
.getPcdBuildDefinition() == null){
1007 moduleSa
.addNewPcdBuildDefinition();
1010 // constructe pcd to modulesa mapping first.
1011 // Attention : for any error condition, remove from map this pcd.
1013 ArrayList
<String
> pcdConsumer
= LookupPlatformPcdData(cName
+ " " + tsGuid
);
1014 if (pcdConsumer
== null) {
1015 pcdConsumer
= new ArrayList
<String
>();
1018 // Using existing Pcd type, if this pcd already exists in other ModuleSA
1020 if (pcdConsumer
.size() > 0) {
1021 String
[] valPart
= pcdConsumer
.get(0).split(" ");
1022 itemType
= valPart
[5];
1024 String listValue
= moduleSa
.getModuleGuid() + " " + moduleSa
.getModuleVersion()
1025 + " " + moduleSa
.getPackageGuid() + " " + moduleSa
.getPackageVersion() + " " + listToString(moduleSa
.getSupArchList())
1027 pcdConsumer
.add(listValue
);
1028 dynPcdMap
.put(cName
+ " " + tsGuid
, pcdConsumer
);
1030 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData fpdPcd
= moduleSa
.getPcdBuildDefinition().addNewPcdData();
1031 fpdPcd
.setCName(cName
);
1032 fpdPcd
.setToken(token
);
1033 fpdPcd
.setTokenSpaceGuidCName(tsGuid
);
1034 fpdPcd
.setDatumType(PcdDataTypes
.Enum
.forString(dataType
));
1035 fpdPcd
.setItemType(PcdItemTypes
.Enum
.forString(itemType
));
1037 if (defaultVal
!= null){
1038 fpdPcd
.setValue(defaultVal
);
1041 if (dataType
.equals("UINT8") || dataType
.equals("UINT16") || dataType
.equals("UINT32") || dataType
.equals("UINT64")) {
1042 fpdPcd
.setValue("0");
1044 if (dataType
.equals("BOOLEAN")){
1045 fpdPcd
.setValue("false");
1047 if (dataType
.equals("VOID*")) {
1048 fpdPcd
.setValue("");
1052 // Using existing pcd value, if this pcd already exists in other moduleSa.
1054 if (defaultPcdValue
.get(cName
+ " " + tsGuid
) == null) {
1055 defaultPcdValue
.put(cName
+ " " + tsGuid
, fpdPcd
.getValue());
1058 fpdPcd
.setValue(defaultPcdValue
.get(cName
+ " " + tsGuid
));
1061 if (dataType
.equals("UINT8")){
1062 fpdPcd
.setMaxDatumSize(1);
1064 if (dataType
.equals("UINT16")) {
1065 fpdPcd
.setMaxDatumSize(2);
1067 if (dataType
.equals("UINT32")) {
1068 fpdPcd
.setMaxDatumSize(4);
1070 if (dataType
.equals("UINT64")){
1071 fpdPcd
.setMaxDatumSize(8);
1073 if (dataType
.equals("BOOLEAN")){
1074 fpdPcd
.setMaxDatumSize(1);
1076 if (dataType
.equals("VOID*")) {
1077 int maxSize
= setMaxSizeForPointer(fpdPcd
.getValue());
1078 fpdPcd
.setMaxDatumSize(maxSize
);
1082 if (itemType
.equals("DYNAMIC") || itemType
.equals("DYNAMIC_EX")) {
1083 ArrayList
<String
> al
= LookupDynamicPcdBuildDefinition(cName
+ " " + tsGuid
);
1085 // if only one module mapped to this pcd, then the one is myself. so no other module mapped.
1086 // so need to add one dyn pcd.
1088 if (al
.size() == 1) {
1089 addDynamicPcdBuildData(cName
, token
, tsGuid
, itemType
, dataType
, defaultVal
);
1095 public int setMaxSizeForPointer(String datum
) throws PcdValueMalFormed
{
1096 if (datum
== null) {
1099 char ch
= datum
.charAt(0);
1103 // For void* type PCD, only three datum is support:
1104 // 1) Unicode: string with start char is "L"
1105 // 2) Ansci: String is ""
1106 // 3) byte array: String start char "{"
1109 start
= datum
.indexOf('\"');
1110 end
= datum
.lastIndexOf('\"');
1111 if ((start
> end
) ||
1112 (end
> datum
.length())||
1113 ((start
== end
) && (datum
.length() > 0))) {
1114 //ToDo Error handling here
1115 throw new PcdValueMalFormed (datum
);
1118 strValue
= datum
.substring(start
+ 1, end
);
1119 return strValue
.length() * 2;
1120 } else if (ch
== '\"'){
1121 start
= datum
.indexOf('\"');
1122 end
= datum
.lastIndexOf('\"');
1123 if ((start
> end
) ||
1124 (end
> datum
.length())||
1125 ((start
== end
) && (datum
.length() > 0))) {
1126 throw new PcdValueMalFormed (datum
);
1128 strValue
= datum
.substring(start
+ 1, end
);
1129 return strValue
.length();
1130 } else if (ch
=='{') {
1131 String
[] strValueArray
;
1133 start
= datum
.indexOf('{');
1134 end
= datum
.lastIndexOf('}');
1135 strValue
= datum
.substring(start
+ 1, end
);
1136 strValue
= strValue
.trim();
1137 if (strValue
.length() == 0) {
1140 strValueArray
= strValue
.split(",");
1141 for (int index
= 0; index
< strValueArray
.length
; index
++) {
1142 Integer value
= Integer
.decode(strValueArray
[index
].trim());
1145 // "[FPD file error] The datum type of PCD %s in %s is VOID*, "+
1146 // "it must be a byte array. But the element of %s exceed the byte range",
1147 throw new PcdValueMalFormed (datum
);
1150 return strValueArray
.length
;
1154 // "[FPD file error] The datum type of PCD %s in %s is VOID*. For VOID* type, you have three format choise:\n "+
1155 // "1) UNICODE string: like L\"xxxx\";\r\n"+
1156 // "2) ANSIC string: like \"xxx\";\r\n"+
1157 // "3) Byte array: like {0x2, 0x45, 0x23}\r\n"+
1158 // "but the datum in seems does not following above format!",
1159 throw new PcdValueMalFormed (datum
);
1164 private ArrayList
<String
> LookupDynamicPcdBuildDefinition(String dynPcdKey
) {
1165 ArrayList
<String
> al
= dynPcdMap
.get(dynPcdKey
);
1170 private ArrayList
<String
> LookupPlatformPcdData(String pcdKey
) {
1172 return dynPcdMap
.get(pcdKey
);
1175 public int getDynamicPcdBuildDataCount() {
1176 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1177 removeElement(getfpdDynPcdBuildDefs());
1178 fpdDynPcdBuildDefs
= null;
1181 return getfpdDynPcdBuildDefs().getPcdBuildDataList().size();
1184 public void getDynamicPcdBuildData(String
[][] saa
) {
1185 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1186 removeElement(getfpdDynPcdBuildDefs());
1187 fpdDynPcdBuildDefs
= null;
1190 List
<DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
> l
= getfpdDynPcdBuildDefs().getPcdBuildDataList();
1191 ListIterator
<DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
> li
= l
.listIterator();
1193 while(li
.hasNext()) {
1194 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData dynPcd
= li
.next();
1195 saa
[i
][0] = dynPcd
.getCName();
1196 saa
[i
][1] = dynPcd
.getToken().toString();
1197 saa
[i
][2] = dynPcd
.getTokenSpaceGuidCName();
1198 saa
[i
][3] = dynPcd
.getMaxDatumSize()+"";
1199 saa
[i
][4] = dynPcd
.getDatumType().toString();
1205 public void addDynamicPcdBuildData(String cName
, Object token
, String tsGuid
, String itemType
, String dataType
, String defaultVal
)
1206 throws PcdValueMalFormed
{
1207 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData dynPcdData
= getfpdDynPcdBuildDefs().addNewPcdBuildData();
1208 dynPcdData
.setItemType(PcdItemTypes
.Enum
.forString(itemType
));
1209 dynPcdData
.setCName(cName
);
1210 dynPcdData
.setToken(token
);
1211 dynPcdData
.setTokenSpaceGuidCName(tsGuid
);
1212 dynPcdData
.setDatumType(PcdDataTypes
.Enum
.forString(dataType
));
1214 BigInteger bigInt
= new BigInteger("0");
1215 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo skuInfo
= dynPcdData
.addNewSkuInfo();
1216 skuInfo
.setSkuId(bigInt
);
1217 if (defaultVal
!= null){
1218 skuInfo
.setValue(defaultVal
);
1221 if (dataType
.equals("UINT8")){
1222 skuInfo
.setValue("0");
1224 if (dataType
.equals("UINT16")) {
1225 skuInfo
.setValue("0");
1227 if (dataType
.equals("UINT32")) {
1228 skuInfo
.setValue("0");
1230 if (dataType
.equals("UINT64")){
1231 skuInfo
.setValue("0");
1233 if (dataType
.equals("BOOLEAN")){
1234 skuInfo
.setValue("false");
1236 if (dataType
.equals("VOID*")) {
1237 skuInfo
.setValue("");
1240 if (dataType
.equals("UINT8")){
1241 dynPcdData
.setMaxDatumSize(1);
1243 if (dataType
.equals("UINT16")) {
1244 dynPcdData
.setMaxDatumSize(2);
1246 if (dataType
.equals("UINT32")) {
1247 dynPcdData
.setMaxDatumSize(4);
1249 if (dataType
.equals("UINT64")){
1250 dynPcdData
.setMaxDatumSize(8);
1252 if (dataType
.equals("BOOLEAN")){
1253 dynPcdData
.setMaxDatumSize(1);
1255 if (dataType
.equals("VOID*")) {
1256 int maxSize
= setMaxSizeForPointer(defaultVal
);
1257 dynPcdData
.setMaxDatumSize(maxSize
);
1261 public void removeDynamicPcdBuildData(String cName
, String tsGuid
) {
1262 XmlObject o
= fpdRoot
.getDynamicPcdBuildDefinitions();
1267 XmlCursor cursor
= o
.newCursor();
1268 if (cursor
.toFirstChild()) {
1270 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdBuildData
=
1271 (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1272 if (pcdBuildData
.getCName().equals(cName
) && pcdBuildData
.getTokenSpaceGuidCName().equals(tsGuid
)) {
1274 if (getDynamicPcdBuildDataCount() == 1) {
1282 while (cursor
.toNextSibling());
1287 // Get the Sku Info count of ith dyn pcd element.
1289 public int getDynamicPcdSkuInfoCount(int i
){
1290 if (fpdRoot
.getDynamicPcdBuildDefinitions() == null || fpdRoot
.getDynamicPcdBuildDefinitions().getPcdBuildDataList() == null
1291 || fpdRoot
.getDynamicPcdBuildDefinitions().getPcdBuildDataList().size() == 0) {
1295 int skuInfoCount
= 0;
1296 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1297 if (cursor
.toFirstChild()) {
1298 for (int j
= 0; j
< i
; ++j
) {
1299 cursor
.toNextSibling();
1301 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1302 if (pcdData
.getSkuInfoList() == null) {
1306 skuInfoCount
= pcdData
.getSkuInfoList().size();
1310 return skuInfoCount
;
1313 public void getDynamicPcdSkuInfos(int i
, String
[][] saa
){
1314 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1315 removeElement(getfpdDynPcdBuildDefs());
1316 fpdDynPcdBuildDefs
= null;
1320 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1321 if (cursor
.toFirstChild()) {
1322 for (int j
= 0; j
< i
; ++j
) {
1323 cursor
.toNextSibling();
1325 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1326 if (pcdData
.getSkuInfoList() == null) {
1331 ListIterator
<DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo
> li
= pcdData
.getSkuInfoList().listIterator();
1333 while (li
.hasNext()) {
1334 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo skuInfo
= li
.next();
1335 saa
[k
][0] = skuInfo
.getSkuId()+"";
1336 saa
[k
][1] = skuInfo
.getVariableName();
1337 saa
[k
][2] = skuInfo
.getVariableGuid();
1338 saa
[k
][3] = skuInfo
.getVariableOffset();
1339 saa
[k
][4] = skuInfo
.getHiiDefaultValue();
1340 saa
[k
][5] = skuInfo
.getVpdOffset();
1341 saa
[k
][6] = skuInfo
.getValue();
1351 public String
getDynamicPcdBuildDataValue(int i
){
1352 String value
= null;
1353 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1354 removeElement(getfpdDynPcdBuildDefs());
1355 fpdDynPcdBuildDefs
= null;
1359 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1360 if (cursor
.toFirstChild()) {
1361 for (int j
= 0; j
< i
; ++j
) {
1362 cursor
.toNextSibling();
1364 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1365 if (pcdData
.getSkuInfoList() == null) {
1369 value
= pcdData
.getSkuInfoArray(0).getValue();
1376 public String
getDynamicPcdBuildDataVpdOffset(int i
){
1377 String vpdOffset
= null;
1378 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1379 removeElement(getfpdDynPcdBuildDefs());
1380 fpdDynPcdBuildDefs
= null;
1384 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1385 if (cursor
.toFirstChild()) {
1386 for (int j
= 0; j
< i
; ++j
) {
1387 cursor
.toNextSibling();
1389 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1390 if (pcdData
.getSkuInfoList() == null) {
1394 vpdOffset
= pcdData
.getSkuInfoArray(0).getVpdOffset();
1401 public void removeDynamicPcdBuildDataSkuInfo(int i
) {
1402 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1403 removeElement(getfpdDynPcdBuildDefs());
1404 fpdDynPcdBuildDefs
= null;
1408 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1409 if (cursor
.toFirstChild()) {
1410 for (int j
= 0; j
< i
; ++j
) {
1411 cursor
.toNextSibling();
1413 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1414 if (pcdData
.getSkuInfoList() == null) {
1419 QName qSkuInfo
= new QName(xmlNs
, "SkuInfo");
1420 cursor
.toChild(qSkuInfo
);
1427 // generate sku info for ith dyn pcd build data.
1429 public void genDynamicPcdBuildDataSkuInfo(String id
, String varName
, String varGuid
, String varOffset
,
1430 String hiiDefault
, String vpdOffset
, String value
, int i
) {
1431 // if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1435 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1436 if (cursor
.toFirstChild()) {
1437 for (int j
= 0; j
< i
; ++j
) {
1438 cursor
.toNextSibling();
1440 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1441 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo skuInfo
= pcdData
.addNewSkuInfo();
1442 skuInfo
.setSkuId(new BigInteger(id
));
1443 if (varName
!= null){
1444 skuInfo
.setVariableName(varName
);
1445 skuInfo
.setVariableGuid(varGuid
);
1446 skuInfo
.setVariableOffset(varOffset
);
1447 skuInfo
.setHiiDefaultValue(hiiDefault
);
1449 else if (vpdOffset
!= null){
1450 skuInfo
.setVpdOffset(vpdOffset
);
1453 skuInfo
.setValue(value
);
1458 public void updateDynamicPcdBuildDataSkuInfo(String id
, String varName
, String varGuid
, String varOffset
,
1459 String hiiDefault
, String vpdOffset
, String value
, int i
){
1460 // if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1464 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1465 if (cursor
.toFirstChild()) {
1466 for (int j
= 0; j
< i
; ++j
) {
1467 cursor
.toNextSibling();
1469 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1470 ListIterator
<DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo
> li
= pcdData
.getSkuInfoList().listIterator();
1471 while (li
.hasNext()) {
1472 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo skuInfo
= li
.next();
1473 if (skuInfo
.getSkuId().toString().equals(id
)){
1474 if (varName
!= null){
1475 skuInfo
.setVariableName(varName
);
1476 skuInfo
.setVariableGuid(varGuid
);
1477 skuInfo
.setVariableOffset(varOffset
);
1478 skuInfo
.setHiiDefaultValue(hiiDefault
);
1480 else if (vpdOffset
!= null){
1481 skuInfo
.setVpdOffset(vpdOffset
);
1484 skuInfo
.setValue(value
);
1492 public BuildOptionsDocument
.BuildOptions
getfpdBuildOpts() {
1493 if (fpdBuildOpts
== null) {
1494 fpdBuildOpts
= fpdRoot
.addNewBuildOptions();
1496 return fpdBuildOpts
;
1499 public void genBuildOptionsUserExtensions(String fvName
, String infName
, String outputFileName
, String
[][] includeModules
) {
1500 UserExtensionsDocument
.UserExtensions userExts
= getfpdBuildOpts().addNewUserExtensions();
1501 userExts
.setUserID("IMAGES");
1502 userExts
.setIdentifier(new BigInteger("1"));
1503 XmlCursor cursor
= userExts
.newCursor();
1504 cursor
.toEndToken();
1506 cursor
.beginElement("FvName");
1507 cursor
.insertChars(fvName
);
1508 cursor
.toNextToken();
1510 cursor
.beginElement("InfFileName");
1511 cursor
.insertChars(infName
);
1512 cursor
.toNextToken();
1514 cursor
.beginElement("IncludeModules");
1515 for (int i
= 0; i
< includeModules
.length
; ++i
) {
1516 cursor
.beginElement("Module");
1517 cursor
.insertAttributeWithValue("ModuleGuid", includeModules
[i
][0]);
1518 cursor
.insertAttributeWithValue("BaseName", includeModules
[i
][1]);
1519 cursor
.toEndToken();
1520 cursor
.toNextToken();
1525 public int getUserExtsIncModCount (String fvName
) {
1526 if (getfpdBuildOpts().getUserExtensionsList() == null) {
1529 ListIterator
<UserExtensionsDocument
.UserExtensions
> li
= getfpdBuildOpts().getUserExtensionsList().listIterator();
1530 while (li
.hasNext()) {
1531 UserExtensionsDocument
.UserExtensions ues
= li
.next();
1532 if (!ues
.getUserID().equals("IMAGES")) {
1535 XmlCursor cursor
= ues
.newCursor();
1536 cursor
.toFirstChild();
1537 String elementName
= cursor
.getTextValue();
1538 if (elementName
.equals(fvName
)) {
1539 cursor
.toNextSibling(new QName("", "IncludeModules"));
1540 if (cursor
.toFirstChild()) {
1542 for (i
= 1; cursor
.toNextSibling(); ++i
);
1554 public void getUserExtsIncMods(String fvName
, String
[][] saa
) {
1555 if (getfpdBuildOpts().getUserExtensionsList() == null) {
1558 ListIterator
<UserExtensionsDocument
.UserExtensions
> li
= getfpdBuildOpts().getUserExtensionsList().listIterator();
1559 while (li
.hasNext()) {
1560 UserExtensionsDocument
.UserExtensions ues
= li
.next();
1561 if (!ues
.getUserID().equals("IMAGES")) {
1564 XmlCursor cursor
= ues
.newCursor();
1565 cursor
.toFirstChild();
1566 String elementName
= cursor
.getTextValue();
1567 if (elementName
.equals(fvName
)) {
1568 cursor
.toNextSibling(new QName("", "IncludeModules"));
1569 if (cursor
.toFirstChild()) {
1572 saa
[i
][0] = cursor
.getAttributeText(new QName("ModuleGuid"));
1573 saa
[i
][1] = cursor
.getAttributeText(new QName("BaseName"));
1575 }while (cursor
.toNextSibling());
1585 public void genBuildOptionsUserDefAntTask (String id
, String fileName
, String execOrder
) {
1586 UserDefinedAntTasksDocument
.UserDefinedAntTasks udats
= getfpdBuildOpts().getUserDefinedAntTasks();
1587 if (udats
== null) {
1588 udats
= getfpdBuildOpts().addNewUserDefinedAntTasks();
1591 AntTaskDocument
.AntTask at
= udats
.addNewAntTask();
1592 setBuildOptionsUserDefAntTask(id
, fileName
, execOrder
, at
);
1595 private void setBuildOptionsUserDefAntTask(String id
, String fileName
, String execOrder
, AntTaskDocument
.AntTask at
) {
1596 at
.setId(new Integer(id
));
1597 XmlCursor cursor
= at
.newCursor();
1598 if (fileName
!= null){
1599 at
.setFilename(fileName
);
1601 else if (cursor
.toChild(xmlNs
, "Filename")) {
1604 if (execOrder
!= null) {
1605 at
.setAntCmdOptions(execOrder
);
1607 else if (cursor
.toChild(xmlNs
, "AntCmdOptions")) {
1613 public void removeBuildOptionsUserDefAntTask(int i
) {
1614 XmlObject o
= getfpdBuildOpts().getUserDefinedAntTasks();
1618 XmlCursor cursor
= o
.newCursor();
1619 if (cursor
.toFirstChild()) {
1620 for (int j
= 0; j
< i
; ++j
) {
1621 cursor
.toNextSibling();
1624 if (getBuildOptionsUserDefAntTaskCount() == 0) {
1632 public void updateBuildOptionsUserDefAntTask(int i
, String id
, String fileName
, String execOrder
){
1633 XmlObject o
= getfpdBuildOpts().getUserDefinedAntTasks();
1637 XmlCursor cursor
= o
.newCursor();
1638 if (cursor
.toFirstChild()) {
1639 for (int j
= 0; j
< i
; ++j
) {
1640 cursor
.toNextSibling();
1642 AntTaskDocument
.AntTask at
= (AntTaskDocument
.AntTask
)cursor
.getObject();
1643 setBuildOptionsUserDefAntTask(id
, fileName
, execOrder
, at
);
1648 public int getBuildOptionsUserDefAntTaskCount() {
1649 UserDefinedAntTasksDocument
.UserDefinedAntTasks udats
= getfpdBuildOpts().getUserDefinedAntTasks();
1650 if (udats
== null || udats
.getAntTaskList() == null) {
1654 return udats
.getAntTaskList().size();
1657 public void getBuildOptionsUserDefAntTasks(String
[][] saa
) {
1658 UserDefinedAntTasksDocument
.UserDefinedAntTasks udats
= getfpdBuildOpts().getUserDefinedAntTasks();
1659 if (udats
== null || udats
.getAntTaskList() == null) {
1663 List
<AntTaskDocument
.AntTask
> l
= udats
.getAntTaskList();
1664 ListIterator li
= l
.listIterator();
1666 while (li
.hasNext()) {
1667 AntTaskDocument
.AntTask at
= (AntTaskDocument
.AntTask
)li
.next();
1668 saa
[i
][0] = at
.getId() + "";
1669 saa
[i
][1] = saa
[i
][2] = "";
1670 if (at
.getFilename() != null){
1671 saa
[i
][1] = at
.getFilename();
1673 if (at
.getAntCmdOptions() != null) {
1674 saa
[i
][2] = at
.getAntCmdOptions();
1679 public void genBuildOptionsOpt(Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
) {
1680 OptionsDocument
.Options opts
= getfpdBuildOpts().getOptions();
1682 opts
= getfpdBuildOpts().addNewOptions();
1684 OptionDocument
.Option opt
= opts
.addNewOption();
1685 setBuildOptionsOpt(buildTargets
, toolChain
, tagName
, toolCmd
, archList
, contents
, opt
);
1688 private void setBuildOptionsOpt(Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
, OptionDocument
.Option opt
){
1689 opt
.setStringValue(contents
);
1691 opt
.setBuildTargets(buildTargets
);
1692 opt
.setToolChainFamily(toolChain
);
1693 opt
.setTagName(tagName
);
1694 opt
.setToolCode(toolCmd
);
1696 if (archList
!= null) {
1697 opt
.setSupArchList(archList
);
1700 if (opt
.isSetSupArchList()) {
1701 opt
.unsetSupArchList();
1706 public void removeBuildOptionsOpt(int i
){
1708 XmlObject o
= getfpdBuildOpts().getOptions();
1713 XmlCursor cursor
= o
.newCursor();
1714 if (cursor
.toFirstChild()) {
1715 for (int j
= 0; j
< i
; ++j
) {
1716 cursor
.toNextSibling();
1719 if (getBuildOptionsOptCount() == 0) {
1727 public void updateBuildOptionsOpt(int i
, Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
) {
1728 XmlObject o
= getfpdBuildOpts().getOptions();
1733 XmlCursor cursor
= o
.newCursor();
1734 if (cursor
.toFirstChild()) {
1735 for (int j
= 0; j
< i
; ++j
) {
1736 cursor
.toNextSibling();
1738 OptionDocument
.Option opt
= (OptionDocument
.Option
)cursor
.getObject();
1739 setBuildOptionsOpt(buildTargets
, toolChain
, tagName
, toolCmd
, archList
, contents
, opt
);
1744 public int getBuildOptionsOptCount(){
1745 if (getfpdBuildOpts().getOptions() == null || getfpdBuildOpts().getOptions().getOptionList() == null) {
1748 return getfpdBuildOpts().getOptions().getOptionList().size();
1751 public void getBuildOptionsOpts(String
[][] saa
) {
1752 if (getfpdBuildOpts().getOptions() == null || getfpdBuildOpts().getOptions().getOptionList() == null) {
1756 List
<OptionDocument
.Option
> lOpt
= getfpdBuildOpts().getOptions().getOptionList();
1757 ListIterator li
= lOpt
.listIterator();
1759 while(li
.hasNext()) {
1760 OptionDocument
.Option opt
= (OptionDocument
.Option
)li
.next();
1761 if (opt
.getBuildTargets() != null) {
1762 saa
[i
][0] = listToString(opt
.getBuildTargets());
1764 saa
[i
][1] = opt
.getToolChainFamily();
1765 if (opt
.getSupArchList() != null){
1766 saa
[i
][2] = listToString(opt
.getSupArchList());
1769 saa
[i
][3] = opt
.getToolCode();
1770 saa
[i
][4] = opt
.getTagName();
1771 saa
[i
][5] = opt
.getStringValue();
1777 public void genBuildOptionsFfs(String ffsKey
, String type
) {
1778 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getfpdBuildOpts().addNewFfs();
1779 ffs
.setFfsKey(ffsKey
);
1781 ffs
.addNewSections().setEncapsulationType(type
);
1785 public void updateBuildOptionsFfsSectionsType(int i
, String type
) {
1786 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getfpdBuildOpts().addNewFfs();
1788 ffs
.addNewSections().setEncapsulationType(type
);
1792 public void genBuildOptionsFfsAttribute(int i
, String name
, String value
) {
1793 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1794 BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute attrib
= ffs
.addNewAttribute();
1795 attrib
.setName(name
);
1796 attrib
.setValue(value
);
1799 /**update jth attribute of ith ffs.
1803 public void updateBuildOptionsFfsAttribute(int i
, int j
, String name
, String value
){
1804 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1805 XmlCursor cursor
= ffs
.newCursor();
1806 QName qAttrib
= new QName(xmlNs
, "Attribute");
1807 if (cursor
.toChild(qAttrib
)) {
1808 for (int k
= 0; k
< j
; ++k
) {
1809 cursor
.toNextSibling(qAttrib
);
1811 BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute attrib
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute
)cursor
.getObject();
1812 attrib
.setName(name
);
1813 attrib
.setValue(value
);
1818 public void removeBuildOptionsFfsAttribute(int i
, int j
){
1819 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1820 XmlCursor cursor
= ffs
.newCursor();
1821 QName qAttrib
= new QName(xmlNs
, "Attribute");
1822 if (cursor
.toChild(qAttrib
)) {
1823 for (int k
= 0; k
< j
; ++k
) {
1824 cursor
.toNextSibling(qAttrib
);
1831 public void genBuildOptionsFfsSectionsSection(int i
, String sectionType
) {
1832 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1836 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1838 if (sections
== null){
1839 sections
= ffs
.addNewSections();
1841 sections
.addNewSection().setSectionType(EfiSectionType
.Enum
.forString(sectionType
));
1844 public void removeBuildOptionsFfsSectionsSection(int i
, int j
) {
1845 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1846 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1847 if (sections
== null) {
1850 XmlCursor cursor
= sections
.newCursor();
1851 QName qSection
= new QName(xmlNs
, "Section");
1852 if (cursor
.toChild(qSection
)) {
1853 for (int k
= 0; k
< j
; ++k
) {
1854 cursor
.toNextSibling(qSection
);
1861 public void updateBuildOptionsFfsSectionsSection(int i
, int j
, String type
){
1862 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1863 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1864 if (sections
== null) {
1867 XmlCursor cursor
= sections
.newCursor();
1868 QName qSection
= new QName(xmlNs
, "Section");
1869 if (cursor
.toChild(qSection
)) {
1870 for (int k
= 0; k
< j
; ++k
) {
1871 cursor
.toNextSibling(qSection
);
1873 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Section section
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Section
)cursor
.getObject();
1874 section
.setSectionType(EfiSectionType
.Enum
.forString(type
));
1879 public void genBuildOptionsFfsSectionsSections(int i
, String encapType
) {
1880 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1884 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1886 if (sections
== null){
1887 sections
= ffs
.addNewSections();
1889 sections
.addNewSections().setEncapsulationType(encapType
);
1892 public void removeBuildOptionsFfsSectionsSections(int i
, int j
) {
1893 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1894 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1895 if (sections
== null) {
1898 XmlCursor cursor
= sections
.newCursor();
1899 QName qSections
= new QName(xmlNs
, "Sections");
1900 if (cursor
.toChild(qSections
)) {
1901 for (int k
= 0; k
< j
; ++k
) {
1902 cursor
.toNextSibling(qSections
);
1909 public void updateBuildOptionsFfsSectionsSections(int i
, int j
, String type
) {
1910 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1911 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1912 if (sections
== null) {
1915 XmlCursor cursor
= sections
.newCursor();
1916 QName qSections
= new QName(xmlNs
, "Sections");
1917 if (cursor
.toChild(qSections
)) {
1918 for (int k
= 0; k
< j
; ++k
) {
1919 cursor
.toNextSibling(qSections
);
1921 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2 sections2
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
)cursor
.getObject();
1922 sections2
.setEncapsulationType(type
);
1927 public void genBuildOptionsFfsSectionsSectionsSection(int i
, int j
, String type
) {
1928 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1932 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1933 XmlCursor cursor
= sections
.newCursor();
1934 QName qSections
= new QName(xmlNs
, "Sections");
1935 if (cursor
.toChild(qSections
)){
1936 for (int k
= 0; k
< j
; ++k
) {
1937 cursor
.toNextSibling(qSections
);
1939 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2 sections2
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
)cursor
.getObject();
1940 sections2
.addNewSection().setSectionType(EfiSectionType
.Enum
.forString(type
));
1945 public void removeBuildOptionsFfsSectionsSectionsSection(int i
, int j
, int k
) {
1946 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1947 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1948 if (sections
== null) {
1951 XmlCursor cursor
= sections
.newCursor();
1952 QName qSections
= new QName(xmlNs
, "Sections");
1953 if (cursor
.toChild(qSections
)) {
1954 for (int l
= 0; l
< j
; ++l
) {
1955 cursor
.toNextSibling(qSections
);
1957 if (cursor
.toFirstChild()) {
1959 for (; m
< k
; ++m
) {
1960 cursor
.toNextSibling();
1972 public void updateBuildOptionsFfsSectionsSectionsSection(int i
, int j
, int k
, String type
) {
1973 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1974 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1975 if (sections
== null) {
1978 XmlCursor cursor
= sections
.newCursor();
1979 QName qSections
= new QName(xmlNs
, "Sections");
1980 if (cursor
.toChild(qSections
)) {
1981 for (int l
= 0; l
< j
; ++l
) {
1982 cursor
.toNextSibling(qSections
);
1984 if (cursor
.toFirstChild()) {
1985 for (int m
= 0; m
< k
; ++m
) {
1986 cursor
.toNextSibling();
1988 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section section
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section
)cursor
.getObject();
1989 section
.setSectionType(EfiSectionType
.Enum
.forString(type
));
1995 public void getBuildOptionsFfsSectionsSectionsSection(int i
, int j
, ArrayList
<String
> al
) {
1996 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2000 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2001 XmlCursor cursor
= sections
.newCursor();
2002 QName qSections
= new QName(xmlNs
, "Sections");
2003 if (cursor
.toChild(qSections
)){
2004 for (int k
= 0; k
< j
; ++k
) {
2005 cursor
.toNextSibling(qSections
);
2007 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2 sections2
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
)cursor
.getObject();
2008 if (sections2
.getSectionList() == null){
2012 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section
> li
= sections2
.getSectionList().listIterator();
2013 while(li
.hasNext()) {
2014 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section section
= li
.next();
2015 if (section
.isSetSectionType()) {
2016 al
.add(section
.getSectionType().toString());
2025 public int getBuildOptionsFfsCount(){
2026 if (getfpdBuildOpts().getFfsList() == null) {
2029 return getfpdBuildOpts().getFfsList().size();
2032 public void getBuildOptionsFfsKey(String
[][] saa
) {
2033 if (getfpdBuildOpts().getFfsList() == null) {
2036 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
> li
= getfpdBuildOpts().getFfsList().listIterator();
2038 while(li
.hasNext()){
2039 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= li
.next();
2040 saa
[i
][0] = ffs
.getFfsKey();
2045 public void updateBuildOptionsFfsKey(int i
, String key
) {
2046 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2050 /**Get ith FFS key and contents.
2053 public void getBuildOptionsFfs(int i
, String
[] sa
, LinkedHashMap
<String
, String
> ffsAttribMap
, ArrayList
<String
> firstLevelSections
, ArrayList
<String
> firstLevelSection
) {
2054 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2058 sa
[0] = ffs
.getFfsKey();
2059 if (ffs
.getSections() != null) {
2060 if(ffs
.getSections().getEncapsulationType() != null){
2061 sa
[1] = ffs
.getSections().getEncapsulationType();
2063 if (ffs
.getSections().getSectionList() != null){
2064 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Section
> li
= ffs
.getSections().getSectionList().listIterator();
2065 while (li
.hasNext()) {
2066 firstLevelSection
.add(li
.next().getSectionType().toString());
2069 if (ffs
.getSections().getSectionsList() != null) {
2070 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
> li
= ffs
.getSections().getSectionsList().listIterator();
2071 while(li
.hasNext()) {
2072 firstLevelSections
.add(li
.next().getEncapsulationType());
2076 if (ffs
.getAttributeList() != null) {
2077 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute
> li
= ffs
.getAttributeList().listIterator();
2078 while(li
.hasNext()) {
2079 BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute attrib
= li
.next();
2080 ffsAttribMap
.put(attrib
.getName(), attrib
.getValue());
2089 private BuildOptionsDocument
.BuildOptions
.Ffs
getFfs(int i
) {
2090 XmlObject o
= getfpdBuildOpts();
2091 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= null;
2093 XmlCursor cursor
= o
.newCursor();
2094 QName qFfs
= new QName(xmlNs
, "Ffs");
2095 if (cursor
.toChild(qFfs
)) {
2096 for (int j
= 0; j
< i
; ++j
) {
2097 cursor
.toNextSibling(qFfs
);
2099 ffs
= (BuildOptionsDocument
.BuildOptions
.Ffs
)cursor
.getObject();
2105 public void removeBuildOptionsFfs(int i
) {
2106 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2111 XmlCursor cursor
= ffs
.newCursor();
2118 public PlatformDefinitionsDocument
.PlatformDefinitions
getfpdPlatformDefs(){
2119 if (fpdPlatformDefs
== null){
2120 fpdPlatformDefs
= fpdRoot
.addNewPlatformDefinitions();
2122 return fpdPlatformDefs
;
2125 public void getPlatformDefsSupportedArchs(Vector
<Object
> archs
){
2126 if (getfpdPlatformDefs().getSupportedArchitectures() == null) {
2129 ListIterator li
= getfpdPlatformDefs().getSupportedArchitectures().listIterator();
2130 while(li
.hasNext()) {
2131 archs
.add(li
.next());
2135 public void setPlatformDefsSupportedArchs(Vector
<Object
> archs
) {
2136 if (archs
!= null) {
2137 getfpdPlatformDefs().setSupportedArchitectures(archs
);
2140 // XmlCursor cursor = getfpdPlatformDefs().newCursor();
2141 // if (cursor.toChild(xmlNs, "SupportedArchitectures")) {
2142 // cursor.removeXml();
2144 // cursor.dispose();
2148 public void getPlatformDefsBuildTargets(Vector
<Object
> targets
) {
2149 if (getfpdPlatformDefs().getBuildTargets() == null) {
2152 ListIterator li
= getfpdPlatformDefs().getBuildTargets().listIterator();
2153 while(li
.hasNext()) {
2154 targets
.add(li
.next());
2158 public void setPlatformDefsBuildTargets(Vector
<Object
> targets
) {
2159 getfpdPlatformDefs().setBuildTargets(targets
);
2162 public void genPlatformDefsSkuInfo(String id
, String name
) {
2163 SkuInfoDocument
.SkuInfo skuInfo
= null;
2164 if (getfpdPlatformDefs().getSkuInfo() == null) {
2165 skuInfo
= getfpdPlatformDefs().addNewSkuInfo();
2167 skuInfo
= getfpdPlatformDefs().getSkuInfo();
2168 if (skuInfo
.getUiSkuNameList() == null || skuInfo
.getUiSkuNameList().size() == 0) {
2169 SkuInfoDocument
.SkuInfo
.UiSkuName skuName
= skuInfo
.addNewUiSkuName();
2170 skuName
.setSkuID(new BigInteger("0"));
2171 skuName
.setStringValue("DEFAULT");
2173 if (id
.equals("0")) {
2176 SkuInfoDocument
.SkuInfo
.UiSkuName skuName
= skuInfo
.addNewUiSkuName();
2177 skuName
.setSkuID(new BigInteger(id
));
2178 skuName
.setStringValue(name
);
2181 public int getPlatformDefsSkuInfoCount(){
2182 if (getfpdPlatformDefs().getSkuInfo() == null || getfpdPlatformDefs().getSkuInfo().getUiSkuNameList() == null) {
2185 return getfpdPlatformDefs().getSkuInfo().getUiSkuNameList().size();
2188 public void getPlatformDefsSkuInfos(String
[][] saa
){
2189 if (getfpdPlatformDefs().getSkuInfo() == null || getfpdPlatformDefs().getSkuInfo().getUiSkuNameList() == null) {
2190 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null) {
2191 removeElement(getfpdDynPcdBuildDefs());
2192 fpdDynPcdBuildDefs
= null;
2197 List
<SkuInfoDocument
.SkuInfo
.UiSkuName
> l
= getfpdPlatformDefs().getSkuInfo().getUiSkuNameList();
2198 ListIterator
<SkuInfoDocument
.SkuInfo
.UiSkuName
> li
= l
.listIterator();
2200 while(li
.hasNext()) {
2201 SkuInfoDocument
.SkuInfo
.UiSkuName sku
= li
.next();
2202 saa
[i
][0] = sku
.getSkuID()+"";
2203 saa
[i
][1] = sku
.getStringValue();
2208 public void removePlatformDefsSkuInfo(int i
) {
2209 SkuInfoDocument
.SkuInfo skuInfo
= getfpdPlatformDefs().getSkuInfo();
2210 if (skuInfo
== null || i
== 0) {
2214 XmlCursor cursor
= skuInfo
.newCursor();
2215 if (cursor
.toFirstChild()) {
2216 for (int j
= 0; j
< i
; ++j
) {
2217 cursor
.toNextSibling();
2224 public void updatePlatformDefsSkuInfo(int i
, String id
, String name
) {
2225 SkuInfoDocument
.SkuInfo skuInfo
= getfpdPlatformDefs().getSkuInfo();
2226 if (skuInfo
== null || i
== 0) {
2230 XmlCursor cursor
= skuInfo
.newCursor();
2231 if (cursor
.toFirstChild()) {
2232 for (int j
= 0; j
< i
; ++j
) {
2233 cursor
.toNextSibling();
2235 SkuInfoDocument
.SkuInfo
.UiSkuName sku
= (SkuInfoDocument
.SkuInfo
.UiSkuName
)cursor
.getObject();
2236 sku
.setSkuID(new BigInteger(id
));
2237 sku
.setStringValue(name
);
2242 public String
getPlatformDefsInterDir(){
2243 if (getfpdPlatformDefs().getIntermediateDirectories() == null) {
2246 return getfpdPlatformDefs().getIntermediateDirectories().toString();
2249 public void setPlatformDefsInterDir(String interDir
){
2250 getfpdPlatformDefs().setIntermediateDirectories(IntermediateOutputType
.Enum
.forString(interDir
));
2253 public String
getPlatformDefsOutputDir() {
2254 return getfpdPlatformDefs().getOutputDirectory();
2257 public void setPlatformDefsOutputDir(String outputDir
) {
2258 if (outputDir
!= null && outputDir
.length() > 0) {
2259 getfpdPlatformDefs().setOutputDirectory(outputDir
);
2262 XmlCursor cursor
= getfpdPlatformDefs().newCursor();
2263 if (cursor
.toChild(new QName(xmlNs
, "OutputDirectory"))) {
2270 public FlashDocument
.Flash
getfpdFlash() {
2271 if (fpdFlash
== null) {
2272 fpdFlash
= fpdRoot
.addNewFlash();
2277 public void genFlashDefinitionFile(String file
) {
2278 FlashDefinitionFileDocument
.FlashDefinitionFile fdf
= getfpdFlash().getFlashDefinitionFile();
2280 fdf
= getfpdFlash().addNewFlashDefinitionFile();
2283 fdf
.setStringValue(file
);
2286 public String
getFlashDefinitionFile() {
2287 FlashDefinitionFileDocument
.FlashDefinitionFile fdf
= getfpdFlash().getFlashDefinitionFile();
2292 return fdf
.getStringValue();
2295 public void genFvImagesNameValue(String name
, String value
) {
2297 FvImagesDocument
.FvImages fi
= getfpdFlash().getFvImages();
2299 fi
= getfpdFlash().addNewFvImages();
2302 FvImagesDocument
.FvImages
.NameValue nv
= fi
.addNewNameValue();
2307 public void removeFvImagesNameValue(int i
){
2309 XmlObject o
= getfpdFlash().getFvImages();
2314 QName qNameValue
= new QName(xmlNs
, "NameValue");
2315 XmlCursor cursor
= o
.newCursor();
2316 if (cursor
.toChild(qNameValue
)) {
2317 for (int j
= 0; j
< i
; ++j
) {
2318 cursor
.toNextSibling(qNameValue
);
2325 public void updateFvImagesNameValue(int i
, String name
, String value
){
2327 XmlObject o
= getfpdFlash().getFvImages();
2332 QName qNameValue
= new QName(xmlNs
, "NameValue");
2333 XmlCursor cursor
= o
.newCursor();
2334 if (cursor
.toChild(qNameValue
)) {
2335 for (int j
= 0; j
< i
; ++j
) {
2336 cursor
.toNextSibling(qNameValue
);
2338 FvImagesDocument
.FvImages
.NameValue nv
= (FvImagesDocument
.FvImages
.NameValue
)cursor
.getObject();
2345 public int getFvImagesNameValueCount() {
2347 FvImagesDocument
.FvImages fi
= null;
2348 if ((fi
= getfpdFlash().getFvImages()) == null || fi
.getNameValueList() == null) {
2351 return fi
.getNameValueList().size();
2354 public void getFvImagesNameValues(String
[][] nv
) {
2356 FvImagesDocument
.FvImages fi
= getfpdFlash().getFvImages();
2360 List
<FvImagesDocument
.FvImages
.NameValue
> l
= fi
.getNameValueList();
2362 ListIterator li
= l
.listIterator();
2363 while (li
.hasNext()) {
2364 FvImagesDocument
.FvImages
.NameValue e
= (FvImagesDocument
.FvImages
.NameValue
) li
2366 nv
[i
][0] = e
.getName();
2367 nv
[i
][1] = e
.getValue();
2373 public void genFvImagesFvImage(String
[] names
, String types
, Map
<String
, String
> options
) {
2375 FvImagesDocument
.FvImages fis
= null;
2376 if ((fis
= getfpdFlash().getFvImages()) == null) {
2377 fis
= getfpdFlash().addNewFvImages();
2381 //gen FvImage with FvImageNames array
2383 FvImagesDocument
.FvImages
.FvImage fi
= fis
.addNewFvImage();
2384 for (int i
= 0; i
< names
.length
; ++i
) {
2385 fi
.addFvImageNames(names
[i
]);
2387 fi
.setType(FvImageTypes
.Enum
.forString(types
));
2388 if (options
!= null){
2389 setFvImagesFvImageFvImageOptions(options
, fi
);
2393 private void setFvImagesFvImageFvImageOptions(Map
<String
, String
> options
, FvImagesDocument
.FvImages
.FvImage fi
){
2394 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions fio
= fi
.getFvImageOptions();
2396 fio
= fi
.addNewFvImageOptions();
2399 Set
<String
> key
= options
.keySet();
2400 Iterator
<String
> i
= key
.iterator();
2401 while (i
.hasNext()) {
2403 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nv
= fio
.addNewNameValue();
2404 String k
= (String
)i
.next();
2407 nv
.setValue((String
)options
.get(k
));
2414 public void removeFvImagesFvImage(int i
) {
2416 XmlObject o
= getfpdFlash().getFvImages();
2421 QName qFvImage
= new QName(xmlNs
, "FvImage");
2422 XmlCursor cursor
= o
.newCursor();
2423 if (cursor
.toChild(qFvImage
)) {
2424 for (int j
= 0; j
< i
; ++j
) {
2425 cursor
.toNextSibling(qFvImage
);
2432 public void updateFvImagesFvImage(int i
, String
[] names
, String types
, Map
<String
, String
> options
){
2434 XmlObject o
= getfpdFlash().getFvImages();
2438 XmlCursor cursor
= o
.newCursor();
2439 QName qFvImage
= new QName(xmlNs
, "FvImage");
2440 if (cursor
.toChild(qFvImage
)) {
2441 for (int j
= 0; j
< i
; ++j
) {
2442 cursor
.toNextSibling(qFvImage
);
2444 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
2445 fi
.setType(FvImageTypes
.Enum
.forString(types
));
2448 // remove old FvImageNames before adding new ones
2450 QName qFvImageNames
= new QName(xmlNs
, "FvImageNames");
2451 cursor
.toChild(qFvImageNames
);
2453 while (cursor
.toNextSibling(qFvImageNames
)) {
2457 for (int k
= 0; k
< names
.length
; ++k
) {
2458 fi
.addFvImageNames(names
[k
]);
2461 // remove old FvImageOptions before adding new options
2463 QName qFvImageOptions
= new QName(xmlNs
, "FvImageOptions");
2464 cursor
.toNextSibling(qFvImageOptions
);
2467 setFvImagesFvImageFvImageOptions(options
, fi
);
2472 public int getFvImagesFvImageCount() {
2474 if (getfpdFlash().getFvImages() == null || getfpdFlash().getFvImages().getFvImageList() == null) {
2477 return getfpdFlash().getFvImages().getFvImageList().size();
2480 /**Only Get Fv image setting - name and type.
2483 public void getFvImagesFvImages(String
[][] saa
) {
2485 if (getfpdFlash().getFvImages() == null) {
2488 List
<FvImagesDocument
.FvImages
.FvImage
> l
= getfpdFlash().getFvImages().getFvImageList();
2492 ListIterator li
= l
.listIterator();
2494 while(li
.hasNext()) {
2495 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)li
.next();
2497 // get FvImageNames array, space separated
2499 List
<String
> lfn
= fi
.getFvImageNamesList();
2500 ListIterator lfni
= lfn
.listIterator();
2502 while (lfni
.hasNext()) {
2503 saa
[i
][0] += (String
)lfni
.next();
2506 saa
[i
][0] = saa
[i
][0].trim();
2508 saa
[i
][1] = fi
.getType()+"";
2514 /**Get FvImage Options for FvImage i
2515 * @param i the ith FvImage
2517 public void getFvImagesFvImageOptions(int i
, Map
<String
, String
> m
) {
2518 XmlObject o
= getfpdFlash().getFvImages();
2522 XmlCursor cursor
= o
.newCursor();
2523 QName qFvImage
= new QName(xmlNs
, "FvImage");
2524 if (cursor
.toChild(qFvImage
)) {
2525 for (int j
= 0; j
< i
; ++j
) {
2526 cursor
.toNextSibling(qFvImage
);
2528 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
2529 if (fi
.getFvImageOptions() == null || fi
.getFvImageOptions().getNameValueList() == null){
2532 ListIterator
<FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
> li
= fi
.getFvImageOptions().getNameValueList().listIterator();
2533 while(li
.hasNext()){
2534 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nv
= li
.next();
2535 m
.put(nv
.getName(), nv
.getValue());
2541 Get platform header element
2542 @return PlatformHeaderDocument.PlatformHeader
2544 public PlatformHeaderDocument
.PlatformHeader
getFpdHdr() {
2545 if (fpdHdr
== null) {
2546 fpdHdr
= fpdRoot
.addNewPlatformHeader();
2552 public String
getFpdHdrPlatformName() {
2553 return getFpdHdr().getPlatformName();
2556 public String
getFpdHdrGuidValue() {
2557 return getFpdHdr().getGuidValue();
2560 public String
getFpdHdrVer() {
2561 return getFpdHdr().getVersion();
2564 public String
getFpdHdrAbs() {
2565 return getFpdHdr().getAbstract();
2568 public String
getFpdHdrDescription() {
2569 return getFpdHdr().getDescription();
2572 public String
getFpdHdrCopyright() {
2573 return getFpdHdr().getCopyright();
2576 public String
getFpdHdrLicense() {
2577 LicenseDocument
.License l
= getFpdHdr().getLicense();
2581 return l
.getStringValue();
2584 public String
getFpdHdrUrl() {
2585 LicenseDocument
.License l
= getFpdHdr().getLicense();
2592 public String
getFpdHdrSpec() {
2594 return "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052";
2595 // return getFpdHdr().getSpecification();
2598 public void setFpdHdrPlatformName(String name
){
2599 getFpdHdr().setPlatformName(name
);
2602 public void setFpdHdrGuidValue(String guid
){
2603 getFpdHdr().setGuidValue(guid
);
2606 public void setFpdHdrVer(String v
){
2607 getFpdHdr().setVersion(v
);
2610 public void setFpdHdrAbs(String abs
) {
2611 getFpdHdr().setAbstract(abs
);
2614 public void setFpdHdrDescription(String desc
){
2615 getFpdHdr().setDescription(desc
);
2618 public void setFpdHdrCopyright(String cr
) {
2619 getFpdHdr().setCopyright(cr
);
2622 public void setFpdHdrLicense(String license
){
2623 LicenseDocument
.License l
= getFpdHdr().getLicense();
2625 getFpdHdr().addNewLicense().setStringValue(license
);
2628 l
.setStringValue(license
);
2632 public void setFpdHdrUrl(String url
){
2633 LicenseDocument
.License l
= getFpdHdr().getLicense();
2639 public void setFpdHdrSpec(String s
){
2640 s
= "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052";
2641 getFpdHdr().setSpecification(s
);
2644 Save the processed xml contents to file
2646 @param fpdFile The file to save xml contents
2647 @throws IOException Exceptions during file operation
2649 public void saveAs(File fpdFile
) throws IOException
{
2651 XmlOptions options
= new XmlOptions();
2653 options
.setCharacterEncoding("UTF-8");
2654 options
.setSavePrettyPrint();
2655 options
.setSavePrettyPrintIndent(2);
2657 fpdd
.save(fpdFile
, options
);
2658 } catch (IOException e
) {
2659 e
.printStackTrace();
2664 private String
listToString(List l
) {
2669 ListIterator li
= l
.listIterator();
2670 while(li
.hasNext()) {
2677 private void removeElement(XmlObject o
) {
2678 XmlCursor cursor
= o
.newCursor();
2684 class PcdItemTypeConflictException
extends Exception
{
2689 private static final long serialVersionUID
= 1L;
2690 private String details
= null;
2692 PcdItemTypeConflictException(String pcdName
, String info
){
2693 ModuleIdentification mi
= WorkspaceProfile
.getModuleId(info
);
2694 details
= pcdName
+ " ItemType Conflicts with " + mi
.getName() + " in Pkg " + mi
.getPackageId().getName();
2697 public String
getMessage() {
2702 class PcdDeclNotFound
extends Exception
{
2707 private static final long serialVersionUID
= 1L;
2708 private String details
= null;
2710 PcdDeclNotFound(String info
) {
2711 details
= "PcdDeclNotFound: " + info
;
2714 public String
getMessage() {
2719 class PcdValueMalFormed
extends Exception
{
2724 private static final long serialVersionUID
= 1L;
2725 private String details
= null;
2727 PcdValueMalFormed(String info
) {
2728 details
= "PcdValueMalFormed: " + info
;
2731 public String
getMessage() {