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
.frameworkwizard
.platform
.ui
.global
.GlobalData
;
61 import org
.tianocore
.frameworkwizard
.platform
.ui
.global
.SurfaceAreaQuery
;
62 import org
.tianocore
.frameworkwizard
.platform
.ui
.id
.ModuleIdentification
;
63 import org
.tianocore
.frameworkwizard
.platform
.ui
.id
.PackageIdentification
;
66 This class processes fpd file contents such as add remove xml elements.
67 @since PackageEditor 1.0
69 public class FpdFileContents
{
71 static final String xmlNs
= "http://www.TianoCore.org/2006/Edk2.0";
73 private PlatformSurfaceAreaDocument fpdd
= null;
75 private PlatformSurfaceAreaDocument
.PlatformSurfaceArea fpdRoot
= null;
77 private PlatformHeaderDocument
.PlatformHeader fpdHdr
= null;
79 private PlatformDefinitionsDocument
.PlatformDefinitions fpdPlatformDefs
= null;
81 private FlashDocument
.Flash fpdFlash
= null;
83 private BuildOptionsDocument
.BuildOptions fpdBuildOpts
= null;
85 private FrameworkModulesDocument
.FrameworkModules fpdFrameworkModules
= null;
87 private DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions fpdDynPcdBuildDefs
= null;
89 private HashMap
<String
, ArrayList
<String
>> dynPcdMap
= null;
92 * look through all pcd data in all ModuleSA, create pcd -> ModuleSA mappings.
94 public void initDynPcdMap() {
95 if (dynPcdMap
== null) {
96 dynPcdMap
= new HashMap
<String
, ArrayList
<String
>>();
97 List
<ModuleSADocument
.ModuleSA
> l
= getfpdFrameworkModules().getModuleSAList();
99 removeElement(getfpdFrameworkModules());
100 fpdFrameworkModules
= null;
103 ListIterator
<ModuleSADocument
.ModuleSA
> li
= l
.listIterator();
104 while (li
.hasNext()) {
105 ModuleSADocument
.ModuleSA moduleSa
= li
.next();
106 if (moduleSa
.getPcdBuildDefinition() == null || moduleSa
.getPcdBuildDefinition().getPcdDataList() == null) {
109 String ModuleInfo
= moduleSa
.getModuleGuid() + " " + moduleSa
.getModuleVersion() +
110 " " + moduleSa
.getPackageGuid() + " " + moduleSa
.getPackageVersion() + " " + listToString(moduleSa
.getSupArchList());
111 List
<PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
> lp
= moduleSa
.getPcdBuildDefinition().getPcdDataList();
112 ListIterator
<PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
> lpi
= lp
.listIterator();
113 while (lpi
.hasNext()) {
114 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= lpi
.next();
115 String pcdKey
= pcdData
.getCName() + " " + pcdData
.getTokenSpaceGuidCName();
116 if (dynPcdMap
.get(pcdKey
) == null) {
117 ArrayList
<String
> al
= new ArrayList
<String
>();
118 al
.add(ModuleInfo
+ " " + pcdData
.getItemType().toString());
119 dynPcdMap
.put(pcdKey
, al
);
122 dynPcdMap
.get(pcdKey
).add(ModuleInfo
+ " " + pcdData
.getItemType().toString());
129 public ArrayList
<String
> getDynPcdMapValue(String key
) {
130 return dynPcdMap
.get(key
);
133 Constructor to create a new spd file
135 public FpdFileContents() {
137 fpdd
= PlatformSurfaceAreaDocument
.Factory
.newInstance();
138 fpdRoot
= fpdd
.addNewPlatformSurfaceArea();
143 Constructor for existing document object
146 public FpdFileContents(PlatformSurfaceAreaDocument
.PlatformSurfaceArea fpd
) {
148 fpdHdr
= fpdRoot
.getPlatformHeader();
149 fpdPlatformDefs
= fpdRoot
.getPlatformDefinitions();
150 fpdBuildOpts
= fpdRoot
.getBuildOptions();
151 fpdFrameworkModules
= fpdRoot
.getFrameworkModules();
152 fpdDynPcdBuildDefs
= fpdRoot
.getDynamicPcdBuildDefinitions();
153 fpdFlash
= fpdRoot
.getFlash();
157 Constructor based on an existing spd file
159 @param f Existing spd file
161 public FpdFileContents(File f
) {
163 fpdd
= PlatformSurfaceAreaDocument
.Factory
.parse(f
);
164 fpdRoot
= fpdd
.getPlatformSurfaceArea();
165 } catch (Exception e
) {
166 System
.out
.println(e
.toString());
170 public DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
getfpdDynPcdBuildDefs() {
171 if (fpdDynPcdBuildDefs
== null){
172 fpdDynPcdBuildDefs
= fpdRoot
.addNewDynamicPcdBuildDefinitions();
174 return fpdDynPcdBuildDefs
;
177 public FrameworkModulesDocument
.FrameworkModules
getfpdFrameworkModules() {
178 if (fpdFrameworkModules
== null){
179 fpdFrameworkModules
= fpdRoot
.addNewFrameworkModules();
181 return fpdFrameworkModules
;
184 public int getFrameworkModulesCount() {
185 if (getfpdFrameworkModules().getModuleSAList() == null || getfpdFrameworkModules().getModuleSAList().size() == 0){
186 removeElement(getfpdFrameworkModules());
187 fpdFrameworkModules
= null;
190 return getfpdFrameworkModules().getModuleSAList().size();
193 public void getFrameworkModulesInfo(String
[][] saa
) {
194 if (getFrameworkModulesCount() == 0){
198 ListIterator li
= getfpdFrameworkModules().getModuleSAList().listIterator();
200 while(li
.hasNext()) {
201 ModuleSADocument
.ModuleSA msa
= (ModuleSADocument
.ModuleSA
)li
.next();
202 saa
[i
][0] = msa
.getModuleGuid();
203 saa
[i
][1] = msa
.getModuleVersion();
205 saa
[i
][2] = msa
.getPackageGuid();
206 saa
[i
][3] = msa
.getPackageVersion();
207 saa
[i
][4] = listToString(msa
.getSupArchList());
212 public void getFrameworkModuleInfo(int i
, String
[] sa
) {
213 ModuleSADocument
.ModuleSA msa
= getModuleSA(i
);
217 sa
[0] = msa
.getModuleGuid();
218 sa
[1] = msa
.getModuleVersion();
219 sa
[2] = msa
.getPackageGuid();
220 sa
[3] = msa
.getPackageVersion();
221 sa
[4] = listToString(msa
.getSupArchList());
224 public ModuleSADocument
.ModuleSA
getModuleSA(String key
) {
225 String
[] s
= key
.split(" ");
226 if (getfpdFrameworkModules().getModuleSAList() == null || getfpdFrameworkModules().getModuleSAList().size() == 0) {
227 removeElement(getfpdFrameworkModules());
228 fpdFrameworkModules
= null;
231 ListIterator li
= getfpdFrameworkModules().getModuleSAList().listIterator();
232 while(li
.hasNext()) {
233 ModuleSADocument
.ModuleSA moduleSa
= (ModuleSADocument
.ModuleSA
)li
.next();
234 if (moduleSa
.getModuleGuid().equalsIgnoreCase(s
[0]) && moduleSa
.getPackageGuid().equalsIgnoreCase(s
[2])) {
235 if (moduleSa
.getModuleVersion() != null) {
236 if (!moduleSa
.getModuleVersion().equals(s
[1])) {
240 if (moduleSa
.getPackageVersion() != null) {
241 if (!moduleSa
.getPackageVersion().equals(s
[3])) {
245 //ToDo add arch check for s[4]
246 if (moduleSa
.getSupArchList() != null) {
247 if (!listToString(moduleSa
.getSupArchList()).equals(s
[4])) {
257 private ModuleSADocument
.ModuleSA
getModuleSA(int i
) {
258 ModuleSADocument
.ModuleSA moduleSa
= null;
259 if (fpdRoot
.getFrameworkModules() == null) {
262 XmlCursor cursor
= fpdRoot
.getFrameworkModules().newCursor();
263 if (cursor
.toFirstChild()) {
264 for (int j
= 0; j
< i
; ++j
) {
265 cursor
.toNextSibling();
267 moduleSa
= (ModuleSADocument
.ModuleSA
)cursor
.getObject();
273 public void removeModuleSA(int i
) {
274 XmlObject o
= fpdRoot
.getFrameworkModules();
279 XmlCursor cursor
= o
.newCursor();
280 if (cursor
.toFirstChild()) {
281 for (int j
= 0; j
< i
; ++j
) {
282 cursor
.toNextSibling();
285 // remove pcd from dynPcdMap, if DynamicPcdBuildData exists, remove them too.
287 ModuleSADocument
.ModuleSA moduleSa
= (ModuleSADocument
.ModuleSA
)cursor
.getObject();
288 String moduleInfo
= moduleSa
.getModuleGuid() + " " + moduleSa
.getModuleVersion() + " " +
289 moduleSa
.getPackageGuid()+ " " + moduleSa
.getPackageVersion() + " " + listToString(moduleSa
.getSupArchList());
290 PcdBuildDefinitionDocument
.PcdBuildDefinition pcdBuildDef
= moduleSa
.getPcdBuildDefinition();
291 if (pcdBuildDef
!= null && pcdBuildDef
.getPcdDataList() != null) {
292 ListIterator
<PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
> li
= pcdBuildDef
.getPcdDataList().listIterator();
293 while(li
.hasNext()) {
294 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= li
.next();
295 maintainDynPcdMap(pcdData
.getCName() + " " + pcdData
.getTokenSpaceGuidCName(), moduleInfo
);
300 cursor
.toPrevToken();
301 if (cursor
.isComment()) {
306 if (getFrameworkModulesCount() == 0) {
314 public boolean adjustPcd (int seqModuleSa
) throws Exception
{
315 boolean dataModified
= false;
316 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(seqModuleSa
);
317 int pcdCount
= getPcdDataCount(seqModuleSa
);
318 String
[][] saaModuleSaPcd
= new String
[pcdCount
][7];
319 getPcdData(seqModuleSa
, saaModuleSaPcd
);
320 String mg
= moduleSa
.getModuleGuid();
321 String mv
= moduleSa
.getModuleVersion();
322 String pg
= moduleSa
.getPackageGuid();
323 String pv
= moduleSa
.getPackageVersion();
324 String arch
= listToString(moduleSa
.getSupArchList());
326 // delete pcd in ModuleSA but not in MSA files any longer.
328 String moduleKey
= mg
+ " " + mv
+ " " + pg
+ " " + pv
+ " " + arch
;
329 int libCount
= getLibraryInstancesCount(moduleKey
);
330 String
[][] saaLib
= new String
[libCount
][5];
331 getLibraryInstances(moduleKey
, saaLib
);
332 ModuleIdentification mi
= GlobalData
.getModuleId(moduleKey
);
333 Vector
<ModuleIdentification
> vMi
= new Vector
<ModuleIdentification
>();
336 nextPcd
:for (int i
= 0; i
< saaModuleSaPcd
.length
; ++i
) {
337 if (GlobalData
.pcdInMsa(saaModuleSaPcd
[i
][0], saaModuleSaPcd
[i
][1], mi
)){
340 for (int j
= 0; j
< saaLib
.length
; ++j
) {
341 String libKey
= saaLib
[j
][1] + " " + saaLib
[j
][2] + " " + saaLib
[j
][3] + " " + saaLib
[j
][4];
342 ModuleIdentification libMi
= GlobalData
.getModuleId(libKey
);
344 if (GlobalData
.pcdInMsa(saaModuleSaPcd
[i
][0], saaModuleSaPcd
[i
][1], libMi
)) {
348 removePcdData(seqModuleSa
, saaModuleSaPcd
[i
][0], saaModuleSaPcd
[i
][1]);
352 catch (Exception e
) {
356 // add new Pcd from MSA file to ModuleSA.
360 for (int i
= 0; i
< vMi
.size(); ++i
) {
361 ModuleSurfaceAreaDocument
.ModuleSurfaceArea msa
= (ModuleSurfaceAreaDocument
.ModuleSurfaceArea
) GlobalData
362 .getModuleXmlObject(vMi
364 if (msa
.getPcdCoded() == null || msa
.getPcdCoded().getPcdEntryList() == null) {
367 ListIterator li
= msa
.getPcdCoded().getPcdEntryList().listIterator();
368 msaPcdIter
:while (li
.hasNext()) {
369 PcdCodedDocument
.PcdCoded
.PcdEntry msaPcd
= (PcdCodedDocument
.PcdCoded
.PcdEntry
) li
.next();
370 ArrayList
<String
> al
= getDynPcdMapValue(msaPcd
.getCName() + " " + msaPcd
.getTokenSpaceGuidCName());
372 for (int j
= 0; j
< al
.size(); ++j
) {
373 if (al
.get(j
).contains(moduleKey
)) {
379 Map
<String
, XmlObject
> m
= new HashMap
<String
, XmlObject
>();
380 m
.put("ModuleSurfaceArea", msa
);
381 SurfaceAreaQuery
.setDoc(m
);
382 PackageIdentification
[] depPkgs
= SurfaceAreaQuery
.getDependencePkg(null);
383 PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry spdPcd
= LookupPcdDeclaration(msaPcd
, depPkgs
);
384 if (spdPcd
== null) {
388 throw new PcdDeclNotFound("No Declaration for PCD Entry " + msaPcd
.getCName() + " in Module "
392 // AddItem to ModuleSA PcdBuildDefinitions
394 String defaultVal
= msaPcd
.getDefaultValue() == null ? spdPcd
.getDefaultValue()
395 : msaPcd
.getDefaultValue();
397 genPcdData(msaPcd
.getCName(), spdPcd
.getToken(), msaPcd
.getTokenSpaceGuidCName(),
398 msaPcd
.getPcdItemType().toString(), spdPcd
.getDatumType() + "", defaultVal
, moduleSa
);
411 private void maintainDynPcdMap(String pcdKey
, String moduleInfo
) {
413 ArrayList
<String
> al
= dynPcdMap
.get(pcdKey
);
417 String
[] s
= moduleInfo
.split(" ");
418 for(int i
= 0; i
< al
.size(); ++i
){
419 String consumer
= al
.get(i
);
420 if (consumer
.contains(s
[0]) && consumer
.contains(s
[2])){
421 String
[] consumerPart
= consumer
.split(" ");
422 if (!consumerPart
[4].equals(s
[4])) {
430 if (al
.size() == 0) {
431 dynPcdMap
.remove(pcdKey
);
432 String
[] s1
= pcdKey
.split(" ");
433 removeDynamicPcdBuildData(s1
[0], s1
[1]);
438 // key for ModuleSA : "ModuleGuid ModuleVer PackageGuid PackageVer Arch"
440 public int getPcdDataCount (int i
){
441 ModuleSADocument
.ModuleSA msa
= getModuleSA(i
);
443 if (msa
== null || msa
.getPcdBuildDefinition() == null || msa
.getPcdBuildDefinition().getPcdDataList() == null){
446 return msa
.getPcdBuildDefinition().getPcdDataList().size();
450 public void getPcdData (int i
, String
[][] saa
) {
451 ModuleSADocument
.ModuleSA msa
= getModuleSA(i
);
453 if (msa
== null || msa
.getPcdBuildDefinition() == null || msa
.getPcdBuildDefinition().getPcdDataList() == null){
456 ListIterator
<PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
>li
= msa
.getPcdBuildDefinition().getPcdDataList().listIterator();
457 for (int k
= 0; k
< saa
.length
; ++k
) {
458 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= li
.next();
459 saa
[k
][0] = pcdData
.getCName();
460 saa
[k
][1] = pcdData
.getTokenSpaceGuidCName();
461 saa
[k
][2] = pcdData
.getItemType()+"";
462 saa
[k
][3] = pcdData
.getToken().toString();
463 saa
[k
][4] = pcdData
.getMaxDatumSize()+"";
464 saa
[k
][5] = pcdData
.getDatumType()+"";
465 saa
[k
][6] = pcdData
.getValue();
470 public void removePcdData (int seqModuleSa
, String cName
, String tsGuid
) {
471 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(seqModuleSa
);
472 if (moduleSa
== null || moduleSa
.getPcdBuildDefinition() == null){
476 String mg
= moduleSa
.getModuleGuid();
477 String mv
= moduleSa
.getModuleVersion();
478 String pg
= moduleSa
.getPackageGuid();
479 String pv
= moduleSa
.getPackageVersion();
480 String arch
= listToString(moduleSa
.getSupArchList());
481 String moduleKey
= mg
+ " " + mv
+ " " + pg
+ " " + pv
+ " " + arch
;
483 XmlCursor cursor
= moduleSa
.getPcdBuildDefinition().newCursor();
484 if (cursor
.toFirstChild()){
487 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= (PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
)cursor
.getObject();
488 if (pcdData
.getCName().equals(cName
) && pcdData
.getTokenSpaceGuidCName().equals(tsGuid
)) {
489 maintainDynPcdMap(cName
+ " " + tsGuid
, moduleKey
);
490 if (getPcdDataCount(seqModuleSa
) == 1) {
497 while(cursor
.toNextSibling());
503 public void updatePcdData (String key
, String cName
, String tsGuid
, String itemType
, String maxSize
, String value
){
504 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(key
);
505 if (moduleSa
== null || moduleSa
.getPcdBuildDefinition() == null){
509 XmlCursor cursor
= moduleSa
.getPcdBuildDefinition().newCursor();
510 if (cursor
.toFirstChild()){
512 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= (PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
)cursor
.getObject();
513 if (pcdData
.getCName().equals(cName
) && pcdData
.getTokenSpaceGuidCName().equals(tsGuid
)) {
514 pcdData
.setItemType(PcdItemTypes
.Enum
.forString(itemType
));
515 if(pcdData
.getDatumType().equals("VOID*")) {
516 pcdData
.setMaxDatumSize(new Integer(maxSize
));
518 pcdData
.setValue(value
);
522 while(cursor
.toNextSibling());
527 /**Get original Pcd info from MSA & SPD files.
528 * @param mi ModuleIdentification from which MSA & SPD come
529 * @param cName PCD cName
530 * @param sa Results: HelpText, Original item type.
533 public boolean getPcdBuildDataInfo(ModuleIdentification mi
, String cName
, String tsGuid
, String
[] sa
) throws Exception
{
536 ModuleSurfaceAreaDocument
.ModuleSurfaceArea msa
= (ModuleSurfaceAreaDocument
.ModuleSurfaceArea
)GlobalData
.getModuleXmlObject(mi
);
537 if (msa
.getPcdCoded() == null) {
541 Map
<String
, XmlObject
> m
= new HashMap
<String
, XmlObject
>();
542 m
.put("ModuleSurfaceArea", msa
);
543 SurfaceAreaQuery
.setDoc(m
);
544 PackageIdentification
[] depPkgs
= SurfaceAreaQuery
.getDependencePkg(null);
546 // First look through MSA pcd entries.
548 List
<PcdCodedDocument
.PcdCoded
.PcdEntry
> l
= msa
.getPcdCoded().getPcdEntryList();
549 ListIterator li
= l
.listIterator();
550 while(li
.hasNext()) {
551 PcdCodedDocument
.PcdCoded
.PcdEntry msaPcd
= (PcdCodedDocument
.PcdCoded
.PcdEntry
)li
.next();
552 if (!msaPcd
.getCName().equals(cName
)) {
555 if (!msaPcd
.getTokenSpaceGuidCName().equals(tsGuid
)) {
558 PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry spdPcd
= LookupPcdDeclaration(msaPcd
, depPkgs
);
559 if (spdPcd
== null) {
563 throw new PcdDeclNotFound(mi
.getName() + " " + msaPcd
.getCName());
566 // Get Pcd help text and original item type.
568 sa
[0] = spdPcd
.getHelpText() + msaPcd
.getHelpText();
569 sa
[1] = msaPcd
.getPcdItemType()+"";
583 /**Remove PCDBuildDefinition entries from ModuleSA
584 * @param moduleKey identifier of ModuleSA.
585 * @param consumer where these entries come from.
587 public void removePcdData(String moduleKey
, ModuleIdentification consumer
) {
589 ModuleSurfaceAreaDocument
.ModuleSurfaceArea msa
= (ModuleSurfaceAreaDocument
.ModuleSurfaceArea
)GlobalData
.getModuleXmlObject(consumer
);
590 if (msa
.getPcdCoded() == null) {
594 List
<PcdCodedDocument
.PcdCoded
.PcdEntry
> l
= msa
.getPcdCoded().getPcdEntryList();
595 ListIterator li
= l
.listIterator();
597 while(li
.hasNext()) {
598 PcdCodedDocument
.PcdCoded
.PcdEntry msaPcd
= (PcdCodedDocument
.PcdCoded
.PcdEntry
)li
.next();
599 ModuleSADocument
.ModuleSA moduleSA
= getModuleSA(moduleKey
);
600 if (moduleSA
.getPcdBuildDefinition() != null) {
601 XmlCursor cursor
= moduleSA
.getPcdBuildDefinition().newCursor();
602 if (cursor
.toFirstChild()) {
603 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= (PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
) cursor
605 if (msaPcd
.getCName().equals(pcdData
.getCName())
606 && msaPcd
.getTokenSpaceGuidCName().equals(pcdData
.getTokenSpaceGuidCName())) {
608 maintainDynPcdMap(pcdData
.getCName() + " " + pcdData
.getTokenSpaceGuidCName(), moduleKey
);
612 while (cursor
.toNextSibling()) {
613 pcdData
= (PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
) cursor
.getObject();
614 if (msaPcd
.getCName().equals(pcdData
.getCName())
615 && msaPcd
.getTokenSpaceGuidCName().equals(pcdData
.getTokenSpaceGuidCName())) {
616 maintainDynPcdMap(pcdData
.getCName() + " " + pcdData
.getTokenSpaceGuidCName(),
634 // key for ModuleSA : "ModuleGuid ModuleVer PackageGuid PackageVer Arch"
636 public int getLibraryInstancesCount(String key
) {
637 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
638 if (msa
== null || msa
.getLibraries() == null || msa
.getLibraries().getInstanceList() == null){
641 return msa
.getLibraries().getInstanceList().size();
644 public void getLibraryInstances(String key
, String
[][] saa
){
645 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
646 if (msa
== null || msa
.getLibraries() == null || msa
.getLibraries().getInstanceList() == null){
650 ListIterator
<LibrariesDocument
.Libraries
.Instance
> li
= msa
.getLibraries().getInstanceList().listIterator();
651 for (int i
= 0; i
< saa
.length
; ++i
) {
652 LibrariesDocument
.Libraries
.Instance instance
= li
.next();
653 saa
[i
][1] = instance
.getModuleGuid();
654 saa
[i
][2] = instance
.getModuleVersion();
655 saa
[i
][3] = instance
.getPackageGuid();
656 saa
[i
][4] = instance
.getPackageVersion();
660 public void removeLibraryInstance(String key
, int i
) {
661 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
662 if (msa
== null || msa
.getLibraries() == null){
666 XmlCursor cursor
= msa
.getLibraries().newCursor();
667 if (cursor
.toFirstChild()) {
668 for (int j
= 0; j
< i
; ++j
) {
669 cursor
.toNextSibling();
672 cursor
.toPrevToken();
673 if (cursor
.isComment()) {
678 if (getLibraryInstancesCount(key
) == 0) {
687 public void genLibraryInstance(ModuleIdentification libMi
, String key
) {
688 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
690 msa
= getfpdFrameworkModules().addNewModuleSA();
692 LibrariesDocument
.Libraries libs
= msa
.getLibraries();
694 libs
= msa
.addNewLibraries();
697 String mn
= libMi
.getName();
698 String mg
= libMi
.getGuid();
699 String mv
= libMi
.getVersion();
700 String pn
= libMi
.getPackage().getName();
701 String pg
= libMi
.getPackage().getGuid();
702 String pv
= libMi
.getPackage().getVersion();
703 LibrariesDocument
.Libraries
.Instance instance
= libs
.addNewInstance();
704 XmlCursor cursor
= instance
.newCursor();
706 String comment
= "Pkg: " + pn
+ " Mod: " + mn
707 + " Path: " + GlobalData
.getMsaFile(libMi
).getPath().substring(System
.getenv("WORKSPACE").length() + 1);
708 cursor
.insertComment(comment
);
717 instance
.setModuleGuid(mg
);
718 instance
.setModuleVersion(mv
);
719 instance
.setPackageGuid(pg
);
720 instance
.setPackageVersion(pv
);
724 public String
getFvBinding(String moduleKey
){
725 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
726 if (msa
== null || msa
.getModuleSaBuildOptions() == null) {
729 return msa
.getModuleSaBuildOptions().getFvBinding();
732 public void setFvBinding(String moduleKey
, String fvBinding
){
733 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
737 if(msa
.getModuleSaBuildOptions() == null){
738 msa
.addNewModuleSaBuildOptions().setFvBinding(fvBinding
);
741 msa
.getModuleSaBuildOptions().setFvBinding(fvBinding
);
744 public String
getFfsFileNameGuid(String moduleKey
){
745 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
746 if (msa
== null || msa
.getModuleSaBuildOptions() == null) {
749 return msa
.getModuleSaBuildOptions().getFfsFileNameGuid();
752 public void setFfsFileNameGuid(String moduleKey
, String fileGuid
){
753 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
757 if(msa
.getModuleSaBuildOptions() == null){
758 msa
.addNewModuleSaBuildOptions();
761 ModuleSaBuildOptionsDocument
.ModuleSaBuildOptions msaBuildOpts
= msa
.getModuleSaBuildOptions();
762 if (fileGuid
!= null) {
763 msaBuildOpts
.setFfsFileNameGuid(fileGuid
);
766 XmlCursor cursor
= msaBuildOpts
.newCursor();
767 if (cursor
.toChild(xmlNs
, "FfsFileNameGuid")) {
775 public String
getFfsFormatKey(String moduleKey
){
776 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
777 if (msa
== null || msa
.getModuleSaBuildOptions() == null) {
780 return msa
.getModuleSaBuildOptions().getFfsFormatKey();
783 public void setFfsFormatKey(String moduleKey
, String ffsKey
){
784 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
788 if(msa
.getModuleSaBuildOptions() == null){
789 msa
.addNewModuleSaBuildOptions().setFfsFormatKey(ffsKey
);
792 msa
.getModuleSaBuildOptions().setFfsFormatKey(ffsKey
);
795 public void getModuleSAOptions(String moduleKey
, String
[][] saa
) {
796 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
797 if (msa
== null || msa
.getModuleSaBuildOptions() == null || msa
.getModuleSaBuildOptions().getOptions() == null
798 || msa
.getModuleSaBuildOptions().getOptions().getOptionList() == null) {
802 List
<OptionDocument
.Option
> lOpt
= msa
.getModuleSaBuildOptions().getOptions().getOptionList();
803 ListIterator li
= lOpt
.listIterator();
805 while(li
.hasNext()) {
806 OptionDocument
.Option opt
= (OptionDocument
.Option
)li
.next();
807 if (opt
.getBuildTargets() != null) {
808 saa
[i
][0] = listToString(opt
.getBuildTargets());
810 saa
[i
][1] = opt
.getToolChainFamily();
811 saa
[i
][2] = opt
.getTagName();
812 saa
[i
][3] = opt
.getToolCode();
814 if (opt
.getSupArchList() != null){
815 saa
[i
][4] = listToString(opt
.getSupArchList());
819 saa
[i
][5] = opt
.getStringValue();
825 public int getModuleSAOptionsCount(String moduleKey
){
826 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
827 if (msa
== null || msa
.getModuleSaBuildOptions() == null || msa
.getModuleSaBuildOptions().getOptions() == null
828 || msa
.getModuleSaBuildOptions().getOptions().getOptionList() == null) {
831 return msa
.getModuleSaBuildOptions().getOptions().getOptionList().size();
834 public void genModuleSAOptionsOpt(String moduleKey
, Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
) {
835 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
836 if (msa
.getModuleSaBuildOptions() == null) {
837 msa
.addNewModuleSaBuildOptions();
839 if (msa
.getModuleSaBuildOptions().getOptions() == null){
840 msa
.getModuleSaBuildOptions().addNewOptions();
842 OptionDocument
.Option opt
= msa
.getModuleSaBuildOptions().getOptions().addNewOption();
843 setBuildOptionsOpt(buildTargets
, toolChain
, tagName
, toolCmd
, archList
, contents
, opt
);
846 public void removeModuleSAOptionsOpt(String moduleKey
, int i
) {
847 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
848 if (msa
.getModuleSaBuildOptions() == null || msa
.getModuleSaBuildOptions().getOptions() == null) {
851 OptionsDocument
.Options opts
= msa
.getModuleSaBuildOptions().getOptions();
852 XmlCursor cursor
= opts
.newCursor();
853 if (cursor
.toFirstChild()) {
854 for (int j
= 0; j
< i
; ++j
){
855 cursor
.toNextSibling();
862 public void updateModuleSAOptionsOpt(String moduleKey
, int i
, Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
) {
863 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
864 if (msa
.getModuleSaBuildOptions() == null || msa
.getModuleSaBuildOptions().getOptions() == null) {
867 OptionsDocument
.Options opts
= msa
.getModuleSaBuildOptions().getOptions();
868 XmlCursor cursor
= opts
.newCursor();
869 if (cursor
.toFirstChild()) {
870 for (int j
= 0; j
< i
; ++j
){
871 cursor
.toNextSibling();
873 OptionDocument
.Option opt
= (OptionDocument
.Option
)cursor
.getObject();
874 setBuildOptionsOpt(buildTargets
, toolChain
, tagName
, toolCmd
, archList
, contents
, opt
);
879 /**add pcd information of module mi to a ModuleSA.
881 * @param moduleSa if null, generate a new ModuleSA.
883 public void addFrameworkModulesPcdBuildDefs(ModuleIdentification mi
, String arch
, ModuleSADocument
.ModuleSA moduleSa
) throws Exception
{
884 //ToDo add Arch filter
887 if (moduleSa
== null) {
888 moduleSa
= genModuleSA(mi
, arch
);
891 ModuleSurfaceAreaDocument
.ModuleSurfaceArea msa
= (ModuleSurfaceAreaDocument
.ModuleSurfaceArea
)GlobalData
.getModuleXmlObject(mi
);
892 if (msa
.getPcdCoded() == null) {
896 Map
<String
, XmlObject
> m
= new HashMap
<String
, XmlObject
>();
897 m
.put("ModuleSurfaceArea", msa
);
898 SurfaceAreaQuery
.setDoc(m
);
899 PackageIdentification
[] depPkgs
= SurfaceAreaQuery
.getDependencePkg(null);
901 // Implementing InitializePlatformPcdBuildDefinitions
903 List
<PcdCodedDocument
.PcdCoded
.PcdEntry
> l
= msa
.getPcdCoded().getPcdEntryList();
904 ListIterator li
= l
.listIterator();
905 while(li
.hasNext()) {
906 PcdCodedDocument
.PcdCoded
.PcdEntry msaPcd
= (PcdCodedDocument
.PcdCoded
.PcdEntry
)li
.next();
907 PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry spdPcd
= LookupPcdDeclaration(msaPcd
, depPkgs
);
908 if (spdPcd
== null) {
912 throw new PcdDeclNotFound("No Declaration for PCD Entry " + msaPcd
.getCName() + " in Module " + mi
.getName());
915 // AddItem to ModuleSA PcdBuildDefinitions
917 String defaultVal
= msaPcd
.getDefaultValue() == null ? spdPcd
.getDefaultValue() : msaPcd
.getDefaultValue();
919 genPcdData(msaPcd
.getCName(), spdPcd
.getToken(), msaPcd
.getTokenSpaceGuidCName(), msaPcd
.getPcdItemType().toString(), spdPcd
.getDatumType()+"", defaultVal
, moduleSa
);
930 private PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry
LookupPcdDeclaration (PcdCodedDocument
.PcdCoded
.PcdEntry msaPcd
, PackageIdentification
[] depPkgs
) {
932 Map
<String
, XmlObject
> m
= new HashMap
<String
, XmlObject
>();
933 PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry spdPcd
= null;
934 for (int i
= 0; i
< depPkgs
.length
; ++i
) {
935 m
.put("PackageSurfaceArea", GlobalData
.getPackageXmlObject(depPkgs
[i
]));
936 SurfaceAreaQuery
.setDoc(m
);
937 XmlObject
[] xo
= SurfaceAreaQuery
.getSpdPcdDeclarations();
941 for (int j
= 0; j
< xo
.length
; ++j
) {
942 spdPcd
= (PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry
)xo
[j
];
943 if (msaPcd
.getTokenSpaceGuidCName() == null) {
944 if (spdPcd
.getCName().equals(msaPcd
.getCName())) {
949 if (spdPcd
.getCName().equals(msaPcd
.getCName()) && spdPcd
.getTokenSpaceGuidCName().equals(msaPcd
.getTokenSpaceGuidCName())) {
960 private ModuleSADocument
.ModuleSA
genModuleSA (ModuleIdentification mi
, String arch
) {
961 PackageIdentification pi
= GlobalData
.getPackageForModule(mi
);
962 ModuleSADocument
.ModuleSA msa
= getfpdFrameworkModules().addNewModuleSA();
963 XmlCursor cursor
= msa
.newCursor();
965 String comment
= "Mod: " + mi
.getName() + " Type: " + mi
.getModuleType() + " Path: "
966 + GlobalData
.getMsaFile(mi
).getPath().substring(System
.getenv("WORKSPACE").length() + 1);
967 cursor
.insertComment(comment
);
975 msa
.setModuleGuid(mi
.getGuid());
976 msa
.setModuleVersion(mi
.getVersion());
977 msa
.setPackageGuid(pi
.getGuid());
978 msa
.setPackageVersion(pi
.getVersion());
980 Vector
<String
> v
= new Vector
<String
>();
982 msa
.setSupArchList(v
);
988 private void genPcdData (String cName
, Object token
, String tsGuid
, String itemType
, String dataType
, String defaultVal
, ModuleSADocument
.ModuleSA moduleSa
)
989 throws PcdItemTypeConflictException
, PcdValueMalFormed
{
990 if (moduleSa
.getPcdBuildDefinition() == null){
991 moduleSa
.addNewPcdBuildDefinition();
994 // constructe pcd to modulesa mapping first.
995 // Attention : for any error condition, remove from map this pcd.
997 ArrayList
<String
> pcdConsumer
= LookupPlatformPcdData(cName
+ " " + tsGuid
);
998 if (pcdConsumer
== null) {
999 pcdConsumer
= new ArrayList
<String
>();
1001 String listValue
= moduleSa
.getModuleGuid() + " " + moduleSa
.getModuleVersion()
1002 + " " + moduleSa
.getPackageGuid() + " " + moduleSa
.getPackageVersion() + " " + listToString(moduleSa
.getSupArchList())
1004 pcdConsumer
.add(listValue
);
1005 dynPcdMap
.put(cName
+ " " + tsGuid
, pcdConsumer
);
1007 // Special dynamic type, if this pcd already exists in other ModuleSA
1009 /* Comment out Item type checking temporarily.
1010 if (itemType.equals("DYNAMIC")) {
1012 ListIterator li = pcdConsumer.listIterator();
1013 while(li.hasNext()) {
1014 String value = li.next().toString();
1015 String[] valuePart= value.split(" ");
1016 if (!valuePart[5].equals("DYNAMIC")) {
1017 //ToDo error for same pcd, other type than dynamic
1018 pcdConsumer.remove(listValue);
1019 throw new PcdItemTypeConflictException(cName, value);
1024 ListIterator li = pcdConsumer.listIterator();
1025 while(li.hasNext()) {
1026 String value = li.next().toString();
1027 String[] valuePart= value.split(" ");
1028 if (valuePart[5].equals("DYNAMIC")) {
1029 //ToDo error for same pcd, other type than non-dynamic
1030 pcdConsumer.remove(listValue);
1031 throw new PcdItemTypeConflictException(cName, value);
1036 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData fpdPcd
= moduleSa
.getPcdBuildDefinition().addNewPcdData();
1037 fpdPcd
.setCName(cName
);
1038 fpdPcd
.setToken(token
);
1039 fpdPcd
.setTokenSpaceGuidCName(tsGuid
);
1040 fpdPcd
.setDatumType(PcdDataTypes
.Enum
.forString(dataType
));
1041 fpdPcd
.setItemType(PcdItemTypes
.Enum
.forString(itemType
));
1043 if (defaultVal
!= null){
1044 fpdPcd
.setValue(defaultVal
);
1047 if (dataType
.equals("UINT8") || dataType
.equals("UINT16") || dataType
.equals("UINT32") || dataType
.equals("UINT64")) {
1048 fpdPcd
.setValue("0");
1050 if (dataType
.equals("BOOLEAN")){
1051 fpdPcd
.setValue("false");
1053 if (dataType
.equals("VOID*")) {
1054 fpdPcd
.setValue("");
1057 if (dataType
.equals("UINT8")){
1058 fpdPcd
.setMaxDatumSize(1);
1060 if (dataType
.equals("UINT16")) {
1061 fpdPcd
.setMaxDatumSize(2);
1063 if (dataType
.equals("UINT32")) {
1064 fpdPcd
.setMaxDatumSize(4);
1066 if (dataType
.equals("UINT64")){
1067 fpdPcd
.setMaxDatumSize(8);
1069 if (dataType
.equals("BOOLEAN")){
1070 fpdPcd
.setMaxDatumSize(1);
1072 if (dataType
.equals("VOID*")) {
1073 int maxSize
= setMaxSizeForPointer(fpdPcd
.getValue());
1074 fpdPcd
.setMaxDatumSize(maxSize
);
1078 if (itemType
.equals("DYNAMIC") || itemType
.equals("DYNAMIC_EX")) {
1079 ArrayList
<String
> al
= LookupDynamicPcdBuildDefinition(cName
+ " " + tsGuid
);
1081 // if only one module mapped to this pcd, then the one is myself. so no other module mapped.
1082 // so need to add one dyn pcd.
1084 if (al
.size() == 1) {
1085 addDynamicPcdBuildData(cName
, token
, tsGuid
, itemType
, dataType
, defaultVal
);
1090 if (defaultVal != null){
1091 fpdPcd.setValue(defaultVal);
1094 if (dataType.equals("UINT8") || dataType.equals("UINT16") || dataType.equals("UINT32") || dataType.equals("UINT64")) {
1095 fpdPcd.setValue("0");
1097 if (dataType.equals("BOOLEAN")){
1098 fpdPcd.setValue("false");
1100 if (dataType.equals("VOID*")) {
1101 fpdPcd.setValue("");
1105 if (dataType.equals("UINT8")){
1106 fpdPcd.setMaxDatumSize(1);
1108 if (dataType.equals("UINT16")) {
1109 fpdPcd.setMaxDatumSize(2);
1111 if (dataType.equals("UINT32")) {
1112 fpdPcd.setMaxDatumSize(4);
1114 if (dataType.equals("UINT64")){
1115 fpdPcd.setMaxDatumSize(8);
1117 if (dataType.equals("BOOLEAN")){
1118 fpdPcd.setMaxDatumSize(1);
1120 if (dataType.equals("VOID*")) {
1121 int maxSize = setMaxSizeForPointer(fpdPcd.getValue());
1122 fpdPcd.setMaxDatumSize(maxSize);
1128 public int setMaxSizeForPointer(String datum
) throws PcdValueMalFormed
{
1129 if (datum
== null) {
1132 char ch
= datum
.charAt(0);
1136 // For void* type PCD, only three datum is support:
1137 // 1) Unicode: string with start char is "L"
1138 // 2) Ansci: String is ""
1139 // 3) byte array: String start char "{"
1142 start
= datum
.indexOf('\"');
1143 end
= datum
.lastIndexOf('\"');
1144 if ((start
> end
) ||
1145 (end
> datum
.length())||
1146 ((start
== end
) && (datum
.length() > 0))) {
1147 //ToDo Error handling here
1148 throw new PcdValueMalFormed (datum
);
1151 strValue
= datum
.substring(start
+ 1, end
);
1152 return strValue
.length() * 2;
1153 } else if (ch
== '\"'){
1154 start
= datum
.indexOf('\"');
1155 end
= datum
.lastIndexOf('\"');
1156 if ((start
> end
) ||
1157 (end
> datum
.length())||
1158 ((start
== end
) && (datum
.length() > 0))) {
1159 throw new PcdValueMalFormed (datum
);
1161 strValue
= datum
.substring(start
+ 1, end
);
1162 return strValue
.length();
1163 } else if (ch
=='{') {
1164 String
[] strValueArray
;
1166 start
= datum
.indexOf('{');
1167 end
= datum
.lastIndexOf('}');
1168 strValue
= datum
.substring(start
+ 1, end
);
1169 strValue
= strValue
.trim();
1170 if (strValue
.length() == 0) {
1173 strValueArray
= strValue
.split(",");
1174 for (int index
= 0; index
< strValueArray
.length
; index
++) {
1175 Integer value
= Integer
.decode(strValueArray
[index
].trim());
1178 // "[FPD file error] The datum type of PCD %s in %s is VOID*, "+
1179 // "it is byte array in fact. But the element of %s exceed the byte range",
1180 throw new PcdValueMalFormed (datum
);
1183 return strValueArray
.length
;
1187 // "[FPD file error] The datum type of PCD %s in %s is VOID*. For VOID* type, you have three format choise:\n "+
1188 // "1) UNICODE string: like L\"xxxx\";\r\n"+
1189 // "2) ANSIC string: like \"xxx\";\r\n"+
1190 // "3) Byte array: like {0x2, 0x45, 0x23}\r\n"+
1191 // "but the datum in seems does not following above format!",
1192 throw new PcdValueMalFormed (datum
);
1197 private ArrayList
<String
> LookupDynamicPcdBuildDefinition(String dynPcdKey
) {
1198 ArrayList
<String
> al
= dynPcdMap
.get(dynPcdKey
);
1203 private ArrayList
<String
> LookupPlatformPcdData(String pcdKey
) {
1205 return dynPcdMap
.get(pcdKey
);
1208 public int getDynamicPcdBuildDataCount() {
1209 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1210 removeElement(getfpdDynPcdBuildDefs());
1211 fpdDynPcdBuildDefs
= null;
1214 return getfpdDynPcdBuildDefs().getPcdBuildDataList().size();
1217 public void getDynamicPcdBuildData(String
[][] saa
) {
1218 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1219 removeElement(getfpdDynPcdBuildDefs());
1220 fpdDynPcdBuildDefs
= null;
1223 List
<DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
> l
= getfpdDynPcdBuildDefs().getPcdBuildDataList();
1224 ListIterator
<DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
> li
= l
.listIterator();
1226 while(li
.hasNext()) {
1227 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData dynPcd
= li
.next();
1228 saa
[i
][0] = dynPcd
.getCName();
1229 saa
[i
][1] = dynPcd
.getToken().toString();
1230 saa
[i
][2] = dynPcd
.getTokenSpaceGuidCName();
1231 saa
[i
][3] = dynPcd
.getMaxDatumSize()+"";
1232 saa
[i
][4] = dynPcd
.getDatumType().toString();
1238 public void addDynamicPcdBuildData(String cName
, Object token
, String tsGuid
, String itemType
, String dataType
, String defaultVal
)
1239 throws PcdValueMalFormed
{
1240 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData dynPcdData
= getfpdDynPcdBuildDefs().addNewPcdBuildData();
1241 dynPcdData
.setItemType(PcdItemTypes
.Enum
.forString(itemType
));
1242 dynPcdData
.setCName(cName
);
1243 dynPcdData
.setToken(token
);
1244 dynPcdData
.setTokenSpaceGuidCName(tsGuid
);
1245 dynPcdData
.setDatumType(PcdDataTypes
.Enum
.forString(dataType
));
1247 BigInteger bigInt
= new BigInteger("0");
1248 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo skuInfo
= dynPcdData
.addNewSkuInfo();
1249 skuInfo
.setSkuId(bigInt
);
1250 if (defaultVal
!= null){
1251 skuInfo
.setValue(defaultVal
);
1254 if (dataType
.equals("UINT8")){
1255 skuInfo
.setValue("0");
1257 if (dataType
.equals("UINT16")) {
1258 skuInfo
.setValue("0");
1260 if (dataType
.equals("UINT32")) {
1261 skuInfo
.setValue("0");
1263 if (dataType
.equals("UINT64")){
1264 skuInfo
.setValue("0");
1266 if (dataType
.equals("BOOLEAN")){
1267 skuInfo
.setValue("false");
1269 if (dataType
.equals("VOID*")) {
1270 skuInfo
.setValue("");
1273 if (dataType
.equals("UINT8")){
1274 dynPcdData
.setMaxDatumSize(1);
1276 if (dataType
.equals("UINT16")) {
1277 dynPcdData
.setMaxDatumSize(2);
1279 if (dataType
.equals("UINT32")) {
1280 dynPcdData
.setMaxDatumSize(4);
1282 if (dataType
.equals("UINT64")){
1283 dynPcdData
.setMaxDatumSize(8);
1285 if (dataType
.equals("BOOLEAN")){
1286 dynPcdData
.setMaxDatumSize(1);
1288 if (dataType
.equals("VOID*")) {
1289 int maxSize
= setMaxSizeForPointer(defaultVal
);
1290 dynPcdData
.setMaxDatumSize(maxSize
);
1294 public void removeDynamicPcdBuildData(String cName
, String tsGuid
) {
1295 XmlObject o
= fpdRoot
.getDynamicPcdBuildDefinitions();
1300 XmlCursor cursor
= o
.newCursor();
1301 if (cursor
.toFirstChild()) {
1303 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdBuildData
=
1304 (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1305 if (pcdBuildData
.getCName().equals(cName
) && pcdBuildData
.getTokenSpaceGuidCName().equals(tsGuid
)) {
1307 if (getDynamicPcdBuildDataCount() == 1) {
1315 while (cursor
.toNextSibling());
1320 // Get the Sku Info count of ith dyn pcd element.
1322 public int getDynamicPcdSkuInfoCount(int i
){
1323 if (fpdRoot
.getDynamicPcdBuildDefinitions() == null || fpdRoot
.getDynamicPcdBuildDefinitions().getPcdBuildDataList() == null
1324 || fpdRoot
.getDynamicPcdBuildDefinitions().getPcdBuildDataList().size() == 0) {
1328 int skuInfoCount
= 0;
1329 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1330 if (cursor
.toFirstChild()) {
1331 for (int j
= 0; j
< i
; ++j
) {
1332 cursor
.toNextSibling();
1334 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1335 if (pcdData
.getSkuInfoList() == null) {
1339 skuInfoCount
= pcdData
.getSkuInfoList().size();
1343 return skuInfoCount
;
1346 public void getDynamicPcdSkuInfos(int i
, String
[][] saa
){
1347 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1348 removeElement(getfpdDynPcdBuildDefs());
1349 fpdDynPcdBuildDefs
= null;
1353 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1354 if (cursor
.toFirstChild()) {
1355 for (int j
= 0; j
< i
; ++j
) {
1356 cursor
.toNextSibling();
1358 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1359 if (pcdData
.getSkuInfoList() == null) {
1364 ListIterator
<DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo
> li
= pcdData
.getSkuInfoList().listIterator();
1366 while (li
.hasNext()) {
1367 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo skuInfo
= li
.next();
1368 saa
[k
][0] = skuInfo
.getSkuId()+"";
1369 saa
[k
][1] = skuInfo
.getVariableName();
1370 saa
[k
][2] = skuInfo
.getVariableGuid();
1371 saa
[k
][3] = skuInfo
.getVariableOffset();
1372 saa
[k
][4] = skuInfo
.getHiiDefaultValue();
1373 saa
[k
][5] = skuInfo
.getVpdOffset();
1374 saa
[k
][6] = skuInfo
.getValue();
1384 public String
getDynamicPcdBuildDataValue(int i
){
1385 String value
= null;
1386 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1387 removeElement(getfpdDynPcdBuildDefs());
1388 fpdDynPcdBuildDefs
= null;
1392 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1393 if (cursor
.toFirstChild()) {
1394 for (int j
= 0; j
< i
; ++j
) {
1395 cursor
.toNextSibling();
1397 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1398 if (pcdData
.getSkuInfoList() == null) {
1402 value
= pcdData
.getSkuInfoArray(0).getValue();
1409 public String
getDynamicPcdBuildDataVpdOffset(int i
){
1410 String vpdOffset
= null;
1411 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1412 removeElement(getfpdDynPcdBuildDefs());
1413 fpdDynPcdBuildDefs
= null;
1417 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1418 if (cursor
.toFirstChild()) {
1419 for (int j
= 0; j
< i
; ++j
) {
1420 cursor
.toNextSibling();
1422 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1423 if (pcdData
.getSkuInfoList() == null) {
1427 vpdOffset
= pcdData
.getSkuInfoArray(0).getVpdOffset();
1434 public void removeDynamicPcdBuildDataSkuInfo(int i
) {
1435 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1436 removeElement(getfpdDynPcdBuildDefs());
1437 fpdDynPcdBuildDefs
= null;
1441 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1442 if (cursor
.toFirstChild()) {
1443 for (int j
= 0; j
< i
; ++j
) {
1444 cursor
.toNextSibling();
1446 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1447 if (pcdData
.getSkuInfoList() == null) {
1452 QName qSkuInfo
= new QName(xmlNs
, "SkuInfo");
1453 cursor
.toChild(qSkuInfo
);
1460 // generate sku info for ith dyn pcd build data.
1462 public void genDynamicPcdBuildDataSkuInfo(String id
, String varName
, String varGuid
, String varOffset
,
1463 String hiiDefault
, String vpdOffset
, String value
, int i
) {
1464 // if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1468 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1469 if (cursor
.toFirstChild()) {
1470 for (int j
= 0; j
< i
; ++j
) {
1471 cursor
.toNextSibling();
1473 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1474 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo skuInfo
= pcdData
.addNewSkuInfo();
1475 skuInfo
.setSkuId(new BigInteger(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
);
1491 public void updateDynamicPcdBuildDataSkuInfo(String id
, String varName
, String varGuid
, String varOffset
,
1492 String hiiDefault
, String vpdOffset
, String value
, int i
){
1493 // if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1497 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1498 if (cursor
.toFirstChild()) {
1499 for (int j
= 0; j
< i
; ++j
) {
1500 cursor
.toNextSibling();
1502 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1503 ListIterator
<DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo
> li
= pcdData
.getSkuInfoList().listIterator();
1504 while (li
.hasNext()) {
1505 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo skuInfo
= li
.next();
1506 if (skuInfo
.getSkuId().toString().equals(id
)){
1507 if (varName
!= null){
1508 skuInfo
.setVariableName(varName
);
1509 skuInfo
.setVariableGuid(varGuid
);
1510 skuInfo
.setVariableOffset(varOffset
);
1511 skuInfo
.setHiiDefaultValue(hiiDefault
);
1513 else if (vpdOffset
!= null){
1514 skuInfo
.setVpdOffset(vpdOffset
);
1517 skuInfo
.setValue(value
);
1525 public BuildOptionsDocument
.BuildOptions
getfpdBuildOpts() {
1526 if (fpdBuildOpts
== null) {
1527 fpdBuildOpts
= fpdRoot
.addNewBuildOptions();
1529 return fpdBuildOpts
;
1532 public void genBuildOptionsUserDefAntTask (String id
, String fileName
, String execOrder
) {
1533 UserDefinedAntTasksDocument
.UserDefinedAntTasks udats
= getfpdBuildOpts().getUserDefinedAntTasks();
1534 if (udats
== null) {
1535 udats
= getfpdBuildOpts().addNewUserDefinedAntTasks();
1538 AntTaskDocument
.AntTask at
= udats
.addNewAntTask();
1539 setBuildOptionsUserDefAntTask(id
, fileName
, execOrder
, at
);
1542 private void setBuildOptionsUserDefAntTask(String id
, String fileName
, String execOrder
, AntTaskDocument
.AntTask at
) {
1543 at
.setId(new Integer(id
));
1544 XmlCursor cursor
= at
.newCursor();
1545 if (fileName
!= null){
1546 at
.setFilename(fileName
);
1548 else if (cursor
.toChild(xmlNs
, "Filename")) {
1551 if (execOrder
!= null) {
1552 at
.setAntCmdOptions(execOrder
);
1554 else if (cursor
.toChild(xmlNs
, "AntCmdOptions")) {
1560 public void removeBuildOptionsUserDefAntTask(int i
) {
1561 XmlObject o
= getfpdBuildOpts().getUserDefinedAntTasks();
1565 XmlCursor cursor
= o
.newCursor();
1566 if (cursor
.toFirstChild()) {
1567 for (int j
= 0; j
< i
; ++j
) {
1568 cursor
.toNextSibling();
1571 if (getBuildOptionsUserDefAntTaskCount() == 0) {
1579 public void updateBuildOptionsUserDefAntTask(int i
, String id
, String fileName
, String execOrder
){
1580 XmlObject o
= getfpdBuildOpts().getUserDefinedAntTasks();
1584 XmlCursor cursor
= o
.newCursor();
1585 if (cursor
.toFirstChild()) {
1586 for (int j
= 0; j
< i
; ++j
) {
1587 cursor
.toNextSibling();
1589 AntTaskDocument
.AntTask at
= (AntTaskDocument
.AntTask
)cursor
.getObject();
1590 setBuildOptionsUserDefAntTask(id
, fileName
, execOrder
, at
);
1595 public int getBuildOptionsUserDefAntTaskCount() {
1596 UserDefinedAntTasksDocument
.UserDefinedAntTasks udats
= getfpdBuildOpts().getUserDefinedAntTasks();
1597 if (udats
== null || udats
.getAntTaskList() == null) {
1601 return udats
.getAntTaskList().size();
1604 public void getBuildOptionsUserDefAntTasks(String
[][] saa
) {
1605 UserDefinedAntTasksDocument
.UserDefinedAntTasks udats
= getfpdBuildOpts().getUserDefinedAntTasks();
1606 if (udats
== null || udats
.getAntTaskList() == null) {
1610 List
<AntTaskDocument
.AntTask
> l
= udats
.getAntTaskList();
1611 ListIterator li
= l
.listIterator();
1613 while (li
.hasNext()) {
1614 AntTaskDocument
.AntTask at
= (AntTaskDocument
.AntTask
)li
.next();
1615 saa
[i
][0] = at
.getId() + "";
1616 saa
[i
][1] = saa
[i
][2] = "";
1617 if (at
.getFilename() != null){
1618 saa
[i
][1] = at
.getFilename();
1620 if (at
.getAntCmdOptions() != null) {
1621 saa
[i
][2] = at
.getAntCmdOptions();
1626 public void genBuildOptionsOpt(Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
) {
1627 OptionsDocument
.Options opts
= getfpdBuildOpts().getOptions();
1629 opts
= getfpdBuildOpts().addNewOptions();
1631 OptionDocument
.Option opt
= opts
.addNewOption();
1632 setBuildOptionsOpt(buildTargets
, toolChain
, tagName
, toolCmd
, archList
, contents
, opt
);
1635 private void setBuildOptionsOpt(Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
, OptionDocument
.Option opt
){
1636 opt
.setStringValue(contents
);
1638 opt
.setBuildTargets(buildTargets
);
1639 opt
.setToolChainFamily(toolChain
);
1640 opt
.setTagName(tagName
);
1641 opt
.setToolCode(toolCmd
);
1643 if (archList
!= null) {
1644 opt
.setSupArchList(archList
);
1647 if (opt
.isSetSupArchList()) {
1648 opt
.unsetSupArchList();
1653 public void removeBuildOptionsOpt(int i
){
1655 XmlObject o
= getfpdBuildOpts().getOptions();
1660 XmlCursor cursor
= o
.newCursor();
1661 if (cursor
.toFirstChild()) {
1662 for (int j
= 0; j
< i
; ++j
) {
1663 cursor
.toNextSibling();
1666 if (getBuildOptionsOptCount() == 0) {
1674 public void updateBuildOptionsOpt(int i
, Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
) {
1675 XmlObject o
= getfpdBuildOpts().getOptions();
1680 XmlCursor cursor
= o
.newCursor();
1681 if (cursor
.toFirstChild()) {
1682 for (int j
= 0; j
< i
; ++j
) {
1683 cursor
.toNextSibling();
1685 OptionDocument
.Option opt
= (OptionDocument
.Option
)cursor
.getObject();
1686 setBuildOptionsOpt(buildTargets
, toolChain
, tagName
, toolCmd
, archList
, contents
, opt
);
1691 public int getBuildOptionsOptCount(){
1692 if (getfpdBuildOpts().getOptions() == null || getfpdBuildOpts().getOptions().getOptionList() == null) {
1695 return getfpdBuildOpts().getOptions().getOptionList().size();
1698 public void getBuildOptionsOpts(String
[][] saa
) {
1699 if (getfpdBuildOpts().getOptions() == null || getfpdBuildOpts().getOptions().getOptionList() == null) {
1703 List
<OptionDocument
.Option
> lOpt
= getfpdBuildOpts().getOptions().getOptionList();
1704 ListIterator li
= lOpt
.listIterator();
1706 while(li
.hasNext()) {
1707 OptionDocument
.Option opt
= (OptionDocument
.Option
)li
.next();
1708 if (opt
.getBuildTargets() != null) {
1709 saa
[i
][0] = listToString(opt
.getBuildTargets());
1711 saa
[i
][1] = opt
.getToolChainFamily();
1712 if (opt
.getSupArchList() != null){
1713 saa
[i
][2] = listToString(opt
.getSupArchList());
1716 saa
[i
][3] = opt
.getToolCode();
1717 saa
[i
][4] = opt
.getTagName();
1718 saa
[i
][5] = opt
.getStringValue();
1724 public void genBuildOptionsFfs(String ffsKey
, String type
) {
1725 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getfpdBuildOpts().addNewFfs();
1726 ffs
.setFfsKey(ffsKey
);
1728 ffs
.addNewSections().setEncapsulationType(type
);
1732 public void updateBuildOptionsFfsSectionsType(int i
, String type
) {
1733 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getfpdBuildOpts().addNewFfs();
1735 ffs
.addNewSections().setEncapsulationType(type
);
1739 public void genBuildOptionsFfsAttribute(int i
, String name
, String value
) {
1740 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1741 BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute attrib
= ffs
.addNewAttribute();
1742 attrib
.setName(name
);
1743 attrib
.setValue(value
);
1746 /**update jth attribute of ith ffs.
1750 public void updateBuildOptionsFfsAttribute(int i
, int j
, String name
, String value
){
1751 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1752 XmlCursor cursor
= ffs
.newCursor();
1753 QName qAttrib
= new QName(xmlNs
, "Attribute");
1754 if (cursor
.toChild(qAttrib
)) {
1755 for (int k
= 0; k
< j
; ++k
) {
1756 cursor
.toNextSibling(qAttrib
);
1758 BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute attrib
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute
)cursor
.getObject();
1759 attrib
.setName(name
);
1760 attrib
.setValue(value
);
1765 public void removeBuildOptionsFfsAttribute(int i
, int j
){
1766 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1767 XmlCursor cursor
= ffs
.newCursor();
1768 QName qAttrib
= new QName(xmlNs
, "Attribute");
1769 if (cursor
.toChild(qAttrib
)) {
1770 for (int k
= 0; k
< j
; ++k
) {
1771 cursor
.toNextSibling(qAttrib
);
1778 public void genBuildOptionsFfsSectionsSection(int i
, String sectionType
) {
1779 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1783 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1785 if (sections
== null){
1786 sections
= ffs
.addNewSections();
1788 sections
.addNewSection().setSectionType(EfiSectionType
.Enum
.forString(sectionType
));
1791 public void removeBuildOptionsFfsSectionsSection(int i
, int j
) {
1792 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1793 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1794 if (sections
== null) {
1797 XmlCursor cursor
= sections
.newCursor();
1798 QName qSection
= new QName(xmlNs
, "Section");
1799 if (cursor
.toChild(qSection
)) {
1800 for (int k
= 0; k
< j
; ++k
) {
1801 cursor
.toNextSibling(qSection
);
1808 public void updateBuildOptionsFfsSectionsSection(int i
, int j
, String type
){
1809 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1810 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1811 if (sections
== null) {
1814 XmlCursor cursor
= sections
.newCursor();
1815 QName qSection
= new QName(xmlNs
, "Section");
1816 if (cursor
.toChild(qSection
)) {
1817 for (int k
= 0; k
< j
; ++k
) {
1818 cursor
.toNextSibling(qSection
);
1820 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Section section
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Section
)cursor
.getObject();
1821 section
.setSectionType(EfiSectionType
.Enum
.forString(type
));
1826 public void genBuildOptionsFfsSectionsSections(int i
, String encapType
) {
1827 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1831 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1833 if (sections
== null){
1834 sections
= ffs
.addNewSections();
1836 sections
.addNewSections().setEncapsulationType(encapType
);
1839 public void removeBuildOptionsFfsSectionsSections(int i
, int j
) {
1840 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1841 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1842 if (sections
== null) {
1845 XmlCursor cursor
= sections
.newCursor();
1846 QName qSections
= new QName(xmlNs
, "Sections");
1847 if (cursor
.toChild(qSections
)) {
1848 for (int k
= 0; k
< j
; ++k
) {
1849 cursor
.toNextSibling(qSections
);
1856 public void updateBuildOptionsFfsSectionsSections(int i
, int j
, String type
) {
1857 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1858 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1859 if (sections
== null) {
1862 XmlCursor cursor
= sections
.newCursor();
1863 QName qSections
= new QName(xmlNs
, "Sections");
1864 if (cursor
.toChild(qSections
)) {
1865 for (int k
= 0; k
< j
; ++k
) {
1866 cursor
.toNextSibling(qSections
);
1868 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2 sections2
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
)cursor
.getObject();
1869 sections2
.setEncapsulationType(type
);
1874 public void genBuildOptionsFfsSectionsSectionsSection(int i
, int j
, String type
) {
1875 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1879 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1880 XmlCursor cursor
= sections
.newCursor();
1881 QName qSections
= new QName(xmlNs
, "Sections");
1882 if (cursor
.toChild(qSections
)){
1883 for (int k
= 0; k
< j
; ++k
) {
1884 cursor
.toNextSibling(qSections
);
1886 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2 sections2
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
)cursor
.getObject();
1887 sections2
.addNewSection().setSectionType(EfiSectionType
.Enum
.forString(type
));
1892 public void removeBuildOptionsFfsSectionsSectionsSection(int i
, int j
, int k
) {
1893 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1894 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1895 if (sections
== null) {
1898 XmlCursor cursor
= sections
.newCursor();
1899 QName qSections
= new QName(xmlNs
, "Sections");
1900 if (cursor
.toChild(qSections
)) {
1901 for (int l
= 0; l
< j
; ++l
) {
1902 cursor
.toNextSibling(qSections
);
1904 if (cursor
.toFirstChild()) {
1906 for (; m
< k
; ++m
) {
1907 cursor
.toNextSibling();
1919 public void updateBuildOptionsFfsSectionsSectionsSection(int i
, int j
, int k
, String type
) {
1920 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1921 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1922 if (sections
== null) {
1925 XmlCursor cursor
= sections
.newCursor();
1926 QName qSections
= new QName(xmlNs
, "Sections");
1927 if (cursor
.toChild(qSections
)) {
1928 for (int l
= 0; l
< j
; ++l
) {
1929 cursor
.toNextSibling(qSections
);
1931 if (cursor
.toFirstChild()) {
1932 for (int m
= 0; m
< k
; ++m
) {
1933 cursor
.toNextSibling();
1935 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section section
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section
)cursor
.getObject();
1936 section
.setSectionType(EfiSectionType
.Enum
.forString(type
));
1942 public void getBuildOptionsFfsSectionsSectionsSection(int i
, int j
, ArrayList
<String
> al
) {
1943 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1947 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1948 XmlCursor cursor
= sections
.newCursor();
1949 QName qSections
= new QName(xmlNs
, "Sections");
1950 if (cursor
.toChild(qSections
)){
1951 for (int k
= 0; k
< j
; ++k
) {
1952 cursor
.toNextSibling(qSections
);
1954 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2 sections2
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
)cursor
.getObject();
1955 if (sections2
.getSectionList() == null){
1959 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section
> li
= sections2
.getSectionList().listIterator();
1960 while(li
.hasNext()) {
1961 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section section
= li
.next();
1962 if (section
.isSetSectionType()) {
1963 al
.add(section
.getSectionType().toString());
1972 public int getBuildOptionsFfsCount(){
1973 if (getfpdBuildOpts().getFfsList() == null) {
1976 return getfpdBuildOpts().getFfsList().size();
1979 public void getBuildOptionsFfsKey(String
[][] saa
) {
1980 if (getfpdBuildOpts().getFfsList() == null) {
1983 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
> li
= getfpdBuildOpts().getFfsList().listIterator();
1985 while(li
.hasNext()){
1986 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= li
.next();
1987 saa
[i
][0] = ffs
.getFfsKey();
1992 public void updateBuildOptionsFfsKey(int i
, String key
) {
1993 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1997 /**Get ith FFS key and contents.
2000 public void getBuildOptionsFfs(int i
, String
[] sa
, LinkedHashMap
<String
, String
> ffsAttribMap
, ArrayList
<String
> firstLevelSections
, ArrayList
<String
> firstLevelSection
) {
2001 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2005 sa
[0] = ffs
.getFfsKey();
2006 if (ffs
.getSections() != null) {
2007 if(ffs
.getSections().getEncapsulationType() != null){
2008 sa
[1] = ffs
.getSections().getEncapsulationType();
2010 if (ffs
.getSections().getSectionList() != null){
2011 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Section
> li
= ffs
.getSections().getSectionList().listIterator();
2012 while (li
.hasNext()) {
2013 firstLevelSection
.add(li
.next().getSectionType().toString());
2016 if (ffs
.getSections().getSectionsList() != null) {
2017 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
> li
= ffs
.getSections().getSectionsList().listIterator();
2018 while(li
.hasNext()) {
2019 firstLevelSections
.add(li
.next().getEncapsulationType());
2023 if (ffs
.getAttributeList() != null) {
2024 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute
> li
= ffs
.getAttributeList().listIterator();
2025 while(li
.hasNext()) {
2026 BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute attrib
= li
.next();
2027 ffsAttribMap
.put(attrib
.getName(), attrib
.getValue());
2036 private BuildOptionsDocument
.BuildOptions
.Ffs
getFfs(int i
) {
2037 XmlObject o
= getfpdBuildOpts();
2038 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= null;
2040 XmlCursor cursor
= o
.newCursor();
2041 QName qFfs
= new QName(xmlNs
, "Ffs");
2042 if (cursor
.toChild(qFfs
)) {
2043 for (int j
= 0; j
< i
; ++j
) {
2044 cursor
.toNextSibling(qFfs
);
2046 ffs
= (BuildOptionsDocument
.BuildOptions
.Ffs
)cursor
.getObject();
2052 public void removeBuildOptionsFfs(int i
) {
2053 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2058 XmlCursor cursor
= ffs
.newCursor();
2065 public PlatformDefinitionsDocument
.PlatformDefinitions
getfpdPlatformDefs(){
2066 if (fpdPlatformDefs
== null){
2067 fpdPlatformDefs
= fpdRoot
.addNewPlatformDefinitions();
2069 return fpdPlatformDefs
;
2072 public void getPlatformDefsSupportedArchs(Vector
<Object
> archs
){
2073 if (getfpdPlatformDefs().getSupportedArchitectures() == null) {
2076 ListIterator li
= getfpdPlatformDefs().getSupportedArchitectures().listIterator();
2077 while(li
.hasNext()) {
2078 archs
.add(li
.next());
2082 public void setPlatformDefsSupportedArchs(Vector
<Object
> archs
) {
2083 if (archs
!= null) {
2084 getfpdPlatformDefs().setSupportedArchitectures(archs
);
2087 // XmlCursor cursor = getfpdPlatformDefs().newCursor();
2088 // if (cursor.toChild(xmlNs, "SupportedArchitectures")) {
2089 // cursor.removeXml();
2091 // cursor.dispose();
2095 public void getPlatformDefsBuildTargets(Vector
<Object
> targets
) {
2096 if (getfpdPlatformDefs().getBuildTargets() == null) {
2099 ListIterator li
= getfpdPlatformDefs().getBuildTargets().listIterator();
2100 while(li
.hasNext()) {
2101 targets
.add(li
.next());
2105 public void setPlatformDefsBuildTargets(Vector
<Object
> targets
) {
2106 getfpdPlatformDefs().setBuildTargets(targets
);
2109 public void genPlatformDefsSkuInfo(String id
, String name
) {
2110 SkuInfoDocument
.SkuInfo skuInfo
= null;
2111 if (getfpdPlatformDefs().getSkuInfo() == null) {
2112 skuInfo
= getfpdPlatformDefs().addNewSkuInfo();
2114 skuInfo
= getfpdPlatformDefs().getSkuInfo();
2115 if (skuInfo
.getUiSkuNameList() == null || skuInfo
.getUiSkuNameList().size() == 0) {
2116 SkuInfoDocument
.SkuInfo
.UiSkuName skuName
= skuInfo
.addNewUiSkuName();
2117 skuName
.setSkuID(new BigInteger("0"));
2118 skuName
.setStringValue("DEFAULT");
2120 if (id
.equals("0")) {
2123 SkuInfoDocument
.SkuInfo
.UiSkuName skuName
= skuInfo
.addNewUiSkuName();
2124 skuName
.setSkuID(new BigInteger(id
));
2125 skuName
.setStringValue(name
);
2128 public int getPlatformDefsSkuInfoCount(){
2129 if (getfpdPlatformDefs().getSkuInfo() == null || getfpdPlatformDefs().getSkuInfo().getUiSkuNameList() == null) {
2132 return getfpdPlatformDefs().getSkuInfo().getUiSkuNameList().size();
2135 public void getPlatformDefsSkuInfos(String
[][] saa
){
2136 if (getfpdPlatformDefs().getSkuInfo() == null || getfpdPlatformDefs().getSkuInfo().getUiSkuNameList() == null) {
2137 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null) {
2138 removeElement(getfpdDynPcdBuildDefs());
2139 fpdDynPcdBuildDefs
= null;
2144 List
<SkuInfoDocument
.SkuInfo
.UiSkuName
> l
= getfpdPlatformDefs().getSkuInfo().getUiSkuNameList();
2145 ListIterator
<SkuInfoDocument
.SkuInfo
.UiSkuName
> li
= l
.listIterator();
2147 while(li
.hasNext()) {
2148 SkuInfoDocument
.SkuInfo
.UiSkuName sku
= li
.next();
2149 saa
[i
][0] = sku
.getSkuID()+"";
2150 saa
[i
][1] = sku
.getStringValue();
2155 public void removePlatformDefsSkuInfo(int i
) {
2156 SkuInfoDocument
.SkuInfo skuInfo
= getfpdPlatformDefs().getSkuInfo();
2157 if (skuInfo
== null || i
== 0) {
2161 XmlCursor cursor
= skuInfo
.newCursor();
2162 if (cursor
.toFirstChild()) {
2163 for (int j
= 0; j
< i
; ++j
) {
2164 cursor
.toNextSibling();
2171 public void updatePlatformDefsSkuInfo(int i
, String id
, String name
) {
2172 SkuInfoDocument
.SkuInfo skuInfo
= getfpdPlatformDefs().getSkuInfo();
2173 if (skuInfo
== null || i
== 0) {
2177 XmlCursor cursor
= skuInfo
.newCursor();
2178 if (cursor
.toFirstChild()) {
2179 for (int j
= 0; j
< i
; ++j
) {
2180 cursor
.toNextSibling();
2182 SkuInfoDocument
.SkuInfo
.UiSkuName sku
= (SkuInfoDocument
.SkuInfo
.UiSkuName
)cursor
.getObject();
2183 sku
.setSkuID(new BigInteger(id
));
2184 sku
.setStringValue(name
);
2189 public String
getPlatformDefsInterDir(){
2190 if (getfpdPlatformDefs().getIntermediateDirectories() == null) {
2193 return getfpdPlatformDefs().getIntermediateDirectories().toString();
2196 public void setPlatformDefsInterDir(String interDir
){
2197 getfpdPlatformDefs().setIntermediateDirectories(IntermediateOutputType
.Enum
.forString(interDir
));
2200 public String
getPlatformDefsOutputDir() {
2201 return getfpdPlatformDefs().getOutputDirectory();
2204 public void setPlatformDefsOutputDir(String outputDir
) {
2205 if (outputDir
!= null && outputDir
.length() > 0) {
2206 getfpdPlatformDefs().setOutputDirectory(outputDir
);
2209 XmlCursor cursor
= getfpdPlatformDefs().newCursor();
2210 if (cursor
.toChild(new QName(xmlNs
, "OutputDirectory"))) {
2217 public FlashDocument
.Flash
getfpdFlash() {
2218 if (fpdFlash
== null) {
2219 fpdFlash
= fpdRoot
.addNewFlash();
2224 public void genFlashDefinitionFile(String file
) {
2225 FlashDefinitionFileDocument
.FlashDefinitionFile fdf
= getfpdFlash().getFlashDefinitionFile();
2227 fdf
= getfpdFlash().addNewFlashDefinitionFile();
2230 fdf
.setStringValue(file
);
2233 public String
getFlashDefinitionFile() {
2234 FlashDefinitionFileDocument
.FlashDefinitionFile fdf
= getfpdFlash().getFlashDefinitionFile();
2239 return fdf
.getStringValue();
2242 public void genFvImagesNameValue(String name
, String value
) {
2244 FvImagesDocument
.FvImages fi
= getfpdFlash().getFvImages();
2246 fi
= getfpdFlash().addNewFvImages();
2249 FvImagesDocument
.FvImages
.NameValue nv
= fi
.addNewNameValue();
2254 public void removeFvImagesNameValue(int i
){
2256 XmlObject o
= getfpdFlash().getFvImages();
2261 QName qNameValue
= new QName(xmlNs
, "NameValue");
2262 XmlCursor cursor
= o
.newCursor();
2263 if (cursor
.toChild(qNameValue
)) {
2264 for (int j
= 0; j
< i
; ++j
) {
2265 cursor
.toNextSibling(qNameValue
);
2272 public void updateFvImagesNameValue(int i
, String name
, String value
){
2274 XmlObject o
= getfpdFlash().getFvImages();
2279 QName qNameValue
= new QName(xmlNs
, "NameValue");
2280 XmlCursor cursor
= o
.newCursor();
2281 if (cursor
.toChild(qNameValue
)) {
2282 for (int j
= 0; j
< i
; ++j
) {
2283 cursor
.toNextSibling(qNameValue
);
2285 FvImagesDocument
.FvImages
.NameValue nv
= (FvImagesDocument
.FvImages
.NameValue
)cursor
.getObject();
2292 public int getFvImagesNameValueCount() {
2294 FvImagesDocument
.FvImages fi
= null;
2295 if ((fi
= getfpdFlash().getFvImages()) == null || fi
.getNameValueList() == null) {
2298 return fi
.getNameValueList().size();
2301 public void getFvImagesNameValues(String
[][] nv
) {
2303 FvImagesDocument
.FvImages fi
= getfpdFlash().getFvImages();
2307 List
<FvImagesDocument
.FvImages
.NameValue
> l
= fi
.getNameValueList();
2309 ListIterator li
= l
.listIterator();
2310 while (li
.hasNext()) {
2311 FvImagesDocument
.FvImages
.NameValue e
= (FvImagesDocument
.FvImages
.NameValue
) li
2313 nv
[i
][0] = e
.getName();
2314 nv
[i
][1] = e
.getValue();
2320 public void genFvImagesFvImage(String
[] names
, String types
, Map
<String
, String
> options
) {
2322 FvImagesDocument
.FvImages fis
= null;
2323 if ((fis
= getfpdFlash().getFvImages()) == null) {
2324 fis
= getfpdFlash().addNewFvImages();
2328 //gen FvImage with FvImageNames array
2330 FvImagesDocument
.FvImages
.FvImage fi
= fis
.addNewFvImage();
2331 for (int i
= 0; i
< names
.length
; ++i
) {
2332 fi
.addFvImageNames(names
[i
]);
2334 fi
.setType(FvImageTypes
.Enum
.forString(types
));
2335 if (options
!= null){
2336 setFvImagesFvImageFvImageOptions(options
, fi
);
2340 private void setFvImagesFvImageFvImageOptions(Map
<String
, String
> options
, FvImagesDocument
.FvImages
.FvImage fi
){
2341 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions fio
= fi
.getFvImageOptions();
2343 fio
= fi
.addNewFvImageOptions();
2346 Set
<String
> key
= options
.keySet();
2347 Iterator
<String
> i
= key
.iterator();
2348 while (i
.hasNext()) {
2350 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nv
= fio
.addNewNameValue();
2351 String k
= (String
)i
.next();
2354 nv
.setValue((String
)options
.get(k
));
2361 public void removeFvImagesFvImage(int i
) {
2363 XmlObject o
= getfpdFlash().getFvImages();
2368 QName qFvImage
= new QName(xmlNs
, "FvImage");
2369 XmlCursor cursor
= o
.newCursor();
2370 if (cursor
.toChild(qFvImage
)) {
2371 for (int j
= 0; j
< i
; ++j
) {
2372 cursor
.toNextSibling(qFvImage
);
2379 public void updateFvImagesFvImage(int i
, String
[] names
, String types
, Map
<String
, String
> options
){
2381 XmlObject o
= getfpdFlash().getFvImages();
2385 XmlCursor cursor
= o
.newCursor();
2386 QName qFvImage
= new QName(xmlNs
, "FvImage");
2387 if (cursor
.toChild(qFvImage
)) {
2388 for (int j
= 0; j
< i
; ++j
) {
2389 cursor
.toNextSibling(qFvImage
);
2391 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
2392 fi
.setType(FvImageTypes
.Enum
.forString(types
));
2395 // remove old FvImageNames before adding new ones
2397 QName qFvImageNames
= new QName(xmlNs
, "FvImageNames");
2398 cursor
.toChild(qFvImageNames
);
2400 while (cursor
.toNextSibling(qFvImageNames
)) {
2404 for (int k
= 0; k
< names
.length
; ++k
) {
2405 fi
.addFvImageNames(names
[k
]);
2408 // remove old FvImageOptions before adding new options
2410 QName qFvImageOptions
= new QName(xmlNs
, "FvImageOptions");
2411 cursor
.toNextSibling(qFvImageOptions
);
2414 setFvImagesFvImageFvImageOptions(options
, fi
);
2419 public int getFvImagesFvImageCount() {
2421 if (getfpdFlash().getFvImages() == null || getfpdFlash().getFvImages().getFvImageList() == null) {
2424 return getfpdFlash().getFvImages().getFvImageList().size();
2427 /**Only Get Fv image setting - name and type.
2430 public void getFvImagesFvImages(String
[][] saa
) {
2432 if (getfpdFlash().getFvImages() == null) {
2435 List
<FvImagesDocument
.FvImages
.FvImage
> l
= getfpdFlash().getFvImages().getFvImageList();
2439 ListIterator li
= l
.listIterator();
2441 while(li
.hasNext()) {
2442 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)li
.next();
2444 // get FvImageNames array, space separated
2446 List
<String
> lfn
= fi
.getFvImageNamesList();
2447 ListIterator lfni
= lfn
.listIterator();
2449 while (lfni
.hasNext()) {
2450 saa
[i
][0] += (String
)lfni
.next();
2453 saa
[i
][0] = saa
[i
][0].trim();
2455 saa
[i
][1] = fi
.getType()+"";
2461 /**Get FvImage Options for FvImage i
2462 * @param i the ith FvImage
2464 public void getFvImagesFvImageOptions(int i
, Map
<String
, String
> m
) {
2465 XmlObject o
= getfpdFlash().getFvImages();
2469 XmlCursor cursor
= o
.newCursor();
2470 QName qFvImage
= new QName(xmlNs
, "FvImage");
2471 if (cursor
.toChild(qFvImage
)) {
2472 for (int j
= 0; j
< i
; ++j
) {
2473 cursor
.toNextSibling(qFvImage
);
2475 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
2476 if (fi
.getFvImageOptions() == null || fi
.getFvImageOptions().getNameValueList() == null){
2479 ListIterator
<FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
> li
= fi
.getFvImageOptions().getNameValueList().listIterator();
2480 while(li
.hasNext()){
2481 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nv
= li
.next();
2482 m
.put(nv
.getName(), nv
.getValue());
2488 Get platform header element
2489 @return PlatformHeaderDocument.PlatformHeader
2491 public PlatformHeaderDocument
.PlatformHeader
getFpdHdr() {
2492 if (fpdHdr
== null) {
2493 fpdHdr
= fpdRoot
.addNewPlatformHeader();
2499 public String
getFpdHdrPlatformName() {
2500 return getFpdHdr().getPlatformName();
2503 public String
getFpdHdrGuidValue() {
2504 return getFpdHdr().getGuidValue();
2507 public String
getFpdHdrVer() {
2508 return getFpdHdr().getVersion();
2511 public String
getFpdHdrAbs() {
2512 return getFpdHdr().getAbstract();
2515 public String
getFpdHdrDescription() {
2516 return getFpdHdr().getDescription();
2519 public String
getFpdHdrCopyright() {
2520 return getFpdHdr().getCopyright();
2523 public String
getFpdHdrLicense() {
2524 LicenseDocument
.License l
= getFpdHdr().getLicense();
2528 return l
.getStringValue();
2531 public String
getFpdHdrUrl() {
2532 LicenseDocument
.License l
= getFpdHdr().getLicense();
2539 public String
getFpdHdrSpec() {
2541 return "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052";
2542 // return getFpdHdr().getSpecification();
2545 public void setFpdHdrPlatformName(String name
){
2546 getFpdHdr().setPlatformName(name
);
2549 public void setFpdHdrGuidValue(String guid
){
2550 getFpdHdr().setGuidValue(guid
);
2553 public void setFpdHdrVer(String v
){
2554 getFpdHdr().setVersion(v
);
2557 public void setFpdHdrAbs(String abs
) {
2558 getFpdHdr().setAbstract(abs
);
2561 public void setFpdHdrDescription(String desc
){
2562 getFpdHdr().setDescription(desc
);
2565 public void setFpdHdrCopyright(String cr
) {
2566 getFpdHdr().setCopyright(cr
);
2569 public void setFpdHdrLicense(String license
){
2570 LicenseDocument
.License l
= getFpdHdr().getLicense();
2572 getFpdHdr().addNewLicense().setStringValue(license
);
2575 l
.setStringValue(license
);
2579 public void setFpdHdrUrl(String url
){
2580 LicenseDocument
.License l
= getFpdHdr().getLicense();
2586 public void setFpdHdrSpec(String s
){
2587 s
= "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052";
2588 getFpdHdr().setSpecification(s
);
2591 Save the processed xml contents to file
2593 @param fpdFile The file to save xml contents
2594 @throws IOException Exceptions during file operation
2596 public void saveAs(File fpdFile
) throws IOException
{
2598 XmlOptions options
= new XmlOptions();
2600 options
.setCharacterEncoding("UTF-8");
2601 options
.setSavePrettyPrint();
2602 options
.setSavePrettyPrintIndent(2);
2604 fpdd
.save(fpdFile
, options
);
2605 } catch (IOException e
) {
2606 e
.printStackTrace();
2611 private String
listToString(List l
) {
2616 ListIterator li
= l
.listIterator();
2617 while(li
.hasNext()) {
2624 private void removeElement(XmlObject o
) {
2625 XmlCursor cursor
= o
.newCursor();
2631 class PcdItemTypeConflictException
extends Exception
{
2636 private static final long serialVersionUID
= 1L;
2637 private String details
= null;
2639 PcdItemTypeConflictException(String pcdName
, String info
){
2640 ModuleIdentification mi
= GlobalData
.getModuleId(info
);
2641 details
= pcdName
+ " ItemType Conflicts with " + mi
.getName() + " in Pkg " + mi
.getPackage().getName();
2644 public String
getMessage() {
2649 class PcdDeclNotFound
extends Exception
{
2654 private static final long serialVersionUID
= 1L;
2655 private String details
= null;
2657 PcdDeclNotFound(String info
) {
2658 details
= "PcdDeclNotFound: " + info
;
2661 public String
getMessage() {
2666 class PcdValueMalFormed
extends Exception
{
2671 private static final long serialVersionUID
= 1L;
2672 private String details
= null;
2674 PcdValueMalFormed(String info
) {
2675 details
= "PcdValueMalFormed: " + info
;
2678 public String
getMessage() {