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()) {
635 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= (PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
) cursor
637 if (msaPcd
.getCName().equals(pcdData
.getCName())
638 && msaPcd
.getTokenSpaceGuidCName().equals(pcdData
.getTokenSpaceGuidCName())) {
640 maintainDynPcdMap(pcdData
.getCName() + " " + pcdData
.getTokenSpaceGuidCName(),
645 } while (cursor
.toNextSibling());
658 // key for ModuleSA : "ModuleGuid ModuleVer PackageGuid PackageVer Arch"
660 public int getLibraryInstancesCount(String key
) {
661 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
662 if (msa
== null || msa
.getLibraries() == null || msa
.getLibraries().getInstanceList() == null){
665 return msa
.getLibraries().getInstanceList().size();
668 public void getLibraryInstances(String key
, String
[][] saa
){
669 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
670 if (msa
== null || msa
.getLibraries() == null || msa
.getLibraries().getInstanceList() == null){
674 ListIterator
<LibrariesDocument
.Libraries
.Instance
> li
= msa
.getLibraries().getInstanceList().listIterator();
675 for (int i
= 0; i
< saa
.length
; ++i
) {
676 LibrariesDocument
.Libraries
.Instance instance
= li
.next();
677 saa
[i
][1] = instance
.getModuleGuid();
678 saa
[i
][2] = instance
.getModuleVersion();
679 saa
[i
][3] = instance
.getPackageGuid();
680 saa
[i
][4] = instance
.getPackageVersion();
684 public void removeLibraryInstance(String key
, int i
) {
685 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
686 if (msa
== null || msa
.getLibraries() == null){
690 XmlCursor cursor
= msa
.getLibraries().newCursor();
691 if (cursor
.toFirstChild()) {
692 for (int j
= 0; j
< i
; ++j
) {
693 cursor
.toNextSibling();
696 cursor
.toPrevToken();
697 if (cursor
.isComment()) {
702 if (getLibraryInstancesCount(key
) == 0) {
711 public void genLibraryInstance(ModuleIdentification libMi
, String key
) {
712 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
714 msa
= getfpdFrameworkModules().addNewModuleSA();
716 LibrariesDocument
.Libraries libs
= msa
.getLibraries();
718 libs
= msa
.addNewLibraries();
721 String mn
= libMi
.getName();
722 String mg
= libMi
.getGuid();
723 String mv
= libMi
.getVersion();
724 String pn
= libMi
.getPackageId().getName();
725 String pg
= libMi
.getPackageId().getGuid();
726 String pv
= libMi
.getPackageId().getVersion();
727 LibrariesDocument
.Libraries
.Instance instance
= libs
.addNewInstance();
728 XmlCursor cursor
= instance
.newCursor();
730 String comment
= "Pkg: " + pn
+ " Mod: " + mn
731 + " Path: " + libMi
.getPath().substring(System
.getenv("WORKSPACE").length() + 1);
732 cursor
.insertComment(comment
);
741 instance
.setModuleGuid(mg
);
742 instance
.setModuleVersion(mv
);
743 instance
.setPackageGuid(pg
);
744 instance
.setPackageVersion(pv
);
748 public String
getFvBinding(String moduleKey
){
749 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(moduleKey
);
750 return getFvBinding (moduleSa
);
753 public String
getFvBinding (ModuleSADocument
.ModuleSA moduleSa
) {
754 if (moduleSa
== null || moduleSa
.getModuleSaBuildOptions() == null) {
757 return moduleSa
.getModuleSaBuildOptions().getFvBinding();
760 public void setFvBinding(ModuleSADocument
.ModuleSA moduleSa
, String fvBinding
) {
761 if (moduleSa
== null ) {
764 if (fvBinding
== null || fvBinding
.length() == 0) {
765 if(moduleSa
.getModuleSaBuildOptions() != null){
766 moduleSa
.getModuleSaBuildOptions().unsetFvBinding();
770 if(moduleSa
.getModuleSaBuildOptions() == null){
771 moduleSa
.addNewModuleSaBuildOptions().setFvBinding(fvBinding
);
774 moduleSa
.getModuleSaBuildOptions().setFvBinding(fvBinding
);
778 public void setFvBinding(String moduleKey
, String fvBinding
){
779 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(moduleKey
);
780 setFvBinding (moduleSa
, fvBinding
);
783 private int fvBindingForModuleSA (ModuleSADocument
.ModuleSA moduleSa
, String fvName
) {
784 if (moduleSa
== null || moduleSa
.getModuleSaBuildOptions() == null || moduleSa
.getModuleSaBuildOptions().getFvBinding() == null) {
788 String fvNameList
= moduleSa
.getModuleSaBuildOptions().getFvBinding();
789 String
[] fvNamesArray
= fvNameList
.split(" ");
791 for (int i
= 0; i
< fvNamesArray
.length
; ++i
) {
792 if (fvNamesArray
[i
].equals(fvName
)) {
800 public void removeFvBinding (ModuleSADocument
.ModuleSA moduleSa
, String fvName
) {
801 if (moduleSa
== null || moduleSa
.getModuleSaBuildOptions() == null || moduleSa
.getModuleSaBuildOptions().getFvBinding() == null) {
805 String fvNameList
= moduleSa
.getModuleSaBuildOptions().getFvBinding();
806 String
[] fvNamesArray
= fvNameList
.split(" ");
808 for (int i
= 0; i
< fvNamesArray
.length
; ++i
) {
809 if (fvNamesArray
[i
].equals(fvName
)) {
814 // jump over where the input fvName occurs in the original Fv list.
815 if (occursAt
!= -1) {
816 String newFvNameList
= " ";
817 for (int i
= 0; i
< fvNamesArray
.length
; ++i
) {
821 newFvNameList
+= fvNamesArray
[i
];
823 setFvBinding (moduleSa
, newFvNameList
.trim());
829 * @param fvName The FV name that to be removed from FvBinding List.
831 public void removeFvBindingAll (String fvName
) {
832 if (getfpdFrameworkModules().getModuleSAList() == null || getfpdFrameworkModules().getModuleSAList().size() == 0){
833 removeElement(getfpdFrameworkModules());
834 fpdFrameworkModules
= null;
838 Iterator
<ModuleSADocument
.ModuleSA
> li
= getfpdFrameworkModules().getModuleSAList().iterator();
839 while (li
.hasNext()) {
840 ModuleSADocument
.ModuleSA moduleSa
= li
.next();
841 removeFvBinding (moduleSa
, fvName
);
845 public void appendFvBindingAll (String fvName
) {
846 if (getfpdFrameworkModules().getModuleSAList() == null || getfpdFrameworkModules().getModuleSAList().size() == 0){
847 removeElement(getfpdFrameworkModules());
848 fpdFrameworkModules
= null;
852 Iterator
<ModuleSADocument
.ModuleSA
> li
= getfpdFrameworkModules().getModuleSAList().iterator();
853 while (li
.hasNext()) {
854 ModuleSADocument
.ModuleSA moduleSa
= li
.next();
855 appendFvBinding (moduleSa
, fvName
);
859 public void appendFvBindingFor (String oldFvName
, String newFvName
) {
860 if (getfpdFrameworkModules().getModuleSAList() == null || getfpdFrameworkModules().getModuleSAList().size() == 0){
861 removeElement(getfpdFrameworkModules());
862 fpdFrameworkModules
= null;
866 Iterator
<ModuleSADocument
.ModuleSA
> li
= getfpdFrameworkModules().getModuleSAList().iterator();
867 while (li
.hasNext()) {
868 ModuleSADocument
.ModuleSA moduleSa
= li
.next();
869 String fvBinding
= getFvBinding (moduleSa
);
870 if (fvBinding
!= null && fvBindingForModuleSA (moduleSa
, oldFvName
) >= 0) {
871 appendFvBinding (moduleSa
, newFvName
);
876 public void appendFvBinding (String moduleKey
, String fvName
) {
877 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(moduleKey
);
878 appendFvBinding (moduleSa
, fvName
);
881 public void appendFvBinding (ModuleSADocument
.ModuleSA moduleSa
, String fvName
) {
882 if (moduleSa
== null) {
886 if (moduleSa
.getModuleSaBuildOptions() == null || moduleSa
.getModuleSaBuildOptions().getFvBinding() == null) {
887 setFvBinding(moduleSa
, fvName
);
891 String fvNameList
= moduleSa
.getModuleSaBuildOptions().getFvBinding();
892 String newFvNameList
= fvNameList
+ " " + fvName
;
893 setFvBinding (moduleSa
, newFvNameList
.trim());
896 public void updateFvBindingInModuleSA (ModuleIdentification mi
, String fvName
) {
897 Vector
<Object
> vSupArchs
= new Vector
<Object
>();
898 getPlatformDefsSupportedArchs(vSupArchs
);
899 String moduleInfo
= mi
.getGuid() + " " + mi
.getVersion() + " " + mi
.getPackageId().getGuid() + " " + mi
.getPackageId().getVersion();
900 for (int i
= 0; i
< vSupArchs
.size(); ++i
) {
901 String moduleKey
= moduleInfo
+ " " + vSupArchs
.get(i
);
902 appendFvBinding (moduleKey
, fvName
);
906 public String
getFfsFileNameGuid(String moduleKey
){
907 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(moduleKey
);
908 if (moduleSa
== null || moduleSa
.getModuleSaBuildOptions() == null) {
911 return moduleSa
.getModuleSaBuildOptions().getFfsFileNameGuid();
914 public void setFfsFileNameGuid(String moduleKey
, String fileGuid
){
915 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
919 if(msa
.getModuleSaBuildOptions() == null){
920 msa
.addNewModuleSaBuildOptions();
923 ModuleSaBuildOptionsDocument
.ModuleSaBuildOptions msaBuildOpts
= msa
.getModuleSaBuildOptions();
924 if (fileGuid
!= null) {
925 msaBuildOpts
.setFfsFileNameGuid(fileGuid
);
928 XmlCursor cursor
= msaBuildOpts
.newCursor();
929 if (cursor
.toChild(xmlNs
, "FfsFileNameGuid")) {
937 public String
getFfsFormatKey(String moduleKey
){
938 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
939 if (msa
== null || msa
.getModuleSaBuildOptions() == null) {
942 return msa
.getModuleSaBuildOptions().getFfsFormatKey();
945 public void setFfsFormatKey(String moduleKey
, String ffsKey
){
946 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
950 if(msa
.getModuleSaBuildOptions() == null){
951 msa
.addNewModuleSaBuildOptions().setFfsFormatKey(ffsKey
);
954 msa
.getModuleSaBuildOptions().setFfsFormatKey(ffsKey
);
957 public void setModuleSAForceDebug(int i
, boolean dbgEnable
) {
958 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(i
);
959 moduleSa
.setForceDebug(dbgEnable
);
962 public boolean getModuleSAForceDebug (int i
) {
963 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(i
);
964 if (moduleSa
.getForceDebug() == true) {
970 public void getModuleSAOptions(String moduleKey
, String
[][] saa
) {
971 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
972 if (msa
== null || msa
.getModuleSaBuildOptions() == null || msa
.getModuleSaBuildOptions().getOptions() == null
973 || msa
.getModuleSaBuildOptions().getOptions().getOptionList() == null) {
977 List
<OptionDocument
.Option
> lOpt
= msa
.getModuleSaBuildOptions().getOptions().getOptionList();
978 ListIterator li
= lOpt
.listIterator();
980 while(li
.hasNext()) {
981 OptionDocument
.Option opt
= (OptionDocument
.Option
)li
.next();
982 if (opt
.getBuildTargets() != null) {
983 saa
[i
][0] = listToString(opt
.getBuildTargets());
985 saa
[i
][1] = opt
.getToolChainFamily();
986 saa
[i
][2] = opt
.getTagName();
987 saa
[i
][3] = opt
.getToolCode();
989 if (opt
.getSupArchList() != null){
990 saa
[i
][4] = listToString(opt
.getSupArchList());
994 saa
[i
][5] = opt
.getStringValue();
1000 public int getModuleSAOptionsCount(String moduleKey
){
1001 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
1002 if (msa
== null || msa
.getModuleSaBuildOptions() == null || msa
.getModuleSaBuildOptions().getOptions() == null
1003 || msa
.getModuleSaBuildOptions().getOptions().getOptionList() == null) {
1006 return msa
.getModuleSaBuildOptions().getOptions().getOptionList().size();
1009 public void genModuleSAOptionsOpt(String moduleKey
, Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
) {
1010 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
1011 if (msa
.getModuleSaBuildOptions() == null) {
1012 msa
.addNewModuleSaBuildOptions();
1014 if (msa
.getModuleSaBuildOptions().getOptions() == null){
1015 msa
.getModuleSaBuildOptions().addNewOptions();
1017 OptionDocument
.Option opt
= msa
.getModuleSaBuildOptions().getOptions().addNewOption();
1018 setBuildOptionsOpt(buildTargets
, toolChain
, tagName
, toolCmd
, archList
, contents
, opt
);
1021 public void removeModuleSAOptionsOpt(String moduleKey
, int i
) {
1022 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
1023 if (msa
.getModuleSaBuildOptions() == null || msa
.getModuleSaBuildOptions().getOptions() == null) {
1026 OptionsDocument
.Options opts
= msa
.getModuleSaBuildOptions().getOptions();
1027 XmlCursor cursor
= opts
.newCursor();
1028 if (cursor
.toFirstChild()) {
1029 for (int j
= 0; j
< i
; ++j
){
1030 cursor
.toNextSibling();
1037 public void updateModuleSAOptionsOpt(String moduleKey
, int i
, Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
) {
1038 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
1039 if (msa
.getModuleSaBuildOptions() == null || msa
.getModuleSaBuildOptions().getOptions() == null) {
1042 OptionsDocument
.Options opts
= msa
.getModuleSaBuildOptions().getOptions();
1043 XmlCursor cursor
= opts
.newCursor();
1044 if (cursor
.toFirstChild()) {
1045 for (int j
= 0; j
< i
; ++j
){
1046 cursor
.toNextSibling();
1048 OptionDocument
.Option opt
= (OptionDocument
.Option
)cursor
.getObject();
1049 setBuildOptionsOpt(buildTargets
, toolChain
, tagName
, toolCmd
, archList
, contents
, opt
);
1054 /**add pcd information of module mi to a ModuleSA.
1056 * @param moduleSa if null, generate a new ModuleSA.
1058 public void addFrameworkModulesPcdBuildDefs(ModuleIdentification mi
, String arch
, ModuleSADocument
.ModuleSA moduleSa
) throws Exception
{
1059 //ToDo add Arch filter
1062 if (moduleSa
== null) {
1063 moduleSa
= genModuleSA(mi
, arch
);
1066 ModuleSurfaceAreaDocument
.ModuleSurfaceArea msa
= (ModuleSurfaceAreaDocument
.ModuleSurfaceArea
)WorkspaceProfile
.getModuleXmlObject(mi
);
1067 if (msa
.getPcdCoded() == null) {
1071 Map
<String
, XmlObject
> m
= new HashMap
<String
, XmlObject
>();
1072 m
.put("ModuleSurfaceArea", msa
);
1073 SurfaceAreaQuery
.setDoc(m
);
1074 PackageIdentification
[] depPkgs
= SurfaceAreaQuery
.getDependencePkg(null, mi
);
1076 // Implementing InitializePlatformPcdBuildDefinitions
1078 List
<PcdCodedDocument
.PcdCoded
.PcdEntry
> l
= msa
.getPcdCoded().getPcdEntryList();
1079 ListIterator li
= l
.listIterator();
1080 while(li
.hasNext()) {
1081 PcdCodedDocument
.PcdCoded
.PcdEntry msaPcd
= (PcdCodedDocument
.PcdCoded
.PcdEntry
)li
.next();
1082 PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry spdPcd
= LookupPcdDeclaration(msaPcd
, depPkgs
);
1083 if (spdPcd
== null) {
1087 throw new PcdDeclNotFound("No Declaration for PCD Entry " + msaPcd
.getCName() + " in Module " + mi
.getName());
1090 // AddItem to ModuleSA PcdBuildDefinitions
1092 String defaultVal
= msaPcd
.getDefaultValue() == null ? spdPcd
.getDefaultValue() : msaPcd
.getDefaultValue();
1094 genPcdData(msaPcd
.getCName(), spdPcd
.getToken(), msaPcd
.getTokenSpaceGuidCName(), msaPcd
.getPcdItemType().toString(), spdPcd
.getDatumType()+"", defaultVal
, moduleSa
);
1098 catch (Exception e
){
1105 private PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry
LookupPcdDeclaration (PcdCodedDocument
.PcdCoded
.PcdEntry msaPcd
, PackageIdentification
[] depPkgs
) {
1107 PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry spdPcd
= null;
1108 for (int i
= 0; i
< depPkgs
.length
; ++i
) {
1110 XmlObject
[] xo
= SurfaceAreaQuery
.getSpdPcdDeclarations(depPkgs
[i
]);
1114 for (int j
= 0; j
< xo
.length
; ++j
) {
1115 spdPcd
= (PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry
)xo
[j
];
1116 if (msaPcd
.getTokenSpaceGuidCName() == null) {
1117 if (spdPcd
.getCName().equals(msaPcd
.getCName())) {
1122 if (spdPcd
.getCName().equals(msaPcd
.getCName()) && spdPcd
.getTokenSpaceGuidCName().equals(msaPcd
.getTokenSpaceGuidCName())) {
1133 private ModuleSADocument
.ModuleSA
genModuleSA (ModuleIdentification mi
, String arch
) {
1134 PackageIdentification pi
= WorkspaceProfile
.getPackageForModule(mi
);
1135 ModuleSADocument
.ModuleSA msa
= getfpdFrameworkModules().addNewModuleSA();
1136 XmlCursor cursor
= msa
.newCursor();
1138 String comment
= "Mod: " + mi
.getName() + " Type: " + SurfaceAreaQuery
.getModuleType(mi
) + " Path: "
1139 + mi
.getPath().substring(System
.getenv("WORKSPACE").length() + 1);
1140 cursor
.insertComment(comment
);
1143 e
.printStackTrace();
1148 msa
.setModuleGuid(mi
.getGuid());
1149 msa
.setModuleVersion(mi
.getVersion());
1150 msa
.setPackageGuid(pi
.getGuid());
1151 msa
.setPackageVersion(pi
.getVersion());
1153 Vector
<String
> v
= new Vector
<String
>();
1155 msa
.setSupArchList(v
);
1161 private void genPcdData (String cName
, Object token
, String tsGuid
, String itemType
, String dataType
, String defaultVal
, ModuleSADocument
.ModuleSA moduleSa
)
1162 throws PcdItemTypeConflictException
, PcdValueMalFormed
{
1163 if (moduleSa
.getPcdBuildDefinition() == null){
1164 moduleSa
.addNewPcdBuildDefinition();
1167 // constructe pcd to modulesa mapping first.
1168 // Attention : for any error condition, remove from map this pcd.
1170 ArrayList
<String
> pcdConsumer
= LookupPlatformPcdData(cName
+ " " + tsGuid
);
1171 if (pcdConsumer
== null) {
1172 pcdConsumer
= new ArrayList
<String
>();
1175 // Using existing Pcd type, if this pcd already exists in other ModuleSA
1177 if (pcdConsumer
.size() > 0) {
1178 String
[] valPart
= pcdConsumer
.get(0).split(" ");
1179 itemType
= valPart
[5];
1181 String listValue
= moduleSa
.getModuleGuid() + " " + moduleSa
.getModuleVersion()
1182 + " " + moduleSa
.getPackageGuid() + " " + moduleSa
.getPackageVersion() + " " + listToString(moduleSa
.getSupArchList())
1184 pcdConsumer
.add(listValue
);
1185 dynPcdMap
.put(cName
+ " " + tsGuid
, pcdConsumer
);
1187 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData fpdPcd
= moduleSa
.getPcdBuildDefinition().addNewPcdData();
1188 fpdPcd
.setCName(cName
);
1189 fpdPcd
.setToken(token
);
1190 fpdPcd
.setTokenSpaceGuidCName(tsGuid
);
1191 fpdPcd
.setDatumType(PcdDataTypes
.Enum
.forString(dataType
));
1192 fpdPcd
.setItemType(PcdItemTypes
.Enum
.forString(itemType
));
1194 if (defaultVal
!= null){
1195 fpdPcd
.setValue(defaultVal
);
1198 if (dataType
.equals("UINT8") || dataType
.equals("UINT16") || dataType
.equals("UINT32") || dataType
.equals("UINT64")) {
1199 fpdPcd
.setValue("0");
1201 if (dataType
.equals("BOOLEAN")){
1202 fpdPcd
.setValue("FALSE");
1204 if (dataType
.equals("VOID*")) {
1205 fpdPcd
.setValue("");
1209 // Using existing pcd value, if this pcd already exists in other moduleSa.
1211 if (defaultPcdValue
.get(cName
+ " " + tsGuid
) == null) {
1212 defaultPcdValue
.put(cName
+ " " + tsGuid
, fpdPcd
.getValue());
1215 fpdPcd
.setValue(defaultPcdValue
.get(cName
+ " " + tsGuid
));
1218 if (dataType
.equals("UINT8")){
1219 fpdPcd
.setMaxDatumSize(1);
1221 if (dataType
.equals("UINT16")) {
1222 fpdPcd
.setMaxDatumSize(2);
1224 if (dataType
.equals("UINT32")) {
1225 fpdPcd
.setMaxDatumSize(4);
1227 if (dataType
.equals("UINT64")){
1228 fpdPcd
.setMaxDatumSize(8);
1230 if (dataType
.equals("BOOLEAN")){
1231 fpdPcd
.setMaxDatumSize(1);
1233 if (dataType
.equals("VOID*")) {
1234 int maxSize
= setMaxSizeForPointer(fpdPcd
.getValue());
1235 fpdPcd
.setMaxDatumSize(maxSize
);
1239 if (itemType
.equals("DYNAMIC") || itemType
.equals("DYNAMIC_EX")) {
1240 ArrayList
<String
> al
= LookupDynamicPcdBuildDefinition(cName
+ " " + tsGuid
);
1242 // if only one module mapped to this pcd, then the one is myself. so no other module mapped.
1243 // so need to add one dyn pcd.
1245 if (al
.size() == 1) {
1246 addDynamicPcdBuildData(cName
, token
, tsGuid
, itemType
, dataType
, defaultVal
);
1252 public int setMaxSizeForPointer(String datum
) throws PcdValueMalFormed
{
1253 if (datum
== null) {
1256 char ch
= datum
.charAt(0);
1260 // For void* type PCD, only three datum is support:
1261 // 1) Unicode: string with start char is "L"
1262 // 2) Ansci: String is ""
1263 // 3) byte array: String start char "{"
1266 start
= datum
.indexOf('\"');
1267 end
= datum
.lastIndexOf('\"');
1268 if ((start
> end
) ||
1269 (end
> datum
.length())||
1270 ((start
== end
) && (datum
.length() > 0))) {
1271 //ToDo Error handling here
1272 throw new PcdValueMalFormed (datum
);
1275 strValue
= datum
.substring(start
+ 1, end
);
1276 return strValue
.length() * 2;
1277 } else if (ch
== '\"'){
1278 start
= datum
.indexOf('\"');
1279 end
= datum
.lastIndexOf('\"');
1280 if ((start
> end
) ||
1281 (end
> datum
.length())||
1282 ((start
== end
) && (datum
.length() > 0))) {
1283 throw new PcdValueMalFormed (datum
);
1285 strValue
= datum
.substring(start
+ 1, end
);
1286 return strValue
.length();
1287 } else if (ch
=='{') {
1288 String
[] strValueArray
;
1290 start
= datum
.indexOf('{');
1291 end
= datum
.lastIndexOf('}');
1292 strValue
= datum
.substring(start
+ 1, end
);
1293 strValue
= strValue
.trim();
1294 if (strValue
.length() == 0) {
1297 strValueArray
= strValue
.split(",");
1298 for (int index
= 0; index
< strValueArray
.length
; index
++) {
1299 Integer value
= Integer
.decode(strValueArray
[index
].trim());
1302 // "[FPD file error] The datum type of PCD %s in %s is VOID*, "+
1303 // "it must be a byte array. But the element of %s exceed the byte range",
1304 throw new PcdValueMalFormed (datum
);
1307 return strValueArray
.length
;
1311 // "[FPD file error] The datum type of PCD %s in %s is VOID*. For VOID* type, you have three format choise:\n "+
1312 // "1) UNICODE string: like L\"xxxx\";\r\n"+
1313 // "2) ANSIC string: like \"xxx\";\r\n"+
1314 // "3) Byte array: like {0x2, 0x45, 0x23}\r\n"+
1315 // "but the datum in seems does not following above format!",
1316 throw new PcdValueMalFormed (datum
);
1321 private ArrayList
<String
> LookupDynamicPcdBuildDefinition(String dynPcdKey
) {
1322 ArrayList
<String
> al
= dynPcdMap
.get(dynPcdKey
);
1327 private ArrayList
<String
> LookupPlatformPcdData(String pcdKey
) {
1329 return dynPcdMap
.get(pcdKey
);
1332 public int getDynamicPcdBuildDataCount() {
1333 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1334 removeElement(getfpdDynPcdBuildDefs());
1335 fpdDynPcdBuildDefs
= null;
1338 return getfpdDynPcdBuildDefs().getPcdBuildDataList().size();
1341 public void getDynamicPcdBuildData(String
[][] saa
) {
1342 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1343 removeElement(getfpdDynPcdBuildDefs());
1344 fpdDynPcdBuildDefs
= null;
1347 List
<DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
> l
= getfpdDynPcdBuildDefs().getPcdBuildDataList();
1348 ListIterator
<DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
> li
= l
.listIterator();
1350 while(li
.hasNext()) {
1351 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData dynPcd
= li
.next();
1352 saa
[i
][0] = dynPcd
.getCName();
1353 saa
[i
][1] = dynPcd
.getToken().toString();
1354 saa
[i
][2] = dynPcd
.getTokenSpaceGuidCName();
1355 saa
[i
][3] = dynPcd
.getMaxDatumSize()+"";
1356 saa
[i
][4] = dynPcd
.getDatumType().toString();
1362 public void addDynamicPcdBuildData(String cName
, Object token
, String tsGuid
, String itemType
, String dataType
, String defaultVal
)
1363 throws PcdValueMalFormed
{
1364 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData dynPcdData
= getfpdDynPcdBuildDefs().addNewPcdBuildData();
1365 dynPcdData
.setItemType(PcdItemTypes
.Enum
.forString(itemType
));
1366 dynPcdData
.setCName(cName
);
1367 dynPcdData
.setToken(token
);
1368 dynPcdData
.setTokenSpaceGuidCName(tsGuid
);
1369 dynPcdData
.setDatumType(PcdDataTypes
.Enum
.forString(dataType
));
1371 BigInteger bigInt
= new BigInteger("0");
1372 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo skuInfo
= dynPcdData
.addNewSkuInfo();
1373 skuInfo
.setSkuId(bigInt
);
1374 if (defaultVal
!= null){
1375 skuInfo
.setValue(defaultVal
);
1378 if (dataType
.equals("UINT8")){
1379 skuInfo
.setValue("0");
1381 if (dataType
.equals("UINT16")) {
1382 skuInfo
.setValue("0");
1384 if (dataType
.equals("UINT32")) {
1385 skuInfo
.setValue("0");
1387 if (dataType
.equals("UINT64")){
1388 skuInfo
.setValue("0");
1390 if (dataType
.equals("BOOLEAN")){
1391 skuInfo
.setValue("false");
1393 if (dataType
.equals("VOID*")) {
1394 skuInfo
.setValue("");
1397 if (dataType
.equals("UINT8")){
1398 dynPcdData
.setMaxDatumSize(1);
1400 if (dataType
.equals("UINT16")) {
1401 dynPcdData
.setMaxDatumSize(2);
1403 if (dataType
.equals("UINT32")) {
1404 dynPcdData
.setMaxDatumSize(4);
1406 if (dataType
.equals("UINT64")){
1407 dynPcdData
.setMaxDatumSize(8);
1409 if (dataType
.equals("BOOLEAN")){
1410 dynPcdData
.setMaxDatumSize(1);
1412 if (dataType
.equals("VOID*")) {
1413 int maxSize
= setMaxSizeForPointer(defaultVal
);
1414 dynPcdData
.setMaxDatumSize(maxSize
);
1418 public void removeDynamicPcdBuildData(String cName
, String tsGuid
) {
1419 XmlObject o
= fpdRoot
.getDynamicPcdBuildDefinitions();
1424 XmlCursor cursor
= o
.newCursor();
1425 if (cursor
.toFirstChild()) {
1427 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdBuildData
=
1428 (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1429 if (pcdBuildData
.getCName().equals(cName
) && pcdBuildData
.getTokenSpaceGuidCName().equals(tsGuid
)) {
1431 if (getDynamicPcdBuildDataCount() == 1) {
1439 while (cursor
.toNextSibling());
1444 // Get the Sku Info count of ith dyn pcd element.
1446 public int getDynamicPcdSkuInfoCount(int i
){
1447 if (fpdRoot
.getDynamicPcdBuildDefinitions() == null || fpdRoot
.getDynamicPcdBuildDefinitions().getPcdBuildDataList() == null
1448 || fpdRoot
.getDynamicPcdBuildDefinitions().getPcdBuildDataList().size() == 0) {
1452 int skuInfoCount
= 0;
1453 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1454 if (cursor
.toFirstChild()) {
1455 for (int j
= 0; j
< i
; ++j
) {
1456 cursor
.toNextSibling();
1458 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1459 if (pcdData
.getSkuInfoList() == null) {
1463 skuInfoCount
= pcdData
.getSkuInfoList().size();
1467 return skuInfoCount
;
1470 public void getDynamicPcdSkuInfos(int i
, String
[][] saa
){
1471 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1472 removeElement(getfpdDynPcdBuildDefs());
1473 fpdDynPcdBuildDefs
= null;
1477 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1478 if (cursor
.toFirstChild()) {
1479 for (int j
= 0; j
< i
; ++j
) {
1480 cursor
.toNextSibling();
1482 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1483 if (pcdData
.getSkuInfoList() == null) {
1488 ListIterator
<DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo
> li
= pcdData
.getSkuInfoList().listIterator();
1490 while (li
.hasNext()) {
1491 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo skuInfo
= li
.next();
1492 saa
[k
][0] = skuInfo
.getSkuId()+"";
1493 saa
[k
][1] = skuInfo
.getVariableName();
1494 saa
[k
][2] = skuInfo
.getVariableGuid();
1495 saa
[k
][3] = skuInfo
.getVariableOffset();
1496 saa
[k
][4] = skuInfo
.getHiiDefaultValue();
1497 saa
[k
][5] = skuInfo
.getVpdOffset();
1498 saa
[k
][6] = skuInfo
.getValue();
1508 public String
getDynamicPcdBuildDataValue(int i
){
1509 String value
= null;
1510 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1511 removeElement(getfpdDynPcdBuildDefs());
1512 fpdDynPcdBuildDefs
= null;
1516 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1517 if (cursor
.toFirstChild()) {
1518 for (int j
= 0; j
< i
; ++j
) {
1519 cursor
.toNextSibling();
1521 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1522 if (pcdData
.getSkuInfoList() == null) {
1526 value
= pcdData
.getSkuInfoArray(0).getValue();
1533 public String
getDynamicPcdBuildDataVpdOffset(int i
){
1534 String vpdOffset
= null;
1535 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1536 removeElement(getfpdDynPcdBuildDefs());
1537 fpdDynPcdBuildDefs
= null;
1541 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1542 if (cursor
.toFirstChild()) {
1543 for (int j
= 0; j
< i
; ++j
) {
1544 cursor
.toNextSibling();
1546 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1547 if (pcdData
.getSkuInfoList() == null) {
1551 vpdOffset
= pcdData
.getSkuInfoArray(0).getVpdOffset();
1558 public void removeDynamicPcdBuildDataSkuInfo(int i
) {
1559 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1560 removeElement(getfpdDynPcdBuildDefs());
1561 fpdDynPcdBuildDefs
= null;
1565 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1566 if (cursor
.toFirstChild()) {
1567 for (int j
= 0; j
< i
; ++j
) {
1568 cursor
.toNextSibling();
1570 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1571 if (pcdData
.getSkuInfoList() == null) {
1576 QName qSkuInfo
= new QName(xmlNs
, "SkuInfo");
1577 cursor
.toChild(qSkuInfo
);
1584 // generate sku info for ith dyn pcd build data.
1586 public void genDynamicPcdBuildDataSkuInfo(String id
, String varName
, String varGuid
, String varOffset
,
1587 String hiiDefault
, String vpdOffset
, String value
, int i
) {
1588 // if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1592 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1593 if (cursor
.toFirstChild()) {
1594 for (int j
= 0; j
< i
; ++j
) {
1595 cursor
.toNextSibling();
1597 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1598 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo skuInfo
= pcdData
.addNewSkuInfo();
1599 skuInfo
.setSkuId(new BigInteger(id
));
1600 if (varName
!= null){
1601 skuInfo
.setVariableName(varName
);
1602 skuInfo
.setVariableGuid(varGuid
);
1603 skuInfo
.setVariableOffset(varOffset
);
1604 skuInfo
.setHiiDefaultValue(hiiDefault
);
1606 else if (vpdOffset
!= null){
1607 skuInfo
.setVpdOffset(vpdOffset
);
1610 skuInfo
.setValue(value
);
1615 public void updateDynamicPcdBuildDataSkuInfo(String id
, String varName
, String varGuid
, String varOffset
,
1616 String hiiDefault
, String vpdOffset
, String value
, int i
){
1617 // if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1621 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1622 if (cursor
.toFirstChild()) {
1623 for (int j
= 0; j
< i
; ++j
) {
1624 cursor
.toNextSibling();
1626 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1627 ListIterator
<DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo
> li
= pcdData
.getSkuInfoList().listIterator();
1628 while (li
.hasNext()) {
1629 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo skuInfo
= li
.next();
1630 if (skuInfo
.getSkuId().toString().equals(id
)){
1631 if (varName
!= null){
1632 skuInfo
.setVariableName(varName
);
1633 skuInfo
.setVariableGuid(varGuid
);
1634 skuInfo
.setVariableOffset(varOffset
);
1635 skuInfo
.setHiiDefaultValue(hiiDefault
);
1637 else if (vpdOffset
!= null){
1638 skuInfo
.setVpdOffset(vpdOffset
);
1641 skuInfo
.setValue(value
);
1649 public BuildOptionsDocument
.BuildOptions
getfpdBuildOpts() {
1650 if (fpdBuildOpts
== null) {
1651 fpdBuildOpts
= fpdRoot
.addNewBuildOptions();
1653 return fpdBuildOpts
;
1656 public void genBuildOptionsUserExtensions(String fvName
, String outputFileName
, Vector
<String
[]> includeModules
) {
1657 QName elementFvName
= new QName (xmlNs
, "FvName");
1658 QName elementIncludeModules
= new QName(xmlNs
, "IncludeModules");
1659 QName elementInfFileName
= new QName(xmlNs
, "InfFileName");
1660 QName elementModule
= new QName(xmlNs
, "Module");
1662 UserExtensionsDocument
.UserExtensions userExts
= getfpdBuildOpts().addNewUserExtensions();
1663 userExts
.setUserID("IMAGES");
1664 userExts
.setIdentifier(new BigInteger("1"));
1665 XmlCursor cursor
= userExts
.newCursor();
1666 cursor
.toEndToken();
1668 cursor
.beginElement(elementFvName
);
1669 cursor
.insertChars(fvName
);
1670 cursor
.toNextToken();
1672 cursor
.beginElement(elementInfFileName
);
1673 cursor
.insertChars(fvName
+ ".inf");
1674 cursor
.toNextToken();
1676 cursor
.beginElement(elementIncludeModules
);
1677 for (int i
= 0; i
< includeModules
.size(); ++i
) {
1678 cursor
.beginElement(elementModule
);
1679 cursor
.insertAttributeWithValue("ModuleGuid", includeModules
.get(i
)[0]);
1680 cursor
.insertAttributeWithValue("BaseName", includeModules
.get(i
)[1]);
1681 cursor
.toEndToken();
1682 cursor
.toNextToken();
1687 public int getUserExtsIncModCount (String fvName
) {
1688 if (getfpdBuildOpts().getUserExtensionsList() == null) {
1691 ListIterator
<UserExtensionsDocument
.UserExtensions
> li
= getfpdBuildOpts().getUserExtensionsList().listIterator();
1692 QName elementIncludeModules
= new QName(xmlNs
, "IncludeModules");
1693 while (li
.hasNext()) {
1694 UserExtensionsDocument
.UserExtensions ues
= li
.next();
1695 if (!ues
.getUserID().equals("IMAGES")) {
1698 XmlCursor cursor
= ues
.newCursor();
1699 cursor
.toFirstChild();
1700 String elementName
= cursor
.getTextValue();
1701 if (elementName
.equals(fvName
)) {
1702 cursor
.toNextSibling(elementIncludeModules
);
1703 if (cursor
.toFirstChild()) {
1705 for (i
= 1; cursor
.toNextSibling(); ++i
);
1717 public void getUserExtsIncMods(String fvName
, String
[][] saa
) {
1718 if (getfpdBuildOpts().getUserExtensionsList() == null) {
1722 XmlCursor cursor
= getfpdBuildOpts().newCursor();
1723 QName elementUserExts
= new QName (xmlNs
, "UserExtensions");
1724 QName attribUserId
= new QName ("UserID");
1725 QName elementFvName
= new QName (xmlNs
, "FvName");
1726 QName elementIncludeModules
= new QName(xmlNs
, "IncludeModules");
1727 QName attribModuleGuid
= new QName("ModuleGuid");
1728 QName attribBaseName
= new QName("BaseName");
1730 if (cursor
.toChild(elementUserExts
)) {
1733 if (cursor
.getAttributeText(attribUserId
).equals("IMAGES")) {
1734 cursor
.toChild(elementFvName
);
1735 String elementName
= cursor
.getTextValue();
1736 if (elementName
.equals(fvName
)) {
1737 cursor
.toNextSibling(elementIncludeModules
);
1738 if (cursor
.toFirstChild()) {
1741 saa
[i
][0] = cursor
.getAttributeText(attribModuleGuid
);
1742 saa
[i
][1] = cursor
.getAttributeText(attribBaseName
);
1744 }while (cursor
.toNextSibling());
1750 }while (cursor
.toNextSibling(elementUserExts
));
1756 public void updateBuildOptionsUserExtensions (String oldFvName
, String newFvName
) {
1757 if (getfpdBuildOpts().getUserExtensionsList() == null) {
1760 ListIterator
<UserExtensionsDocument
.UserExtensions
> li
= getfpdBuildOpts().getUserExtensionsList().listIterator();
1761 while (li
.hasNext()) {
1762 UserExtensionsDocument
.UserExtensions ues
= li
.next();
1763 if (!ues
.getUserID().equals("IMAGES")) {
1766 XmlCursor cursor
= ues
.newCursor();
1767 cursor
.toFirstChild();
1768 String elementName
= cursor
.getTextValue();
1769 if (elementName
.equals(oldFvName
)) {
1770 cursor
.setTextValue(newFvName
);
1777 public void removeBuildOptionsUserExtensions (String fvName
) {
1778 if (getfpdBuildOpts().getUserExtensionsList() == null) {
1782 ListIterator
<UserExtensionsDocument
.UserExtensions
> li
= getfpdBuildOpts().getUserExtensionsList().listIterator();
1783 while (li
.hasNext()) {
1784 UserExtensionsDocument
.UserExtensions ues
= li
.next();
1785 if (!ues
.getUserID().equals("IMAGES")) {
1788 XmlCursor cursor
= ues
.newCursor();
1789 cursor
.toFirstChild();
1790 String elementName
= cursor
.getTextValue();
1791 if (elementName
.equals(fvName
)) {
1803 public void genBuildOptionsUserDefAntTask (String id
, String fileName
, String execOrder
) {
1804 UserDefinedAntTasksDocument
.UserDefinedAntTasks udats
= getfpdBuildOpts().getUserDefinedAntTasks();
1805 if (udats
== null) {
1806 udats
= getfpdBuildOpts().addNewUserDefinedAntTasks();
1809 AntTaskDocument
.AntTask at
= udats
.addNewAntTask();
1810 setBuildOptionsUserDefAntTask(id
, fileName
, execOrder
, at
);
1813 private void setBuildOptionsUserDefAntTask(String id
, String fileName
, String execOrder
, AntTaskDocument
.AntTask at
) {
1814 at
.setId(new Integer(id
));
1815 XmlCursor cursor
= at
.newCursor();
1816 if (fileName
!= null){
1817 at
.setFilename(fileName
);
1819 else if (cursor
.toChild(xmlNs
, "Filename")) {
1822 if (execOrder
!= null) {
1823 at
.setAntCmdOptions(execOrder
);
1825 else if (cursor
.toChild(xmlNs
, "AntCmdOptions")) {
1831 public void removeBuildOptionsUserDefAntTask(int i
) {
1832 XmlObject o
= getfpdBuildOpts().getUserDefinedAntTasks();
1836 XmlCursor cursor
= o
.newCursor();
1837 if (cursor
.toFirstChild()) {
1838 for (int j
= 0; j
< i
; ++j
) {
1839 cursor
.toNextSibling();
1842 if (getBuildOptionsUserDefAntTaskCount() == 0) {
1850 public void updateBuildOptionsUserDefAntTask(int i
, String id
, String fileName
, String execOrder
){
1851 XmlObject o
= getfpdBuildOpts().getUserDefinedAntTasks();
1855 XmlCursor cursor
= o
.newCursor();
1856 if (cursor
.toFirstChild()) {
1857 for (int j
= 0; j
< i
; ++j
) {
1858 cursor
.toNextSibling();
1860 AntTaskDocument
.AntTask at
= (AntTaskDocument
.AntTask
)cursor
.getObject();
1861 setBuildOptionsUserDefAntTask(id
, fileName
, execOrder
, at
);
1866 public int getBuildOptionsUserDefAntTaskCount() {
1867 UserDefinedAntTasksDocument
.UserDefinedAntTasks udats
= getfpdBuildOpts().getUserDefinedAntTasks();
1868 if (udats
== null || udats
.getAntTaskList() == null) {
1872 return udats
.getAntTaskList().size();
1875 public void getBuildOptionsUserDefAntTasks(String
[][] saa
) {
1876 UserDefinedAntTasksDocument
.UserDefinedAntTasks udats
= getfpdBuildOpts().getUserDefinedAntTasks();
1877 if (udats
== null || udats
.getAntTaskList() == null) {
1881 List
<AntTaskDocument
.AntTask
> l
= udats
.getAntTaskList();
1882 ListIterator li
= l
.listIterator();
1884 while (li
.hasNext()) {
1885 AntTaskDocument
.AntTask at
= (AntTaskDocument
.AntTask
)li
.next();
1886 saa
[i
][0] = at
.getId() + "";
1887 saa
[i
][1] = saa
[i
][2] = "";
1888 if (at
.getFilename() != null){
1889 saa
[i
][1] = at
.getFilename();
1891 if (at
.getAntCmdOptions() != null) {
1892 saa
[i
][2] = at
.getAntCmdOptions();
1897 public void genBuildOptionsOpt(Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
) {
1898 OptionsDocument
.Options opts
= getfpdBuildOpts().getOptions();
1900 opts
= getfpdBuildOpts().addNewOptions();
1902 OptionDocument
.Option opt
= opts
.addNewOption();
1903 setBuildOptionsOpt(buildTargets
, toolChain
, tagName
, toolCmd
, archList
, contents
, opt
);
1906 private void setBuildOptionsOpt(Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
, OptionDocument
.Option opt
){
1907 opt
.setStringValue(contents
);
1909 opt
.setBuildTargets(buildTargets
);
1910 opt
.setToolChainFamily(toolChain
);
1911 opt
.setTagName(tagName
);
1912 opt
.setToolCode(toolCmd
);
1914 if (archList
!= null) {
1915 opt
.setSupArchList(archList
);
1918 if (opt
.isSetSupArchList()) {
1919 opt
.unsetSupArchList();
1924 public void removeBuildOptionsOpt(int i
){
1926 XmlObject o
= getfpdBuildOpts().getOptions();
1931 XmlCursor cursor
= o
.newCursor();
1932 if (cursor
.toFirstChild()) {
1933 for (int j
= 0; j
< i
; ++j
) {
1934 cursor
.toNextSibling();
1937 if (getBuildOptionsOptCount() == 0) {
1945 public void updateBuildOptionsOpt(int i
, Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
) {
1946 XmlObject o
= getfpdBuildOpts().getOptions();
1951 XmlCursor cursor
= o
.newCursor();
1952 if (cursor
.toFirstChild()) {
1953 for (int j
= 0; j
< i
; ++j
) {
1954 cursor
.toNextSibling();
1956 OptionDocument
.Option opt
= (OptionDocument
.Option
)cursor
.getObject();
1957 setBuildOptionsOpt(buildTargets
, toolChain
, tagName
, toolCmd
, archList
, contents
, opt
);
1962 public int getBuildOptionsOptCount(){
1963 if (getfpdBuildOpts().getOptions() == null || getfpdBuildOpts().getOptions().getOptionList() == null) {
1966 return getfpdBuildOpts().getOptions().getOptionList().size();
1969 public void getBuildOptionsOpts(String
[][] saa
) {
1970 if (getfpdBuildOpts().getOptions() == null || getfpdBuildOpts().getOptions().getOptionList() == null) {
1974 List
<OptionDocument
.Option
> lOpt
= getfpdBuildOpts().getOptions().getOptionList();
1975 ListIterator li
= lOpt
.listIterator();
1977 while(li
.hasNext()) {
1978 OptionDocument
.Option opt
= (OptionDocument
.Option
)li
.next();
1979 if (opt
.getBuildTargets() != null) {
1980 saa
[i
][0] = listToString(opt
.getBuildTargets());
1982 saa
[i
][1] = opt
.getToolChainFamily();
1983 if (opt
.getSupArchList() != null){
1984 saa
[i
][2] = listToString(opt
.getSupArchList());
1987 saa
[i
][3] = opt
.getToolCode();
1988 saa
[i
][4] = opt
.getTagName();
1989 saa
[i
][5] = opt
.getStringValue();
1995 public void genBuildOptionsFfs(String ffsKey
, String type
) {
1996 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getfpdBuildOpts().addNewFfs();
1997 ffs
.setFfsKey(ffsKey
);
1999 ffs
.addNewSections().setEncapsulationType(type
);
2003 public void updateBuildOptionsFfsSectionsType(int i
, String type
) {
2004 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getfpdBuildOpts().addNewFfs();
2006 ffs
.addNewSections().setEncapsulationType(type
);
2010 public void genBuildOptionsFfsAttribute(int i
, String name
, String value
) {
2011 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2012 BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute attrib
= ffs
.addNewAttribute();
2013 attrib
.setName(name
);
2014 attrib
.setValue(value
);
2017 /**update jth attribute of ith ffs.
2021 public void updateBuildOptionsFfsAttribute(int i
, int j
, String name
, String value
){
2022 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2023 XmlCursor cursor
= ffs
.newCursor();
2024 QName qAttrib
= new QName(xmlNs
, "Attribute");
2025 if (cursor
.toChild(qAttrib
)) {
2026 for (int k
= 0; k
< j
; ++k
) {
2027 cursor
.toNextSibling(qAttrib
);
2029 BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute attrib
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute
)cursor
.getObject();
2030 attrib
.setName(name
);
2031 attrib
.setValue(value
);
2036 public void removeBuildOptionsFfsAttribute(int i
, int j
){
2037 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2038 XmlCursor cursor
= ffs
.newCursor();
2039 QName qAttrib
= new QName(xmlNs
, "Attribute");
2040 if (cursor
.toChild(qAttrib
)) {
2041 for (int k
= 0; k
< j
; ++k
) {
2042 cursor
.toNextSibling(qAttrib
);
2049 public void genBuildOptionsFfsSectionsSection(int i
, String sectionType
) {
2050 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2054 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2056 if (sections
== null){
2057 sections
= ffs
.addNewSections();
2059 sections
.addNewSection().setSectionType(EfiSectionType
.Enum
.forString(sectionType
));
2062 public void removeBuildOptionsFfsSectionsSection(int i
, int j
) {
2063 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2064 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2065 if (sections
== null) {
2068 XmlCursor cursor
= sections
.newCursor();
2069 QName qSection
= new QName(xmlNs
, "Section");
2070 if (cursor
.toChild(qSection
)) {
2071 for (int k
= 0; k
< j
; ++k
) {
2072 cursor
.toNextSibling(qSection
);
2079 public void updateBuildOptionsFfsSectionsSection(int i
, int j
, String type
){
2080 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2081 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2082 if (sections
== null) {
2085 XmlCursor cursor
= sections
.newCursor();
2086 QName qSection
= new QName(xmlNs
, "Section");
2087 if (cursor
.toChild(qSection
)) {
2088 for (int k
= 0; k
< j
; ++k
) {
2089 cursor
.toNextSibling(qSection
);
2091 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Section section
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Section
)cursor
.getObject();
2092 section
.setSectionType(EfiSectionType
.Enum
.forString(type
));
2097 public void genBuildOptionsFfsSectionsSections(int i
, String encapType
) {
2098 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2102 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2104 if (sections
== null){
2105 sections
= ffs
.addNewSections();
2107 sections
.addNewSections().setEncapsulationType(encapType
);
2110 public void removeBuildOptionsFfsSectionsSections(int i
, int j
) {
2111 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2112 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2113 if (sections
== null) {
2116 XmlCursor cursor
= sections
.newCursor();
2117 QName qSections
= new QName(xmlNs
, "Sections");
2118 if (cursor
.toChild(qSections
)) {
2119 for (int k
= 0; k
< j
; ++k
) {
2120 cursor
.toNextSibling(qSections
);
2127 public void updateBuildOptionsFfsSectionsSections(int i
, int j
, String type
) {
2128 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2129 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2130 if (sections
== null) {
2133 XmlCursor cursor
= sections
.newCursor();
2134 QName qSections
= new QName(xmlNs
, "Sections");
2135 if (cursor
.toChild(qSections
)) {
2136 for (int k
= 0; k
< j
; ++k
) {
2137 cursor
.toNextSibling(qSections
);
2139 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2 sections2
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
)cursor
.getObject();
2140 sections2
.setEncapsulationType(type
);
2145 public void genBuildOptionsFfsSectionsSectionsSection(int i
, int j
, String type
) {
2146 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2150 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2151 XmlCursor cursor
= sections
.newCursor();
2152 QName qSections
= new QName(xmlNs
, "Sections");
2153 if (cursor
.toChild(qSections
)){
2154 for (int k
= 0; k
< j
; ++k
) {
2155 cursor
.toNextSibling(qSections
);
2157 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2 sections2
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
)cursor
.getObject();
2158 sections2
.addNewSection().setSectionType(EfiSectionType
.Enum
.forString(type
));
2163 public void removeBuildOptionsFfsSectionsSectionsSection(int i
, int j
, int k
) {
2164 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2165 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2166 if (sections
== null) {
2169 XmlCursor cursor
= sections
.newCursor();
2170 QName qSections
= new QName(xmlNs
, "Sections");
2171 if (cursor
.toChild(qSections
)) {
2172 for (int l
= 0; l
< j
; ++l
) {
2173 cursor
.toNextSibling(qSections
);
2175 if (cursor
.toFirstChild()) {
2177 for (; m
< k
; ++m
) {
2178 cursor
.toNextSibling();
2190 public void updateBuildOptionsFfsSectionsSectionsSection(int i
, int j
, int k
, String type
) {
2191 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2192 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2193 if (sections
== null) {
2196 XmlCursor cursor
= sections
.newCursor();
2197 QName qSections
= new QName(xmlNs
, "Sections");
2198 if (cursor
.toChild(qSections
)) {
2199 for (int l
= 0; l
< j
; ++l
) {
2200 cursor
.toNextSibling(qSections
);
2202 if (cursor
.toFirstChild()) {
2203 for (int m
= 0; m
< k
; ++m
) {
2204 cursor
.toNextSibling();
2206 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section section
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section
)cursor
.getObject();
2207 section
.setSectionType(EfiSectionType
.Enum
.forString(type
));
2213 public void getBuildOptionsFfsSectionsSectionsSection(int i
, int j
, ArrayList
<String
> al
) {
2214 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2218 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2219 XmlCursor cursor
= sections
.newCursor();
2220 QName qSections
= new QName(xmlNs
, "Sections");
2221 if (cursor
.toChild(qSections
)){
2222 for (int k
= 0; k
< j
; ++k
) {
2223 cursor
.toNextSibling(qSections
);
2225 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2 sections2
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
)cursor
.getObject();
2226 if (sections2
.getSectionList() == null){
2230 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section
> li
= sections2
.getSectionList().listIterator();
2231 while(li
.hasNext()) {
2232 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section section
= li
.next();
2233 if (section
.isSetSectionType()) {
2234 al
.add(section
.getSectionType().toString());
2243 public int getBuildOptionsFfsCount(){
2244 if (getfpdBuildOpts().getFfsList() == null) {
2247 return getfpdBuildOpts().getFfsList().size();
2250 public void getBuildOptionsFfsKey(String
[][] saa
) {
2251 if (getfpdBuildOpts().getFfsList() == null) {
2254 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
> li
= getfpdBuildOpts().getFfsList().listIterator();
2256 while(li
.hasNext()){
2257 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= li
.next();
2258 saa
[i
][0] = ffs
.getFfsKey();
2263 public void updateBuildOptionsFfsKey(int i
, String key
) {
2264 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2268 /**Get ith FFS key and contents.
2271 public void getBuildOptionsFfs(int i
, String
[] sa
, LinkedHashMap
<String
, String
> ffsAttribMap
, ArrayList
<String
> firstLevelSections
, ArrayList
<String
> firstLevelSection
) {
2272 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2276 sa
[0] = ffs
.getFfsKey();
2277 if (ffs
.getSections() != null) {
2278 if(ffs
.getSections().getEncapsulationType() != null){
2279 sa
[1] = ffs
.getSections().getEncapsulationType();
2281 if (ffs
.getSections().getSectionList() != null){
2282 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Section
> li
= ffs
.getSections().getSectionList().listIterator();
2283 while (li
.hasNext()) {
2284 firstLevelSection
.add(li
.next().getSectionType().toString());
2287 if (ffs
.getSections().getSectionsList() != null) {
2288 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
> li
= ffs
.getSections().getSectionsList().listIterator();
2289 while(li
.hasNext()) {
2290 firstLevelSections
.add(li
.next().getEncapsulationType());
2294 if (ffs
.getAttributeList() != null) {
2295 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute
> li
= ffs
.getAttributeList().listIterator();
2296 while(li
.hasNext()) {
2297 BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute attrib
= li
.next();
2298 ffsAttribMap
.put(attrib
.getName(), attrib
.getValue());
2307 private BuildOptionsDocument
.BuildOptions
.Ffs
getFfs(int i
) {
2308 XmlObject o
= getfpdBuildOpts();
2309 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= null;
2311 XmlCursor cursor
= o
.newCursor();
2312 QName qFfs
= new QName(xmlNs
, "Ffs");
2313 if (cursor
.toChild(qFfs
)) {
2314 for (int j
= 0; j
< i
; ++j
) {
2315 cursor
.toNextSibling(qFfs
);
2317 ffs
= (BuildOptionsDocument
.BuildOptions
.Ffs
)cursor
.getObject();
2323 public void removeBuildOptionsFfs(int i
) {
2324 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2329 XmlCursor cursor
= ffs
.newCursor();
2336 public PlatformDefinitionsDocument
.PlatformDefinitions
getfpdPlatformDefs(){
2337 if (fpdPlatformDefs
== null){
2338 fpdPlatformDefs
= fpdRoot
.addNewPlatformDefinitions();
2340 return fpdPlatformDefs
;
2343 public void getPlatformDefsSupportedArchs(Vector
<Object
> archs
){
2344 if (getfpdPlatformDefs().getSupportedArchitectures() == null) {
2347 ListIterator li
= getfpdPlatformDefs().getSupportedArchitectures().listIterator();
2348 while(li
.hasNext()) {
2349 archs
.add(li
.next());
2353 public void setPlatformDefsSupportedArchs(Vector
<Object
> archs
) {
2354 if (archs
!= null) {
2355 getfpdPlatformDefs().setSupportedArchitectures(archs
);
2358 // XmlCursor cursor = getfpdPlatformDefs().newCursor();
2359 // if (cursor.toChild(xmlNs, "SupportedArchitectures")) {
2360 // cursor.removeXml();
2362 // cursor.dispose();
2366 public void getPlatformDefsBuildTargets(Vector
<Object
> targets
) {
2367 if (getfpdPlatformDefs().getBuildTargets() == null) {
2370 ListIterator li
= getfpdPlatformDefs().getBuildTargets().listIterator();
2371 while(li
.hasNext()) {
2372 targets
.add(li
.next());
2376 public void setPlatformDefsBuildTargets(Vector
<Object
> targets
) {
2377 getfpdPlatformDefs().setBuildTargets(targets
);
2380 public void genPlatformDefsSkuInfo(String id
, String name
) {
2381 SkuInfoDocument
.SkuInfo skuInfo
= null;
2382 if (getfpdPlatformDefs().getSkuInfo() == null) {
2383 skuInfo
= getfpdPlatformDefs().addNewSkuInfo();
2385 skuInfo
= getfpdPlatformDefs().getSkuInfo();
2386 if (skuInfo
.getUiSkuNameList() == null || skuInfo
.getUiSkuNameList().size() == 0) {
2387 SkuInfoDocument
.SkuInfo
.UiSkuName skuName
= skuInfo
.addNewUiSkuName();
2388 skuName
.setSkuID(new BigInteger("0"));
2389 skuName
.setStringValue("DEFAULT");
2391 if (id
.equals("0")) {
2394 SkuInfoDocument
.SkuInfo
.UiSkuName skuName
= skuInfo
.addNewUiSkuName();
2395 skuName
.setSkuID(new BigInteger(id
));
2396 skuName
.setStringValue(name
);
2399 public int getPlatformDefsSkuInfoCount(){
2400 if (getfpdPlatformDefs().getSkuInfo() == null || getfpdPlatformDefs().getSkuInfo().getUiSkuNameList() == null) {
2403 return getfpdPlatformDefs().getSkuInfo().getUiSkuNameList().size();
2406 public void getPlatformDefsSkuInfos(String
[][] saa
){
2407 if (getfpdPlatformDefs().getSkuInfo() == null || getfpdPlatformDefs().getSkuInfo().getUiSkuNameList() == null) {
2408 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null) {
2409 removeElement(getfpdDynPcdBuildDefs());
2410 fpdDynPcdBuildDefs
= null;
2415 List
<SkuInfoDocument
.SkuInfo
.UiSkuName
> l
= getfpdPlatformDefs().getSkuInfo().getUiSkuNameList();
2416 ListIterator
<SkuInfoDocument
.SkuInfo
.UiSkuName
> li
= l
.listIterator();
2418 while(li
.hasNext()) {
2419 SkuInfoDocument
.SkuInfo
.UiSkuName sku
= li
.next();
2420 saa
[i
][0] = sku
.getSkuID()+"";
2421 saa
[i
][1] = sku
.getStringValue();
2426 public void removePlatformDefsSkuInfo(int i
) {
2427 SkuInfoDocument
.SkuInfo skuInfo
= getfpdPlatformDefs().getSkuInfo();
2428 if (skuInfo
== null || i
== 0) {
2432 XmlCursor cursor
= skuInfo
.newCursor();
2433 if (cursor
.toFirstChild()) {
2434 for (int j
= 0; j
< i
; ++j
) {
2435 cursor
.toNextSibling();
2442 public void updatePlatformDefsSkuInfo(int i
, String id
, String name
) {
2443 SkuInfoDocument
.SkuInfo skuInfo
= getfpdPlatformDefs().getSkuInfo();
2444 if (skuInfo
== null || i
== 0) {
2448 XmlCursor cursor
= skuInfo
.newCursor();
2449 if (cursor
.toFirstChild()) {
2450 for (int j
= 0; j
< i
; ++j
) {
2451 cursor
.toNextSibling();
2453 SkuInfoDocument
.SkuInfo
.UiSkuName sku
= (SkuInfoDocument
.SkuInfo
.UiSkuName
)cursor
.getObject();
2454 sku
.setSkuID(new BigInteger(id
));
2455 sku
.setStringValue(name
);
2460 public String
getPlatformDefsInterDir(){
2461 if (getfpdPlatformDefs().getIntermediateDirectories() == null) {
2464 return getfpdPlatformDefs().getIntermediateDirectories().toString();
2467 public void setPlatformDefsInterDir(String interDir
){
2468 getfpdPlatformDefs().setIntermediateDirectories(IntermediateOutputType
.Enum
.forString(interDir
));
2471 public String
getPlatformDefsOutputDir() {
2472 return getfpdPlatformDefs().getOutputDirectory();
2475 public void setPlatformDefsOutputDir(String outputDir
) {
2476 if (outputDir
!= null && outputDir
.length() > 0) {
2477 getfpdPlatformDefs().setOutputDirectory(outputDir
);
2480 XmlCursor cursor
= getfpdPlatformDefs().newCursor();
2481 if (cursor
.toChild(new QName(xmlNs
, "OutputDirectory"))) {
2488 public FlashDocument
.Flash
getfpdFlash() {
2489 if (fpdFlash
== null) {
2490 fpdFlash
= fpdRoot
.addNewFlash();
2495 public void genFlashDefinitionFile(String file
) {
2496 FlashDefinitionFileDocument
.FlashDefinitionFile fdf
= getfpdFlash().getFlashDefinitionFile();
2498 fdf
= getfpdFlash().addNewFlashDefinitionFile();
2501 fdf
.setStringValue(file
);
2504 public String
getFlashDefinitionFile() {
2505 FlashDefinitionFileDocument
.FlashDefinitionFile fdf
= getfpdFlash().getFlashDefinitionFile();
2510 return fdf
.getStringValue();
2513 public void genFvImagesNameValue(String name
, String value
) {
2515 FvImagesDocument
.FvImages fi
= getfpdFlash().getFvImages();
2517 fi
= getfpdFlash().addNewFvImages();
2520 FvImagesDocument
.FvImages
.NameValue nv
= fi
.addNewNameValue();
2525 public void removeFvImagesNameValue(int i
){
2527 XmlObject o
= getfpdFlash().getFvImages();
2532 QName qNameValue
= new QName(xmlNs
, "NameValue");
2533 XmlCursor cursor
= o
.newCursor();
2534 if (cursor
.toChild(qNameValue
)) {
2535 for (int j
= 0; j
< i
; ++j
) {
2536 cursor
.toNextSibling(qNameValue
);
2543 public void updateFvImagesNameValue(int i
, String name
, String value
){
2545 XmlObject o
= getfpdFlash().getFvImages();
2550 QName qNameValue
= new QName(xmlNs
, "NameValue");
2551 XmlCursor cursor
= o
.newCursor();
2552 if (cursor
.toChild(qNameValue
)) {
2553 for (int j
= 0; j
< i
; ++j
) {
2554 cursor
.toNextSibling(qNameValue
);
2556 FvImagesDocument
.FvImages
.NameValue nv
= (FvImagesDocument
.FvImages
.NameValue
)cursor
.getObject();
2563 public int getFvImagesNameValueCount() {
2565 FvImagesDocument
.FvImages fi
= null;
2566 if ((fi
= getfpdFlash().getFvImages()) == null || fi
.getNameValueList() == null) {
2569 return fi
.getNameValueList().size();
2572 public void getFvImagesNameValues(String
[][] nv
) {
2574 FvImagesDocument
.FvImages fi
= getfpdFlash().getFvImages();
2578 List
<FvImagesDocument
.FvImages
.NameValue
> l
= fi
.getNameValueList();
2580 ListIterator li
= l
.listIterator();
2581 while (li
.hasNext()) {
2582 FvImagesDocument
.FvImages
.NameValue e
= (FvImagesDocument
.FvImages
.NameValue
) li
2584 nv
[i
][0] = e
.getName();
2585 nv
[i
][1] = e
.getValue();
2591 public void getFvImagesFvImageFvImageNames (Vector
<String
> vImageNames
) {
2595 public void AddFvImageFvImageNames (String
[] fvNames
) {
2596 FvImagesDocument
.FvImages fis
= getfpdFlash().getFvImages();
2597 if (fis
== null || fis
.getFvImageList() == null) {
2598 genFvImagesFvImage (fvNames
, "ImageName", null);
2602 ListIterator
<FvImagesDocument
.FvImages
.FvImage
> li
= fis
.getFvImageList().listIterator();
2603 while (li
.hasNext()) {
2604 FvImagesDocument
.FvImages
.FvImage fi
= li
.next();
2605 if (fi
.getType().toString().equals("ImageName")) {
2606 for (int i
= 0; i
< fvNames
.length
; ++i
) {
2607 fi
.addFvImageNames(fvNames
[i
]);
2612 genFvImagesFvImage (fvNames
, "ImageName", null);
2616 public void genFvImagesFvImage(String
[] names
, String types
, Map
<String
, String
> options
) {
2618 FvImagesDocument
.FvImages fis
= null;
2619 if ((fis
= getfpdFlash().getFvImages()) == null) {
2620 fis
= getfpdFlash().addNewFvImages();
2624 //gen FvImage with FvImageNames array
2626 FvImagesDocument
.FvImages
.FvImage fi
= fis
.addNewFvImage();
2627 for (int i
= 0; i
< names
.length
; ++i
) {
2628 fi
.addFvImageNames(names
[i
]);
2630 fi
.setType(FvImageTypes
.Enum
.forString(types
));
2631 if (options
!= null){
2632 setFvImagesFvImageFvImageOptions(options
, fi
);
2636 private void setFvImagesFvImageFvImageOptions(Map
<String
, String
> options
, FvImagesDocument
.FvImages
.FvImage fi
){
2637 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions fio
= fi
.getFvImageOptions();
2639 fio
= fi
.addNewFvImageOptions();
2642 Set
<String
> key
= options
.keySet();
2643 Iterator
<String
> i
= key
.iterator();
2644 while (i
.hasNext()) {
2646 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nv
= fio
.addNewNameValue();
2647 String k
= (String
)i
.next();
2650 nv
.setValue((String
)options
.get(k
));
2657 public void removeFvImagesFvImage(int i
) {
2659 XmlObject o
= getfpdFlash().getFvImages();
2664 QName qFvImage
= new QName(xmlNs
, "FvImage");
2665 XmlCursor cursor
= o
.newCursor();
2666 if (cursor
.toChild(qFvImage
)) {
2667 for (int j
= 0; j
< i
; ++j
) {
2668 cursor
.toNextSibling(qFvImage
);