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
.platform
.ui
.id
.ModuleIdentification
;
64 import org
.tianocore
.frameworkwizard
.platform
.ui
.id
.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
.getPackage().getName();
706 String pg
= libMi
.getPackage().getGuid();
707 String pv
= libMi
.getPackage().getVersion();
708 LibrariesDocument
.Libraries
.Instance instance
= libs
.addNewInstance();
709 XmlCursor cursor
= instance
.newCursor();
711 String comment
= "Pkg: " + pn
+ " Mod: " + mn
712 + " Path: " + WorkspaceProfile
.getMsaFile(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 getModuleSAOptions(String moduleKey
, String
[][] saa
) {
801 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
802 if (msa
== null || msa
.getModuleSaBuildOptions() == null || msa
.getModuleSaBuildOptions().getOptions() == null
803 || msa
.getModuleSaBuildOptions().getOptions().getOptionList() == null) {
807 List
<OptionDocument
.Option
> lOpt
= msa
.getModuleSaBuildOptions().getOptions().getOptionList();
808 ListIterator li
= lOpt
.listIterator();
810 while(li
.hasNext()) {
811 OptionDocument
.Option opt
= (OptionDocument
.Option
)li
.next();
812 if (opt
.getBuildTargets() != null) {
813 saa
[i
][0] = listToString(opt
.getBuildTargets());
815 saa
[i
][1] = opt
.getToolChainFamily();
816 saa
[i
][2] = opt
.getTagName();
817 saa
[i
][3] = opt
.getToolCode();
819 if (opt
.getSupArchList() != null){
820 saa
[i
][4] = listToString(opt
.getSupArchList());
824 saa
[i
][5] = opt
.getStringValue();
830 public int getModuleSAOptionsCount(String moduleKey
){
831 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
832 if (msa
== null || msa
.getModuleSaBuildOptions() == null || msa
.getModuleSaBuildOptions().getOptions() == null
833 || msa
.getModuleSaBuildOptions().getOptions().getOptionList() == null) {
836 return msa
.getModuleSaBuildOptions().getOptions().getOptionList().size();
839 public void genModuleSAOptionsOpt(String moduleKey
, Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
) {
840 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
841 if (msa
.getModuleSaBuildOptions() == null) {
842 msa
.addNewModuleSaBuildOptions();
844 if (msa
.getModuleSaBuildOptions().getOptions() == null){
845 msa
.getModuleSaBuildOptions().addNewOptions();
847 OptionDocument
.Option opt
= msa
.getModuleSaBuildOptions().getOptions().addNewOption();
848 setBuildOptionsOpt(buildTargets
, toolChain
, tagName
, toolCmd
, archList
, contents
, opt
);
851 public void removeModuleSAOptionsOpt(String moduleKey
, int i
) {
852 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
853 if (msa
.getModuleSaBuildOptions() == null || msa
.getModuleSaBuildOptions().getOptions() == null) {
856 OptionsDocument
.Options opts
= msa
.getModuleSaBuildOptions().getOptions();
857 XmlCursor cursor
= opts
.newCursor();
858 if (cursor
.toFirstChild()) {
859 for (int j
= 0; j
< i
; ++j
){
860 cursor
.toNextSibling();
867 public void updateModuleSAOptionsOpt(String moduleKey
, int i
, Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
) {
868 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
869 if (msa
.getModuleSaBuildOptions() == null || msa
.getModuleSaBuildOptions().getOptions() == null) {
872 OptionsDocument
.Options opts
= msa
.getModuleSaBuildOptions().getOptions();
873 XmlCursor cursor
= opts
.newCursor();
874 if (cursor
.toFirstChild()) {
875 for (int j
= 0; j
< i
; ++j
){
876 cursor
.toNextSibling();
878 OptionDocument
.Option opt
= (OptionDocument
.Option
)cursor
.getObject();
879 setBuildOptionsOpt(buildTargets
, toolChain
, tagName
, toolCmd
, archList
, contents
, opt
);
884 /**add pcd information of module mi to a ModuleSA.
886 * @param moduleSa if null, generate a new ModuleSA.
888 public void addFrameworkModulesPcdBuildDefs(ModuleIdentification mi
, String arch
, ModuleSADocument
.ModuleSA moduleSa
) throws Exception
{
889 //ToDo add Arch filter
892 if (moduleSa
== null) {
893 moduleSa
= genModuleSA(mi
, arch
);
896 ModuleSurfaceAreaDocument
.ModuleSurfaceArea msa
= (ModuleSurfaceAreaDocument
.ModuleSurfaceArea
)WorkspaceProfile
.getModuleXmlObject(mi
);
897 if (msa
.getPcdCoded() == null) {
901 Map
<String
, XmlObject
> m
= new HashMap
<String
, XmlObject
>();
902 m
.put("ModuleSurfaceArea", msa
);
903 SurfaceAreaQuery
.setDoc(m
);
904 PackageIdentification
[] depPkgs
= SurfaceAreaQuery
.getDependencePkg(null, mi
);
906 // Implementing InitializePlatformPcdBuildDefinitions
908 List
<PcdCodedDocument
.PcdCoded
.PcdEntry
> l
= msa
.getPcdCoded().getPcdEntryList();
909 ListIterator li
= l
.listIterator();
910 while(li
.hasNext()) {
911 PcdCodedDocument
.PcdCoded
.PcdEntry msaPcd
= (PcdCodedDocument
.PcdCoded
.PcdEntry
)li
.next();
912 PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry spdPcd
= LookupPcdDeclaration(msaPcd
, depPkgs
);
913 if (spdPcd
== null) {
917 throw new PcdDeclNotFound("No Declaration for PCD Entry " + msaPcd
.getCName() + " in Module " + mi
.getName());
920 // AddItem to ModuleSA PcdBuildDefinitions
922 String defaultVal
= msaPcd
.getDefaultValue() == null ? spdPcd
.getDefaultValue() : msaPcd
.getDefaultValue();
924 genPcdData(msaPcd
.getCName(), spdPcd
.getToken(), msaPcd
.getTokenSpaceGuidCName(), msaPcd
.getPcdItemType().toString(), spdPcd
.getDatumType()+"", defaultVal
, moduleSa
);
935 private PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry
LookupPcdDeclaration (PcdCodedDocument
.PcdCoded
.PcdEntry msaPcd
, PackageIdentification
[] depPkgs
) {
937 Map
<String
, XmlObject
> m
= new HashMap
<String
, XmlObject
>();
938 PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry spdPcd
= null;
939 for (int i
= 0; i
< depPkgs
.length
; ++i
) {
940 m
.put("PackageSurfaceArea", WorkspaceProfile
.getPackageXmlObject(depPkgs
[i
]));
941 SurfaceAreaQuery
.setDoc(m
);
942 XmlObject
[] xo
= SurfaceAreaQuery
.getSpdPcdDeclarations();
946 for (int j
= 0; j
< xo
.length
; ++j
) {
947 spdPcd
= (PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry
)xo
[j
];
948 if (msaPcd
.getTokenSpaceGuidCName() == null) {
949 if (spdPcd
.getCName().equals(msaPcd
.getCName())) {
954 if (spdPcd
.getCName().equals(msaPcd
.getCName()) && spdPcd
.getTokenSpaceGuidCName().equals(msaPcd
.getTokenSpaceGuidCName())) {
965 private ModuleSADocument
.ModuleSA
genModuleSA (ModuleIdentification mi
, String arch
) {
966 PackageIdentification pi
= WorkspaceProfile
.getPackageForModule(mi
);
967 ModuleSADocument
.ModuleSA msa
= getfpdFrameworkModules().addNewModuleSA();
968 XmlCursor cursor
= msa
.newCursor();
970 String comment
= "Mod: " + mi
.getName() + " Type: " + mi
.getModuleType() + " Path: "
971 + WorkspaceProfile
.getMsaFile(mi
).getPath().substring(System
.getenv("WORKSPACE").length() + 1);
972 cursor
.insertComment(comment
);
980 msa
.setModuleGuid(mi
.getGuid());
981 msa
.setModuleVersion(mi
.getVersion());
982 msa
.setPackageGuid(pi
.getGuid());
983 msa
.setPackageVersion(pi
.getVersion());
985 Vector
<String
> v
= new Vector
<String
>();
987 msa
.setSupArchList(v
);
993 private void genPcdData (String cName
, Object token
, String tsGuid
, String itemType
, String dataType
, String defaultVal
, ModuleSADocument
.ModuleSA moduleSa
)
994 throws PcdItemTypeConflictException
, PcdValueMalFormed
{
995 if (moduleSa
.getPcdBuildDefinition() == null){
996 moduleSa
.addNewPcdBuildDefinition();
999 // constructe pcd to modulesa mapping first.
1000 // Attention : for any error condition, remove from map this pcd.
1002 ArrayList
<String
> pcdConsumer
= LookupPlatformPcdData(cName
+ " " + tsGuid
);
1003 if (pcdConsumer
== null) {
1004 pcdConsumer
= new ArrayList
<String
>();
1007 // Using existing Pcd type, if this pcd already exists in other ModuleSA
1009 if (pcdConsumer
.size() > 0) {
1010 String
[] valPart
= pcdConsumer
.get(0).split(" ");
1011 itemType
= valPart
[5];
1013 String listValue
= moduleSa
.getModuleGuid() + " " + moduleSa
.getModuleVersion()
1014 + " " + moduleSa
.getPackageGuid() + " " + moduleSa
.getPackageVersion() + " " + listToString(moduleSa
.getSupArchList())
1016 pcdConsumer
.add(listValue
);
1017 dynPcdMap
.put(cName
+ " " + tsGuid
, pcdConsumer
);
1019 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData fpdPcd
= moduleSa
.getPcdBuildDefinition().addNewPcdData();
1020 fpdPcd
.setCName(cName
);
1021 fpdPcd
.setToken(token
);
1022 fpdPcd
.setTokenSpaceGuidCName(tsGuid
);
1023 fpdPcd
.setDatumType(PcdDataTypes
.Enum
.forString(dataType
));
1024 fpdPcd
.setItemType(PcdItemTypes
.Enum
.forString(itemType
));
1026 if (defaultVal
!= null){
1027 fpdPcd
.setValue(defaultVal
);
1030 if (dataType
.equals("UINT8") || dataType
.equals("UINT16") || dataType
.equals("UINT32") || dataType
.equals("UINT64")) {
1031 fpdPcd
.setValue("0");
1033 if (dataType
.equals("BOOLEAN")){
1034 fpdPcd
.setValue("false");
1036 if (dataType
.equals("VOID*")) {
1037 fpdPcd
.setValue("");
1041 // Using existing pcd value, if this pcd already exists in other moduleSa.
1043 if (defaultPcdValue
.get(cName
+ " " + tsGuid
) == null) {
1044 defaultPcdValue
.put(cName
+ " " + tsGuid
, fpdPcd
.getValue());
1047 fpdPcd
.setValue(defaultPcdValue
.get(cName
+ " " + tsGuid
));
1050 if (dataType
.equals("UINT8")){
1051 fpdPcd
.setMaxDatumSize(1);
1053 if (dataType
.equals("UINT16")) {
1054 fpdPcd
.setMaxDatumSize(2);
1056 if (dataType
.equals("UINT32")) {
1057 fpdPcd
.setMaxDatumSize(4);
1059 if (dataType
.equals("UINT64")){
1060 fpdPcd
.setMaxDatumSize(8);
1062 if (dataType
.equals("BOOLEAN")){
1063 fpdPcd
.setMaxDatumSize(1);
1065 if (dataType
.equals("VOID*")) {
1066 int maxSize
= setMaxSizeForPointer(fpdPcd
.getValue());
1067 fpdPcd
.setMaxDatumSize(maxSize
);
1071 if (itemType
.equals("DYNAMIC") || itemType
.equals("DYNAMIC_EX")) {
1072 ArrayList
<String
> al
= LookupDynamicPcdBuildDefinition(cName
+ " " + tsGuid
);
1074 // if only one module mapped to this pcd, then the one is myself. so no other module mapped.
1075 // so need to add one dyn pcd.
1077 if (al
.size() == 1) {
1078 addDynamicPcdBuildData(cName
, token
, tsGuid
, itemType
, dataType
, defaultVal
);
1084 public int setMaxSizeForPointer(String datum
) throws PcdValueMalFormed
{
1085 if (datum
== null) {
1088 char ch
= datum
.charAt(0);
1092 // For void* type PCD, only three datum is support:
1093 // 1) Unicode: string with start char is "L"
1094 // 2) Ansci: String is ""
1095 // 3) byte array: String start char "{"
1098 start
= datum
.indexOf('\"');
1099 end
= datum
.lastIndexOf('\"');
1100 if ((start
> end
) ||
1101 (end
> datum
.length())||
1102 ((start
== end
) && (datum
.length() > 0))) {
1103 //ToDo Error handling here
1104 throw new PcdValueMalFormed (datum
);
1107 strValue
= datum
.substring(start
+ 1, end
);
1108 return strValue
.length() * 2;
1109 } else if (ch
== '\"'){
1110 start
= datum
.indexOf('\"');
1111 end
= datum
.lastIndexOf('\"');
1112 if ((start
> end
) ||
1113 (end
> datum
.length())||
1114 ((start
== end
) && (datum
.length() > 0))) {
1115 throw new PcdValueMalFormed (datum
);
1117 strValue
= datum
.substring(start
+ 1, end
);
1118 return strValue
.length();
1119 } else if (ch
=='{') {
1120 String
[] strValueArray
;
1122 start
= datum
.indexOf('{');
1123 end
= datum
.lastIndexOf('}');
1124 strValue
= datum
.substring(start
+ 1, end
);
1125 strValue
= strValue
.trim();
1126 if (strValue
.length() == 0) {
1129 strValueArray
= strValue
.split(",");
1130 for (int index
= 0; index
< strValueArray
.length
; index
++) {
1131 Integer value
= Integer
.decode(strValueArray
[index
].trim());
1134 // "[FPD file error] The datum type of PCD %s in %s is VOID*, "+
1135 // "it is byte array in fact. But the element of %s exceed the byte range",
1136 throw new PcdValueMalFormed (datum
);
1139 return strValueArray
.length
;
1143 // "[FPD file error] The datum type of PCD %s in %s is VOID*. For VOID* type, you have three format choise:\n "+
1144 // "1) UNICODE string: like L\"xxxx\";\r\n"+
1145 // "2) ANSIC string: like \"xxx\";\r\n"+
1146 // "3) Byte array: like {0x2, 0x45, 0x23}\r\n"+
1147 // "but the datum in seems does not following above format!",
1148 throw new PcdValueMalFormed (datum
);
1153 private ArrayList
<String
> LookupDynamicPcdBuildDefinition(String dynPcdKey
) {
1154 ArrayList
<String
> al
= dynPcdMap
.get(dynPcdKey
);
1159 private ArrayList
<String
> LookupPlatformPcdData(String pcdKey
) {
1161 return dynPcdMap
.get(pcdKey
);
1164 public int getDynamicPcdBuildDataCount() {
1165 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1166 removeElement(getfpdDynPcdBuildDefs());
1167 fpdDynPcdBuildDefs
= null;
1170 return getfpdDynPcdBuildDefs().getPcdBuildDataList().size();
1173 public void getDynamicPcdBuildData(String
[][] saa
) {
1174 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1175 removeElement(getfpdDynPcdBuildDefs());
1176 fpdDynPcdBuildDefs
= null;
1179 List
<DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
> l
= getfpdDynPcdBuildDefs().getPcdBuildDataList();
1180 ListIterator
<DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
> li
= l
.listIterator();
1182 while(li
.hasNext()) {
1183 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData dynPcd
= li
.next();
1184 saa
[i
][0] = dynPcd
.getCName();
1185 saa
[i
][1] = dynPcd
.getToken().toString();
1186 saa
[i
][2] = dynPcd
.getTokenSpaceGuidCName();
1187 saa
[i
][3] = dynPcd
.getMaxDatumSize()+"";
1188 saa
[i
][4] = dynPcd
.getDatumType().toString();
1194 public void addDynamicPcdBuildData(String cName
, Object token
, String tsGuid
, String itemType
, String dataType
, String defaultVal
)
1195 throws PcdValueMalFormed
{
1196 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData dynPcdData
= getfpdDynPcdBuildDefs().addNewPcdBuildData();
1197 dynPcdData
.setItemType(PcdItemTypes
.Enum
.forString(itemType
));
1198 dynPcdData
.setCName(cName
);
1199 dynPcdData
.setToken(token
);
1200 dynPcdData
.setTokenSpaceGuidCName(tsGuid
);
1201 dynPcdData
.setDatumType(PcdDataTypes
.Enum
.forString(dataType
));
1203 BigInteger bigInt
= new BigInteger("0");
1204 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo skuInfo
= dynPcdData
.addNewSkuInfo();
1205 skuInfo
.setSkuId(bigInt
);
1206 if (defaultVal
!= null){
1207 skuInfo
.setValue(defaultVal
);
1210 if (dataType
.equals("UINT8")){
1211 skuInfo
.setValue("0");
1213 if (dataType
.equals("UINT16")) {
1214 skuInfo
.setValue("0");
1216 if (dataType
.equals("UINT32")) {
1217 skuInfo
.setValue("0");
1219 if (dataType
.equals("UINT64")){
1220 skuInfo
.setValue("0");
1222 if (dataType
.equals("BOOLEAN")){
1223 skuInfo
.setValue("false");
1225 if (dataType
.equals("VOID*")) {
1226 skuInfo
.setValue("");
1229 if (dataType
.equals("UINT8")){
1230 dynPcdData
.setMaxDatumSize(1);
1232 if (dataType
.equals("UINT16")) {
1233 dynPcdData
.setMaxDatumSize(2);
1235 if (dataType
.equals("UINT32")) {
1236 dynPcdData
.setMaxDatumSize(4);
1238 if (dataType
.equals("UINT64")){
1239 dynPcdData
.setMaxDatumSize(8);
1241 if (dataType
.equals("BOOLEAN")){
1242 dynPcdData
.setMaxDatumSize(1);
1244 if (dataType
.equals("VOID*")) {
1245 int maxSize
= setMaxSizeForPointer(defaultVal
);
1246 dynPcdData
.setMaxDatumSize(maxSize
);
1250 public void removeDynamicPcdBuildData(String cName
, String tsGuid
) {
1251 XmlObject o
= fpdRoot
.getDynamicPcdBuildDefinitions();
1256 XmlCursor cursor
= o
.newCursor();
1257 if (cursor
.toFirstChild()) {
1259 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdBuildData
=
1260 (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1261 if (pcdBuildData
.getCName().equals(cName
) && pcdBuildData
.getTokenSpaceGuidCName().equals(tsGuid
)) {
1263 if (getDynamicPcdBuildDataCount() == 1) {
1271 while (cursor
.toNextSibling());
1276 // Get the Sku Info count of ith dyn pcd element.
1278 public int getDynamicPcdSkuInfoCount(int i
){
1279 if (fpdRoot
.getDynamicPcdBuildDefinitions() == null || fpdRoot
.getDynamicPcdBuildDefinitions().getPcdBuildDataList() == null
1280 || fpdRoot
.getDynamicPcdBuildDefinitions().getPcdBuildDataList().size() == 0) {
1284 int skuInfoCount
= 0;
1285 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1286 if (cursor
.toFirstChild()) {
1287 for (int j
= 0; j
< i
; ++j
) {
1288 cursor
.toNextSibling();
1290 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1291 if (pcdData
.getSkuInfoList() == null) {
1295 skuInfoCount
= pcdData
.getSkuInfoList().size();
1299 return skuInfoCount
;
1302 public void getDynamicPcdSkuInfos(int i
, String
[][] saa
){
1303 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1304 removeElement(getfpdDynPcdBuildDefs());
1305 fpdDynPcdBuildDefs
= null;
1309 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1310 if (cursor
.toFirstChild()) {
1311 for (int j
= 0; j
< i
; ++j
) {
1312 cursor
.toNextSibling();
1314 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1315 if (pcdData
.getSkuInfoList() == null) {
1320 ListIterator
<DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo
> li
= pcdData
.getSkuInfoList().listIterator();
1322 while (li
.hasNext()) {
1323 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo skuInfo
= li
.next();
1324 saa
[k
][0] = skuInfo
.getSkuId()+"";
1325 saa
[k
][1] = skuInfo
.getVariableName();
1326 saa
[k
][2] = skuInfo
.getVariableGuid();
1327 saa
[k
][3] = skuInfo
.getVariableOffset();
1328 saa
[k
][4] = skuInfo
.getHiiDefaultValue();
1329 saa
[k
][5] = skuInfo
.getVpdOffset();
1330 saa
[k
][6] = skuInfo
.getValue();
1340 public String
getDynamicPcdBuildDataValue(int i
){
1341 String value
= null;
1342 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1343 removeElement(getfpdDynPcdBuildDefs());
1344 fpdDynPcdBuildDefs
= null;
1348 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1349 if (cursor
.toFirstChild()) {
1350 for (int j
= 0; j
< i
; ++j
) {
1351 cursor
.toNextSibling();
1353 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1354 if (pcdData
.getSkuInfoList() == null) {
1358 value
= pcdData
.getSkuInfoArray(0).getValue();
1365 public String
getDynamicPcdBuildDataVpdOffset(int i
){
1366 String vpdOffset
= null;
1367 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1368 removeElement(getfpdDynPcdBuildDefs());
1369 fpdDynPcdBuildDefs
= null;
1373 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1374 if (cursor
.toFirstChild()) {
1375 for (int j
= 0; j
< i
; ++j
) {
1376 cursor
.toNextSibling();
1378 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1379 if (pcdData
.getSkuInfoList() == null) {
1383 vpdOffset
= pcdData
.getSkuInfoArray(0).getVpdOffset();
1390 public void removeDynamicPcdBuildDataSkuInfo(int i
) {
1391 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1392 removeElement(getfpdDynPcdBuildDefs());
1393 fpdDynPcdBuildDefs
= null;
1397 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1398 if (cursor
.toFirstChild()) {
1399 for (int j
= 0; j
< i
; ++j
) {
1400 cursor
.toNextSibling();
1402 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1403 if (pcdData
.getSkuInfoList() == null) {
1408 QName qSkuInfo
= new QName(xmlNs
, "SkuInfo");
1409 cursor
.toChild(qSkuInfo
);
1416 // generate sku info for ith dyn pcd build data.
1418 public void genDynamicPcdBuildDataSkuInfo(String id
, String varName
, String varGuid
, String varOffset
,
1419 String hiiDefault
, String vpdOffset
, String value
, int i
) {
1420 // if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1424 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1425 if (cursor
.toFirstChild()) {
1426 for (int j
= 0; j
< i
; ++j
) {
1427 cursor
.toNextSibling();
1429 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1430 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo skuInfo
= pcdData
.addNewSkuInfo();
1431 skuInfo
.setSkuId(new BigInteger(id
));
1432 if (varName
!= null){
1433 skuInfo
.setVariableName(varName
);
1434 skuInfo
.setVariableGuid(varGuid
);
1435 skuInfo
.setVariableOffset(varOffset
);
1436 skuInfo
.setHiiDefaultValue(hiiDefault
);
1438 else if (vpdOffset
!= null){
1439 skuInfo
.setVpdOffset(vpdOffset
);
1442 skuInfo
.setValue(value
);
1447 public void updateDynamicPcdBuildDataSkuInfo(String id
, String varName
, String varGuid
, String varOffset
,
1448 String hiiDefault
, String vpdOffset
, String value
, int i
){
1449 // if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1453 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1454 if (cursor
.toFirstChild()) {
1455 for (int j
= 0; j
< i
; ++j
) {
1456 cursor
.toNextSibling();
1458 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1459 ListIterator
<DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo
> li
= pcdData
.getSkuInfoList().listIterator();
1460 while (li
.hasNext()) {
1461 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo skuInfo
= li
.next();
1462 if (skuInfo
.getSkuId().toString().equals(id
)){
1463 if (varName
!= null){
1464 skuInfo
.setVariableName(varName
);
1465 skuInfo
.setVariableGuid(varGuid
);
1466 skuInfo
.setVariableOffset(varOffset
);
1467 skuInfo
.setHiiDefaultValue(hiiDefault
);
1469 else if (vpdOffset
!= null){
1470 skuInfo
.setVpdOffset(vpdOffset
);
1473 skuInfo
.setValue(value
);
1481 public BuildOptionsDocument
.BuildOptions
getfpdBuildOpts() {
1482 if (fpdBuildOpts
== null) {
1483 fpdBuildOpts
= fpdRoot
.addNewBuildOptions();
1485 return fpdBuildOpts
;
1488 public void genBuildOptionsUserExtensions(String fvName
, String infName
, String outputFileName
, String
[][] includeModules
) {
1489 UserExtensionsDocument
.UserExtensions userExts
= getfpdBuildOpts().addNewUserExtensions();
1490 userExts
.setUserID("IMAGES");
1491 userExts
.setIdentifier(new BigInteger("1"));
1492 XmlCursor cursor
= userExts
.newCursor();
1493 cursor
.toEndToken();
1495 cursor
.beginElement("FvName");
1496 cursor
.insertChars(fvName
);
1497 cursor
.toNextToken();
1499 cursor
.beginElement("InfFileName");
1500 cursor
.insertChars(infName
);
1501 cursor
.toNextToken();
1503 cursor
.beginElement("IncludeModules");
1504 for (int i
= 0; i
< includeModules
.length
; ++i
) {
1505 cursor
.beginElement("Module");
1506 cursor
.insertAttributeWithValue("ModuleGuid", includeModules
[i
][0]);
1507 cursor
.insertAttributeWithValue("BaseName", includeModules
[i
][1]);
1508 cursor
.toEndToken();
1509 cursor
.toNextToken();
1514 public int getUserExtsIncModCount (String fvName
) {
1515 if (getfpdBuildOpts().getUserExtensionsList() == null) {
1518 ListIterator
<UserExtensionsDocument
.UserExtensions
> li
= getfpdBuildOpts().getUserExtensionsList().listIterator();
1519 while (li
.hasNext()) {
1520 UserExtensionsDocument
.UserExtensions ues
= li
.next();
1521 if (!ues
.getUserID().equals("IMAGES")) {
1524 XmlCursor cursor
= ues
.newCursor();
1525 cursor
.toFirstChild();
1526 String elementName
= cursor
.getTextValue();
1527 if (elementName
.equals(fvName
)) {
1528 cursor
.toNextSibling(new QName("", "IncludeModules"));
1529 if (cursor
.toFirstChild()) {
1531 for (i
= 1; cursor
.toNextSibling(); ++i
);
1543 public void getUserExtsIncMods(String fvName
, String
[][] saa
) {
1544 if (getfpdBuildOpts().getUserExtensionsList() == null) {
1547 ListIterator
<UserExtensionsDocument
.UserExtensions
> li
= getfpdBuildOpts().getUserExtensionsList().listIterator();
1548 while (li
.hasNext()) {
1549 UserExtensionsDocument
.UserExtensions ues
= li
.next();
1550 if (!ues
.getUserID().equals("IMAGES")) {
1553 XmlCursor cursor
= ues
.newCursor();
1554 cursor
.toFirstChild();
1555 String elementName
= cursor
.getTextValue();
1556 if (elementName
.equals(fvName
)) {
1557 cursor
.toNextSibling(new QName("", "IncludeModules"));
1558 if (cursor
.toFirstChild()) {
1561 saa
[i
][0] = cursor
.getAttributeText(new QName("ModuleGuid"));
1562 saa
[i
][1] = cursor
.getAttributeText(new QName("BaseName"));
1564 }while (cursor
.toNextSibling());
1574 public void genBuildOptionsUserDefAntTask (String id
, String fileName
, String execOrder
) {
1575 UserDefinedAntTasksDocument
.UserDefinedAntTasks udats
= getfpdBuildOpts().getUserDefinedAntTasks();
1576 if (udats
== null) {
1577 udats
= getfpdBuildOpts().addNewUserDefinedAntTasks();
1580 AntTaskDocument
.AntTask at
= udats
.addNewAntTask();
1581 setBuildOptionsUserDefAntTask(id
, fileName
, execOrder
, at
);
1584 private void setBuildOptionsUserDefAntTask(String id
, String fileName
, String execOrder
, AntTaskDocument
.AntTask at
) {
1585 at
.setId(new Integer(id
));
1586 XmlCursor cursor
= at
.newCursor();
1587 if (fileName
!= null){
1588 at
.setFilename(fileName
);
1590 else if (cursor
.toChild(xmlNs
, "Filename")) {
1593 if (execOrder
!= null) {
1594 at
.setAntCmdOptions(execOrder
);
1596 else if (cursor
.toChild(xmlNs
, "AntCmdOptions")) {
1602 public void removeBuildOptionsUserDefAntTask(int i
) {
1603 XmlObject o
= getfpdBuildOpts().getUserDefinedAntTasks();
1607 XmlCursor cursor
= o
.newCursor();
1608 if (cursor
.toFirstChild()) {
1609 for (int j
= 0; j
< i
; ++j
) {
1610 cursor
.toNextSibling();
1613 if (getBuildOptionsUserDefAntTaskCount() == 0) {
1621 public void updateBuildOptionsUserDefAntTask(int i
, String id
, String fileName
, String execOrder
){
1622 XmlObject o
= getfpdBuildOpts().getUserDefinedAntTasks();
1626 XmlCursor cursor
= o
.newCursor();
1627 if (cursor
.toFirstChild()) {
1628 for (int j
= 0; j
< i
; ++j
) {
1629 cursor
.toNextSibling();
1631 AntTaskDocument
.AntTask at
= (AntTaskDocument
.AntTask
)cursor
.getObject();
1632 setBuildOptionsUserDefAntTask(id
, fileName
, execOrder
, at
);
1637 public int getBuildOptionsUserDefAntTaskCount() {
1638 UserDefinedAntTasksDocument
.UserDefinedAntTasks udats
= getfpdBuildOpts().getUserDefinedAntTasks();
1639 if (udats
== null || udats
.getAntTaskList() == null) {
1643 return udats
.getAntTaskList().size();
1646 public void getBuildOptionsUserDefAntTasks(String
[][] saa
) {
1647 UserDefinedAntTasksDocument
.UserDefinedAntTasks udats
= getfpdBuildOpts().getUserDefinedAntTasks();
1648 if (udats
== null || udats
.getAntTaskList() == null) {
1652 List
<AntTaskDocument
.AntTask
> l
= udats
.getAntTaskList();
1653 ListIterator li
= l
.listIterator();
1655 while (li
.hasNext()) {
1656 AntTaskDocument
.AntTask at
= (AntTaskDocument
.AntTask
)li
.next();
1657 saa
[i
][0] = at
.getId() + "";
1658 saa
[i
][1] = saa
[i
][2] = "";
1659 if (at
.getFilename() != null){
1660 saa
[i
][1] = at
.getFilename();
1662 if (at
.getAntCmdOptions() != null) {
1663 saa
[i
][2] = at
.getAntCmdOptions();
1668 public void genBuildOptionsOpt(Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
) {
1669 OptionsDocument
.Options opts
= getfpdBuildOpts().getOptions();
1671 opts
= getfpdBuildOpts().addNewOptions();
1673 OptionDocument
.Option opt
= opts
.addNewOption();
1674 setBuildOptionsOpt(buildTargets
, toolChain
, tagName
, toolCmd
, archList
, contents
, opt
);
1677 private void setBuildOptionsOpt(Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
, OptionDocument
.Option opt
){
1678 opt
.setStringValue(contents
);
1680 opt
.setBuildTargets(buildTargets
);
1681 opt
.setToolChainFamily(toolChain
);
1682 opt
.setTagName(tagName
);
1683 opt
.setToolCode(toolCmd
);
1685 if (archList
!= null) {
1686 opt
.setSupArchList(archList
);
1689 if (opt
.isSetSupArchList()) {
1690 opt
.unsetSupArchList();
1695 public void removeBuildOptionsOpt(int i
){
1697 XmlObject o
= getfpdBuildOpts().getOptions();
1702 XmlCursor cursor
= o
.newCursor();
1703 if (cursor
.toFirstChild()) {
1704 for (int j
= 0; j
< i
; ++j
) {
1705 cursor
.toNextSibling();
1708 if (getBuildOptionsOptCount() == 0) {
1716 public void updateBuildOptionsOpt(int i
, Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
) {
1717 XmlObject o
= getfpdBuildOpts().getOptions();
1722 XmlCursor cursor
= o
.newCursor();
1723 if (cursor
.toFirstChild()) {
1724 for (int j
= 0; j
< i
; ++j
) {
1725 cursor
.toNextSibling();
1727 OptionDocument
.Option opt
= (OptionDocument
.Option
)cursor
.getObject();
1728 setBuildOptionsOpt(buildTargets
, toolChain
, tagName
, toolCmd
, archList
, contents
, opt
);
1733 public int getBuildOptionsOptCount(){
1734 if (getfpdBuildOpts().getOptions() == null || getfpdBuildOpts().getOptions().getOptionList() == null) {
1737 return getfpdBuildOpts().getOptions().getOptionList().size();
1740 public void getBuildOptionsOpts(String
[][] saa
) {
1741 if (getfpdBuildOpts().getOptions() == null || getfpdBuildOpts().getOptions().getOptionList() == null) {
1745 List
<OptionDocument
.Option
> lOpt
= getfpdBuildOpts().getOptions().getOptionList();
1746 ListIterator li
= lOpt
.listIterator();
1748 while(li
.hasNext()) {
1749 OptionDocument
.Option opt
= (OptionDocument
.Option
)li
.next();
1750 if (opt
.getBuildTargets() != null) {
1751 saa
[i
][0] = listToString(opt
.getBuildTargets());
1753 saa
[i
][1] = opt
.getToolChainFamily();
1754 if (opt
.getSupArchList() != null){
1755 saa
[i
][2] = listToString(opt
.getSupArchList());
1758 saa
[i
][3] = opt
.getToolCode();
1759 saa
[i
][4] = opt
.getTagName();
1760 saa
[i
][5] = opt
.getStringValue();
1766 public void genBuildOptionsFfs(String ffsKey
, String type
) {
1767 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getfpdBuildOpts().addNewFfs();
1768 ffs
.setFfsKey(ffsKey
);
1770 ffs
.addNewSections().setEncapsulationType(type
);
1774 public void updateBuildOptionsFfsSectionsType(int i
, String type
) {
1775 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getfpdBuildOpts().addNewFfs();
1777 ffs
.addNewSections().setEncapsulationType(type
);
1781 public void genBuildOptionsFfsAttribute(int i
, String name
, String value
) {
1782 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1783 BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute attrib
= ffs
.addNewAttribute();
1784 attrib
.setName(name
);
1785 attrib
.setValue(value
);
1788 /**update jth attribute of ith ffs.
1792 public void updateBuildOptionsFfsAttribute(int i
, int j
, String name
, String value
){
1793 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1794 XmlCursor cursor
= ffs
.newCursor();
1795 QName qAttrib
= new QName(xmlNs
, "Attribute");
1796 if (cursor
.toChild(qAttrib
)) {
1797 for (int k
= 0; k
< j
; ++k
) {
1798 cursor
.toNextSibling(qAttrib
);
1800 BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute attrib
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute
)cursor
.getObject();
1801 attrib
.setName(name
);
1802 attrib
.setValue(value
);
1807 public void removeBuildOptionsFfsAttribute(int i
, int j
){
1808 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1809 XmlCursor cursor
= ffs
.newCursor();
1810 QName qAttrib
= new QName(xmlNs
, "Attribute");
1811 if (cursor
.toChild(qAttrib
)) {
1812 for (int k
= 0; k
< j
; ++k
) {
1813 cursor
.toNextSibling(qAttrib
);
1820 public void genBuildOptionsFfsSectionsSection(int i
, String sectionType
) {
1821 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1825 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1827 if (sections
== null){
1828 sections
= ffs
.addNewSections();
1830 sections
.addNewSection().setSectionType(EfiSectionType
.Enum
.forString(sectionType
));
1833 public void removeBuildOptionsFfsSectionsSection(int i
, int j
) {
1834 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1835 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1836 if (sections
== null) {
1839 XmlCursor cursor
= sections
.newCursor();
1840 QName qSection
= new QName(xmlNs
, "Section");
1841 if (cursor
.toChild(qSection
)) {
1842 for (int k
= 0; k
< j
; ++k
) {
1843 cursor
.toNextSibling(qSection
);
1850 public void updateBuildOptionsFfsSectionsSection(int i
, int j
, String type
){
1851 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1852 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1853 if (sections
== null) {
1856 XmlCursor cursor
= sections
.newCursor();
1857 QName qSection
= new QName(xmlNs
, "Section");
1858 if (cursor
.toChild(qSection
)) {
1859 for (int k
= 0; k
< j
; ++k
) {
1860 cursor
.toNextSibling(qSection
);
1862 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Section section
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Section
)cursor
.getObject();
1863 section
.setSectionType(EfiSectionType
.Enum
.forString(type
));
1868 public void genBuildOptionsFfsSectionsSections(int i
, String encapType
) {
1869 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1873 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1875 if (sections
== null){
1876 sections
= ffs
.addNewSections();
1878 sections
.addNewSections().setEncapsulationType(encapType
);
1881 public void removeBuildOptionsFfsSectionsSections(int i
, int j
) {
1882 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1883 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1884 if (sections
== null) {
1887 XmlCursor cursor
= sections
.newCursor();
1888 QName qSections
= new QName(xmlNs
, "Sections");
1889 if (cursor
.toChild(qSections
)) {
1890 for (int k
= 0; k
< j
; ++k
) {
1891 cursor
.toNextSibling(qSections
);
1898 public void updateBuildOptionsFfsSectionsSections(int i
, int j
, String type
) {
1899 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1900 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1901 if (sections
== null) {
1904 XmlCursor cursor
= sections
.newCursor();
1905 QName qSections
= new QName(xmlNs
, "Sections");
1906 if (cursor
.toChild(qSections
)) {
1907 for (int k
= 0; k
< j
; ++k
) {
1908 cursor
.toNextSibling(qSections
);
1910 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2 sections2
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
)cursor
.getObject();
1911 sections2
.setEncapsulationType(type
);
1916 public void genBuildOptionsFfsSectionsSectionsSection(int i
, int j
, String type
) {
1917 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1921 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1922 XmlCursor cursor
= sections
.newCursor();
1923 QName qSections
= new QName(xmlNs
, "Sections");
1924 if (cursor
.toChild(qSections
)){
1925 for (int k
= 0; k
< j
; ++k
) {
1926 cursor
.toNextSibling(qSections
);
1928 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2 sections2
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
)cursor
.getObject();
1929 sections2
.addNewSection().setSectionType(EfiSectionType
.Enum
.forString(type
));
1934 public void removeBuildOptionsFfsSectionsSectionsSection(int i
, int j
, int k
) {
1935 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1936 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1937 if (sections
== null) {
1940 XmlCursor cursor
= sections
.newCursor();
1941 QName qSections
= new QName(xmlNs
, "Sections");
1942 if (cursor
.toChild(qSections
)) {
1943 for (int l
= 0; l
< j
; ++l
) {
1944 cursor
.toNextSibling(qSections
);
1946 if (cursor
.toFirstChild()) {
1948 for (; m
< k
; ++m
) {
1949 cursor
.toNextSibling();
1961 public void updateBuildOptionsFfsSectionsSectionsSection(int i
, int j
, int k
, String type
) {
1962 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1963 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1964 if (sections
== null) {
1967 XmlCursor cursor
= sections
.newCursor();
1968 QName qSections
= new QName(xmlNs
, "Sections");
1969 if (cursor
.toChild(qSections
)) {
1970 for (int l
= 0; l
< j
; ++l
) {
1971 cursor
.toNextSibling(qSections
);
1973 if (cursor
.toFirstChild()) {
1974 for (int m
= 0; m
< k
; ++m
) {
1975 cursor
.toNextSibling();
1977 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section section
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section
)cursor
.getObject();
1978 section
.setSectionType(EfiSectionType
.Enum
.forString(type
));
1984 public void getBuildOptionsFfsSectionsSectionsSection(int i
, int j
, ArrayList
<String
> al
) {
1985 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1989 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1990 XmlCursor cursor
= sections
.newCursor();
1991 QName qSections
= new QName(xmlNs
, "Sections");
1992 if (cursor
.toChild(qSections
)){
1993 for (int k
= 0; k
< j
; ++k
) {
1994 cursor
.toNextSibling(qSections
);
1996 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2 sections2
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
)cursor
.getObject();
1997 if (sections2
.getSectionList() == null){
2001 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section
> li
= sections2
.getSectionList().listIterator();
2002 while(li
.hasNext()) {
2003 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section section
= li
.next();
2004 if (section
.isSetSectionType()) {
2005 al
.add(section
.getSectionType().toString());
2014 public int getBuildOptionsFfsCount(){
2015 if (getfpdBuildOpts().getFfsList() == null) {
2018 return getfpdBuildOpts().getFfsList().size();
2021 public void getBuildOptionsFfsKey(String
[][] saa
) {
2022 if (getfpdBuildOpts().getFfsList() == null) {
2025 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
> li
= getfpdBuildOpts().getFfsList().listIterator();
2027 while(li
.hasNext()){
2028 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= li
.next();
2029 saa
[i
][0] = ffs
.getFfsKey();
2034 public void updateBuildOptionsFfsKey(int i
, String key
) {
2035 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2039 /**Get ith FFS key and contents.
2042 public void getBuildOptionsFfs(int i
, String
[] sa
, LinkedHashMap
<String
, String
> ffsAttribMap
, ArrayList
<String
> firstLevelSections
, ArrayList
<String
> firstLevelSection
) {
2043 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2047 sa
[0] = ffs
.getFfsKey();
2048 if (ffs
.getSections() != null) {
2049 if(ffs
.getSections().getEncapsulationType() != null){
2050 sa
[1] = ffs
.getSections().getEncapsulationType();
2052 if (ffs
.getSections().getSectionList() != null){
2053 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Section
> li
= ffs
.getSections().getSectionList().listIterator();
2054 while (li
.hasNext()) {
2055 firstLevelSection
.add(li
.next().getSectionType().toString());
2058 if (ffs
.getSections().getSectionsList() != null) {
2059 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
> li
= ffs
.getSections().getSectionsList().listIterator();
2060 while(li
.hasNext()) {
2061 firstLevelSections
.add(li
.next().getEncapsulationType());
2065 if (ffs
.getAttributeList() != null) {
2066 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute
> li
= ffs
.getAttributeList().listIterator();
2067 while(li
.hasNext()) {
2068 BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute attrib
= li
.next();
2069 ffsAttribMap
.put(attrib
.getName(), attrib
.getValue());
2078 private BuildOptionsDocument
.BuildOptions
.Ffs
getFfs(int i
) {
2079 XmlObject o
= getfpdBuildOpts();
2080 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= null;
2082 XmlCursor cursor
= o
.newCursor();
2083 QName qFfs
= new QName(xmlNs
, "Ffs");
2084 if (cursor
.toChild(qFfs
)) {
2085 for (int j
= 0; j
< i
; ++j
) {
2086 cursor
.toNextSibling(qFfs
);
2088 ffs
= (BuildOptionsDocument
.BuildOptions
.Ffs
)cursor
.getObject();
2094 public void removeBuildOptionsFfs(int i
) {
2095 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2100 XmlCursor cursor
= ffs
.newCursor();
2107 public PlatformDefinitionsDocument
.PlatformDefinitions
getfpdPlatformDefs(){
2108 if (fpdPlatformDefs
== null){
2109 fpdPlatformDefs
= fpdRoot
.addNewPlatformDefinitions();
2111 return fpdPlatformDefs
;
2114 public void getPlatformDefsSupportedArchs(Vector
<Object
> archs
){
2115 if (getfpdPlatformDefs().getSupportedArchitectures() == null) {
2118 ListIterator li
= getfpdPlatformDefs().getSupportedArchitectures().listIterator();
2119 while(li
.hasNext()) {
2120 archs
.add(li
.next());
2124 public void setPlatformDefsSupportedArchs(Vector
<Object
> archs
) {
2125 if (archs
!= null) {
2126 getfpdPlatformDefs().setSupportedArchitectures(archs
);
2129 // XmlCursor cursor = getfpdPlatformDefs().newCursor();
2130 // if (cursor.toChild(xmlNs, "SupportedArchitectures")) {
2131 // cursor.removeXml();
2133 // cursor.dispose();
2137 public void getPlatformDefsBuildTargets(Vector
<Object
> targets
) {
2138 if (getfpdPlatformDefs().getBuildTargets() == null) {
2141 ListIterator li
= getfpdPlatformDefs().getBuildTargets().listIterator();
2142 while(li
.hasNext()) {
2143 targets
.add(li
.next());
2147 public void setPlatformDefsBuildTargets(Vector
<Object
> targets
) {
2148 getfpdPlatformDefs().setBuildTargets(targets
);
2151 public void genPlatformDefsSkuInfo(String id
, String name
) {
2152 SkuInfoDocument
.SkuInfo skuInfo
= null;
2153 if (getfpdPlatformDefs().getSkuInfo() == null) {
2154 skuInfo
= getfpdPlatformDefs().addNewSkuInfo();
2156 skuInfo
= getfpdPlatformDefs().getSkuInfo();
2157 if (skuInfo
.getUiSkuNameList() == null || skuInfo
.getUiSkuNameList().size() == 0) {
2158 SkuInfoDocument
.SkuInfo
.UiSkuName skuName
= skuInfo
.addNewUiSkuName();
2159 skuName
.setSkuID(new BigInteger("0"));
2160 skuName
.setStringValue("DEFAULT");
2162 if (id
.equals("0")) {
2165 SkuInfoDocument
.SkuInfo
.UiSkuName skuName
= skuInfo
.addNewUiSkuName();
2166 skuName
.setSkuID(new BigInteger(id
));
2167 skuName
.setStringValue(name
);
2170 public int getPlatformDefsSkuInfoCount(){
2171 if (getfpdPlatformDefs().getSkuInfo() == null || getfpdPlatformDefs().getSkuInfo().getUiSkuNameList() == null) {
2174 return getfpdPlatformDefs().getSkuInfo().getUiSkuNameList().size();
2177 public void getPlatformDefsSkuInfos(String
[][] saa
){
2178 if (getfpdPlatformDefs().getSkuInfo() == null || getfpdPlatformDefs().getSkuInfo().getUiSkuNameList() == null) {
2179 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null) {
2180 removeElement(getfpdDynPcdBuildDefs());
2181 fpdDynPcdBuildDefs
= null;
2186 List
<SkuInfoDocument
.SkuInfo
.UiSkuName
> l
= getfpdPlatformDefs().getSkuInfo().getUiSkuNameList();
2187 ListIterator
<SkuInfoDocument
.SkuInfo
.UiSkuName
> li
= l
.listIterator();
2189 while(li
.hasNext()) {
2190 SkuInfoDocument
.SkuInfo
.UiSkuName sku
= li
.next();
2191 saa
[i
][0] = sku
.getSkuID()+"";
2192 saa
[i
][1] = sku
.getStringValue();
2197 public void removePlatformDefsSkuInfo(int i
) {
2198 SkuInfoDocument
.SkuInfo skuInfo
= getfpdPlatformDefs().getSkuInfo();
2199 if (skuInfo
== null || i
== 0) {
2203 XmlCursor cursor
= skuInfo
.newCursor();
2204 if (cursor
.toFirstChild()) {
2205 for (int j
= 0; j
< i
; ++j
) {
2206 cursor
.toNextSibling();
2213 public void updatePlatformDefsSkuInfo(int i
, String id
, String name
) {
2214 SkuInfoDocument
.SkuInfo skuInfo
= getfpdPlatformDefs().getSkuInfo();
2215 if (skuInfo
== null || i
== 0) {
2219 XmlCursor cursor
= skuInfo
.newCursor();
2220 if (cursor
.toFirstChild()) {
2221 for (int j
= 0; j
< i
; ++j
) {
2222 cursor
.toNextSibling();
2224 SkuInfoDocument
.SkuInfo
.UiSkuName sku
= (SkuInfoDocument
.SkuInfo
.UiSkuName
)cursor
.getObject();
2225 sku
.setSkuID(new BigInteger(id
));
2226 sku
.setStringValue(name
);
2231 public String
getPlatformDefsInterDir(){
2232 if (getfpdPlatformDefs().getIntermediateDirectories() == null) {
2235 return getfpdPlatformDefs().getIntermediateDirectories().toString();
2238 public void setPlatformDefsInterDir(String interDir
){
2239 getfpdPlatformDefs().setIntermediateDirectories(IntermediateOutputType
.Enum
.forString(interDir
));
2242 public String
getPlatformDefsOutputDir() {
2243 return getfpdPlatformDefs().getOutputDirectory();
2246 public void setPlatformDefsOutputDir(String outputDir
) {
2247 if (outputDir
!= null && outputDir
.length() > 0) {
2248 getfpdPlatformDefs().setOutputDirectory(outputDir
);
2251 XmlCursor cursor
= getfpdPlatformDefs().newCursor();
2252 if (cursor
.toChild(new QName(xmlNs
, "OutputDirectory"))) {
2259 public FlashDocument
.Flash
getfpdFlash() {
2260 if (fpdFlash
== null) {
2261 fpdFlash
= fpdRoot
.addNewFlash();
2266 public void genFlashDefinitionFile(String file
) {
2267 FlashDefinitionFileDocument
.FlashDefinitionFile fdf
= getfpdFlash().getFlashDefinitionFile();
2269 fdf
= getfpdFlash().addNewFlashDefinitionFile();
2272 fdf
.setStringValue(file
);
2275 public String
getFlashDefinitionFile() {
2276 FlashDefinitionFileDocument
.FlashDefinitionFile fdf
= getfpdFlash().getFlashDefinitionFile();
2281 return fdf
.getStringValue();
2284 public void genFvImagesNameValue(String name
, String value
) {
2286 FvImagesDocument
.FvImages fi
= getfpdFlash().getFvImages();
2288 fi
= getfpdFlash().addNewFvImages();
2291 FvImagesDocument
.FvImages
.NameValue nv
= fi
.addNewNameValue();
2296 public void removeFvImagesNameValue(int i
){
2298 XmlObject o
= getfpdFlash().getFvImages();
2303 QName qNameValue
= new QName(xmlNs
, "NameValue");
2304 XmlCursor cursor
= o
.newCursor();
2305 if (cursor
.toChild(qNameValue
)) {
2306 for (int j
= 0; j
< i
; ++j
) {
2307 cursor
.toNextSibling(qNameValue
);
2314 public void updateFvImagesNameValue(int i
, String name
, String value
){
2316 XmlObject o
= getfpdFlash().getFvImages();
2321 QName qNameValue
= new QName(xmlNs
, "NameValue");
2322 XmlCursor cursor
= o
.newCursor();
2323 if (cursor
.toChild(qNameValue
)) {
2324 for (int j
= 0; j
< i
; ++j
) {
2325 cursor
.toNextSibling(qNameValue
);
2327 FvImagesDocument
.FvImages
.NameValue nv
= (FvImagesDocument
.FvImages
.NameValue
)cursor
.getObject();
2334 public int getFvImagesNameValueCount() {
2336 FvImagesDocument
.FvImages fi
= null;
2337 if ((fi
= getfpdFlash().getFvImages()) == null || fi
.getNameValueList() == null) {
2340 return fi
.getNameValueList().size();
2343 public void getFvImagesNameValues(String
[][] nv
) {
2345 FvImagesDocument
.FvImages fi
= getfpdFlash().getFvImages();
2349 List
<FvImagesDocument
.FvImages
.NameValue
> l
= fi
.getNameValueList();
2351 ListIterator li
= l
.listIterator();
2352 while (li
.hasNext()) {
2353 FvImagesDocument
.FvImages
.NameValue e
= (FvImagesDocument
.FvImages
.NameValue
) li
2355 nv
[i
][0] = e
.getName();
2356 nv
[i
][1] = e
.getValue();
2362 public void genFvImagesFvImage(String
[] names
, String types
, Map
<String
, String
> options
) {
2364 FvImagesDocument
.FvImages fis
= null;
2365 if ((fis
= getfpdFlash().getFvImages()) == null) {
2366 fis
= getfpdFlash().addNewFvImages();
2370 //gen FvImage with FvImageNames array
2372 FvImagesDocument
.FvImages
.FvImage fi
= fis
.addNewFvImage();
2373 for (int i
= 0; i
< names
.length
; ++i
) {
2374 fi
.addFvImageNames(names
[i
]);
2376 fi
.setType(FvImageTypes
.Enum
.forString(types
));
2377 if (options
!= null){
2378 setFvImagesFvImageFvImageOptions(options
, fi
);
2382 private void setFvImagesFvImageFvImageOptions(Map
<String
, String
> options
, FvImagesDocument
.FvImages
.FvImage fi
){
2383 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions fio
= fi
.getFvImageOptions();
2385 fio
= fi
.addNewFvImageOptions();
2388 Set
<String
> key
= options
.keySet();
2389 Iterator
<String
> i
= key
.iterator();
2390 while (i
.hasNext()) {
2392 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nv
= fio
.addNewNameValue();
2393 String k
= (String
)i
.next();
2396 nv
.setValue((String
)options
.get(k
));
2403 public void removeFvImagesFvImage(int i
) {
2405 XmlObject o
= getfpdFlash().getFvImages();
2410 QName qFvImage
= new QName(xmlNs
, "FvImage");
2411 XmlCursor cursor
= o
.newCursor();
2412 if (cursor
.toChild(qFvImage
)) {
2413 for (int j
= 0; j
< i
; ++j
) {
2414 cursor
.toNextSibling(qFvImage
);
2421 public void updateFvImagesFvImage(int i
, String
[] names
, String types
, Map
<String
, String
> options
){
2423 XmlObject o
= getfpdFlash().getFvImages();
2427 XmlCursor cursor
= o
.newCursor();
2428 QName qFvImage
= new QName(xmlNs
, "FvImage");
2429 if (cursor
.toChild(qFvImage
)) {
2430 for (int j
= 0; j
< i
; ++j
) {
2431 cursor
.toNextSibling(qFvImage
);
2433 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
2434 fi
.setType(FvImageTypes
.Enum
.forString(types
));
2437 // remove old FvImageNames before adding new ones
2439 QName qFvImageNames
= new QName(xmlNs
, "FvImageNames");
2440 cursor
.toChild(qFvImageNames
);
2442 while (cursor
.toNextSibling(qFvImageNames
)) {
2446 for (int k
= 0; k
< names
.length
; ++k
) {
2447 fi
.addFvImageNames(names
[k
]);
2450 // remove old FvImageOptions before adding new options
2452 QName qFvImageOptions
= new QName(xmlNs
, "FvImageOptions");
2453 cursor
.toNextSibling(qFvImageOptions
);
2456 setFvImagesFvImageFvImageOptions(options
, fi
);
2461 public int getFvImagesFvImageCount() {
2463 if (getfpdFlash().getFvImages() == null || getfpdFlash().getFvImages().getFvImageList() == null) {
2466 return getfpdFlash().getFvImages().getFvImageList().size();
2469 /**Only Get Fv image setting - name and type.
2472 public void getFvImagesFvImages(String
[][] saa
) {
2474 if (getfpdFlash().getFvImages() == null) {
2477 List
<FvImagesDocument
.FvImages
.FvImage
> l
= getfpdFlash().getFvImages().getFvImageList();
2481 ListIterator li
= l
.listIterator();
2483 while(li
.hasNext()) {
2484 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)li
.next();
2486 // get FvImageNames array, space separated
2488 List
<String
> lfn
= fi
.getFvImageNamesList();
2489 ListIterator lfni
= lfn
.listIterator();
2491 while (lfni
.hasNext()) {
2492 saa
[i
][0] += (String
)lfni
.next();
2495 saa
[i
][0] = saa
[i
][0].trim();
2497 saa
[i
][1] = fi
.getType()+"";
2503 /**Get FvImage Options for FvImage i
2504 * @param i the ith FvImage
2506 public void getFvImagesFvImageOptions(int i
, Map
<String
, String
> m
) {
2507 XmlObject o
= getfpdFlash().getFvImages();
2511 XmlCursor cursor
= o
.newCursor();
2512 QName qFvImage
= new QName(xmlNs
, "FvImage");
2513 if (cursor
.toChild(qFvImage
)) {
2514 for (int j
= 0; j
< i
; ++j
) {
2515 cursor
.toNextSibling(qFvImage
);
2517 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
2518 if (fi
.getFvImageOptions() == null || fi
.getFvImageOptions().getNameValueList() == null){
2521 ListIterator
<FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
> li
= fi
.getFvImageOptions().getNameValueList().listIterator();
2522 while(li
.hasNext()){
2523 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nv
= li
.next();
2524 m
.put(nv
.getName(), nv
.getValue());
2530 Get platform header element
2531 @return PlatformHeaderDocument.PlatformHeader
2533 public PlatformHeaderDocument
.PlatformHeader
getFpdHdr() {
2534 if (fpdHdr
== null) {
2535 fpdHdr
= fpdRoot
.addNewPlatformHeader();
2541 public String
getFpdHdrPlatformName() {
2542 return getFpdHdr().getPlatformName();
2545 public String
getFpdHdrGuidValue() {
2546 return getFpdHdr().getGuidValue();
2549 public String
getFpdHdrVer() {
2550 return getFpdHdr().getVersion();
2553 public String
getFpdHdrAbs() {
2554 return getFpdHdr().getAbstract();
2557 public String
getFpdHdrDescription() {
2558 return getFpdHdr().getDescription();
2561 public String
getFpdHdrCopyright() {
2562 return getFpdHdr().getCopyright();
2565 public String
getFpdHdrLicense() {
2566 LicenseDocument
.License l
= getFpdHdr().getLicense();
2570 return l
.getStringValue();
2573 public String
getFpdHdrUrl() {
2574 LicenseDocument
.License l
= getFpdHdr().getLicense();
2581 public String
getFpdHdrSpec() {
2583 return "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052";
2584 // return getFpdHdr().getSpecification();
2587 public void setFpdHdrPlatformName(String name
){
2588 getFpdHdr().setPlatformName(name
);
2591 public void setFpdHdrGuidValue(String guid
){
2592 getFpdHdr().setGuidValue(guid
);
2595 public void setFpdHdrVer(String v
){
2596 getFpdHdr().setVersion(v
);
2599 public void setFpdHdrAbs(String abs
) {
2600 getFpdHdr().setAbstract(abs
);
2603 public void setFpdHdrDescription(String desc
){
2604 getFpdHdr().setDescription(desc
);
2607 public void setFpdHdrCopyright(String cr
) {
2608 getFpdHdr().setCopyright(cr
);
2611 public void setFpdHdrLicense(String license
){
2612 LicenseDocument
.License l
= getFpdHdr().getLicense();
2614 getFpdHdr().addNewLicense().setStringValue(license
);
2617 l
.setStringValue(license
);
2621 public void setFpdHdrUrl(String url
){
2622 LicenseDocument
.License l
= getFpdHdr().getLicense();
2628 public void setFpdHdrSpec(String s
){
2629 s
= "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052";
2630 getFpdHdr().setSpecification(s
);
2633 Save the processed xml contents to file
2635 @param fpdFile The file to save xml contents
2636 @throws IOException Exceptions during file operation
2638 public void saveAs(File fpdFile
) throws IOException
{
2640 XmlOptions options
= new XmlOptions();
2642 options
.setCharacterEncoding("UTF-8");
2643 options
.setSavePrettyPrint();
2644 options
.setSavePrettyPrintIndent(2);
2646 fpdd
.save(fpdFile
, options
);
2647 } catch (IOException e
) {
2648 e
.printStackTrace();
2653 private String
listToString(List l
) {
2658 ListIterator li
= l
.listIterator();
2659 while(li
.hasNext()) {
2666 private void removeElement(XmlObject o
) {
2667 XmlCursor cursor
= o
.newCursor();
2673 class PcdItemTypeConflictException
extends Exception
{
2678 private static final long serialVersionUID
= 1L;
2679 private String details
= null;
2681 PcdItemTypeConflictException(String pcdName
, String info
){
2682 ModuleIdentification mi
= WorkspaceProfile
.getModuleId(info
);
2683 details
= pcdName
+ " ItemType Conflicts with " + mi
.getName() + " in Pkg " + mi
.getPackage().getName();
2686 public String
getMessage() {
2691 class PcdDeclNotFound
extends Exception
{
2696 private static final long serialVersionUID
= 1L;
2697 private String details
= null;
2699 PcdDeclNotFound(String info
) {
2700 details
= "PcdDeclNotFound: " + info
;
2703 public String
getMessage() {
2708 class PcdValueMalFormed
extends Exception
{
2713 private static final long serialVersionUID
= 1L;
2714 private String details
= null;
2716 PcdValueMalFormed(String info
) {
2717 details
= "PcdValueMalFormed: " + info
;
2720 public String
getMessage() {