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 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 Map
<String
, XmlObject
> m
= new HashMap
<String
, XmlObject
>();
951 PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry spdPcd
= null;
952 for (int i
= 0; i
< depPkgs
.length
; ++i
) {
953 m
.put("PackageSurfaceArea", WorkspaceProfile
.getPackageXmlObject(depPkgs
[i
]));
954 SurfaceAreaQuery
.setDoc(m
);
955 XmlObject
[] xo
= SurfaceAreaQuery
.getSpdPcdDeclarations();
959 for (int j
= 0; j
< xo
.length
; ++j
) {
960 spdPcd
= (PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry
)xo
[j
];
961 if (msaPcd
.getTokenSpaceGuidCName() == null) {
962 if (spdPcd
.getCName().equals(msaPcd
.getCName())) {
967 if (spdPcd
.getCName().equals(msaPcd
.getCName()) && spdPcd
.getTokenSpaceGuidCName().equals(msaPcd
.getTokenSpaceGuidCName())) {
978 private ModuleSADocument
.ModuleSA
genModuleSA (ModuleIdentification mi
, String arch
) {
979 PackageIdentification pi
= WorkspaceProfile
.getPackageForModule(mi
);
980 ModuleSADocument
.ModuleSA msa
= getfpdFrameworkModules().addNewModuleSA();
981 XmlCursor cursor
= msa
.newCursor();
983 String comment
= "Mod: " + mi
.getName() + " Type: " + mi
.getModuleType() + " Path: "
984 + WorkspaceProfile
.getMsaFile(mi
).getPath().substring(System
.getenv("WORKSPACE").length() + 1);
985 cursor
.insertComment(comment
);
993 msa
.setModuleGuid(mi
.getGuid());
994 msa
.setModuleVersion(mi
.getVersion());
995 msa
.setPackageGuid(pi
.getGuid());
996 msa
.setPackageVersion(pi
.getVersion());
998 Vector
<String
> v
= new Vector
<String
>();
1000 msa
.setSupArchList(v
);
1006 private void genPcdData (String cName
, Object token
, String tsGuid
, String itemType
, String dataType
, String defaultVal
, ModuleSADocument
.ModuleSA moduleSa
)
1007 throws PcdItemTypeConflictException
, PcdValueMalFormed
{
1008 if (moduleSa
.getPcdBuildDefinition() == null){
1009 moduleSa
.addNewPcdBuildDefinition();
1012 // constructe pcd to modulesa mapping first.
1013 // Attention : for any error condition, remove from map this pcd.
1015 ArrayList
<String
> pcdConsumer
= LookupPlatformPcdData(cName
+ " " + tsGuid
);
1016 if (pcdConsumer
== null) {
1017 pcdConsumer
= new ArrayList
<String
>();
1020 // Using existing Pcd type, if this pcd already exists in other ModuleSA
1022 if (pcdConsumer
.size() > 0) {
1023 String
[] valPart
= pcdConsumer
.get(0).split(" ");
1024 itemType
= valPart
[5];
1026 String listValue
= moduleSa
.getModuleGuid() + " " + moduleSa
.getModuleVersion()
1027 + " " + moduleSa
.getPackageGuid() + " " + moduleSa
.getPackageVersion() + " " + listToString(moduleSa
.getSupArchList())
1029 pcdConsumer
.add(listValue
);
1030 dynPcdMap
.put(cName
+ " " + tsGuid
, pcdConsumer
);
1032 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData fpdPcd
= moduleSa
.getPcdBuildDefinition().addNewPcdData();
1033 fpdPcd
.setCName(cName
);
1034 fpdPcd
.setToken(token
);
1035 fpdPcd
.setTokenSpaceGuidCName(tsGuid
);
1036 fpdPcd
.setDatumType(PcdDataTypes
.Enum
.forString(dataType
));
1037 fpdPcd
.setItemType(PcdItemTypes
.Enum
.forString(itemType
));
1039 if (defaultVal
!= null){
1040 fpdPcd
.setValue(defaultVal
);
1043 if (dataType
.equals("UINT8") || dataType
.equals("UINT16") || dataType
.equals("UINT32") || dataType
.equals("UINT64")) {
1044 fpdPcd
.setValue("0");
1046 if (dataType
.equals("BOOLEAN")){
1047 fpdPcd
.setValue("false");
1049 if (dataType
.equals("VOID*")) {
1050 fpdPcd
.setValue("");
1054 // Using existing pcd value, if this pcd already exists in other moduleSa.
1056 if (defaultPcdValue
.get(cName
+ " " + tsGuid
) == null) {
1057 defaultPcdValue
.put(cName
+ " " + tsGuid
, fpdPcd
.getValue());
1060 fpdPcd
.setValue(defaultPcdValue
.get(cName
+ " " + tsGuid
));
1063 if (dataType
.equals("UINT8")){
1064 fpdPcd
.setMaxDatumSize(1);
1066 if (dataType
.equals("UINT16")) {
1067 fpdPcd
.setMaxDatumSize(2);
1069 if (dataType
.equals("UINT32")) {
1070 fpdPcd
.setMaxDatumSize(4);
1072 if (dataType
.equals("UINT64")){
1073 fpdPcd
.setMaxDatumSize(8);
1075 if (dataType
.equals("BOOLEAN")){
1076 fpdPcd
.setMaxDatumSize(1);
1078 if (dataType
.equals("VOID*")) {
1079 int maxSize
= setMaxSizeForPointer(fpdPcd
.getValue());
1080 fpdPcd
.setMaxDatumSize(maxSize
);
1084 if (itemType
.equals("DYNAMIC") || itemType
.equals("DYNAMIC_EX")) {
1085 ArrayList
<String
> al
= LookupDynamicPcdBuildDefinition(cName
+ " " + tsGuid
);
1087 // if only one module mapped to this pcd, then the one is myself. so no other module mapped.
1088 // so need to add one dyn pcd.
1090 if (al
.size() == 1) {
1091 addDynamicPcdBuildData(cName
, token
, tsGuid
, itemType
, dataType
, defaultVal
);
1097 public int setMaxSizeForPointer(String datum
) throws PcdValueMalFormed
{
1098 if (datum
== null) {
1101 char ch
= datum
.charAt(0);
1105 // For void* type PCD, only three datum is support:
1106 // 1) Unicode: string with start char is "L"
1107 // 2) Ansci: String is ""
1108 // 3) byte array: String start char "{"
1111 start
= datum
.indexOf('\"');
1112 end
= datum
.lastIndexOf('\"');
1113 if ((start
> end
) ||
1114 (end
> datum
.length())||
1115 ((start
== end
) && (datum
.length() > 0))) {
1116 //ToDo Error handling here
1117 throw new PcdValueMalFormed (datum
);
1120 strValue
= datum
.substring(start
+ 1, end
);
1121 return strValue
.length() * 2;
1122 } else if (ch
== '\"'){
1123 start
= datum
.indexOf('\"');
1124 end
= datum
.lastIndexOf('\"');
1125 if ((start
> end
) ||
1126 (end
> datum
.length())||
1127 ((start
== end
) && (datum
.length() > 0))) {
1128 throw new PcdValueMalFormed (datum
);
1130 strValue
= datum
.substring(start
+ 1, end
);
1131 return strValue
.length();
1132 } else if (ch
=='{') {
1133 String
[] strValueArray
;
1135 start
= datum
.indexOf('{');
1136 end
= datum
.lastIndexOf('}');
1137 strValue
= datum
.substring(start
+ 1, end
);
1138 strValue
= strValue
.trim();
1139 if (strValue
.length() == 0) {
1142 strValueArray
= strValue
.split(",");
1143 for (int index
= 0; index
< strValueArray
.length
; index
++) {
1144 Integer value
= Integer
.decode(strValueArray
[index
].trim());
1147 // "[FPD file error] The datum type of PCD %s in %s is VOID*, "+
1148 // "it is byte array in fact. But the element of %s exceed the byte range",
1149 throw new PcdValueMalFormed (datum
);
1152 return strValueArray
.length
;
1156 // "[FPD file error] The datum type of PCD %s in %s is VOID*. For VOID* type, you have three format choise:\n "+
1157 // "1) UNICODE string: like L\"xxxx\";\r\n"+
1158 // "2) ANSIC string: like \"xxx\";\r\n"+
1159 // "3) Byte array: like {0x2, 0x45, 0x23}\r\n"+
1160 // "but the datum in seems does not following above format!",
1161 throw new PcdValueMalFormed (datum
);
1166 private ArrayList
<String
> LookupDynamicPcdBuildDefinition(String dynPcdKey
) {
1167 ArrayList
<String
> al
= dynPcdMap
.get(dynPcdKey
);
1172 private ArrayList
<String
> LookupPlatformPcdData(String pcdKey
) {
1174 return dynPcdMap
.get(pcdKey
);
1177 public int getDynamicPcdBuildDataCount() {
1178 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1179 removeElement(getfpdDynPcdBuildDefs());
1180 fpdDynPcdBuildDefs
= null;
1183 return getfpdDynPcdBuildDefs().getPcdBuildDataList().size();
1186 public void getDynamicPcdBuildData(String
[][] saa
) {
1187 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1188 removeElement(getfpdDynPcdBuildDefs());
1189 fpdDynPcdBuildDefs
= null;
1192 List
<DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
> l
= getfpdDynPcdBuildDefs().getPcdBuildDataList();
1193 ListIterator
<DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
> li
= l
.listIterator();
1195 while(li
.hasNext()) {
1196 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData dynPcd
= li
.next();
1197 saa
[i
][0] = dynPcd
.getCName();
1198 saa
[i
][1] = dynPcd
.getToken().toString();
1199 saa
[i
][2] = dynPcd
.getTokenSpaceGuidCName();
1200 saa
[i
][3] = dynPcd
.getMaxDatumSize()+"";
1201 saa
[i
][4] = dynPcd
.getDatumType().toString();
1207 public void addDynamicPcdBuildData(String cName
, Object token
, String tsGuid
, String itemType
, String dataType
, String defaultVal
)
1208 throws PcdValueMalFormed
{
1209 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData dynPcdData
= getfpdDynPcdBuildDefs().addNewPcdBuildData();
1210 dynPcdData
.setItemType(PcdItemTypes
.Enum
.forString(itemType
));
1211 dynPcdData
.setCName(cName
);
1212 dynPcdData
.setToken(token
);
1213 dynPcdData
.setTokenSpaceGuidCName(tsGuid
);
1214 dynPcdData
.setDatumType(PcdDataTypes
.Enum
.forString(dataType
));
1216 BigInteger bigInt
= new BigInteger("0");
1217 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo skuInfo
= dynPcdData
.addNewSkuInfo();
1218 skuInfo
.setSkuId(bigInt
);
1219 if (defaultVal
!= null){
1220 skuInfo
.setValue(defaultVal
);
1223 if (dataType
.equals("UINT8")){
1224 skuInfo
.setValue("0");
1226 if (dataType
.equals("UINT16")) {
1227 skuInfo
.setValue("0");
1229 if (dataType
.equals("UINT32")) {
1230 skuInfo
.setValue("0");
1232 if (dataType
.equals("UINT64")){
1233 skuInfo
.setValue("0");
1235 if (dataType
.equals("BOOLEAN")){
1236 skuInfo
.setValue("false");
1238 if (dataType
.equals("VOID*")) {
1239 skuInfo
.setValue("");
1242 if (dataType
.equals("UINT8")){
1243 dynPcdData
.setMaxDatumSize(1);
1245 if (dataType
.equals("UINT16")) {
1246 dynPcdData
.setMaxDatumSize(2);
1248 if (dataType
.equals("UINT32")) {
1249 dynPcdData
.setMaxDatumSize(4);
1251 if (dataType
.equals("UINT64")){
1252 dynPcdData
.setMaxDatumSize(8);
1254 if (dataType
.equals("BOOLEAN")){
1255 dynPcdData
.setMaxDatumSize(1);
1257 if (dataType
.equals("VOID*")) {
1258 int maxSize
= setMaxSizeForPointer(defaultVal
);
1259 dynPcdData
.setMaxDatumSize(maxSize
);
1263 public void removeDynamicPcdBuildData(String cName
, String tsGuid
) {
1264 XmlObject o
= fpdRoot
.getDynamicPcdBuildDefinitions();
1269 XmlCursor cursor
= o
.newCursor();
1270 if (cursor
.toFirstChild()) {
1272 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdBuildData
=
1273 (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1274 if (pcdBuildData
.getCName().equals(cName
) && pcdBuildData
.getTokenSpaceGuidCName().equals(tsGuid
)) {
1276 if (getDynamicPcdBuildDataCount() == 1) {
1284 while (cursor
.toNextSibling());
1289 // Get the Sku Info count of ith dyn pcd element.
1291 public int getDynamicPcdSkuInfoCount(int i
){
1292 if (fpdRoot
.getDynamicPcdBuildDefinitions() == null || fpdRoot
.getDynamicPcdBuildDefinitions().getPcdBuildDataList() == null
1293 || fpdRoot
.getDynamicPcdBuildDefinitions().getPcdBuildDataList().size() == 0) {
1297 int skuInfoCount
= 0;
1298 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1299 if (cursor
.toFirstChild()) {
1300 for (int j
= 0; j
< i
; ++j
) {
1301 cursor
.toNextSibling();
1303 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1304 if (pcdData
.getSkuInfoList() == null) {
1308 skuInfoCount
= pcdData
.getSkuInfoList().size();
1312 return skuInfoCount
;
1315 public void getDynamicPcdSkuInfos(int i
, String
[][] saa
){
1316 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1317 removeElement(getfpdDynPcdBuildDefs());
1318 fpdDynPcdBuildDefs
= null;
1322 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1323 if (cursor
.toFirstChild()) {
1324 for (int j
= 0; j
< i
; ++j
) {
1325 cursor
.toNextSibling();
1327 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1328 if (pcdData
.getSkuInfoList() == null) {
1333 ListIterator
<DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo
> li
= pcdData
.getSkuInfoList().listIterator();
1335 while (li
.hasNext()) {
1336 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo skuInfo
= li
.next();
1337 saa
[k
][0] = skuInfo
.getSkuId()+"";
1338 saa
[k
][1] = skuInfo
.getVariableName();
1339 saa
[k
][2] = skuInfo
.getVariableGuid();
1340 saa
[k
][3] = skuInfo
.getVariableOffset();
1341 saa
[k
][4] = skuInfo
.getHiiDefaultValue();
1342 saa
[k
][5] = skuInfo
.getVpdOffset();
1343 saa
[k
][6] = skuInfo
.getValue();
1353 public String
getDynamicPcdBuildDataValue(int i
){
1354 String value
= null;
1355 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1356 removeElement(getfpdDynPcdBuildDefs());
1357 fpdDynPcdBuildDefs
= null;
1361 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1362 if (cursor
.toFirstChild()) {
1363 for (int j
= 0; j
< i
; ++j
) {
1364 cursor
.toNextSibling();
1366 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1367 if (pcdData
.getSkuInfoList() == null) {
1371 value
= pcdData
.getSkuInfoArray(0).getValue();
1378 public String
getDynamicPcdBuildDataVpdOffset(int i
){
1379 String vpdOffset
= null;
1380 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1381 removeElement(getfpdDynPcdBuildDefs());
1382 fpdDynPcdBuildDefs
= null;
1386 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1387 if (cursor
.toFirstChild()) {
1388 for (int j
= 0; j
< i
; ++j
) {
1389 cursor
.toNextSibling();
1391 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1392 if (pcdData
.getSkuInfoList() == null) {
1396 vpdOffset
= pcdData
.getSkuInfoArray(0).getVpdOffset();
1403 public void removeDynamicPcdBuildDataSkuInfo(int i
) {
1404 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1405 removeElement(getfpdDynPcdBuildDefs());
1406 fpdDynPcdBuildDefs
= null;
1410 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1411 if (cursor
.toFirstChild()) {
1412 for (int j
= 0; j
< i
; ++j
) {
1413 cursor
.toNextSibling();
1415 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1416 if (pcdData
.getSkuInfoList() == null) {
1421 QName qSkuInfo
= new QName(xmlNs
, "SkuInfo");
1422 cursor
.toChild(qSkuInfo
);
1429 // generate sku info for ith dyn pcd build data.
1431 public void genDynamicPcdBuildDataSkuInfo(String id
, String varName
, String varGuid
, String varOffset
,
1432 String hiiDefault
, String vpdOffset
, String value
, int i
) {
1433 // if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1437 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1438 if (cursor
.toFirstChild()) {
1439 for (int j
= 0; j
< i
; ++j
) {
1440 cursor
.toNextSibling();
1442 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1443 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo skuInfo
= pcdData
.addNewSkuInfo();
1444 skuInfo
.setSkuId(new BigInteger(id
));
1445 if (varName
!= null){
1446 skuInfo
.setVariableName(varName
);
1447 skuInfo
.setVariableGuid(varGuid
);
1448 skuInfo
.setVariableOffset(varOffset
);
1449 skuInfo
.setHiiDefaultValue(hiiDefault
);
1451 else if (vpdOffset
!= null){
1452 skuInfo
.setVpdOffset(vpdOffset
);
1455 skuInfo
.setValue(value
);
1460 public void updateDynamicPcdBuildDataSkuInfo(String id
, String varName
, String varGuid
, String varOffset
,
1461 String hiiDefault
, String vpdOffset
, String value
, int i
){
1462 // if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1466 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1467 if (cursor
.toFirstChild()) {
1468 for (int j
= 0; j
< i
; ++j
) {
1469 cursor
.toNextSibling();
1471 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1472 ListIterator
<DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo
> li
= pcdData
.getSkuInfoList().listIterator();
1473 while (li
.hasNext()) {
1474 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo skuInfo
= li
.next();
1475 if (skuInfo
.getSkuId().toString().equals(id
)){
1476 if (varName
!= null){
1477 skuInfo
.setVariableName(varName
);
1478 skuInfo
.setVariableGuid(varGuid
);
1479 skuInfo
.setVariableOffset(varOffset
);
1480 skuInfo
.setHiiDefaultValue(hiiDefault
);
1482 else if (vpdOffset
!= null){
1483 skuInfo
.setVpdOffset(vpdOffset
);
1486 skuInfo
.setValue(value
);
1494 public BuildOptionsDocument
.BuildOptions
getfpdBuildOpts() {
1495 if (fpdBuildOpts
== null) {
1496 fpdBuildOpts
= fpdRoot
.addNewBuildOptions();
1498 return fpdBuildOpts
;
1501 public void genBuildOptionsUserExtensions(String fvName
, String infName
, String outputFileName
, String
[][] includeModules
) {
1502 UserExtensionsDocument
.UserExtensions userExts
= getfpdBuildOpts().addNewUserExtensions();
1503 userExts
.setUserID("IMAGES");
1504 userExts
.setIdentifier(new BigInteger("1"));
1505 XmlCursor cursor
= userExts
.newCursor();
1506 cursor
.toEndToken();
1508 cursor
.beginElement("FvName");
1509 cursor
.insertChars(fvName
);
1510 cursor
.toNextToken();
1512 cursor
.beginElement("InfFileName");
1513 cursor
.insertChars(infName
);
1514 cursor
.toNextToken();
1516 cursor
.beginElement("IncludeModules");
1517 for (int i
= 0; i
< includeModules
.length
; ++i
) {
1518 cursor
.beginElement("Module");
1519 cursor
.insertAttributeWithValue("ModuleGuid", includeModules
[i
][0]);
1520 cursor
.insertAttributeWithValue("BaseName", includeModules
[i
][1]);
1521 cursor
.toEndToken();
1522 cursor
.toNextToken();
1527 public int getUserExtsIncModCount (String fvName
) {
1528 if (getfpdBuildOpts().getUserExtensionsList() == null) {
1531 ListIterator
<UserExtensionsDocument
.UserExtensions
> li
= getfpdBuildOpts().getUserExtensionsList().listIterator();
1532 while (li
.hasNext()) {
1533 UserExtensionsDocument
.UserExtensions ues
= li
.next();
1534 if (!ues
.getUserID().equals("IMAGES")) {
1537 XmlCursor cursor
= ues
.newCursor();
1538 cursor
.toFirstChild();
1539 String elementName
= cursor
.getTextValue();
1540 if (elementName
.equals(fvName
)) {
1541 cursor
.toNextSibling(new QName("", "IncludeModules"));
1542 if (cursor
.toFirstChild()) {
1544 for (i
= 1; cursor
.toNextSibling(); ++i
);
1556 public void getUserExtsIncMods(String fvName
, String
[][] saa
) {
1557 if (getfpdBuildOpts().getUserExtensionsList() == null) {
1560 ListIterator
<UserExtensionsDocument
.UserExtensions
> li
= getfpdBuildOpts().getUserExtensionsList().listIterator();
1561 while (li
.hasNext()) {
1562 UserExtensionsDocument
.UserExtensions ues
= li
.next();
1563 if (!ues
.getUserID().equals("IMAGES")) {
1566 XmlCursor cursor
= ues
.newCursor();
1567 cursor
.toFirstChild();
1568 String elementName
= cursor
.getTextValue();
1569 if (elementName
.equals(fvName
)) {
1570 cursor
.toNextSibling(new QName("", "IncludeModules"));
1571 if (cursor
.toFirstChild()) {
1574 saa
[i
][0] = cursor
.getAttributeText(new QName("ModuleGuid"));
1575 saa
[i
][1] = cursor
.getAttributeText(new QName("BaseName"));
1577 }while (cursor
.toNextSibling());
1587 public void genBuildOptionsUserDefAntTask (String id
, String fileName
, String execOrder
) {
1588 UserDefinedAntTasksDocument
.UserDefinedAntTasks udats
= getfpdBuildOpts().getUserDefinedAntTasks();
1589 if (udats
== null) {
1590 udats
= getfpdBuildOpts().addNewUserDefinedAntTasks();
1593 AntTaskDocument
.AntTask at
= udats
.addNewAntTask();
1594 setBuildOptionsUserDefAntTask(id
, fileName
, execOrder
, at
);
1597 private void setBuildOptionsUserDefAntTask(String id
, String fileName
, String execOrder
, AntTaskDocument
.AntTask at
) {
1598 at
.setId(new Integer(id
));
1599 XmlCursor cursor
= at
.newCursor();
1600 if (fileName
!= null){
1601 at
.setFilename(fileName
);
1603 else if (cursor
.toChild(xmlNs
, "Filename")) {
1606 if (execOrder
!= null) {
1607 at
.setAntCmdOptions(execOrder
);
1609 else if (cursor
.toChild(xmlNs
, "AntCmdOptions")) {
1615 public void removeBuildOptionsUserDefAntTask(int i
) {
1616 XmlObject o
= getfpdBuildOpts().getUserDefinedAntTasks();
1620 XmlCursor cursor
= o
.newCursor();
1621 if (cursor
.toFirstChild()) {
1622 for (int j
= 0; j
< i
; ++j
) {
1623 cursor
.toNextSibling();
1626 if (getBuildOptionsUserDefAntTaskCount() == 0) {
1634 public void updateBuildOptionsUserDefAntTask(int i
, String id
, String fileName
, String execOrder
){
1635 XmlObject o
= getfpdBuildOpts().getUserDefinedAntTasks();
1639 XmlCursor cursor
= o
.newCursor();
1640 if (cursor
.toFirstChild()) {
1641 for (int j
= 0; j
< i
; ++j
) {
1642 cursor
.toNextSibling();
1644 AntTaskDocument
.AntTask at
= (AntTaskDocument
.AntTask
)cursor
.getObject();
1645 setBuildOptionsUserDefAntTask(id
, fileName
, execOrder
, at
);
1650 public int getBuildOptionsUserDefAntTaskCount() {
1651 UserDefinedAntTasksDocument
.UserDefinedAntTasks udats
= getfpdBuildOpts().getUserDefinedAntTasks();
1652 if (udats
== null || udats
.getAntTaskList() == null) {
1656 return udats
.getAntTaskList().size();
1659 public void getBuildOptionsUserDefAntTasks(String
[][] saa
) {
1660 UserDefinedAntTasksDocument
.UserDefinedAntTasks udats
= getfpdBuildOpts().getUserDefinedAntTasks();
1661 if (udats
== null || udats
.getAntTaskList() == null) {
1665 List
<AntTaskDocument
.AntTask
> l
= udats
.getAntTaskList();
1666 ListIterator li
= l
.listIterator();
1668 while (li
.hasNext()) {
1669 AntTaskDocument
.AntTask at
= (AntTaskDocument
.AntTask
)li
.next();
1670 saa
[i
][0] = at
.getId() + "";
1671 saa
[i
][1] = saa
[i
][2] = "";
1672 if (at
.getFilename() != null){
1673 saa
[i
][1] = at
.getFilename();
1675 if (at
.getAntCmdOptions() != null) {
1676 saa
[i
][2] = at
.getAntCmdOptions();
1681 public void genBuildOptionsOpt(Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
) {
1682 OptionsDocument
.Options opts
= getfpdBuildOpts().getOptions();
1684 opts
= getfpdBuildOpts().addNewOptions();
1686 OptionDocument
.Option opt
= opts
.addNewOption();
1687 setBuildOptionsOpt(buildTargets
, toolChain
, tagName
, toolCmd
, archList
, contents
, opt
);
1690 private void setBuildOptionsOpt(Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
, OptionDocument
.Option opt
){
1691 opt
.setStringValue(contents
);
1693 opt
.setBuildTargets(buildTargets
);
1694 opt
.setToolChainFamily(toolChain
);
1695 opt
.setTagName(tagName
);
1696 opt
.setToolCode(toolCmd
);
1698 if (archList
!= null) {
1699 opt
.setSupArchList(archList
);
1702 if (opt
.isSetSupArchList()) {
1703 opt
.unsetSupArchList();
1708 public void removeBuildOptionsOpt(int i
){
1710 XmlObject o
= getfpdBuildOpts().getOptions();
1715 XmlCursor cursor
= o
.newCursor();
1716 if (cursor
.toFirstChild()) {
1717 for (int j
= 0; j
< i
; ++j
) {
1718 cursor
.toNextSibling();
1721 if (getBuildOptionsOptCount() == 0) {
1729 public void updateBuildOptionsOpt(int i
, Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
) {
1730 XmlObject o
= getfpdBuildOpts().getOptions();
1735 XmlCursor cursor
= o
.newCursor();
1736 if (cursor
.toFirstChild()) {
1737 for (int j
= 0; j
< i
; ++j
) {
1738 cursor
.toNextSibling();
1740 OptionDocument
.Option opt
= (OptionDocument
.Option
)cursor
.getObject();
1741 setBuildOptionsOpt(buildTargets
, toolChain
, tagName
, toolCmd
, archList
, contents
, opt
);
1746 public int getBuildOptionsOptCount(){
1747 if (getfpdBuildOpts().getOptions() == null || getfpdBuildOpts().getOptions().getOptionList() == null) {
1750 return getfpdBuildOpts().getOptions().getOptionList().size();
1753 public void getBuildOptionsOpts(String
[][] saa
) {
1754 if (getfpdBuildOpts().getOptions() == null || getfpdBuildOpts().getOptions().getOptionList() == null) {
1758 List
<OptionDocument
.Option
> lOpt
= getfpdBuildOpts().getOptions().getOptionList();
1759 ListIterator li
= lOpt
.listIterator();
1761 while(li
.hasNext()) {
1762 OptionDocument
.Option opt
= (OptionDocument
.Option
)li
.next();
1763 if (opt
.getBuildTargets() != null) {
1764 saa
[i
][0] = listToString(opt
.getBuildTargets());
1766 saa
[i
][1] = opt
.getToolChainFamily();
1767 if (opt
.getSupArchList() != null){
1768 saa
[i
][2] = listToString(opt
.getSupArchList());
1771 saa
[i
][3] = opt
.getToolCode();
1772 saa
[i
][4] = opt
.getTagName();
1773 saa
[i
][5] = opt
.getStringValue();
1779 public void genBuildOptionsFfs(String ffsKey
, String type
) {
1780 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getfpdBuildOpts().addNewFfs();
1781 ffs
.setFfsKey(ffsKey
);
1783 ffs
.addNewSections().setEncapsulationType(type
);
1787 public void updateBuildOptionsFfsSectionsType(int i
, String type
) {
1788 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getfpdBuildOpts().addNewFfs();
1790 ffs
.addNewSections().setEncapsulationType(type
);
1794 public void genBuildOptionsFfsAttribute(int i
, String name
, String value
) {
1795 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1796 BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute attrib
= ffs
.addNewAttribute();
1797 attrib
.setName(name
);
1798 attrib
.setValue(value
);
1801 /**update jth attribute of ith ffs.
1805 public void updateBuildOptionsFfsAttribute(int i
, int j
, String name
, String value
){
1806 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1807 XmlCursor cursor
= ffs
.newCursor();
1808 QName qAttrib
= new QName(xmlNs
, "Attribute");
1809 if (cursor
.toChild(qAttrib
)) {
1810 for (int k
= 0; k
< j
; ++k
) {
1811 cursor
.toNextSibling(qAttrib
);
1813 BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute attrib
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute
)cursor
.getObject();
1814 attrib
.setName(name
);
1815 attrib
.setValue(value
);
1820 public void removeBuildOptionsFfsAttribute(int i
, int j
){
1821 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1822 XmlCursor cursor
= ffs
.newCursor();
1823 QName qAttrib
= new QName(xmlNs
, "Attribute");
1824 if (cursor
.toChild(qAttrib
)) {
1825 for (int k
= 0; k
< j
; ++k
) {
1826 cursor
.toNextSibling(qAttrib
);
1833 public void genBuildOptionsFfsSectionsSection(int i
, String sectionType
) {
1834 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1838 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1840 if (sections
== null){
1841 sections
= ffs
.addNewSections();
1843 sections
.addNewSection().setSectionType(EfiSectionType
.Enum
.forString(sectionType
));
1846 public void removeBuildOptionsFfsSectionsSection(int i
, int j
) {
1847 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1848 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1849 if (sections
== null) {
1852 XmlCursor cursor
= sections
.newCursor();
1853 QName qSection
= new QName(xmlNs
, "Section");
1854 if (cursor
.toChild(qSection
)) {
1855 for (int k
= 0; k
< j
; ++k
) {
1856 cursor
.toNextSibling(qSection
);
1863 public void updateBuildOptionsFfsSectionsSection(int i
, int j
, String type
){
1864 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1865 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1866 if (sections
== null) {
1869 XmlCursor cursor
= sections
.newCursor();
1870 QName qSection
= new QName(xmlNs
, "Section");
1871 if (cursor
.toChild(qSection
)) {
1872 for (int k
= 0; k
< j
; ++k
) {
1873 cursor
.toNextSibling(qSection
);
1875 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Section section
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Section
)cursor
.getObject();
1876 section
.setSectionType(EfiSectionType
.Enum
.forString(type
));
1881 public void genBuildOptionsFfsSectionsSections(int i
, String encapType
) {
1882 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1886 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1888 if (sections
== null){
1889 sections
= ffs
.addNewSections();
1891 sections
.addNewSections().setEncapsulationType(encapType
);
1894 public void removeBuildOptionsFfsSectionsSections(int i
, int j
) {
1895 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1896 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1897 if (sections
== null) {
1900 XmlCursor cursor
= sections
.newCursor();
1901 QName qSections
= new QName(xmlNs
, "Sections");
1902 if (cursor
.toChild(qSections
)) {
1903 for (int k
= 0; k
< j
; ++k
) {
1904 cursor
.toNextSibling(qSections
);
1911 public void updateBuildOptionsFfsSectionsSections(int i
, int j
, String type
) {
1912 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1913 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1914 if (sections
== null) {
1917 XmlCursor cursor
= sections
.newCursor();
1918 QName qSections
= new QName(xmlNs
, "Sections");
1919 if (cursor
.toChild(qSections
)) {
1920 for (int k
= 0; k
< j
; ++k
) {
1921 cursor
.toNextSibling(qSections
);
1923 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2 sections2
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
)cursor
.getObject();
1924 sections2
.setEncapsulationType(type
);
1929 public void genBuildOptionsFfsSectionsSectionsSection(int i
, int j
, String type
) {
1930 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1934 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1935 XmlCursor cursor
= sections
.newCursor();
1936 QName qSections
= new QName(xmlNs
, "Sections");
1937 if (cursor
.toChild(qSections
)){
1938 for (int k
= 0; k
< j
; ++k
) {
1939 cursor
.toNextSibling(qSections
);
1941 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2 sections2
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
)cursor
.getObject();
1942 sections2
.addNewSection().setSectionType(EfiSectionType
.Enum
.forString(type
));
1947 public void removeBuildOptionsFfsSectionsSectionsSection(int i
, int j
, int k
) {
1948 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1949 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1950 if (sections
== null) {
1953 XmlCursor cursor
= sections
.newCursor();
1954 QName qSections
= new QName(xmlNs
, "Sections");
1955 if (cursor
.toChild(qSections
)) {
1956 for (int l
= 0; l
< j
; ++l
) {
1957 cursor
.toNextSibling(qSections
);
1959 if (cursor
.toFirstChild()) {
1961 for (; m
< k
; ++m
) {
1962 cursor
.toNextSibling();
1974 public void updateBuildOptionsFfsSectionsSectionsSection(int i
, int j
, int k
, String type
) {
1975 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1976 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1977 if (sections
== null) {
1980 XmlCursor cursor
= sections
.newCursor();
1981 QName qSections
= new QName(xmlNs
, "Sections");
1982 if (cursor
.toChild(qSections
)) {
1983 for (int l
= 0; l
< j
; ++l
) {
1984 cursor
.toNextSibling(qSections
);
1986 if (cursor
.toFirstChild()) {
1987 for (int m
= 0; m
< k
; ++m
) {
1988 cursor
.toNextSibling();
1990 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section section
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section
)cursor
.getObject();
1991 section
.setSectionType(EfiSectionType
.Enum
.forString(type
));
1997 public void getBuildOptionsFfsSectionsSectionsSection(int i
, int j
, ArrayList
<String
> al
) {
1998 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2002 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2003 XmlCursor cursor
= sections
.newCursor();
2004 QName qSections
= new QName(xmlNs
, "Sections");
2005 if (cursor
.toChild(qSections
)){
2006 for (int k
= 0; k
< j
; ++k
) {
2007 cursor
.toNextSibling(qSections
);
2009 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2 sections2
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
)cursor
.getObject();
2010 if (sections2
.getSectionList() == null){
2014 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section
> li
= sections2
.getSectionList().listIterator();
2015 while(li
.hasNext()) {
2016 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section section
= li
.next();
2017 if (section
.isSetSectionType()) {
2018 al
.add(section
.getSectionType().toString());
2027 public int getBuildOptionsFfsCount(){
2028 if (getfpdBuildOpts().getFfsList() == null) {
2031 return getfpdBuildOpts().getFfsList().size();
2034 public void getBuildOptionsFfsKey(String
[][] saa
) {
2035 if (getfpdBuildOpts().getFfsList() == null) {
2038 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
> li
= getfpdBuildOpts().getFfsList().listIterator();
2040 while(li
.hasNext()){
2041 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= li
.next();
2042 saa
[i
][0] = ffs
.getFfsKey();
2047 public void updateBuildOptionsFfsKey(int i
, String key
) {
2048 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2052 /**Get ith FFS key and contents.
2055 public void getBuildOptionsFfs(int i
, String
[] sa
, LinkedHashMap
<String
, String
> ffsAttribMap
, ArrayList
<String
> firstLevelSections
, ArrayList
<String
> firstLevelSection
) {
2056 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2060 sa
[0] = ffs
.getFfsKey();
2061 if (ffs
.getSections() != null) {
2062 if(ffs
.getSections().getEncapsulationType() != null){
2063 sa
[1] = ffs
.getSections().getEncapsulationType();
2065 if (ffs
.getSections().getSectionList() != null){
2066 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Section
> li
= ffs
.getSections().getSectionList().listIterator();
2067 while (li
.hasNext()) {
2068 firstLevelSection
.add(li
.next().getSectionType().toString());
2071 if (ffs
.getSections().getSectionsList() != null) {
2072 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
> li
= ffs
.getSections().getSectionsList().listIterator();
2073 while(li
.hasNext()) {
2074 firstLevelSections
.add(li
.next().getEncapsulationType());
2078 if (ffs
.getAttributeList() != null) {
2079 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute
> li
= ffs
.getAttributeList().listIterator();
2080 while(li
.hasNext()) {
2081 BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute attrib
= li
.next();
2082 ffsAttribMap
.put(attrib
.getName(), attrib
.getValue());
2091 private BuildOptionsDocument
.BuildOptions
.Ffs
getFfs(int i
) {
2092 XmlObject o
= getfpdBuildOpts();
2093 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= null;
2095 XmlCursor cursor
= o
.newCursor();
2096 QName qFfs
= new QName(xmlNs
, "Ffs");
2097 if (cursor
.toChild(qFfs
)) {
2098 for (int j
= 0; j
< i
; ++j
) {
2099 cursor
.toNextSibling(qFfs
);
2101 ffs
= (BuildOptionsDocument
.BuildOptions
.Ffs
)cursor
.getObject();
2107 public void removeBuildOptionsFfs(int i
) {
2108 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2113 XmlCursor cursor
= ffs
.newCursor();
2120 public PlatformDefinitionsDocument
.PlatformDefinitions
getfpdPlatformDefs(){
2121 if (fpdPlatformDefs
== null){
2122 fpdPlatformDefs
= fpdRoot
.addNewPlatformDefinitions();
2124 return fpdPlatformDefs
;
2127 public void getPlatformDefsSupportedArchs(Vector
<Object
> archs
){
2128 if (getfpdPlatformDefs().getSupportedArchitectures() == null) {
2131 ListIterator li
= getfpdPlatformDefs().getSupportedArchitectures().listIterator();
2132 while(li
.hasNext()) {
2133 archs
.add(li
.next());
2137 public void setPlatformDefsSupportedArchs(Vector
<Object
> archs
) {
2138 if (archs
!= null) {
2139 getfpdPlatformDefs().setSupportedArchitectures(archs
);
2142 // XmlCursor cursor = getfpdPlatformDefs().newCursor();
2143 // if (cursor.toChild(xmlNs, "SupportedArchitectures")) {
2144 // cursor.removeXml();
2146 // cursor.dispose();
2150 public void getPlatformDefsBuildTargets(Vector
<Object
> targets
) {
2151 if (getfpdPlatformDefs().getBuildTargets() == null) {
2154 ListIterator li
= getfpdPlatformDefs().getBuildTargets().listIterator();
2155 while(li
.hasNext()) {
2156 targets
.add(li
.next());
2160 public void setPlatformDefsBuildTargets(Vector
<Object
> targets
) {
2161 getfpdPlatformDefs().setBuildTargets(targets
);
2164 public void genPlatformDefsSkuInfo(String id
, String name
) {
2165 SkuInfoDocument
.SkuInfo skuInfo
= null;
2166 if (getfpdPlatformDefs().getSkuInfo() == null) {
2167 skuInfo
= getfpdPlatformDefs().addNewSkuInfo();
2169 skuInfo
= getfpdPlatformDefs().getSkuInfo();
2170 if (skuInfo
.getUiSkuNameList() == null || skuInfo
.getUiSkuNameList().size() == 0) {
2171 SkuInfoDocument
.SkuInfo
.UiSkuName skuName
= skuInfo
.addNewUiSkuName();
2172 skuName
.setSkuID(new BigInteger("0"));
2173 skuName
.setStringValue("DEFAULT");
2175 if (id
.equals("0")) {
2178 SkuInfoDocument
.SkuInfo
.UiSkuName skuName
= skuInfo
.addNewUiSkuName();
2179 skuName
.setSkuID(new BigInteger(id
));
2180 skuName
.setStringValue(name
);
2183 public int getPlatformDefsSkuInfoCount(){
2184 if (getfpdPlatformDefs().getSkuInfo() == null || getfpdPlatformDefs().getSkuInfo().getUiSkuNameList() == null) {
2187 return getfpdPlatformDefs().getSkuInfo().getUiSkuNameList().size();
2190 public void getPlatformDefsSkuInfos(String
[][] saa
){
2191 if (getfpdPlatformDefs().getSkuInfo() == null || getfpdPlatformDefs().getSkuInfo().getUiSkuNameList() == null) {
2192 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null) {
2193 removeElement(getfpdDynPcdBuildDefs());
2194 fpdDynPcdBuildDefs
= null;
2199 List
<SkuInfoDocument
.SkuInfo
.UiSkuName
> l
= getfpdPlatformDefs().getSkuInfo().getUiSkuNameList();
2200 ListIterator
<SkuInfoDocument
.SkuInfo
.UiSkuName
> li
= l
.listIterator();
2202 while(li
.hasNext()) {
2203 SkuInfoDocument
.SkuInfo
.UiSkuName sku
= li
.next();
2204 saa
[i
][0] = sku
.getSkuID()+"";
2205 saa
[i
][1] = sku
.getStringValue();
2210 public void removePlatformDefsSkuInfo(int i
) {
2211 SkuInfoDocument
.SkuInfo skuInfo
= getfpdPlatformDefs().getSkuInfo();
2212 if (skuInfo
== null || i
== 0) {
2216 XmlCursor cursor
= skuInfo
.newCursor();
2217 if (cursor
.toFirstChild()) {
2218 for (int j
= 0; j
< i
; ++j
) {
2219 cursor
.toNextSibling();
2226 public void updatePlatformDefsSkuInfo(int i
, String id
, String name
) {
2227 SkuInfoDocument
.SkuInfo skuInfo
= getfpdPlatformDefs().getSkuInfo();
2228 if (skuInfo
== null || i
== 0) {
2232 XmlCursor cursor
= skuInfo
.newCursor();
2233 if (cursor
.toFirstChild()) {
2234 for (int j
= 0; j
< i
; ++j
) {
2235 cursor
.toNextSibling();
2237 SkuInfoDocument
.SkuInfo
.UiSkuName sku
= (SkuInfoDocument
.SkuInfo
.UiSkuName
)cursor
.getObject();
2238 sku
.setSkuID(new BigInteger(id
));
2239 sku
.setStringValue(name
);
2244 public String
getPlatformDefsInterDir(){
2245 if (getfpdPlatformDefs().getIntermediateDirectories() == null) {
2248 return getfpdPlatformDefs().getIntermediateDirectories().toString();
2251 public void setPlatformDefsInterDir(String interDir
){
2252 getfpdPlatformDefs().setIntermediateDirectories(IntermediateOutputType
.Enum
.forString(interDir
));
2255 public String
getPlatformDefsOutputDir() {
2256 return getfpdPlatformDefs().getOutputDirectory();
2259 public void setPlatformDefsOutputDir(String outputDir
) {
2260 if (outputDir
!= null && outputDir
.length() > 0) {
2261 getfpdPlatformDefs().setOutputDirectory(outputDir
);
2264 XmlCursor cursor
= getfpdPlatformDefs().newCursor();
2265 if (cursor
.toChild(new QName(xmlNs
, "OutputDirectory"))) {
2272 public FlashDocument
.Flash
getfpdFlash() {
2273 if (fpdFlash
== null) {
2274 fpdFlash
= fpdRoot
.addNewFlash();
2279 public void genFlashDefinitionFile(String file
) {
2280 FlashDefinitionFileDocument
.FlashDefinitionFile fdf
= getfpdFlash().getFlashDefinitionFile();
2282 fdf
= getfpdFlash().addNewFlashDefinitionFile();
2285 fdf
.setStringValue(file
);
2288 public String
getFlashDefinitionFile() {
2289 FlashDefinitionFileDocument
.FlashDefinitionFile fdf
= getfpdFlash().getFlashDefinitionFile();
2294 return fdf
.getStringValue();
2297 public void genFvImagesNameValue(String name
, String value
) {
2299 FvImagesDocument
.FvImages fi
= getfpdFlash().getFvImages();
2301 fi
= getfpdFlash().addNewFvImages();
2304 FvImagesDocument
.FvImages
.NameValue nv
= fi
.addNewNameValue();
2309 public void removeFvImagesNameValue(int i
){
2311 XmlObject o
= getfpdFlash().getFvImages();
2316 QName qNameValue
= new QName(xmlNs
, "NameValue");
2317 XmlCursor cursor
= o
.newCursor();
2318 if (cursor
.toChild(qNameValue
)) {
2319 for (int j
= 0; j
< i
; ++j
) {
2320 cursor
.toNextSibling(qNameValue
);
2327 public void updateFvImagesNameValue(int i
, String name
, String value
){
2329 XmlObject o
= getfpdFlash().getFvImages();
2334 QName qNameValue
= new QName(xmlNs
, "NameValue");
2335 XmlCursor cursor
= o
.newCursor();
2336 if (cursor
.toChild(qNameValue
)) {
2337 for (int j
= 0; j
< i
; ++j
) {
2338 cursor
.toNextSibling(qNameValue
);
2340 FvImagesDocument
.FvImages
.NameValue nv
= (FvImagesDocument
.FvImages
.NameValue
)cursor
.getObject();
2347 public int getFvImagesNameValueCount() {
2349 FvImagesDocument
.FvImages fi
= null;
2350 if ((fi
= getfpdFlash().getFvImages()) == null || fi
.getNameValueList() == null) {
2353 return fi
.getNameValueList().size();
2356 public void getFvImagesNameValues(String
[][] nv
) {
2358 FvImagesDocument
.FvImages fi
= getfpdFlash().getFvImages();
2362 List
<FvImagesDocument
.FvImages
.NameValue
> l
= fi
.getNameValueList();
2364 ListIterator li
= l
.listIterator();
2365 while (li
.hasNext()) {
2366 FvImagesDocument
.FvImages
.NameValue e
= (FvImagesDocument
.FvImages
.NameValue
) li
2368 nv
[i
][0] = e
.getName();
2369 nv
[i
][1] = e
.getValue();
2375 public void genFvImagesFvImage(String
[] names
, String types
, Map
<String
, String
> options
) {
2377 FvImagesDocument
.FvImages fis
= null;
2378 if ((fis
= getfpdFlash().getFvImages()) == null) {
2379 fis
= getfpdFlash().addNewFvImages();
2383 //gen FvImage with FvImageNames array
2385 FvImagesDocument
.FvImages
.FvImage fi
= fis
.addNewFvImage();
2386 for (int i
= 0; i
< names
.length
; ++i
) {
2387 fi
.addFvImageNames(names
[i
]);
2389 fi
.setType(FvImageTypes
.Enum
.forString(types
));
2390 if (options
!= null){
2391 setFvImagesFvImageFvImageOptions(options
, fi
);
2395 private void setFvImagesFvImageFvImageOptions(Map
<String
, String
> options
, FvImagesDocument
.FvImages
.FvImage fi
){
2396 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions fio
= fi
.getFvImageOptions();
2398 fio
= fi
.addNewFvImageOptions();
2401 Set
<String
> key
= options
.keySet();
2402 Iterator
<String
> i
= key
.iterator();
2403 while (i
.hasNext()) {
2405 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nv
= fio
.addNewNameValue();
2406 String k
= (String
)i
.next();
2409 nv
.setValue((String
)options
.get(k
));
2416 public void removeFvImagesFvImage(int i
) {
2418 XmlObject o
= getfpdFlash().getFvImages();
2423 QName qFvImage
= new QName(xmlNs
, "FvImage");
2424 XmlCursor cursor
= o
.newCursor();
2425 if (cursor
.toChild(qFvImage
)) {
2426 for (int j
= 0; j
< i
; ++j
) {
2427 cursor
.toNextSibling(qFvImage
);
2434 public void updateFvImagesFvImage(int i
, String
[] names
, String types
, Map
<String
, String
> options
){
2436 XmlObject o
= getfpdFlash().getFvImages();
2440 XmlCursor cursor
= o
.newCursor();
2441 QName qFvImage
= new QName(xmlNs
, "FvImage");
2442 if (cursor
.toChild(qFvImage
)) {
2443 for (int j
= 0; j
< i
; ++j
) {
2444 cursor
.toNextSibling(qFvImage
);
2446 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
2447 fi
.setType(FvImageTypes
.Enum
.forString(types
));
2450 // remove old FvImageNames before adding new ones
2452 QName qFvImageNames
= new QName(xmlNs
, "FvImageNames");
2453 cursor
.toChild(qFvImageNames
);
2455 while (cursor
.toNextSibling(qFvImageNames
)) {
2459 for (int k
= 0; k
< names
.length
; ++k
) {
2460 fi
.addFvImageNames(names
[k
]);
2463 // remove old FvImageOptions before adding new options
2465 QName qFvImageOptions
= new QName(xmlNs
, "FvImageOptions");
2466 cursor
.toNextSibling(qFvImageOptions
);
2469 setFvImagesFvImageFvImageOptions(options
, fi
);
2474 public int getFvImagesFvImageCount() {
2476 if (getfpdFlash().getFvImages() == null || getfpdFlash().getFvImages().getFvImageList() == null) {
2479 return getfpdFlash().getFvImages().getFvImageList().size();
2482 /**Only Get Fv image setting - name and type.
2485 public void getFvImagesFvImages(String
[][] saa
) {
2487 if (getfpdFlash().getFvImages() == null) {
2490 List
<FvImagesDocument
.FvImages
.FvImage
> l
= getfpdFlash().getFvImages().getFvImageList();
2494 ListIterator li
= l
.listIterator();
2496 while(li
.hasNext()) {
2497 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)li
.next();
2499 // get FvImageNames array, space separated
2501 List
<String
> lfn
= fi
.getFvImageNamesList();
2502 ListIterator lfni
= lfn
.listIterator();
2504 while (lfni
.hasNext()) {
2505 saa
[i
][0] += (String
)lfni
.next();
2508 saa
[i
][0] = saa
[i
][0].trim();
2510 saa
[i
][1] = fi
.getType()+"";
2516 /**Get FvImage Options for FvImage i
2517 * @param i the ith FvImage
2519 public void getFvImagesFvImageOptions(int i
, Map
<String
, String
> m
) {
2520 XmlObject o
= getfpdFlash().getFvImages();
2524 XmlCursor cursor
= o
.newCursor();
2525 QName qFvImage
= new QName(xmlNs
, "FvImage");
2526 if (cursor
.toChild(qFvImage
)) {
2527 for (int j
= 0; j
< i
; ++j
) {
2528 cursor
.toNextSibling(qFvImage
);
2530 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
2531 if (fi
.getFvImageOptions() == null || fi
.getFvImageOptions().getNameValueList() == null){
2534 ListIterator
<FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
> li
= fi
.getFvImageOptions().getNameValueList().listIterator();
2535 while(li
.hasNext()){
2536 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nv
= li
.next();
2537 m
.put(nv
.getName(), nv
.getValue());
2543 Get platform header element
2544 @return PlatformHeaderDocument.PlatformHeader
2546 public PlatformHeaderDocument
.PlatformHeader
getFpdHdr() {
2547 if (fpdHdr
== null) {
2548 fpdHdr
= fpdRoot
.addNewPlatformHeader();
2554 public String
getFpdHdrPlatformName() {
2555 return getFpdHdr().getPlatformName();
2558 public String
getFpdHdrGuidValue() {
2559 return getFpdHdr().getGuidValue();
2562 public String
getFpdHdrVer() {
2563 return getFpdHdr().getVersion();
2566 public String
getFpdHdrAbs() {
2567 return getFpdHdr().getAbstract();
2570 public String
getFpdHdrDescription() {
2571 return getFpdHdr().getDescription();
2574 public String
getFpdHdrCopyright() {
2575 return getFpdHdr().getCopyright();
2578 public String
getFpdHdrLicense() {
2579 LicenseDocument
.License l
= getFpdHdr().getLicense();
2583 return l
.getStringValue();
2586 public String
getFpdHdrUrl() {
2587 LicenseDocument
.License l
= getFpdHdr().getLicense();
2594 public String
getFpdHdrSpec() {
2596 return "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052";
2597 // return getFpdHdr().getSpecification();
2600 public void setFpdHdrPlatformName(String name
){
2601 getFpdHdr().setPlatformName(name
);
2604 public void setFpdHdrGuidValue(String guid
){
2605 getFpdHdr().setGuidValue(guid
);
2608 public void setFpdHdrVer(String v
){
2609 getFpdHdr().setVersion(v
);
2612 public void setFpdHdrAbs(String abs
) {
2613 getFpdHdr().setAbstract(abs
);
2616 public void setFpdHdrDescription(String desc
){
2617 getFpdHdr().setDescription(desc
);
2620 public void setFpdHdrCopyright(String cr
) {
2621 getFpdHdr().setCopyright(cr
);
2624 public void setFpdHdrLicense(String license
){
2625 LicenseDocument
.License l
= getFpdHdr().getLicense();
2627 getFpdHdr().addNewLicense().setStringValue(license
);
2630 l
.setStringValue(license
);
2634 public void setFpdHdrUrl(String url
){
2635 LicenseDocument
.License l
= getFpdHdr().getLicense();
2641 public void setFpdHdrSpec(String s
){
2642 s
= "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052";
2643 getFpdHdr().setSpecification(s
);
2646 Save the processed xml contents to file
2648 @param fpdFile The file to save xml contents
2649 @throws IOException Exceptions during file operation
2651 public void saveAs(File fpdFile
) throws IOException
{
2653 XmlOptions options
= new XmlOptions();
2655 options
.setCharacterEncoding("UTF-8");
2656 options
.setSavePrettyPrint();
2657 options
.setSavePrettyPrintIndent(2);
2659 fpdd
.save(fpdFile
, options
);
2660 } catch (IOException e
) {
2661 e
.printStackTrace();
2666 private String
listToString(List l
) {
2671 ListIterator li
= l
.listIterator();
2672 while(li
.hasNext()) {
2679 private void removeElement(XmlObject o
) {
2680 XmlCursor cursor
= o
.newCursor();
2686 class PcdItemTypeConflictException
extends Exception
{
2691 private static final long serialVersionUID
= 1L;
2692 private String details
= null;
2694 PcdItemTypeConflictException(String pcdName
, String info
){
2695 ModuleIdentification mi
= WorkspaceProfile
.getModuleId(info
);
2696 details
= pcdName
+ " ItemType Conflicts with " + mi
.getName() + " in Pkg " + mi
.getPackage().getName();
2699 public String
getMessage() {
2704 class PcdDeclNotFound
extends Exception
{
2709 private static final long serialVersionUID
= 1L;
2710 private String details
= null;
2712 PcdDeclNotFound(String info
) {
2713 details
= "PcdDeclNotFound: " + info
;
2716 public String
getMessage() {
2721 class PcdValueMalFormed
extends Exception
{
2726 private static final long serialVersionUID
= 1L;
2727 private String details
= null;
2729 PcdValueMalFormed(String info
) {
2730 details
= "PcdValueMalFormed: " + info
;
2733 public String
getMessage() {