2 Java class FpdFileContents is used to parse fpd xml file.
4 Copyright (c) 2006, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13 package org
.tianocore
.frameworkwizard
.platform
.ui
;
16 import java
.io
.IOException
;
17 import java
.math
.BigInteger
;
18 import java
.util
.ArrayList
;
19 import java
.util
.HashMap
;
20 import java
.util
.Iterator
;
21 import java
.util
.LinkedHashMap
;
22 import java
.util
.List
;
23 import java
.util
.ListIterator
;
26 import java
.util
.Vector
;
28 import javax
.xml
.namespace
.QName
;
30 import org
.apache
.xmlbeans
.XmlCursor
;
31 import org
.apache
.xmlbeans
.XmlObject
;
32 import org
.apache
.xmlbeans
.XmlOptions
;
33 import org
.tianocore
.AntTaskDocument
;
34 import org
.tianocore
.BuildOptionsDocument
;
35 import org
.tianocore
.DynamicPcdBuildDefinitionsDocument
;
36 import org
.tianocore
.EfiSectionType
;
37 import org
.tianocore
.FlashDefinitionFileDocument
;
38 import org
.tianocore
.FlashDocument
;
39 import org
.tianocore
.FrameworkModulesDocument
;
40 import org
.tianocore
.IntermediateOutputType
;
41 import org
.tianocore
.LibrariesDocument
;
42 import org
.tianocore
.ModuleSADocument
;
43 import org
.tianocore
.ModuleSaBuildOptionsDocument
;
44 import org
.tianocore
.ModuleSurfaceAreaDocument
;
45 import org
.tianocore
.OptionDocument
;
46 import org
.tianocore
.OptionsDocument
;
47 import org
.tianocore
.PcdBuildDefinitionDocument
;
48 import org
.tianocore
.PcdCodedDocument
;
49 import org
.tianocore
.PcdDataTypes
;
50 import org
.tianocore
.PcdDeclarationsDocument
;
51 import org
.tianocore
.PcdItemTypes
;
52 import org
.tianocore
.PlatformDefinitionsDocument
;
53 import org
.tianocore
.PlatformSurfaceAreaDocument
;
54 import org
.tianocore
.FvImageTypes
;
55 import org
.tianocore
.FvImagesDocument
;
56 import org
.tianocore
.LicenseDocument
;
57 import org
.tianocore
.PlatformHeaderDocument
;
58 import org
.tianocore
.SkuInfoDocument
;
59 import org
.tianocore
.UserDefinedAntTasksDocument
;
60 import org
.tianocore
.UserExtensionsDocument
;
61 import org
.tianocore
.frameworkwizard
.platform
.ui
.global
.WorkspaceProfile
;
62 import org
.tianocore
.frameworkwizard
.platform
.ui
.global
.SurfaceAreaQuery
;
63 import org
.tianocore
.frameworkwizard
.module
.Identifications
.ModuleIdentification
;
64 import org
.tianocore
.frameworkwizard
.packaging
.PackageIdentification
;
67 This class processes fpd file contents such as add remove xml elements.
68 @since PackageEditor 1.0
70 public class FpdFileContents
{
72 static final String xmlNs
= "http://www.TianoCore.org/2006/Edk2.0";
74 private PlatformSurfaceAreaDocument fpdd
= null;
76 private PlatformSurfaceAreaDocument
.PlatformSurfaceArea fpdRoot
= null;
78 private PlatformHeaderDocument
.PlatformHeader fpdHdr
= null;
80 private PlatformDefinitionsDocument
.PlatformDefinitions fpdPlatformDefs
= null;
82 private FlashDocument
.Flash fpdFlash
= null;
84 private BuildOptionsDocument
.BuildOptions fpdBuildOpts
= null;
86 private FrameworkModulesDocument
.FrameworkModules fpdFrameworkModules
= null;
88 private DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions fpdDynPcdBuildDefs
= null;
90 private HashMap
<String
, ArrayList
<String
>> dynPcdMap
= null;
92 private HashMap
<String
, String
> defaultPcdValue
= new HashMap
<String
, String
>();
95 * look through all pcd data in all ModuleSA, create pcd -> ModuleSA mappings.
97 public void initDynPcdMap() {
98 if (dynPcdMap
== null) {
99 dynPcdMap
= new HashMap
<String
, ArrayList
<String
>>();
100 List
<ModuleSADocument
.ModuleSA
> l
= getfpdFrameworkModules().getModuleSAList();
102 removeElement(getfpdFrameworkModules());
103 fpdFrameworkModules
= null;
106 ListIterator
<ModuleSADocument
.ModuleSA
> li
= l
.listIterator();
107 while (li
.hasNext()) {
108 ModuleSADocument
.ModuleSA moduleSa
= li
.next();
109 if (moduleSa
.getPcdBuildDefinition() == null || moduleSa
.getPcdBuildDefinition().getPcdDataList() == null) {
112 String ModuleInfo
= moduleSa
.getModuleGuid() + " " + moduleSa
.getModuleVersion() +
113 " " + moduleSa
.getPackageGuid() + " " + moduleSa
.getPackageVersion() + " " + listToString(moduleSa
.getSupArchList());
114 List
<PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
> lp
= moduleSa
.getPcdBuildDefinition().getPcdDataList();
115 ListIterator
<PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
> lpi
= lp
.listIterator();
116 while (lpi
.hasNext()) {
117 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= lpi
.next();
118 String pcdKey
= pcdData
.getCName() + " " + pcdData
.getTokenSpaceGuidCName();
119 if (dynPcdMap
.get(pcdKey
) == null) {
120 ArrayList
<String
> al
= new ArrayList
<String
>();
121 al
.add(ModuleInfo
+ " " + pcdData
.getItemType().toString());
122 dynPcdMap
.put(pcdKey
, al
);
125 dynPcdMap
.get(pcdKey
).add(ModuleInfo
+ " " + pcdData
.getItemType().toString());
132 public ArrayList
<String
> getDynPcdMapValue(String key
) {
133 return dynPcdMap
.get(key
);
136 Constructor to create a new spd file
138 public FpdFileContents() {
140 fpdd
= PlatformSurfaceAreaDocument
.Factory
.newInstance();
141 fpdRoot
= fpdd
.addNewPlatformSurfaceArea();
146 Constructor for existing document object
149 public FpdFileContents(PlatformSurfaceAreaDocument
.PlatformSurfaceArea fpd
) {
151 fpdHdr
= fpdRoot
.getPlatformHeader();
152 fpdPlatformDefs
= fpdRoot
.getPlatformDefinitions();
153 fpdBuildOpts
= fpdRoot
.getBuildOptions();
154 fpdFrameworkModules
= fpdRoot
.getFrameworkModules();
155 fpdDynPcdBuildDefs
= fpdRoot
.getDynamicPcdBuildDefinitions();
156 fpdFlash
= fpdRoot
.getFlash();
160 Constructor based on an existing spd file
162 @param f Existing spd file
164 public FpdFileContents(File f
) {
166 fpdd
= PlatformSurfaceAreaDocument
.Factory
.parse(f
);
167 fpdRoot
= fpdd
.getPlatformSurfaceArea();
168 } catch (Exception e
) {
169 System
.out
.println(e
.toString());
173 public DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
getfpdDynPcdBuildDefs() {
174 if (fpdDynPcdBuildDefs
== null){
175 fpdDynPcdBuildDefs
= fpdRoot
.addNewDynamicPcdBuildDefinitions();
177 return fpdDynPcdBuildDefs
;
180 public FrameworkModulesDocument
.FrameworkModules
getfpdFrameworkModules() {
181 if (fpdFrameworkModules
== null){
182 fpdFrameworkModules
= fpdRoot
.addNewFrameworkModules();
184 return fpdFrameworkModules
;
187 public void getFrameworkModuleGuid (String fvName
, Vector
<String
> vGuid
) {
188 if (getFrameworkModulesCount() == 0){
192 ListIterator li
= getfpdFrameworkModules().getModuleSAList().listIterator();
193 while(li
.hasNext()) {
194 ModuleSADocument
.ModuleSA moduleSa
= (ModuleSADocument
.ModuleSA
)li
.next();
195 if (moduleSa
.getModuleSaBuildOptions() == null) {
198 String fvBinding
= moduleSa
.getModuleSaBuildOptions().getFvBinding();
199 if (fvBinding
== null) {
203 String
[] fvNames
= fvBinding
.split(" ");
204 for (int i
= 0; i
< fvNames
.length
; ++i
) {
205 if (fvNames
[i
].equals(fvName
) || fvNames
[i
].replaceAll("_", "").equals(fvName
)) {
206 vGuid
.add(moduleSa
.getModuleGuid());
213 public int getFrameworkModulesCount() {
214 if (getfpdFrameworkModules().getModuleSAList() == null || getfpdFrameworkModules().getModuleSAList().size() == 0){
215 removeElement(getfpdFrameworkModules());
216 fpdFrameworkModules
= null;
219 return getfpdFrameworkModules().getModuleSAList().size();
222 public void getFrameworkModulesInfo(String
[][] saa
) {
223 if (getFrameworkModulesCount() == 0){
227 ListIterator li
= getfpdFrameworkModules().getModuleSAList().listIterator();
229 while(li
.hasNext()) {
230 ModuleSADocument
.ModuleSA moduleSa
= (ModuleSADocument
.ModuleSA
)li
.next();
231 saa
[i
][0] = moduleSa
.getModuleGuid();
232 saa
[i
][1] = moduleSa
.getModuleVersion();
234 saa
[i
][2] = moduleSa
.getPackageGuid();
235 saa
[i
][3] = moduleSa
.getPackageVersion();
236 saa
[i
][4] = listToString(moduleSa
.getSupArchList());
241 public void getFrameworkModuleInfo(int i
, String
[] sa
) {
242 ModuleSADocument
.ModuleSA msa
= getModuleSA(i
);
246 sa
[0] = msa
.getModuleGuid();
247 sa
[1] = msa
.getModuleVersion();
248 sa
[2] = msa
.getPackageGuid();
249 sa
[3] = msa
.getPackageVersion();
250 sa
[4] = listToString(msa
.getSupArchList());
253 public ModuleSADocument
.ModuleSA
getModuleSA(String key
) {
254 String
[] s
= key
.split(" ");
255 if (getfpdFrameworkModules().getModuleSAList() == null || getfpdFrameworkModules().getModuleSAList().size() == 0) {
256 removeElement(getfpdFrameworkModules());
257 fpdFrameworkModules
= null;
260 ListIterator li
= getfpdFrameworkModules().getModuleSAList().listIterator();
261 while(li
.hasNext()) {
262 ModuleSADocument
.ModuleSA moduleSa
= (ModuleSADocument
.ModuleSA
)li
.next();
263 if (moduleSa
.getModuleGuid().equalsIgnoreCase(s
[0]) && moduleSa
.getPackageGuid().equalsIgnoreCase(s
[2])) {
264 if (moduleSa
.getModuleVersion() != null) {
265 if (!moduleSa
.getModuleVersion().equals(s
[1])) {
269 if (moduleSa
.getPackageVersion() != null) {
270 if (!moduleSa
.getPackageVersion().equals(s
[3])) {
274 //ToDo add arch check for s[4]
275 if (moduleSa
.getSupArchList() != null) {
276 if (!listToString(moduleSa
.getSupArchList()).equals(s
[4])) {
286 private ModuleSADocument
.ModuleSA
getModuleSA(int i
) {
287 ModuleSADocument
.ModuleSA moduleSa
= null;
288 if (fpdRoot
.getFrameworkModules() == null) {
291 XmlCursor cursor
= fpdRoot
.getFrameworkModules().newCursor();
292 if (cursor
.toFirstChild()) {
293 for (int j
= 0; j
< i
; ++j
) {
294 cursor
.toNextSibling();
296 moduleSa
= (ModuleSADocument
.ModuleSA
)cursor
.getObject();
302 public void removeModuleSA(int i
) {
303 XmlObject o
= fpdRoot
.getFrameworkModules();
308 XmlCursor cursor
= o
.newCursor();
309 if (cursor
.toFirstChild()) {
310 for (int j
= 0; j
< i
; ++j
) {
311 cursor
.toNextSibling();
314 // remove pcd from dynPcdMap, if DynamicPcdBuildData exists, remove them too.
316 ModuleSADocument
.ModuleSA moduleSa
= (ModuleSADocument
.ModuleSA
)cursor
.getObject();
317 String moduleInfo
= moduleSa
.getModuleGuid() + " " + moduleSa
.getModuleVersion() + " " +
318 moduleSa
.getPackageGuid()+ " " + moduleSa
.getPackageVersion() + " " + listToString(moduleSa
.getSupArchList());
319 PcdBuildDefinitionDocument
.PcdBuildDefinition pcdBuildDef
= moduleSa
.getPcdBuildDefinition();
320 if (pcdBuildDef
!= null && pcdBuildDef
.getPcdDataList() != null) {
321 ListIterator
<PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
> li
= pcdBuildDef
.getPcdDataList().listIterator();
322 while(li
.hasNext()) {
323 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= li
.next();
324 maintainDynPcdMap(pcdData
.getCName() + " " + pcdData
.getTokenSpaceGuidCName(), moduleInfo
);
329 cursor
.toPrevToken();
330 if (cursor
.isComment()) {
335 if (getFrameworkModulesCount() == 0) {
343 public boolean adjustPcd (int seqModuleSa
) throws Exception
{
344 boolean dataModified
= false;
345 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(seqModuleSa
);
346 int pcdCount
= getPcdDataCount(seqModuleSa
);
347 String
[][] saaModuleSaPcd
= new String
[pcdCount
][7];
348 getPcdData(seqModuleSa
, saaModuleSaPcd
);
349 String mg
= moduleSa
.getModuleGuid();
350 String mv
= moduleSa
.getModuleVersion();
351 String pg
= moduleSa
.getPackageGuid();
352 String pv
= moduleSa
.getPackageVersion();
353 String arch
= listToString(moduleSa
.getSupArchList());
355 // delete pcd in ModuleSA but not in MSA files any longer.
357 String moduleKey
= mg
+ " " + mv
+ " " + pg
+ " " + pv
+ " " + arch
;
358 int libCount
= getLibraryInstancesCount(moduleKey
);
359 String
[][] saaLib
= new String
[libCount
][5];
360 getLibraryInstances(moduleKey
, saaLib
);
361 ModuleIdentification mi
= WorkspaceProfile
.getModuleId(moduleKey
);
362 Vector
<ModuleIdentification
> vMi
= new Vector
<ModuleIdentification
>();
365 nextPcd
:for (int i
= 0; i
< saaModuleSaPcd
.length
; ++i
) {
366 if (WorkspaceProfile
.pcdInMsa(saaModuleSaPcd
[i
][0], saaModuleSaPcd
[i
][1], mi
)){
369 for (int j
= 0; j
< saaLib
.length
; ++j
) {
370 String libKey
= saaLib
[j
][1] + " " + saaLib
[j
][2] + " " + saaLib
[j
][3] + " " + saaLib
[j
][4];
371 ModuleIdentification libMi
= WorkspaceProfile
.getModuleId(libKey
);
373 if (WorkspaceProfile
.pcdInMsa(saaModuleSaPcd
[i
][0], saaModuleSaPcd
[i
][1], libMi
)) {
377 removePcdData(seqModuleSa
, saaModuleSaPcd
[i
][0], saaModuleSaPcd
[i
][1]);
381 catch (Exception e
) {
385 // add new Pcd from MSA file to ModuleSA.
389 for (int i
= 0; i
< vMi
.size(); ++i
) {
390 ModuleSurfaceAreaDocument
.ModuleSurfaceArea msa
= (ModuleSurfaceAreaDocument
.ModuleSurfaceArea
) WorkspaceProfile
391 .getModuleXmlObject(vMi
393 if (msa
.getPcdCoded() == null || msa
.getPcdCoded().getPcdEntryList() == null) {
396 ListIterator li
= msa
.getPcdCoded().getPcdEntryList().listIterator();
397 msaPcdIter
:while (li
.hasNext()) {
398 PcdCodedDocument
.PcdCoded
.PcdEntry msaPcd
= (PcdCodedDocument
.PcdCoded
.PcdEntry
) li
.next();
399 ArrayList
<String
> al
= getDynPcdMapValue(msaPcd
.getCName() + " " + msaPcd
.getTokenSpaceGuidCName());
401 for (int j
= 0; j
< al
.size(); ++j
) {
402 if (al
.get(j
).contains(moduleKey
)) {
408 Map
<String
, XmlObject
> m
= new HashMap
<String
, XmlObject
>();
409 m
.put("ModuleSurfaceArea", msa
);
410 SurfaceAreaQuery
.setDoc(m
);
411 PackageIdentification
[] depPkgs
= SurfaceAreaQuery
.getDependencePkg(null, vMi
.get(i
));
412 PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry spdPcd
= LookupPcdDeclaration(msaPcd
, depPkgs
);
413 if (spdPcd
== null) {
417 throw new PcdDeclNotFound("No Declaration for PCD Entry " + msaPcd
.getCName() + " in Module "
421 // AddItem to ModuleSA PcdBuildDefinitions
423 String defaultVal
= msaPcd
.getDefaultValue() == null ? spdPcd
.getDefaultValue()
424 : msaPcd
.getDefaultValue();
426 genPcdData(msaPcd
.getCName(), spdPcd
.getToken(), msaPcd
.getTokenSpaceGuidCName(),
427 msaPcd
.getPcdItemType().toString(), spdPcd
.getDatumType() + "", defaultVal
, moduleSa
);
440 private void maintainDynPcdMap(String pcdKey
, String moduleInfo
) {
442 ArrayList
<String
> al
= dynPcdMap
.get(pcdKey
);
446 String
[] s
= moduleInfo
.split(" ");
447 for(int i
= 0; i
< al
.size(); ++i
){
448 String consumer
= al
.get(i
);
449 if (consumer
.contains(s
[0]) && consumer
.contains(s
[2])){
450 String
[] consumerPart
= consumer
.split(" ");
451 if (!consumerPart
[4].equals(s
[4])) {
459 if (al
.size() == 0) {
460 defaultPcdValue
.remove(pcdKey
);
461 dynPcdMap
.remove(pcdKey
);
462 String
[] s1
= pcdKey
.split(" ");
463 removeDynamicPcdBuildData(s1
[0], s1
[1]);
468 // key for ModuleSA : "ModuleGuid ModuleVer PackageGuid PackageVer Arch"
470 public int getPcdDataCount (int i
){
471 ModuleSADocument
.ModuleSA msa
= getModuleSA(i
);
473 if (msa
== null || msa
.getPcdBuildDefinition() == null || msa
.getPcdBuildDefinition().getPcdDataList() == null){
476 return msa
.getPcdBuildDefinition().getPcdDataList().size();
480 public void getPcdData (int i
, String
[][] saa
) {
481 ModuleSADocument
.ModuleSA msa
= getModuleSA(i
);
483 if (msa
== null || msa
.getPcdBuildDefinition() == null || msa
.getPcdBuildDefinition().getPcdDataList() == null){
486 ListIterator
<PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
>li
= msa
.getPcdBuildDefinition().getPcdDataList().listIterator();
487 for (int k
= 0; k
< saa
.length
; ++k
) {
488 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= li
.next();
489 saa
[k
][0] = pcdData
.getCName();
490 saa
[k
][1] = pcdData
.getTokenSpaceGuidCName();
491 saa
[k
][2] = pcdData
.getItemType()+"";
492 saa
[k
][3] = pcdData
.getToken().toString();
493 saa
[k
][4] = pcdData
.getMaxDatumSize()+"";
494 saa
[k
][5] = pcdData
.getDatumType()+"";
495 saa
[k
][6] = pcdData
.getValue();
500 public void removePcdData (int seqModuleSa
, String cName
, String tsGuid
) {
501 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(seqModuleSa
);
502 if (moduleSa
== null || moduleSa
.getPcdBuildDefinition() == null){
506 String mg
= moduleSa
.getModuleGuid();
507 String mv
= moduleSa
.getModuleVersion();
508 String pg
= moduleSa
.getPackageGuid();
509 String pv
= moduleSa
.getPackageVersion();
510 String arch
= listToString(moduleSa
.getSupArchList());
511 String moduleKey
= mg
+ " " + mv
+ " " + pg
+ " " + pv
+ " " + arch
;
513 XmlCursor cursor
= moduleSa
.getPcdBuildDefinition().newCursor();
514 if (cursor
.toFirstChild()){
517 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= (PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
)cursor
.getObject();
518 if (pcdData
.getCName().equals(cName
) && pcdData
.getTokenSpaceGuidCName().equals(tsGuid
)) {
519 maintainDynPcdMap(cName
+ " " + tsGuid
, moduleKey
);
520 if (getPcdDataCount(seqModuleSa
) == 1) {
527 while(cursor
.toNextSibling());
533 public void updatePcdData (String key
, String cName
, String tsGuid
, String itemType
, String maxSize
, String value
){
534 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(key
);
535 if (moduleSa
== null || moduleSa
.getPcdBuildDefinition() == null){
539 XmlCursor cursor
= moduleSa
.getPcdBuildDefinition().newCursor();
540 if (cursor
.toFirstChild()){
542 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= (PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
)cursor
.getObject();
543 if (pcdData
.getCName().equals(cName
) && pcdData
.getTokenSpaceGuidCName().equals(tsGuid
)) {
544 pcdData
.setItemType(PcdItemTypes
.Enum
.forString(itemType
));
545 if(pcdData
.getDatumType().equals("VOID*")) {
546 pcdData
.setMaxDatumSize(new Integer(maxSize
));
548 pcdData
.setValue(value
);
549 defaultPcdValue
.put(cName
+ " " + tsGuid
, value
);
553 while(cursor
.toNextSibling());
558 /**Get original Pcd info from MSA & SPD files.
559 * @param mi ModuleIdentification from which MSA & SPD come
560 * @param cName PCD cName
561 * @param sa Results: HelpText, Original item type.
564 public boolean getPcdBuildDataInfo(ModuleIdentification mi
, String cName
, String tsGuid
, String
[] sa
) throws Exception
{
567 ModuleSurfaceAreaDocument
.ModuleSurfaceArea msa
= (ModuleSurfaceAreaDocument
.ModuleSurfaceArea
)WorkspaceProfile
.getModuleXmlObject(mi
);
568 if (msa
.getPcdCoded() == null) {
572 Map
<String
, XmlObject
> m
= new HashMap
<String
, XmlObject
>();
573 m
.put("ModuleSurfaceArea", msa
);
574 SurfaceAreaQuery
.setDoc(m
);
575 PackageIdentification
[] depPkgs
= SurfaceAreaQuery
.getDependencePkg(null, mi
);
577 // First look through MSA pcd entries.
579 List
<PcdCodedDocument
.PcdCoded
.PcdEntry
> l
= msa
.getPcdCoded().getPcdEntryList();
580 ListIterator li
= l
.listIterator();
581 while(li
.hasNext()) {
582 PcdCodedDocument
.PcdCoded
.PcdEntry msaPcd
= (PcdCodedDocument
.PcdCoded
.PcdEntry
)li
.next();
583 if (!msaPcd
.getCName().equals(cName
)) {
586 if (!msaPcd
.getTokenSpaceGuidCName().equals(tsGuid
)) {
589 PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry spdPcd
= LookupPcdDeclaration(msaPcd
, depPkgs
);
590 if (spdPcd
== null) {
594 throw new PcdDeclNotFound(mi
.getName() + " " + msaPcd
.getCName());
597 // Get Pcd help text and original item type.
599 sa
[0] = spdPcd
.getHelpText() + msaPcd
.getHelpText();
600 sa
[1] = msaPcd
.getPcdItemType()+"";
614 /**Remove PCDBuildDefinition entries from ModuleSA
615 * @param moduleKey identifier of ModuleSA.
616 * @param consumer where these entries come from.
618 public void removePcdData(String moduleKey
, ModuleIdentification consumer
) {
620 ModuleSurfaceAreaDocument
.ModuleSurfaceArea msa
= (ModuleSurfaceAreaDocument
.ModuleSurfaceArea
)WorkspaceProfile
.getModuleXmlObject(consumer
);
621 if (msa
.getPcdCoded() == null) {
625 List
<PcdCodedDocument
.PcdCoded
.PcdEntry
> l
= msa
.getPcdCoded().getPcdEntryList();
626 ListIterator li
= l
.listIterator();
628 while(li
.hasNext()) {
629 PcdCodedDocument
.PcdCoded
.PcdEntry msaPcd
= (PcdCodedDocument
.PcdCoded
.PcdEntry
)li
.next();
630 ModuleSADocument
.ModuleSA moduleSA
= getModuleSA(moduleKey
);
631 if (moduleSA
.getPcdBuildDefinition() != null) {
632 XmlCursor cursor
= moduleSA
.getPcdBuildDefinition().newCursor();
633 if (cursor
.toFirstChild()) {
634 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= (PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
) cursor
636 if (msaPcd
.getCName().equals(pcdData
.getCName())
637 && msaPcd
.getTokenSpaceGuidCName().equals(pcdData
.getTokenSpaceGuidCName())) {
639 maintainDynPcdMap(pcdData
.getCName() + " " + pcdData
.getTokenSpaceGuidCName(), moduleKey
);
643 while (cursor
.toNextSibling()) {
644 pcdData
= (PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
) cursor
.getObject();
645 if (msaPcd
.getCName().equals(pcdData
.getCName())
646 && msaPcd
.getTokenSpaceGuidCName().equals(pcdData
.getTokenSpaceGuidCName())) {
647 maintainDynPcdMap(pcdData
.getCName() + " " + pcdData
.getTokenSpaceGuidCName(),
665 // key for ModuleSA : "ModuleGuid ModuleVer PackageGuid PackageVer Arch"
667 public int getLibraryInstancesCount(String key
) {
668 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
669 if (msa
== null || msa
.getLibraries() == null || msa
.getLibraries().getInstanceList() == null){
672 return msa
.getLibraries().getInstanceList().size();
675 public void getLibraryInstances(String key
, String
[][] saa
){
676 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
677 if (msa
== null || msa
.getLibraries() == null || msa
.getLibraries().getInstanceList() == null){
681 ListIterator
<LibrariesDocument
.Libraries
.Instance
> li
= msa
.getLibraries().getInstanceList().listIterator();
682 for (int i
= 0; i
< saa
.length
; ++i
) {
683 LibrariesDocument
.Libraries
.Instance instance
= li
.next();
684 saa
[i
][1] = instance
.getModuleGuid();
685 saa
[i
][2] = instance
.getModuleVersion();
686 saa
[i
][3] = instance
.getPackageGuid();
687 saa
[i
][4] = instance
.getPackageVersion();
691 public void removeLibraryInstance(String key
, int i
) {
692 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
693 if (msa
== null || msa
.getLibraries() == null){
697 XmlCursor cursor
= msa
.getLibraries().newCursor();
698 if (cursor
.toFirstChild()) {
699 for (int j
= 0; j
< i
; ++j
) {
700 cursor
.toNextSibling();
703 cursor
.toPrevToken();
704 if (cursor
.isComment()) {
709 if (getLibraryInstancesCount(key
) == 0) {
718 public void genLibraryInstance(ModuleIdentification libMi
, String key
) {
719 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
721 msa
= getfpdFrameworkModules().addNewModuleSA();
723 LibrariesDocument
.Libraries libs
= msa
.getLibraries();
725 libs
= msa
.addNewLibraries();
728 String mn
= libMi
.getName();
729 String mg
= libMi
.getGuid();
730 String mv
= libMi
.getVersion();
731 String pn
= libMi
.getPackageId().getName();
732 String pg
= libMi
.getPackageId().getGuid();
733 String pv
= libMi
.getPackageId().getVersion();
734 LibrariesDocument
.Libraries
.Instance instance
= libs
.addNewInstance();
735 XmlCursor cursor
= instance
.newCursor();
737 String comment
= "Pkg: " + pn
+ " Mod: " + mn
738 + " Path: " + libMi
.getPath().substring(System
.getenv("WORKSPACE").length() + 1);
739 cursor
.insertComment(comment
);
748 instance
.setModuleGuid(mg
);
749 instance
.setModuleVersion(mv
);
750 instance
.setPackageGuid(pg
);
751 instance
.setPackageVersion(pv
);
755 public String
getFvBinding(String moduleKey
){
756 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
757 if (msa
== null || msa
.getModuleSaBuildOptions() == null) {
760 return msa
.getModuleSaBuildOptions().getFvBinding();
763 public void setFvBinding(String moduleKey
, String fvBinding
){
764 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
768 if (fvBinding
== null || fvBinding
.length() == 0) {
769 if(msa
.getModuleSaBuildOptions() != null){
770 msa
.getModuleSaBuildOptions().unsetFvBinding();
774 if(msa
.getModuleSaBuildOptions() == null){
775 msa
.addNewModuleSaBuildOptions().setFvBinding(fvBinding
);
778 msa
.getModuleSaBuildOptions().setFvBinding(fvBinding
);
782 public String
getFfsFileNameGuid(String moduleKey
){
783 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
784 if (msa
== null || msa
.getModuleSaBuildOptions() == null) {
787 return msa
.getModuleSaBuildOptions().getFfsFileNameGuid();
790 public void setFfsFileNameGuid(String moduleKey
, String fileGuid
){
791 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
795 if(msa
.getModuleSaBuildOptions() == null){
796 msa
.addNewModuleSaBuildOptions();
799 ModuleSaBuildOptionsDocument
.ModuleSaBuildOptions msaBuildOpts
= msa
.getModuleSaBuildOptions();
800 if (fileGuid
!= null) {
801 msaBuildOpts
.setFfsFileNameGuid(fileGuid
);
804 XmlCursor cursor
= msaBuildOpts
.newCursor();
805 if (cursor
.toChild(xmlNs
, "FfsFileNameGuid")) {
813 public String
getFfsFormatKey(String moduleKey
){
814 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
815 if (msa
== null || msa
.getModuleSaBuildOptions() == null) {
818 return msa
.getModuleSaBuildOptions().getFfsFormatKey();
821 public void setFfsFormatKey(String moduleKey
, String ffsKey
){
822 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
826 if(msa
.getModuleSaBuildOptions() == null){
827 msa
.addNewModuleSaBuildOptions().setFfsFormatKey(ffsKey
);
830 msa
.getModuleSaBuildOptions().setFfsFormatKey(ffsKey
);
833 public void setModuleSAForceDebug(int i
, boolean dbgEnable
) {
834 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(i
);
835 moduleSa
.setForceDebug(dbgEnable
);
838 public boolean getModuleSAForceDebug (int i
) {
839 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(i
);
840 if (moduleSa
.getForceDebug() == true) {
846 public void getModuleSAOptions(String moduleKey
, String
[][] saa
) {
847 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
848 if (msa
== null || msa
.getModuleSaBuildOptions() == null || msa
.getModuleSaBuildOptions().getOptions() == null
849 || msa
.getModuleSaBuildOptions().getOptions().getOptionList() == null) {
853 List
<OptionDocument
.Option
> lOpt
= msa
.getModuleSaBuildOptions().getOptions().getOptionList();
854 ListIterator li
= lOpt
.listIterator();
856 while(li
.hasNext()) {
857 OptionDocument
.Option opt
= (OptionDocument
.Option
)li
.next();
858 if (opt
.getBuildTargets() != null) {
859 saa
[i
][0] = listToString(opt
.getBuildTargets());
861 saa
[i
][1] = opt
.getToolChainFamily();
862 saa
[i
][2] = opt
.getTagName();
863 saa
[i
][3] = opt
.getToolCode();
865 if (opt
.getSupArchList() != null){
866 saa
[i
][4] = listToString(opt
.getSupArchList());
870 saa
[i
][5] = opt
.getStringValue();
876 public int getModuleSAOptionsCount(String moduleKey
){
877 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
878 if (msa
== null || msa
.getModuleSaBuildOptions() == null || msa
.getModuleSaBuildOptions().getOptions() == null
879 || msa
.getModuleSaBuildOptions().getOptions().getOptionList() == null) {
882 return msa
.getModuleSaBuildOptions().getOptions().getOptionList().size();
885 public void genModuleSAOptionsOpt(String moduleKey
, Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
) {
886 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
887 if (msa
.getModuleSaBuildOptions() == null) {
888 msa
.addNewModuleSaBuildOptions();
890 if (msa
.getModuleSaBuildOptions().getOptions() == null){
891 msa
.getModuleSaBuildOptions().addNewOptions();
893 OptionDocument
.Option opt
= msa
.getModuleSaBuildOptions().getOptions().addNewOption();
894 setBuildOptionsOpt(buildTargets
, toolChain
, tagName
, toolCmd
, archList
, contents
, opt
);
897 public void removeModuleSAOptionsOpt(String moduleKey
, int i
) {
898 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
899 if (msa
.getModuleSaBuildOptions() == null || msa
.getModuleSaBuildOptions().getOptions() == null) {
902 OptionsDocument
.Options opts
= msa
.getModuleSaBuildOptions().getOptions();
903 XmlCursor cursor
= opts
.newCursor();
904 if (cursor
.toFirstChild()) {
905 for (int j
= 0; j
< i
; ++j
){
906 cursor
.toNextSibling();
913 public void updateModuleSAOptionsOpt(String moduleKey
, int i
, Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
) {
914 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
915 if (msa
.getModuleSaBuildOptions() == null || msa
.getModuleSaBuildOptions().getOptions() == null) {
918 OptionsDocument
.Options opts
= msa
.getModuleSaBuildOptions().getOptions();
919 XmlCursor cursor
= opts
.newCursor();
920 if (cursor
.toFirstChild()) {
921 for (int j
= 0; j
< i
; ++j
){
922 cursor
.toNextSibling();
924 OptionDocument
.Option opt
= (OptionDocument
.Option
)cursor
.getObject();
925 setBuildOptionsOpt(buildTargets
, toolChain
, tagName
, toolCmd
, archList
, contents
, opt
);
930 /**add pcd information of module mi to a ModuleSA.
932 * @param moduleSa if null, generate a new ModuleSA.
934 public void addFrameworkModulesPcdBuildDefs(ModuleIdentification mi
, String arch
, ModuleSADocument
.ModuleSA moduleSa
) throws Exception
{
935 //ToDo add Arch filter
938 if (moduleSa
== null) {
939 moduleSa
= genModuleSA(mi
, arch
);
942 ModuleSurfaceAreaDocument
.ModuleSurfaceArea msa
= (ModuleSurfaceAreaDocument
.ModuleSurfaceArea
)WorkspaceProfile
.getModuleXmlObject(mi
);
943 if (msa
.getPcdCoded() == null) {
947 Map
<String
, XmlObject
> m
= new HashMap
<String
, XmlObject
>();
948 m
.put("ModuleSurfaceArea", msa
);
949 SurfaceAreaQuery
.setDoc(m
);
950 PackageIdentification
[] depPkgs
= SurfaceAreaQuery
.getDependencePkg(null, mi
);
952 // Implementing InitializePlatformPcdBuildDefinitions
954 List
<PcdCodedDocument
.PcdCoded
.PcdEntry
> l
= msa
.getPcdCoded().getPcdEntryList();
955 ListIterator li
= l
.listIterator();
956 while(li
.hasNext()) {
957 PcdCodedDocument
.PcdCoded
.PcdEntry msaPcd
= (PcdCodedDocument
.PcdCoded
.PcdEntry
)li
.next();
958 PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry spdPcd
= LookupPcdDeclaration(msaPcd
, depPkgs
);
959 if (spdPcd
== null) {
963 throw new PcdDeclNotFound("No Declaration for PCD Entry " + msaPcd
.getCName() + " in Module " + mi
.getName());
966 // AddItem to ModuleSA PcdBuildDefinitions
968 String defaultVal
= msaPcd
.getDefaultValue() == null ? spdPcd
.getDefaultValue() : msaPcd
.getDefaultValue();
970 genPcdData(msaPcd
.getCName(), spdPcd
.getToken(), msaPcd
.getTokenSpaceGuidCName(), msaPcd
.getPcdItemType().toString(), spdPcd
.getDatumType()+"", defaultVal
, moduleSa
);
981 private PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry
LookupPcdDeclaration (PcdCodedDocument
.PcdCoded
.PcdEntry msaPcd
, PackageIdentification
[] depPkgs
) {
983 PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry spdPcd
= null;
984 for (int i
= 0; i
< depPkgs
.length
; ++i
) {
986 XmlObject
[] xo
= SurfaceAreaQuery
.getSpdPcdDeclarations(depPkgs
[i
]);
990 for (int j
= 0; j
< xo
.length
; ++j
) {
991 spdPcd
= (PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry
)xo
[j
];
992 if (msaPcd
.getTokenSpaceGuidCName() == null) {
993 if (spdPcd
.getCName().equals(msaPcd
.getCName())) {
998 if (spdPcd
.getCName().equals(msaPcd
.getCName()) && spdPcd
.getTokenSpaceGuidCName().equals(msaPcd
.getTokenSpaceGuidCName())) {
1009 private ModuleSADocument
.ModuleSA
genModuleSA (ModuleIdentification mi
, String arch
) {
1010 PackageIdentification pi
= WorkspaceProfile
.getPackageForModule(mi
);
1011 ModuleSADocument
.ModuleSA msa
= getfpdFrameworkModules().addNewModuleSA();
1012 XmlCursor cursor
= msa
.newCursor();
1014 String comment
= "Mod: " + mi
.getName() + " Type: " + SurfaceAreaQuery
.getModuleType(mi
) + " Path: "
1015 + mi
.getPath().substring(System
.getenv("WORKSPACE").length() + 1);
1016 cursor
.insertComment(comment
);
1019 e
.printStackTrace();
1024 msa
.setModuleGuid(mi
.getGuid());
1025 msa
.setModuleVersion(mi
.getVersion());
1026 msa
.setPackageGuid(pi
.getGuid());
1027 msa
.setPackageVersion(pi
.getVersion());
1029 Vector
<String
> v
= new Vector
<String
>();
1031 msa
.setSupArchList(v
);
1037 private void genPcdData (String cName
, Object token
, String tsGuid
, String itemType
, String dataType
, String defaultVal
, ModuleSADocument
.ModuleSA moduleSa
)
1038 throws PcdItemTypeConflictException
, PcdValueMalFormed
{
1039 if (moduleSa
.getPcdBuildDefinition() == null){
1040 moduleSa
.addNewPcdBuildDefinition();
1043 // constructe pcd to modulesa mapping first.
1044 // Attention : for any error condition, remove from map this pcd.
1046 ArrayList
<String
> pcdConsumer
= LookupPlatformPcdData(cName
+ " " + tsGuid
);
1047 if (pcdConsumer
== null) {
1048 pcdConsumer
= new ArrayList
<String
>();
1051 // Using existing Pcd type, if this pcd already exists in other ModuleSA
1053 if (pcdConsumer
.size() > 0) {
1054 String
[] valPart
= pcdConsumer
.get(0).split(" ");
1055 itemType
= valPart
[5];
1057 String listValue
= moduleSa
.getModuleGuid() + " " + moduleSa
.getModuleVersion()
1058 + " " + moduleSa
.getPackageGuid() + " " + moduleSa
.getPackageVersion() + " " + listToString(moduleSa
.getSupArchList())
1060 pcdConsumer
.add(listValue
);
1061 dynPcdMap
.put(cName
+ " " + tsGuid
, pcdConsumer
);
1063 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData fpdPcd
= moduleSa
.getPcdBuildDefinition().addNewPcdData();
1064 fpdPcd
.setCName(cName
);
1065 fpdPcd
.setToken(token
);
1066 fpdPcd
.setTokenSpaceGuidCName(tsGuid
);
1067 fpdPcd
.setDatumType(PcdDataTypes
.Enum
.forString(dataType
));
1068 fpdPcd
.setItemType(PcdItemTypes
.Enum
.forString(itemType
));
1070 if (defaultVal
!= null){
1071 fpdPcd
.setValue(defaultVal
);
1074 if (dataType
.equals("UINT8") || dataType
.equals("UINT16") || dataType
.equals("UINT32") || dataType
.equals("UINT64")) {
1075 fpdPcd
.setValue("0");
1077 if (dataType
.equals("BOOLEAN")){
1078 fpdPcd
.setValue("false");
1080 if (dataType
.equals("VOID*")) {
1081 fpdPcd
.setValue("");
1085 // Using existing pcd value, if this pcd already exists in other moduleSa.
1087 if (defaultPcdValue
.get(cName
+ " " + tsGuid
) == null) {
1088 defaultPcdValue
.put(cName
+ " " + tsGuid
, fpdPcd
.getValue());
1091 fpdPcd
.setValue(defaultPcdValue
.get(cName
+ " " + tsGuid
));
1094 if (dataType
.equals("UINT8")){
1095 fpdPcd
.setMaxDatumSize(1);
1097 if (dataType
.equals("UINT16")) {
1098 fpdPcd
.setMaxDatumSize(2);
1100 if (dataType
.equals("UINT32")) {
1101 fpdPcd
.setMaxDatumSize(4);
1103 if (dataType
.equals("UINT64")){
1104 fpdPcd
.setMaxDatumSize(8);
1106 if (dataType
.equals("BOOLEAN")){
1107 fpdPcd
.setMaxDatumSize(1);
1109 if (dataType
.equals("VOID*")) {
1110 int maxSize
= setMaxSizeForPointer(fpdPcd
.getValue());
1111 fpdPcd
.setMaxDatumSize(maxSize
);
1115 if (itemType
.equals("DYNAMIC") || itemType
.equals("DYNAMIC_EX")) {
1116 ArrayList
<String
> al
= LookupDynamicPcdBuildDefinition(cName
+ " " + tsGuid
);
1118 // if only one module mapped to this pcd, then the one is myself. so no other module mapped.
1119 // so need to add one dyn pcd.
1121 if (al
.size() == 1) {
1122 addDynamicPcdBuildData(cName
, token
, tsGuid
, itemType
, dataType
, defaultVal
);
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 must be a byte array. 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 genBuildOptionsUserExtensions(String fvName
, String outputFileName
, String
[][] includeModules
) {
1533 UserExtensionsDocument
.UserExtensions userExts
= getfpdBuildOpts().addNewUserExtensions();
1534 userExts
.setUserID("IMAGES");
1535 userExts
.setIdentifier(new BigInteger("1"));
1536 XmlCursor cursor
= userExts
.newCursor();
1537 cursor
.toEndToken();
1539 cursor
.beginElement("FvName");
1540 cursor
.insertChars(fvName
);
1541 cursor
.toNextToken();
1543 cursor
.beginElement("InfFileName");
1544 cursor
.insertChars(fvName
+ ".inf");
1545 cursor
.toNextToken();
1547 cursor
.beginElement("IncludeModules");
1548 for (int i
= 0; i
< includeModules
.length
; ++i
) {
1549 cursor
.beginElement("Module");
1550 cursor
.insertAttributeWithValue("ModuleGuid", includeModules
[i
][0]);
1551 cursor
.insertAttributeWithValue("BaseName", includeModules
[i
][1]);
1552 cursor
.toEndToken();
1553 cursor
.toNextToken();
1558 public int getUserExtsIncModCount (String fvName
) {
1559 if (getfpdBuildOpts().getUserExtensionsList() == null) {
1562 ListIterator
<UserExtensionsDocument
.UserExtensions
> li
= getfpdBuildOpts().getUserExtensionsList().listIterator();
1563 while (li
.hasNext()) {
1564 UserExtensionsDocument
.UserExtensions ues
= li
.next();
1565 if (!ues
.getUserID().equals("IMAGES")) {
1568 XmlCursor cursor
= ues
.newCursor();
1569 cursor
.toFirstChild();
1570 String elementName
= cursor
.getTextValue();
1571 if (elementName
.equals(fvName
)) {
1572 cursor
.toNextSibling(new QName("", "IncludeModules"));
1573 if (cursor
.toFirstChild()) {
1575 for (i
= 1; cursor
.toNextSibling(); ++i
);
1587 public void getUserExtsIncMods(String fvName
, String
[][] saa
) {
1588 if (getfpdBuildOpts().getUserExtensionsList() == null) {
1591 ListIterator
<UserExtensionsDocument
.UserExtensions
> li
= getfpdBuildOpts().getUserExtensionsList().listIterator();
1592 while (li
.hasNext()) {
1593 UserExtensionsDocument
.UserExtensions ues
= li
.next();
1594 if (!ues
.getUserID().equals("IMAGES")) {
1597 XmlCursor cursor
= ues
.newCursor();
1598 cursor
.toFirstChild();
1599 String elementName
= cursor
.getTextValue();
1600 if (elementName
.equals(fvName
)) {
1601 cursor
.toNextSibling(new QName("", "IncludeModules"));
1602 if (cursor
.toFirstChild()) {
1605 saa
[i
][0] = cursor
.getAttributeText(new QName("ModuleGuid"));
1606 saa
[i
][1] = cursor
.getAttributeText(new QName("BaseName"));
1608 }while (cursor
.toNextSibling());
1618 public void removeBuildOptionsUserExtensions (String fvName
) {
1619 if (getfpdBuildOpts().getUserExtensionsList() == null) {
1623 ListIterator
<UserExtensionsDocument
.UserExtensions
> li
= getfpdBuildOpts().getUserExtensionsList().listIterator();
1624 while (li
.hasNext()) {
1625 UserExtensionsDocument
.UserExtensions ues
= li
.next();
1626 if (!ues
.getUserID().equals("IMAGES")) {
1629 XmlCursor cursor
= ues
.newCursor();
1630 cursor
.toFirstChild();
1631 String elementName
= cursor
.getTextValue();
1632 if (elementName
.equals(fvName
)) {
1644 public void genBuildOptionsUserDefAntTask (String id
, String fileName
, String execOrder
) {
1645 UserDefinedAntTasksDocument
.UserDefinedAntTasks udats
= getfpdBuildOpts().getUserDefinedAntTasks();
1646 if (udats
== null) {
1647 udats
= getfpdBuildOpts().addNewUserDefinedAntTasks();
1650 AntTaskDocument
.AntTask at
= udats
.addNewAntTask();
1651 setBuildOptionsUserDefAntTask(id
, fileName
, execOrder
, at
);
1654 private void setBuildOptionsUserDefAntTask(String id
, String fileName
, String execOrder
, AntTaskDocument
.AntTask at
) {
1655 at
.setId(new Integer(id
));
1656 XmlCursor cursor
= at
.newCursor();
1657 if (fileName
!= null){
1658 at
.setFilename(fileName
);
1660 else if (cursor
.toChild(xmlNs
, "Filename")) {
1663 if (execOrder
!= null) {
1664 at
.setAntCmdOptions(execOrder
);
1666 else if (cursor
.toChild(xmlNs
, "AntCmdOptions")) {
1672 public void removeBuildOptionsUserDefAntTask(int i
) {
1673 XmlObject o
= getfpdBuildOpts().getUserDefinedAntTasks();
1677 XmlCursor cursor
= o
.newCursor();
1678 if (cursor
.toFirstChild()) {
1679 for (int j
= 0; j
< i
; ++j
) {
1680 cursor
.toNextSibling();
1683 if (getBuildOptionsUserDefAntTaskCount() == 0) {
1691 public void updateBuildOptionsUserDefAntTask(int i
, String id
, String fileName
, String execOrder
){
1692 XmlObject o
= getfpdBuildOpts().getUserDefinedAntTasks();
1696 XmlCursor cursor
= o
.newCursor();
1697 if (cursor
.toFirstChild()) {
1698 for (int j
= 0; j
< i
; ++j
) {
1699 cursor
.toNextSibling();
1701 AntTaskDocument
.AntTask at
= (AntTaskDocument
.AntTask
)cursor
.getObject();
1702 setBuildOptionsUserDefAntTask(id
, fileName
, execOrder
, at
);
1707 public int getBuildOptionsUserDefAntTaskCount() {
1708 UserDefinedAntTasksDocument
.UserDefinedAntTasks udats
= getfpdBuildOpts().getUserDefinedAntTasks();
1709 if (udats
== null || udats
.getAntTaskList() == null) {
1713 return udats
.getAntTaskList().size();
1716 public void getBuildOptionsUserDefAntTasks(String
[][] saa
) {
1717 UserDefinedAntTasksDocument
.UserDefinedAntTasks udats
= getfpdBuildOpts().getUserDefinedAntTasks();
1718 if (udats
== null || udats
.getAntTaskList() == null) {
1722 List
<AntTaskDocument
.AntTask
> l
= udats
.getAntTaskList();
1723 ListIterator li
= l
.listIterator();
1725 while (li
.hasNext()) {
1726 AntTaskDocument
.AntTask at
= (AntTaskDocument
.AntTask
)li
.next();
1727 saa
[i
][0] = at
.getId() + "";
1728 saa
[i
][1] = saa
[i
][2] = "";
1729 if (at
.getFilename() != null){
1730 saa
[i
][1] = at
.getFilename();
1732 if (at
.getAntCmdOptions() != null) {
1733 saa
[i
][2] = at
.getAntCmdOptions();
1738 public void genBuildOptionsOpt(Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
) {
1739 OptionsDocument
.Options opts
= getfpdBuildOpts().getOptions();
1741 opts
= getfpdBuildOpts().addNewOptions();
1743 OptionDocument
.Option opt
= opts
.addNewOption();
1744 setBuildOptionsOpt(buildTargets
, toolChain
, tagName
, toolCmd
, archList
, contents
, opt
);
1747 private void setBuildOptionsOpt(Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
, OptionDocument
.Option opt
){
1748 opt
.setStringValue(contents
);
1750 opt
.setBuildTargets(buildTargets
);
1751 opt
.setToolChainFamily(toolChain
);
1752 opt
.setTagName(tagName
);
1753 opt
.setToolCode(toolCmd
);
1755 if (archList
!= null) {
1756 opt
.setSupArchList(archList
);
1759 if (opt
.isSetSupArchList()) {
1760 opt
.unsetSupArchList();
1765 public void removeBuildOptionsOpt(int i
){
1767 XmlObject o
= getfpdBuildOpts().getOptions();
1772 XmlCursor cursor
= o
.newCursor();
1773 if (cursor
.toFirstChild()) {
1774 for (int j
= 0; j
< i
; ++j
) {
1775 cursor
.toNextSibling();
1778 if (getBuildOptionsOptCount() == 0) {
1786 public void updateBuildOptionsOpt(int i
, Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
) {
1787 XmlObject o
= getfpdBuildOpts().getOptions();
1792 XmlCursor cursor
= o
.newCursor();
1793 if (cursor
.toFirstChild()) {
1794 for (int j
= 0; j
< i
; ++j
) {
1795 cursor
.toNextSibling();
1797 OptionDocument
.Option opt
= (OptionDocument
.Option
)cursor
.getObject();
1798 setBuildOptionsOpt(buildTargets
, toolChain
, tagName
, toolCmd
, archList
, contents
, opt
);
1803 public int getBuildOptionsOptCount(){
1804 if (getfpdBuildOpts().getOptions() == null || getfpdBuildOpts().getOptions().getOptionList() == null) {
1807 return getfpdBuildOpts().getOptions().getOptionList().size();
1810 public void getBuildOptionsOpts(String
[][] saa
) {
1811 if (getfpdBuildOpts().getOptions() == null || getfpdBuildOpts().getOptions().getOptionList() == null) {
1815 List
<OptionDocument
.Option
> lOpt
= getfpdBuildOpts().getOptions().getOptionList();
1816 ListIterator li
= lOpt
.listIterator();
1818 while(li
.hasNext()) {
1819 OptionDocument
.Option opt
= (OptionDocument
.Option
)li
.next();
1820 if (opt
.getBuildTargets() != null) {
1821 saa
[i
][0] = listToString(opt
.getBuildTargets());
1823 saa
[i
][1] = opt
.getToolChainFamily();
1824 if (opt
.getSupArchList() != null){
1825 saa
[i
][2] = listToString(opt
.getSupArchList());
1828 saa
[i
][3] = opt
.getToolCode();
1829 saa
[i
][4] = opt
.getTagName();
1830 saa
[i
][5] = opt
.getStringValue();
1836 public void genBuildOptionsFfs(String ffsKey
, String type
) {
1837 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getfpdBuildOpts().addNewFfs();
1838 ffs
.setFfsKey(ffsKey
);
1840 ffs
.addNewSections().setEncapsulationType(type
);
1844 public void updateBuildOptionsFfsSectionsType(int i
, String type
) {
1845 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getfpdBuildOpts().addNewFfs();
1847 ffs
.addNewSections().setEncapsulationType(type
);
1851 public void genBuildOptionsFfsAttribute(int i
, String name
, String value
) {
1852 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1853 BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute attrib
= ffs
.addNewAttribute();
1854 attrib
.setName(name
);
1855 attrib
.setValue(value
);
1858 /**update jth attribute of ith ffs.
1862 public void updateBuildOptionsFfsAttribute(int i
, int j
, String name
, String value
){
1863 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1864 XmlCursor cursor
= ffs
.newCursor();
1865 QName qAttrib
= new QName(xmlNs
, "Attribute");
1866 if (cursor
.toChild(qAttrib
)) {
1867 for (int k
= 0; k
< j
; ++k
) {
1868 cursor
.toNextSibling(qAttrib
);
1870 BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute attrib
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute
)cursor
.getObject();
1871 attrib
.setName(name
);
1872 attrib
.setValue(value
);
1877 public void removeBuildOptionsFfsAttribute(int i
, int j
){
1878 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1879 XmlCursor cursor
= ffs
.newCursor();
1880 QName qAttrib
= new QName(xmlNs
, "Attribute");
1881 if (cursor
.toChild(qAttrib
)) {
1882 for (int k
= 0; k
< j
; ++k
) {
1883 cursor
.toNextSibling(qAttrib
);
1890 public void genBuildOptionsFfsSectionsSection(int i
, String sectionType
) {
1891 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1895 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1897 if (sections
== null){
1898 sections
= ffs
.addNewSections();
1900 sections
.addNewSection().setSectionType(EfiSectionType
.Enum
.forString(sectionType
));
1903 public void removeBuildOptionsFfsSectionsSection(int i
, int j
) {
1904 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1905 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1906 if (sections
== null) {
1909 XmlCursor cursor
= sections
.newCursor();
1910 QName qSection
= new QName(xmlNs
, "Section");
1911 if (cursor
.toChild(qSection
)) {
1912 for (int k
= 0; k
< j
; ++k
) {
1913 cursor
.toNextSibling(qSection
);
1920 public void updateBuildOptionsFfsSectionsSection(int i
, int j
, String type
){
1921 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1922 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1923 if (sections
== null) {
1926 XmlCursor cursor
= sections
.newCursor();
1927 QName qSection
= new QName(xmlNs
, "Section");
1928 if (cursor
.toChild(qSection
)) {
1929 for (int k
= 0; k
< j
; ++k
) {
1930 cursor
.toNextSibling(qSection
);
1932 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Section section
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Section
)cursor
.getObject();
1933 section
.setSectionType(EfiSectionType
.Enum
.forString(type
));
1938 public void genBuildOptionsFfsSectionsSections(int i
, String encapType
) {
1939 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1943 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1945 if (sections
== null){
1946 sections
= ffs
.addNewSections();
1948 sections
.addNewSections().setEncapsulationType(encapType
);
1951 public void removeBuildOptionsFfsSectionsSections(int i
, int j
) {
1952 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1953 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1954 if (sections
== null) {
1957 XmlCursor cursor
= sections
.newCursor();
1958 QName qSections
= new QName(xmlNs
, "Sections");
1959 if (cursor
.toChild(qSections
)) {
1960 for (int k
= 0; k
< j
; ++k
) {
1961 cursor
.toNextSibling(qSections
);
1968 public void updateBuildOptionsFfsSectionsSections(int i
, int j
, String type
) {
1969 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1970 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1971 if (sections
== null) {
1974 XmlCursor cursor
= sections
.newCursor();
1975 QName qSections
= new QName(xmlNs
, "Sections");
1976 if (cursor
.toChild(qSections
)) {
1977 for (int k
= 0; k
< j
; ++k
) {
1978 cursor
.toNextSibling(qSections
);
1980 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2 sections2
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
)cursor
.getObject();
1981 sections2
.setEncapsulationType(type
);
1986 public void genBuildOptionsFfsSectionsSectionsSection(int i
, int j
, String type
) {
1987 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1991 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1992 XmlCursor cursor
= sections
.newCursor();
1993 QName qSections
= new QName(xmlNs
, "Sections");
1994 if (cursor
.toChild(qSections
)){
1995 for (int k
= 0; k
< j
; ++k
) {
1996 cursor
.toNextSibling(qSections
);
1998 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2 sections2
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
)cursor
.getObject();
1999 sections2
.addNewSection().setSectionType(EfiSectionType
.Enum
.forString(type
));
2004 public void removeBuildOptionsFfsSectionsSectionsSection(int i
, int j
, int k
) {
2005 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2006 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2007 if (sections
== null) {
2010 XmlCursor cursor
= sections
.newCursor();
2011 QName qSections
= new QName(xmlNs
, "Sections");
2012 if (cursor
.toChild(qSections
)) {
2013 for (int l
= 0; l
< j
; ++l
) {
2014 cursor
.toNextSibling(qSections
);
2016 if (cursor
.toFirstChild()) {
2018 for (; m
< k
; ++m
) {
2019 cursor
.toNextSibling();
2031 public void updateBuildOptionsFfsSectionsSectionsSection(int i
, int j
, int k
, String type
) {
2032 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2033 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2034 if (sections
== null) {
2037 XmlCursor cursor
= sections
.newCursor();
2038 QName qSections
= new QName(xmlNs
, "Sections");
2039 if (cursor
.toChild(qSections
)) {
2040 for (int l
= 0; l
< j
; ++l
) {
2041 cursor
.toNextSibling(qSections
);
2043 if (cursor
.toFirstChild()) {
2044 for (int m
= 0; m
< k
; ++m
) {
2045 cursor
.toNextSibling();
2047 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section section
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section
)cursor
.getObject();
2048 section
.setSectionType(EfiSectionType
.Enum
.forString(type
));
2054 public void getBuildOptionsFfsSectionsSectionsSection(int i
, int j
, ArrayList
<String
> al
) {
2055 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2059 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2060 XmlCursor cursor
= sections
.newCursor();
2061 QName qSections
= new QName(xmlNs
, "Sections");
2062 if (cursor
.toChild(qSections
)){
2063 for (int k
= 0; k
< j
; ++k
) {
2064 cursor
.toNextSibling(qSections
);
2066 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2 sections2
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
)cursor
.getObject();
2067 if (sections2
.getSectionList() == null){
2071 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section
> li
= sections2
.getSectionList().listIterator();
2072 while(li
.hasNext()) {
2073 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section section
= li
.next();
2074 if (section
.isSetSectionType()) {
2075 al
.add(section
.getSectionType().toString());
2084 public int getBuildOptionsFfsCount(){
2085 if (getfpdBuildOpts().getFfsList() == null) {
2088 return getfpdBuildOpts().getFfsList().size();
2091 public void getBuildOptionsFfsKey(String
[][] saa
) {
2092 if (getfpdBuildOpts().getFfsList() == null) {
2095 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
> li
= getfpdBuildOpts().getFfsList().listIterator();
2097 while(li
.hasNext()){
2098 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= li
.next();
2099 saa
[i
][0] = ffs
.getFfsKey();
2104 public void updateBuildOptionsFfsKey(int i
, String key
) {
2105 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2109 /**Get ith FFS key and contents.
2112 public void getBuildOptionsFfs(int i
, String
[] sa
, LinkedHashMap
<String
, String
> ffsAttribMap
, ArrayList
<String
> firstLevelSections
, ArrayList
<String
> firstLevelSection
) {
2113 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2117 sa
[0] = ffs
.getFfsKey();
2118 if (ffs
.getSections() != null) {
2119 if(ffs
.getSections().getEncapsulationType() != null){
2120 sa
[1] = ffs
.getSections().getEncapsulationType();
2122 if (ffs
.getSections().getSectionList() != null){
2123 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Section
> li
= ffs
.getSections().getSectionList().listIterator();
2124 while (li
.hasNext()) {
2125 firstLevelSection
.add(li
.next().getSectionType().toString());
2128 if (ffs
.getSections().getSectionsList() != null) {
2129 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
> li
= ffs
.getSections().getSectionsList().listIterator();
2130 while(li
.hasNext()) {
2131 firstLevelSections
.add(li
.next().getEncapsulationType());
2135 if (ffs
.getAttributeList() != null) {
2136 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute
> li
= ffs
.getAttributeList().listIterator();
2137 while(li
.hasNext()) {
2138 BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute attrib
= li
.next();
2139 ffsAttribMap
.put(attrib
.getName(), attrib
.getValue());
2148 private BuildOptionsDocument
.BuildOptions
.Ffs
getFfs(int i
) {
2149 XmlObject o
= getfpdBuildOpts();
2150 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= null;
2152 XmlCursor cursor
= o
.newCursor();
2153 QName qFfs
= new QName(xmlNs
, "Ffs");
2154 if (cursor
.toChild(qFfs
)) {
2155 for (int j
= 0; j
< i
; ++j
) {
2156 cursor
.toNextSibling(qFfs
);
2158 ffs
= (BuildOptionsDocument
.BuildOptions
.Ffs
)cursor
.getObject();
2164 public void removeBuildOptionsFfs(int i
) {
2165 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2170 XmlCursor cursor
= ffs
.newCursor();
2177 public PlatformDefinitionsDocument
.PlatformDefinitions
getfpdPlatformDefs(){
2178 if (fpdPlatformDefs
== null){
2179 fpdPlatformDefs
= fpdRoot
.addNewPlatformDefinitions();
2181 return fpdPlatformDefs
;
2184 public void getPlatformDefsSupportedArchs(Vector
<Object
> archs
){
2185 if (getfpdPlatformDefs().getSupportedArchitectures() == null) {
2188 ListIterator li
= getfpdPlatformDefs().getSupportedArchitectures().listIterator();
2189 while(li
.hasNext()) {
2190 archs
.add(li
.next());
2194 public void setPlatformDefsSupportedArchs(Vector
<Object
> archs
) {
2195 if (archs
!= null) {
2196 getfpdPlatformDefs().setSupportedArchitectures(archs
);
2199 // XmlCursor cursor = getfpdPlatformDefs().newCursor();
2200 // if (cursor.toChild(xmlNs, "SupportedArchitectures")) {
2201 // cursor.removeXml();
2203 // cursor.dispose();
2207 public void getPlatformDefsBuildTargets(Vector
<Object
> targets
) {
2208 if (getfpdPlatformDefs().getBuildTargets() == null) {
2211 ListIterator li
= getfpdPlatformDefs().getBuildTargets().listIterator();
2212 while(li
.hasNext()) {
2213 targets
.add(li
.next());
2217 public void setPlatformDefsBuildTargets(Vector
<Object
> targets
) {
2218 getfpdPlatformDefs().setBuildTargets(targets
);
2221 public void genPlatformDefsSkuInfo(String id
, String name
) {
2222 SkuInfoDocument
.SkuInfo skuInfo
= null;
2223 if (getfpdPlatformDefs().getSkuInfo() == null) {
2224 skuInfo
= getfpdPlatformDefs().addNewSkuInfo();
2226 skuInfo
= getfpdPlatformDefs().getSkuInfo();
2227 if (skuInfo
.getUiSkuNameList() == null || skuInfo
.getUiSkuNameList().size() == 0) {
2228 SkuInfoDocument
.SkuInfo
.UiSkuName skuName
= skuInfo
.addNewUiSkuName();
2229 skuName
.setSkuID(new BigInteger("0"));
2230 skuName
.setStringValue("DEFAULT");
2232 if (id
.equals("0")) {
2235 SkuInfoDocument
.SkuInfo
.UiSkuName skuName
= skuInfo
.addNewUiSkuName();
2236 skuName
.setSkuID(new BigInteger(id
));
2237 skuName
.setStringValue(name
);
2240 public int getPlatformDefsSkuInfoCount(){
2241 if (getfpdPlatformDefs().getSkuInfo() == null || getfpdPlatformDefs().getSkuInfo().getUiSkuNameList() == null) {
2244 return getfpdPlatformDefs().getSkuInfo().getUiSkuNameList().size();
2247 public void getPlatformDefsSkuInfos(String
[][] saa
){
2248 if (getfpdPlatformDefs().getSkuInfo() == null || getfpdPlatformDefs().getSkuInfo().getUiSkuNameList() == null) {
2249 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null) {
2250 removeElement(getfpdDynPcdBuildDefs());
2251 fpdDynPcdBuildDefs
= null;
2256 List
<SkuInfoDocument
.SkuInfo
.UiSkuName
> l
= getfpdPlatformDefs().getSkuInfo().getUiSkuNameList();
2257 ListIterator
<SkuInfoDocument
.SkuInfo
.UiSkuName
> li
= l
.listIterator();
2259 while(li
.hasNext()) {
2260 SkuInfoDocument
.SkuInfo
.UiSkuName sku
= li
.next();
2261 saa
[i
][0] = sku
.getSkuID()+"";
2262 saa
[i
][1] = sku
.getStringValue();
2267 public void removePlatformDefsSkuInfo(int i
) {
2268 SkuInfoDocument
.SkuInfo skuInfo
= getfpdPlatformDefs().getSkuInfo();
2269 if (skuInfo
== null || i
== 0) {
2273 XmlCursor cursor
= skuInfo
.newCursor();
2274 if (cursor
.toFirstChild()) {
2275 for (int j
= 0; j
< i
; ++j
) {
2276 cursor
.toNextSibling();
2283 public void updatePlatformDefsSkuInfo(int i
, String id
, String name
) {
2284 SkuInfoDocument
.SkuInfo skuInfo
= getfpdPlatformDefs().getSkuInfo();
2285 if (skuInfo
== null || i
== 0) {
2289 XmlCursor cursor
= skuInfo
.newCursor();
2290 if (cursor
.toFirstChild()) {
2291 for (int j
= 0; j
< i
; ++j
) {
2292 cursor
.toNextSibling();
2294 SkuInfoDocument
.SkuInfo
.UiSkuName sku
= (SkuInfoDocument
.SkuInfo
.UiSkuName
)cursor
.getObject();
2295 sku
.setSkuID(new BigInteger(id
));
2296 sku
.setStringValue(name
);
2301 public String
getPlatformDefsInterDir(){
2302 if (getfpdPlatformDefs().getIntermediateDirectories() == null) {
2305 return getfpdPlatformDefs().getIntermediateDirectories().toString();
2308 public void setPlatformDefsInterDir(String interDir
){
2309 getfpdPlatformDefs().setIntermediateDirectories(IntermediateOutputType
.Enum
.forString(interDir
));
2312 public String
getPlatformDefsOutputDir() {
2313 return getfpdPlatformDefs().getOutputDirectory();
2316 public void setPlatformDefsOutputDir(String outputDir
) {
2317 if (outputDir
!= null && outputDir
.length() > 0) {
2318 getfpdPlatformDefs().setOutputDirectory(outputDir
);
2321 XmlCursor cursor
= getfpdPlatformDefs().newCursor();
2322 if (cursor
.toChild(new QName(xmlNs
, "OutputDirectory"))) {
2329 public FlashDocument
.Flash
getfpdFlash() {
2330 if (fpdFlash
== null) {
2331 fpdFlash
= fpdRoot
.addNewFlash();
2336 public void genFlashDefinitionFile(String file
) {
2337 FlashDefinitionFileDocument
.FlashDefinitionFile fdf
= getfpdFlash().getFlashDefinitionFile();
2339 fdf
= getfpdFlash().addNewFlashDefinitionFile();
2342 fdf
.setStringValue(file
);
2345 public String
getFlashDefinitionFile() {
2346 FlashDefinitionFileDocument
.FlashDefinitionFile fdf
= getfpdFlash().getFlashDefinitionFile();
2351 return fdf
.getStringValue();
2354 public void genFvImagesNameValue(String name
, String value
) {
2356 FvImagesDocument
.FvImages fi
= getfpdFlash().getFvImages();
2358 fi
= getfpdFlash().addNewFvImages();
2361 FvImagesDocument
.FvImages
.NameValue nv
= fi
.addNewNameValue();
2366 public void removeFvImagesNameValue(int i
){
2368 XmlObject o
= getfpdFlash().getFvImages();
2373 QName qNameValue
= new QName(xmlNs
, "NameValue");
2374 XmlCursor cursor
= o
.newCursor();
2375 if (cursor
.toChild(qNameValue
)) {
2376 for (int j
= 0; j
< i
; ++j
) {
2377 cursor
.toNextSibling(qNameValue
);
2384 public void updateFvImagesNameValue(int i
, String name
, String value
){
2386 XmlObject o
= getfpdFlash().getFvImages();
2391 QName qNameValue
= new QName(xmlNs
, "NameValue");
2392 XmlCursor cursor
= o
.newCursor();
2393 if (cursor
.toChild(qNameValue
)) {
2394 for (int j
= 0; j
< i
; ++j
) {
2395 cursor
.toNextSibling(qNameValue
);
2397 FvImagesDocument
.FvImages
.NameValue nv
= (FvImagesDocument
.FvImages
.NameValue
)cursor
.getObject();
2404 public int getFvImagesNameValueCount() {
2406 FvImagesDocument
.FvImages fi
= null;
2407 if ((fi
= getfpdFlash().getFvImages()) == null || fi
.getNameValueList() == null) {
2410 return fi
.getNameValueList().size();
2413 public void getFvImagesNameValues(String
[][] nv
) {
2415 FvImagesDocument
.FvImages fi
= getfpdFlash().getFvImages();
2419 List
<FvImagesDocument
.FvImages
.NameValue
> l
= fi
.getNameValueList();
2421 ListIterator li
= l
.listIterator();
2422 while (li
.hasNext()) {
2423 FvImagesDocument
.FvImages
.NameValue e
= (FvImagesDocument
.FvImages
.NameValue
) li
2425 nv
[i
][0] = e
.getName();
2426 nv
[i
][1] = e
.getValue();
2432 public void genFvImagesFvImage(String
[] names
, String types
, Map
<String
, String
> options
) {
2434 FvImagesDocument
.FvImages fis
= null;
2435 if ((fis
= getfpdFlash().getFvImages()) == null) {
2436 fis
= getfpdFlash().addNewFvImages();
2440 //gen FvImage with FvImageNames array
2442 FvImagesDocument
.FvImages
.FvImage fi
= fis
.addNewFvImage();
2443 for (int i
= 0; i
< names
.length
; ++i
) {
2444 fi
.addFvImageNames(names
[i
]);
2446 fi
.setType(FvImageTypes
.Enum
.forString(types
));
2447 if (options
!= null){
2448 setFvImagesFvImageFvImageOptions(options
, fi
);
2452 private void setFvImagesFvImageFvImageOptions(Map
<String
, String
> options
, FvImagesDocument
.FvImages
.FvImage fi
){
2453 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions fio
= fi
.getFvImageOptions();
2455 fio
= fi
.addNewFvImageOptions();
2458 Set
<String
> key
= options
.keySet();
2459 Iterator
<String
> i
= key
.iterator();
2460 while (i
.hasNext()) {
2462 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nv
= fio
.addNewNameValue();
2463 String k
= (String
)i
.next();
2466 nv
.setValue((String
)options
.get(k
));
2473 public void removeFvImagesFvImage(int i
) {
2475 XmlObject o
= getfpdFlash().getFvImages();
2480 QName qFvImage
= new QName(xmlNs
, "FvImage");
2481 XmlCursor cursor
= o
.newCursor();
2482 if (cursor
.toChild(qFvImage
)) {
2483 for (int j
= 0; j
< i
; ++j
) {
2484 cursor
.toNextSibling(qFvImage
);
2491 public void updateFvImagesFvImage(int i
, String
[] names
, String types
, Map
<String
, String
> options
){
2493 XmlObject o
= getfpdFlash().getFvImages();
2497 XmlCursor cursor
= o
.newCursor();
2498 QName qFvImage
= new QName(xmlNs
, "FvImage");
2499 if (cursor
.toChild(qFvImage
)) {
2500 for (int j
= 0; j
< i
; ++j
) {
2501 cursor
.toNextSibling(qFvImage
);
2503 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
2504 fi
.setType(FvImageTypes
.Enum
.forString(types
));
2507 // remove old FvImageNames before adding new ones
2509 QName qFvImageNames
= new QName(xmlNs
, "FvImageNames");
2510 cursor
.toChild(qFvImageNames
);
2512 while (cursor
.toNextSibling(qFvImageNames
)) {
2516 for (int k
= 0; k
< names
.length
; ++k
) {
2517 fi
.addFvImageNames(names
[k
]);
2520 // remove old FvImageOptions before adding new options
2522 QName qFvImageOptions
= new QName(xmlNs
, "FvImageOptions");
2523 cursor
.toNextSibling(qFvImageOptions
);
2526 setFvImagesFvImageFvImageOptions(options
, fi
);
2531 public int getFvImagesFvImageCount() {
2533 if (getfpdFlash().getFvImages() == null || getfpdFlash().getFvImages().getFvImageList() == null) {
2536 return getfpdFlash().getFvImages().getFvImageList().size();
2539 /**Only Get Fv image setting - name and type.
2542 public void getFvImagesFvImages(String
[][] saa
) {
2544 if (getfpdFlash().getFvImages() == null) {
2547 List
<FvImagesDocument
.FvImages
.FvImage
> l
= getfpdFlash().getFvImages().getFvImageList();
2551 ListIterator li
= l
.listIterator();
2553 while(li
.hasNext()) {
2554 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)li
.next();
2556 // get FvImageNames array, space separated
2558 List
<String
> lfn
= fi
.getFvImageNamesList();
2559 ListIterator lfni
= lfn
.listIterator();
2561 while (lfni
.hasNext()) {
2562 saa
[i
][0] += (String
)lfni
.next();
2565 saa
[i
][0] = saa
[i
][0].trim();
2567 saa
[i
][1] = fi
.getType()+"";
2573 /**Get FvImage Options for FvImage i
2574 * @param i the ith FvImage
2576 public void getFvImagesFvImageOptions(int i
, Map
<String
, String
> m
) {
2577 XmlObject o
= getfpdFlash().getFvImages();
2581 XmlCursor cursor
= o
.newCursor();
2582 QName qFvImage
= new QName(xmlNs
, "FvImage");
2583 if (cursor
.toChild(qFvImage
)) {
2584 for (int j
= 0; j
< i
; ++j
) {
2585 cursor
.toNextSibling(qFvImage
);
2587 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
2588 if (fi
.getFvImageOptions() == null || fi
.getFvImageOptions().getNameValueList() == null){
2591 ListIterator
<FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
> li
= fi
.getFvImageOptions().getNameValueList().listIterator();
2592 while(li
.hasNext()){
2593 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nv
= li
.next();
2594 m
.put(nv
.getName(), nv
.getValue());
2600 Get platform header element
2601 @return PlatformHeaderDocument.PlatformHeader
2603 public PlatformHeaderDocument
.PlatformHeader
getFpdHdr() {
2604 if (fpdHdr
== null) {
2605 fpdHdr
= fpdRoot
.addNewPlatformHeader();
2611 public String
getFpdHdrPlatformName() {
2612 return getFpdHdr().getPlatformName();
2615 public String
getFpdHdrGuidValue() {
2616 return getFpdHdr().getGuidValue();
2619 public String
getFpdHdrVer() {
2620 return getFpdHdr().getVersion();
2623 public String
getFpdHdrAbs() {
2624 return getFpdHdr().getAbstract();
2627 public String
getFpdHdrDescription() {
2628 return getFpdHdr().getDescription();
2631 public String
getFpdHdrCopyright() {
2632 return getFpdHdr().getCopyright();
2635 public String
getFpdHdrLicense() {
2636 LicenseDocument
.License l
= getFpdHdr().getLicense();
2640 return l
.getStringValue();
2643 public String
getFpdHdrUrl() {
2644 LicenseDocument
.License l
= getFpdHdr().getLicense();
2651 public String
getFpdHdrSpec() {
2653 return "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052";
2654 // return getFpdHdr().getSpecification();
2657 public void setFpdHdrPlatformName(String name
){
2658 getFpdHdr().setPlatformName(name
);
2661 public void setFpdHdrGuidValue(String guid
){
2662 getFpdHdr().setGuidValue(guid
);
2665 public void setFpdHdrVer(String v
){
2666 getFpdHdr().setVersion(v
);
2669 public void setFpdHdrAbs(String abs
) {
2670 getFpdHdr().setAbstract(abs
);
2673 public void setFpdHdrDescription(String desc
){
2674 getFpdHdr().setDescription(desc
);
2677 public void setFpdHdrCopyright(String cr
) {
2678 getFpdHdr().setCopyright(cr
);
2681 public void setFpdHdrLicense(String license
){
2682 LicenseDocument
.License l
= getFpdHdr().getLicense();
2684 getFpdHdr().addNewLicense().setStringValue(license
);
2687 l
.setStringValue(license
);
2691 public void setFpdHdrUrl(String url
){
2692 LicenseDocument
.License l
= getFpdHdr().getLicense();
2698 public void setFpdHdrSpec(String s
){
2699 s
= "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052";
2700 getFpdHdr().setSpecification(s
);
2703 Save the processed xml contents to file
2705 @param fpdFile The file to save xml contents
2706 @throws IOException Exceptions during file operation
2708 public void saveAs(File fpdFile
) throws IOException
{
2710 XmlOptions options
= new XmlOptions();
2712 options
.setCharacterEncoding("UTF-8");
2713 options
.setSavePrettyPrint();
2714 options
.setSavePrettyPrintIndent(2);
2716 fpdd
.save(fpdFile
, options
);
2717 } catch (IOException e
) {
2718 e
.printStackTrace();
2723 private String
listToString(List l
) {
2728 ListIterator li
= l
.listIterator();
2729 while(li
.hasNext()) {
2736 private void removeElement(XmlObject o
) {
2737 XmlCursor cursor
= o
.newCursor();
2743 class PcdItemTypeConflictException
extends Exception
{
2748 private static final long serialVersionUID
= 1L;
2749 private String details
= null;
2751 PcdItemTypeConflictException(String pcdName
, String info
){
2752 ModuleIdentification mi
= WorkspaceProfile
.getModuleId(info
);
2753 details
= pcdName
+ " ItemType Conflicts with " + mi
.getName() + " in Pkg " + mi
.getPackageId().getName();
2756 public String
getMessage() {
2761 class PcdDeclNotFound
extends Exception
{
2766 private static final long serialVersionUID
= 1L;
2767 private String details
= null;
2769 PcdDeclNotFound(String info
) {
2770 details
= "PcdDeclNotFound: " + info
;
2773 public String
getMessage() {
2778 class PcdValueMalFormed
extends Exception
{
2783 private static final long serialVersionUID
= 1L;
2784 private String details
= null;
2786 PcdValueMalFormed(String info
) {
2787 details
= "PcdValueMalFormed: " + info
;
2790 public String
getMessage() {