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
.ModuleSurfaceAreaDocument
;
44 import org
.tianocore
.OptionDocument
;
45 import org
.tianocore
.OptionsDocument
;
46 import org
.tianocore
.PcdBuildDefinitionDocument
;
47 import org
.tianocore
.PcdCodedDocument
;
48 import org
.tianocore
.PcdDataTypes
;
49 import org
.tianocore
.PcdDeclarationsDocument
;
50 import org
.tianocore
.PcdItemTypes
;
51 import org
.tianocore
.PlatformDefinitionsDocument
;
52 import org
.tianocore
.PlatformSurfaceAreaDocument
;
53 import org
.tianocore
.FvImageTypes
;
54 import org
.tianocore
.FvImagesDocument
;
55 import org
.tianocore
.LicenseDocument
;
56 import org
.tianocore
.PlatformHeaderDocument
;
57 import org
.tianocore
.SkuInfoDocument
;
58 import org
.tianocore
.UserDefinedAntTasksDocument
;
59 import org
.tianocore
.frameworkwizard
.platform
.ui
.global
.GlobalData
;
60 import org
.tianocore
.frameworkwizard
.platform
.ui
.global
.SurfaceAreaQuery
;
61 import org
.tianocore
.frameworkwizard
.platform
.ui
.id
.ModuleIdentification
;
62 import org
.tianocore
.frameworkwizard
.platform
.ui
.id
.PackageIdentification
;
65 This class processes fpd file contents such as add remove xml elements.
66 @since PackageEditor 1.0
68 public class FpdFileContents
{
70 static final String xmlNs
= "http://www.TianoCore.org/2006/Edk2.0";
72 private PlatformSurfaceAreaDocument fpdd
= null;
74 private PlatformSurfaceAreaDocument
.PlatformSurfaceArea fpdRoot
= null;
76 private PlatformHeaderDocument
.PlatformHeader fpdHdr
= null;
78 private PlatformDefinitionsDocument
.PlatformDefinitions fpdPlatformDefs
= null;
80 private FlashDocument
.Flash fpdFlash
= null;
82 private BuildOptionsDocument
.BuildOptions fpdBuildOpts
= null;
84 private FrameworkModulesDocument
.FrameworkModules fpdFrameworkModules
= null;
86 private DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions fpdDynPcdBuildDefs
= null;
88 public static HashMap
<String
, ArrayList
<String
>> dynPcdMap
= null;
91 * look through all pcd data in all ModuleSA, create pcd -> ModuleSA mappings.
93 public void initDynPcdMap() {
94 if (dynPcdMap
== null) {
95 dynPcdMap
= new HashMap
<String
, ArrayList
<String
>>();
96 List
<ModuleSADocument
.ModuleSA
> l
= getfpdFrameworkModules().getModuleSAList();
100 ListIterator
<ModuleSADocument
.ModuleSA
> li
= l
.listIterator();
101 while (li
.hasNext()) {
102 ModuleSADocument
.ModuleSA msa
= li
.next();
103 if (msa
.getPcdBuildDefinition() == null || msa
.getPcdBuildDefinition().getPcdDataList() == null) {
106 String ModuleInfo
= msa
.getModuleGuid() + " " + msa
.getModuleVersion() +
107 " " + msa
.getPackageGuid() + " " + msa
.getPackageVersion();
108 List
<PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
> lp
= msa
.getPcdBuildDefinition().getPcdDataList();
109 ListIterator
<PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
> lpi
= lp
.listIterator();
110 while (lpi
.hasNext()) {
111 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= lpi
.next();
112 String pcdKey
= pcdData
.getCName() + " " + pcdData
.getTokenSpaceGuidCName();
113 if (dynPcdMap
.get(pcdKey
) == null) {
114 ArrayList
<String
> al
= new ArrayList
<String
>();
115 al
.add(ModuleInfo
+ " " + pcdData
.getItemType().toString());
116 dynPcdMap
.put(pcdKey
, al
);
119 dynPcdMap
.get(pcdKey
).add(ModuleInfo
+ " " + pcdData
.getItemType().toString());
126 Constructor to create a new spd file
128 public FpdFileContents() {
130 fpdd
= PlatformSurfaceAreaDocument
.Factory
.newInstance();
131 fpdRoot
= fpdd
.addNewPlatformSurfaceArea();
136 Constructor for existing document object
139 public FpdFileContents(PlatformSurfaceAreaDocument
.PlatformSurfaceArea fpd
) {
141 fpdHdr
= fpdRoot
.getPlatformHeader();
142 fpdPlatformDefs
= fpdRoot
.getPlatformDefinitions();
143 fpdBuildOpts
= fpdRoot
.getBuildOptions();
144 fpdFrameworkModules
= fpdRoot
.getFrameworkModules();
145 fpdDynPcdBuildDefs
= fpdRoot
.getDynamicPcdBuildDefinitions();
146 fpdFlash
= fpdRoot
.getFlash();
150 Constructor based on an existing spd file
152 @param f Existing spd file
154 public FpdFileContents(File f
) {
156 fpdd
= PlatformSurfaceAreaDocument
.Factory
.parse(f
);
157 fpdRoot
= fpdd
.getPlatformSurfaceArea();
158 } catch (Exception e
) {
159 System
.out
.println(e
.toString());
163 public DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
getfpdDynPcdBuildDefs() {
164 if (fpdDynPcdBuildDefs
== null){
165 fpdDynPcdBuildDefs
= fpdRoot
.addNewDynamicPcdBuildDefinitions();
167 return fpdDynPcdBuildDefs
;
170 public FrameworkModulesDocument
.FrameworkModules
getfpdFrameworkModules() {
171 if (fpdFrameworkModules
== null){
172 fpdFrameworkModules
= fpdRoot
.addNewFrameworkModules();
174 return fpdFrameworkModules
;
177 public int getFrameworkModulesCount() {
178 if (getfpdFrameworkModules().getModuleSAList() == null){
181 return getfpdFrameworkModules().getModuleSAList().size();
184 public void getFrameworkModulesInfo(String
[][] saa
) {
185 if (getFrameworkModulesCount() == 0){
189 ListIterator li
= getfpdFrameworkModules().getModuleSAList().listIterator();
191 while(li
.hasNext()) {
192 ModuleSADocument
.ModuleSA msa
= (ModuleSADocument
.ModuleSA
)li
.next();
193 saa
[i
][1] = msa
.getModuleGuid();
194 saa
[i
][2] = msa
.getModuleVersion();
196 saa
[i
][3] = msa
.getPackageGuid();
197 saa
[i
][4] = msa
.getPackageVersion();
198 // saa[i][4] = listToString(msa.getSupArchList());
203 public ModuleSADocument
.ModuleSA
getModuleSA(String key
) {
204 String
[] s
= key
.split(" ");
205 if (getfpdFrameworkModules().getModuleSAList() == null) {
208 ListIterator li
= getfpdFrameworkModules().getModuleSAList().listIterator();
209 while(li
.hasNext()) {
210 ModuleSADocument
.ModuleSA msa
= (ModuleSADocument
.ModuleSA
)li
.next();
211 if (msa
.getModuleGuid().equals(s
[0]) && msa
.getPackageGuid().equals(s
[2])) {
212 // if (msa.getModuleVersion() != null) {
213 // if (!msa.getModuleVersion().equals(s[1])) {
218 // if (s[1] != null) {
222 // if (msa.getPackageVersion() != null) {
223 // if (!msa.getPackageVersion().equals(s[3])) {
228 // if (s[3] != null) {
237 public void removeModuleSA(int i
) {
238 XmlObject o
= getfpdFrameworkModules();
243 XmlCursor cursor
= o
.newCursor();
244 if (cursor
.toFirstChild()) {
245 for (int j
= 0; j
< i
; ++j
) {
246 cursor
.toNextSibling();
249 // remove pcd from dynPcdMap, if DynamicPcdBuildData exists, remove them too.
251 ModuleSADocument
.ModuleSA moduleSa
= (ModuleSADocument
.ModuleSA
)cursor
.getObject();
252 String moduleInfo
= moduleSa
.getModuleGuid() + " " + moduleSa
.getModuleVersion() + " " +
253 moduleSa
.getPackageGuid()+ " " + moduleSa
.getPackageVersion();
254 PcdBuildDefinitionDocument
.PcdBuildDefinition pcdBuildDef
= moduleSa
.getPcdBuildDefinition();
255 if (pcdBuildDef
!= null) {
256 maintainDynPcdMap(pcdBuildDef
, moduleInfo
);
263 private void maintainDynPcdMap(PcdBuildDefinitionDocument
.PcdBuildDefinition o
, String moduleInfo
) {
264 XmlCursor cursor
= o
.newCursor();
265 boolean fromLibInstance
= false;
266 if (!cursor
.toFirstChild()){
270 // deal with first child, same process in the while loop below for siblings.
272 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= (PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
)cursor
.getObject();
273 String pcdKey
= pcdData
.getCName() + " " + pcdData
.getTokenSpaceGuidCName();
274 ArrayList
<String
> al
= dynPcdMap
.get(pcdKey
);
275 for(int i
= 0; i
< al
.size(); ++i
){
276 if (al
.get(i
).startsWith(moduleInfo
)){
277 fromLibInstance
= true;
281 al
.remove(moduleInfo
+ " " + pcdData
.getItemType().toString());
282 if (al
.size() == 0) {
283 dynPcdMap
.remove(pcdKey
);
286 if (pcdData
.getItemType().toString().equals("DYNAMIC")) {
287 if (dynPcdMap
.get(pcdKey
) == null) {
288 removeDynamicPcdBuildData(pcdData
.getCName(), pcdData
.getTokenSpaceGuidCName());
291 if (fromLibInstance
){
294 while(cursor
.toNextSibling()) {
295 fromLibInstance
= false;
296 pcdData
= (PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
)cursor
.getObject();
298 // remove each pcd record from dynPcdMap
300 pcdKey
= pcdData
.getCName() + " " + pcdData
.getTokenSpaceGuidCName();
301 al
= dynPcdMap
.get(pcdKey
);
302 for(int i
= 0; i
< al
.size(); ++i
){
303 if (al
.get(i
).startsWith(moduleInfo
)){
304 fromLibInstance
= true;
308 al
.remove(moduleInfo
+ " " + pcdData
.getItemType().toString());
309 if (al
.size() == 0) {
310 dynPcdMap
.remove(pcdKey
);
313 if (pcdData
.getItemType().toString().equals("DYNAMIC")) {
315 // First check whether this is the only consumer of this dyn pcd.
317 if (dynPcdMap
.get(pcdKey
) == null) {
319 // delete corresponding entry in DynamicPcdBuildData
321 removeDynamicPcdBuildData(pcdData
.getCName(), pcdData
.getTokenSpaceGuidCName());
324 if (fromLibInstance
){
330 // key for ModuleSA : "ModuleGuid ModuleVer PackageGuid PackageVer"
332 public int getPcdDataCount(String key
){
333 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
334 if (msa
== null || msa
.getPcdBuildDefinition() == null || msa
.getPcdBuildDefinition().getPcdDataList() == null){
337 return msa
.getPcdBuildDefinition().getPcdDataList().size();
340 public void getPcdData(String key
, String
[][] saa
) {
341 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
342 if (msa
== null || msa
.getPcdBuildDefinition() == null || msa
.getPcdBuildDefinition().getPcdDataList() == null){
345 ListIterator
<PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
>li
= msa
.getPcdBuildDefinition().getPcdDataList().listIterator();
346 for (int i
= 0; i
< saa
.length
; ++i
) {
347 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= li
.next();
348 saa
[i
][0] = pcdData
.getCName();
349 saa
[i
][1] = pcdData
.getTokenSpaceGuidCName();
350 saa
[i
][2] = pcdData
.getItemType().toString();
351 saa
[i
][3] = pcdData
.getToken().toString();
352 saa
[i
][4] = pcdData
.getDatumType().toString();
353 saa
[i
][5] = pcdData
.getValue();
358 // key for ModuleSA : "ModuleGuid ModuleVer PackageGuid PackageVer"
360 public int getLibraryInstancesCount(String key
) {
361 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
362 if (msa
== null || msa
.getLibraries() == null || msa
.getLibraries().getInstanceList() == null){
365 return msa
.getLibraries().getInstanceList().size();
368 public void getLibraryInstances(String key
, String
[][] saa
){
369 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
370 if (msa
== null || msa
.getLibraries() == null || msa
.getLibraries().getInstanceList() == null){
374 ListIterator
<LibrariesDocument
.Libraries
.Instance
> li
= msa
.getLibraries().getInstanceList().listIterator();
375 for (int i
= 0; i
< saa
.length
; ++i
) {
376 LibrariesDocument
.Libraries
.Instance instance
= li
.next();
377 saa
[i
][1] = instance
.getModuleGuid();
378 saa
[i
][2] = instance
.getModuleVersion();
379 saa
[i
][3] = instance
.getPackageGuid();
380 saa
[i
][4] = instance
.getPackageVersion();
384 public void removeLibraryInstances(String key
) {
385 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
386 if (msa
== null || msa
.getLibraries() == null){
390 XmlCursor cursor
= msa
.getLibraries().newCursor();
395 public void genLibraryInstance(String mg
, String mv
, String pg
, String pv
, String key
) {
396 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
398 msa
= getfpdFrameworkModules().addNewModuleSA();
400 LibrariesDocument
.Libraries libs
= msa
.getLibraries();
402 libs
= msa
.addNewLibraries();
405 LibrariesDocument
.Libraries
.Instance instance
= libs
.addNewInstance();
406 instance
.setModuleGuid(mg
);
407 instance
.setModuleVersion(mv
);
408 instance
.setPackageGuid(pg
);
409 instance
.setPackageVersion(pv
);
413 public String
getFvBinding(String moduleKey
){
414 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
415 if (msa
== null || msa
.getModuleSaBuildOptions() == null) {
418 return msa
.getModuleSaBuildOptions().getFvBinding();
421 public void setFvBinding(String moduleKey
, String fvBinding
){
422 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
426 if(msa
.getModuleSaBuildOptions() == null){
427 msa
.addNewModuleSaBuildOptions().setFvBinding(fvBinding
);
430 msa
.getModuleSaBuildOptions().setFvBinding(fvBinding
);
433 public String
getFfsFileNameGuid(String moduleKey
){
434 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
435 if (msa
== null || msa
.getModuleSaBuildOptions() == null) {
438 return msa
.getModuleSaBuildOptions().getFfsFileNameGuid();
441 public void setFfsFileNameGuid(String moduleKey
, String fileGuid
){
442 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
446 if(msa
.getModuleSaBuildOptions() == null){
447 msa
.addNewModuleSaBuildOptions().setFfsFileNameGuid(fileGuid
);
450 msa
.getModuleSaBuildOptions().setFfsFileNameGuid(fileGuid
);
453 public String
getFfsFormatKey(String moduleKey
){
454 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
455 if (msa
== null || msa
.getModuleSaBuildOptions() == null) {
458 return msa
.getModuleSaBuildOptions().getFfsFormatKey();
461 public void setFfsFormatKey(String moduleKey
, String ffsKey
){
462 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
466 if(msa
.getModuleSaBuildOptions() == null){
467 msa
.addNewModuleSaBuildOptions().setFfsFormatKey(ffsKey
);
470 msa
.getModuleSaBuildOptions().setFvBinding(ffsKey
);
473 public void getModuleSAOptions(String moduleKey
, String
[][] saa
) {
474 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
475 if (msa
.getModuleSaBuildOptions() == null || msa
.getModuleSaBuildOptions().getOptions() == null
476 || msa
.getModuleSaBuildOptions().getOptions().getOptionList() == null) {
480 List
<OptionDocument
.Option
> lOpt
= msa
.getModuleSaBuildOptions().getOptions().getOptionList();
481 ListIterator li
= lOpt
.listIterator();
483 while(li
.hasNext()) {
484 OptionDocument
.Option opt
= (OptionDocument
.Option
)li
.next();
485 if (opt
.getBuildTargets() != null) {
486 saa
[i
][0] = listToString(opt
.getBuildTargets());
488 saa
[i
][1] = opt
.getToolChainFamily();
489 if (opt
.getSupArchList() != null){
490 saa
[i
][2] = listToString(opt
.getSupArchList());
493 saa
[i
][3] = opt
.getToolCode();
494 saa
[i
][4] = opt
.getTagName();
495 saa
[i
][5] = opt
.getStringValue();
501 public int getModuleSAOptionsCount(String moduleKey
){
502 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
503 if (msa
.getModuleSaBuildOptions() == null || msa
.getModuleSaBuildOptions().getOptions() == null
504 || msa
.getModuleSaBuildOptions().getOptions().getOptionList() == null) {
507 return msa
.getModuleSaBuildOptions().getOptions().getOptionList().size();
510 public void genModuleSAOptionsOpt(String moduleKey
, Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
) {
511 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
512 if (msa
.getModuleSaBuildOptions() == null) {
513 msa
.addNewModuleSaBuildOptions();
515 if (msa
.getModuleSaBuildOptions().getOptions() == null){
516 msa
.getModuleSaBuildOptions().addNewOptions();
518 OptionDocument
.Option opt
= msa
.getModuleSaBuildOptions().getOptions().addNewOption();
519 setBuildOptionsOpt(buildTargets
, toolChain
, tagName
, toolCmd
, archList
, contents
, opt
);
522 public void removeModuleSAOptionsOpt(String moduleKey
, int i
) {
523 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
524 if (msa
.getModuleSaBuildOptions() == null || msa
.getModuleSaBuildOptions().getOptions() == null) {
527 OptionsDocument
.Options opts
= msa
.getModuleSaBuildOptions().getOptions();
528 XmlCursor cursor
= opts
.newCursor();
529 if (cursor
.toFirstChild()) {
530 for (int j
= 0; j
< i
; ++j
){
531 cursor
.toNextSibling();
538 public void updateModuleSAOptionsOpt(String moduleKey
, int i
, Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
) {
539 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
540 if (msa
.getModuleSaBuildOptions() == null || msa
.getModuleSaBuildOptions().getOptions() == null) {
543 OptionsDocument
.Options opts
= msa
.getModuleSaBuildOptions().getOptions();
544 XmlCursor cursor
= opts
.newCursor();
545 if (cursor
.toFirstChild()) {
546 for (int j
= 0; j
< i
; ++j
){
547 cursor
.toNextSibling();
549 OptionDocument
.Option opt
= (OptionDocument
.Option
)cursor
.getObject();
550 setBuildOptionsOpt(buildTargets
, toolChain
, tagName
, toolCmd
, archList
, contents
, opt
);
555 /**add pcd information of module mi to a ModuleSA.
557 * @param moduleSa if null, generate a new ModuleSA.
559 public void addFrameworkModulesPcdBuildDefs(ModuleIdentification mi
, ModuleSADocument
.ModuleSA moduleSa
){
560 //ToDo add Arch filter
563 ModuleSurfaceAreaDocument
.ModuleSurfaceArea msa
= (ModuleSurfaceAreaDocument
.ModuleSurfaceArea
)GlobalData
.getModuleXmlObject(mi
);
564 if (msa
.getPcdCoded() == null) {
567 if (moduleSa
== null) {
568 moduleSa
= genModuleSA(mi
);
570 Map
<String
, XmlObject
> m
= new HashMap
<String
, XmlObject
>();
571 m
.put("ModuleSurfaceArea", msa
);
572 SurfaceAreaQuery
.setDoc(m
);
573 PackageIdentification
[] depPkgs
= SurfaceAreaQuery
.getDependencePkg(null);
575 // Implementing InitializePlatformPcdBuildDefinitions
577 List
<PcdCodedDocument
.PcdCoded
.PcdEntry
> l
= msa
.getPcdCoded().getPcdEntryList();
578 ListIterator li
= l
.listIterator();
579 while(li
.hasNext()) {
580 PcdCodedDocument
.PcdCoded
.PcdEntry msaPcd
= (PcdCodedDocument
.PcdCoded
.PcdEntry
)li
.next();
581 PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry spdPcd
= LookupPcdDeclaration(msaPcd
, depPkgs
);
582 if (spdPcd
== null) {
589 // AddItem to ModuleSA PcdBuildDefinitions
591 String defaultVal
= msaPcd
.getDefaultValue() == null ? spdPcd
.getDefaultValue() : msaPcd
.getDefaultValue();
592 genPcdData(msaPcd
.getCName(), spdPcd
.getToken(), msaPcd
.getTokenSpaceGuidCName(), msaPcd
.getPcdItemType().toString(), spdPcd
.getDatumType()+"", defaultVal
, moduleSa
);
602 private PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry
LookupPcdDeclaration (PcdCodedDocument
.PcdCoded
.PcdEntry msaPcd
, PackageIdentification
[] depPkgs
) {
604 Map
<String
, XmlObject
> m
= new HashMap
<String
, XmlObject
>();
605 PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry spdPcd
= null;
606 for (int i
= 0; i
< depPkgs
.length
; ++i
) {
607 m
.put("PackageSurfaceArea", GlobalData
.getPackageXmlObject(depPkgs
[i
]));
608 SurfaceAreaQuery
.setDoc(m
);
609 XmlObject
[] xo
= SurfaceAreaQuery
.getSpdPcdDeclarations();
613 for (int j
= 0; j
< xo
.length
; ++j
) {
614 spdPcd
= (PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry
)xo
[j
];
615 if (msaPcd
.getTokenSpaceGuidCName() == null) {
616 if (spdPcd
.getCName().equals(msaPcd
.getCName())) {
621 if (spdPcd
.getCName().equals(msaPcd
.getCName()) && spdPcd
.getTokenSpaceGuidCName().equals(msaPcd
.getTokenSpaceGuidCName())) {
632 private ModuleSADocument
.ModuleSA
genModuleSA (ModuleIdentification mi
) {
633 PackageIdentification pi
= GlobalData
.getPackageForModule(mi
);
634 ModuleSADocument
.ModuleSA msa
= getfpdFrameworkModules().addNewModuleSA();
635 msa
.setModuleGuid(mi
.getGuid());
636 msa
.setModuleVersion(mi
.getVersion());
637 msa
.setPackageGuid(pi
.getGuid());
638 msa
.setPackageVersion(pi
.getVersion());
643 private void genPcdData (String cName
, Object token
, String tsGuid
, String itemType
, String dataType
, String defaultVal
, ModuleSADocument
.ModuleSA moduleSa
) {
644 if (moduleSa
.getPcdBuildDefinition() == null){
645 moduleSa
.addNewPcdBuildDefinition();
648 // constructe pcd to modulesa mapping first.
649 // Attention : for any error condition, remove from map this pcd.
651 ArrayList
<String
> pcdConsumer
= LookupPlatformPcdData(cName
+ " " + tsGuid
);
652 if (pcdConsumer
== null) {
653 pcdConsumer
= new ArrayList
<String
>();
655 String listValue
= moduleSa
.getModuleGuid() + " " + moduleSa
.getModuleVersion()
656 + " " + moduleSa
.getPackageGuid() + " " + moduleSa
.getPackageVersion()
658 pcdConsumer
.add(listValue
);
659 dynPcdMap
.put(cName
+ " " + tsGuid
, pcdConsumer
);
661 // Special dynamic type, if this pcd already exists in other ModuleSA
663 if (itemType
.equals("DYNAMIC")) {
665 ListIterator li
= pcdConsumer
.listIterator();
666 while(li
.hasNext()) {
667 String value
= li
.next().toString();
668 String
[] valuePart
= value
.split(" ");
669 if (!valuePart
[4].equals("DYNAMIC")) {
670 //ToDo error for same pcd, other type than dynamic
671 pcdConsumer
.remove(listValue
);
677 ListIterator li
= pcdConsumer
.listIterator();
678 while(li
.hasNext()) {
679 String value
= li
.next().toString();
680 String
[] valuePart
= value
.split(" ");
681 if (valuePart
[4].equals("DYNAMIC")) {
682 //ToDo error for same pcd, other type than non-dynamic
683 pcdConsumer
.remove(listValue
);
689 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData fpdPcd
= moduleSa
.getPcdBuildDefinition().addNewPcdData();
690 fpdPcd
.setCName(cName
);
691 fpdPcd
.setToken(token
);
692 fpdPcd
.setTokenSpaceGuidCName(tsGuid
);
693 fpdPcd
.setDatumType(PcdDataTypes
.Enum
.forString(dataType
));
694 fpdPcd
.setItemType(PcdItemTypes
.Enum
.forString(itemType
));
696 if (itemType
.equals("DYNAMIC") || itemType
.equals("DYNAMIC_EX")) {
697 ArrayList
<String
> al
= LookupDynamicPcdBuildDefinition(cName
+ " " + tsGuid
);
699 // if only one module mapped to this pcd, then the one is myself. so no other module mapped.
700 // so need to add one dyn pcd.
702 if (al
.size() == 1) {
703 addDynamicPcdBuildData(cName
, token
, tsGuid
, itemType
, dataType
, defaultVal
);
707 if (defaultVal
!= null){
708 fpdPcd
.setValue(defaultVal
);
711 if (dataType
.equals("UINT8") || dataType
.equals("UINT16") || dataType
.equals("UINT32") || dataType
.equals("UINT64")) {
712 fpdPcd
.setValue("0");
714 if (dataType
.equals("BOOLEAN")){
715 fpdPcd
.setValue("false");
717 if (dataType
.equals("VOID*")) {
721 if (dataType
.equals("UINT8")){
722 fpdPcd
.setMaxDatumSize(1);
724 if (dataType
.equals("UINT16")) {
725 fpdPcd
.setMaxDatumSize(2);
727 if (dataType
.equals("UINT32")) {
728 fpdPcd
.setMaxDatumSize(4);
730 if (dataType
.equals("UINT64")){
731 fpdPcd
.setMaxDatumSize(8);
733 if (dataType
.equals("BOOLEAN")){
734 fpdPcd
.setMaxDatumSize(1);
736 if (dataType
.equals("VOID*")) {
737 int maxSize
= setMaxSizeForPointer(fpdPcd
.getValue());
738 fpdPcd
.setMaxDatumSize(maxSize
);
743 private int setMaxSizeForPointer(String datum
) {
747 char ch
= datum
.charAt(0);
751 // For void* type PCD, only three datum is support:
752 // 1) Unicode: string with start char is "L"
753 // 2) Ansci: String is ""
754 // 3) byte array: String start char "{"
757 start
= datum
.indexOf('\"');
758 end
= datum
.lastIndexOf('\"');
760 (end
> datum
.length())||
761 ((start
== end
) && (datum
.length() > 0))) {
762 //ToDo Error handling here
765 strValue
= datum
.substring(start
+ 1, end
);
766 return strValue
.length() * 2;
767 } else if (ch
== '\"'){
768 start
= datum
.indexOf('\"');
769 end
= datum
.lastIndexOf('\"');
771 (end
> datum
.length())||
772 ((start
== end
) && (datum
.length() > 0))) {
775 strValue
= datum
.substring(start
+ 1, end
);
776 return strValue
.length();
777 } else if (ch
=='{') {
778 String
[] strValueArray
;
780 start
= datum
.indexOf('{');
781 end
= datum
.lastIndexOf('}');
782 strValue
= datum
.substring(start
+ 1, end
);
783 strValue
= strValue
.trim();
784 if (strValue
.length() == 0) {
787 strValueArray
= strValue
.split(",");
788 for (int index
= 0; index
< strValueArray
.length
; index
++) {
789 Integer value
= Integer
.decode(strValueArray
[index
].trim());
792 // "[FPD file error] The datum type of PCD %s in %s is VOID*, "+
793 // "it is byte array in fact. But the element of %s exceed the byte range",
797 return strValueArray
.length
;
801 // "[FPD file error] The datum type of PCD %s in %s is VOID*. For VOID* type, you have three format choise:\n "+
802 // "1) UNICODE string: like L\"xxxx\";\r\n"+
803 // "2) ANSIC string: like \"xxx\";\r\n"+
804 // "3) Byte array: like {0x2, 0x45, 0x23}\r\n"+
805 // "but the datum in seems does not following above format!",
811 private ArrayList
<String
> LookupDynamicPcdBuildDefinition(String dynPcdKey
) {
812 ArrayList
<String
> al
= dynPcdMap
.get(dynPcdKey
);
817 private ArrayList
<String
> LookupPlatformPcdData(String pcdKey
) {
819 return dynPcdMap
.get("pcdKey");
822 public int getDynamicPcdBuildDataCount() {
823 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null) {
826 return getfpdDynPcdBuildDefs().getPcdBuildDataList().size();
829 public void getDynamicPcdBuildData(String
[][] saa
) {
830 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null) {
833 List
<DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
> l
= getfpdDynPcdBuildDefs().getPcdBuildDataList();
834 ListIterator
<DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
> li
= l
.listIterator();
836 while(li
.hasNext()) {
837 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData dynPcd
= li
.next();
838 saa
[i
][0] = dynPcd
.getCName();
839 saa
[i
][1] = dynPcd
.getToken().toString();
840 saa
[i
][2] = dynPcd
.getTokenSpaceGuidCName();
841 saa
[i
][3] = dynPcd
.getMaxDatumSize()+"";
842 saa
[i
][4] = dynPcd
.getDatumType().toString();
848 private void addDynamicPcdBuildData(String cName
, Object token
, String tsGuid
, String itemType
, String dataType
, String defaultVal
) {
849 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData dynPcdData
= getfpdDynPcdBuildDefs().addNewPcdBuildData();
850 dynPcdData
.setItemType(PcdItemTypes
.Enum
.forString(itemType
));
851 dynPcdData
.setCName(cName
);
852 dynPcdData
.setToken(token
);
853 dynPcdData
.setTokenSpaceGuidCName(tsGuid
);
854 dynPcdData
.setDatumType(PcdDataTypes
.Enum
.forString(dataType
));
856 BigInteger bigInt
= new BigInteger("0");
857 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo skuInfo
= dynPcdData
.addNewSkuInfo();
858 skuInfo
.setSkuId(bigInt
);
859 if (defaultVal
!= null){
860 skuInfo
.setValue(defaultVal
);
863 if (dataType
.equals("UINT8")){
864 skuInfo
.setValue("0");
866 if (dataType
.equals("UINT16")) {
867 skuInfo
.setValue("0");
869 if (dataType
.equals("UINT32")) {
870 skuInfo
.setValue("0");
872 if (dataType
.equals("UINT64")){
873 skuInfo
.setValue("0");
875 if (dataType
.equals("BOOLEAN")){
876 skuInfo
.setValue("false");
878 if (dataType
.equals("VOID*")) {
879 skuInfo
.setValue("");
882 if (dataType
.equals("UINT8")){
883 dynPcdData
.setMaxDatumSize(1);
885 if (dataType
.equals("UINT16")) {
886 dynPcdData
.setMaxDatumSize(2);
888 if (dataType
.equals("UINT32")) {
889 dynPcdData
.setMaxDatumSize(4);
891 if (dataType
.equals("UINT64")){
892 dynPcdData
.setMaxDatumSize(8);
894 if (dataType
.equals("BOOLEAN")){
895 dynPcdData
.setMaxDatumSize(1);
897 if (dataType
.equals("VOID*")) {
898 int maxSize
= setMaxSizeForPointer(defaultVal
);
899 dynPcdData
.setMaxDatumSize(maxSize
);
903 private void removeDynamicPcdBuildData(String cName
, String tsGuid
) {
904 XmlObject o
= getfpdDynPcdBuildDefs();
906 XmlCursor cursor
= o
.newCursor();
907 if (cursor
.toFirstChild()) {
908 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdBuildData
=
909 (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
910 while (!(pcdBuildData
.getCName().equals(cName
) && pcdBuildData
.getTokenSpaceGuidCName().equals(tsGuid
))) {
911 cursor
.toNextSibling();
912 pcdBuildData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
920 // Get the Sku Info count of ith dyn pcd element.
922 public int getDynamicPcdSkuInfoCount(int i
){
923 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
927 int skuInfoCount
= 0;
928 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
929 if (cursor
.toFirstChild()) {
930 for (int j
= 0; j
< i
; ++j
) {
931 cursor
.toNextSibling();
933 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
934 if (pcdData
.getSkuInfoList() == null) {
938 skuInfoCount
= pcdData
.getSkuInfoList().size();
945 public void getDynamicPcdSkuInfos(int i
, String
[][] saa
){
946 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
950 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
951 if (cursor
.toFirstChild()) {
952 for (int j
= 0; j
< i
; ++j
) {
953 cursor
.toNextSibling();
955 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
956 if (pcdData
.getSkuInfoList() == null) {
961 ListIterator
<DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo
> li
= pcdData
.getSkuInfoList().listIterator();
963 while (li
.hasNext()) {
964 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo skuInfo
= li
.next();
965 saa
[k
][0] = skuInfo
.getSkuId()+"";
966 saa
[k
][1] = skuInfo
.getVariableName();
967 saa
[k
][2] = skuInfo
.getVariableGuid();
968 saa
[k
][3] = skuInfo
.getVariableOffset();
969 saa
[k
][4] = skuInfo
.getHiiDefaultValue();
970 saa
[k
][5] = skuInfo
.getVpdOffset();
971 saa
[k
][6] = skuInfo
.getValue();
981 public String
getDynamicPcdBuildDataValue(int i
){
983 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
987 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
988 if (cursor
.toFirstChild()) {
989 for (int j
= 0; j
< i
; ++j
) {
990 cursor
.toNextSibling();
992 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
993 if (pcdData
.getSkuInfoList() == null) {
997 value
= pcdData
.getSkuInfoArray(0).getValue();
1004 public String
getDynamicPcdBuildDataVpdOffset(int i
){
1005 String vpdOffset
= null;
1006 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1010 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1011 if (cursor
.toFirstChild()) {
1012 for (int j
= 0; j
< i
; ++j
) {
1013 cursor
.toNextSibling();
1015 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1016 if (pcdData
.getSkuInfoList() == null) {
1020 vpdOffset
= pcdData
.getSkuInfoArray(0).getVpdOffset();
1027 public void removeDynamicPcdBuildDataSkuInfo(int i
) {
1028 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1032 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1033 if (cursor
.toFirstChild()) {
1034 for (int j
= 0; j
< i
; ++j
) {
1035 cursor
.toNextSibling();
1037 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1038 if (pcdData
.getSkuInfoList() == null) {
1043 QName qSkuInfo
= new QName(xmlNs
, "SkuInfo");
1044 cursor
.toChild(qSkuInfo
);
1051 // generate sku info for ith dyn pcd build data.
1053 public void genDynamicPcdBuildDataSkuInfo(String id
, String varName
, String varGuid
, String varOffset
,
1054 String hiiDefault
, String vpdOffset
, String value
, int i
) {
1055 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1059 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1060 if (cursor
.toFirstChild()) {
1061 for (int j
= 0; j
< i
; ++j
) {
1062 cursor
.toNextSibling();
1064 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1065 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo skuInfo
= pcdData
.addNewSkuInfo();
1066 skuInfo
.setSkuId(new BigInteger(id
));
1067 if (varName
!= null){
1068 skuInfo
.setVariableName(varName
);
1069 skuInfo
.setVariableGuid(varGuid
);
1070 skuInfo
.setVariableOffset(varOffset
);
1071 skuInfo
.setHiiDefaultValue(hiiDefault
);
1073 else if (vpdOffset
!= null){
1074 skuInfo
.setVpdOffset(vpdOffset
);
1077 skuInfo
.setValue(value
);
1082 public void updateDynamicPcdBuildDataSkuInfo(String id
, String varName
, String varGuid
, String varOffset
,
1083 String hiiDefault
, String vpdOffset
, String value
, int i
){
1084 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1088 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1089 if (cursor
.toFirstChild()) {
1090 for (int j
= 0; j
< i
; ++j
) {
1091 cursor
.toNextSibling();
1093 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1094 ListIterator
<DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo
> li
= pcdData
.getSkuInfoList().listIterator();
1095 while (li
.hasNext()) {
1096 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo skuInfo
= li
.next();
1097 if (skuInfo
.getSkuId().toString().equals(id
)){
1098 if (varName
!= null){
1099 skuInfo
.setVariableName(varName
);
1100 skuInfo
.setVariableGuid(varGuid
);
1101 skuInfo
.setVariableOffset(varOffset
);
1102 skuInfo
.setHiiDefaultValue(hiiDefault
);
1104 else if (vpdOffset
!= null){
1105 skuInfo
.setVpdOffset(vpdOffset
);
1108 skuInfo
.setValue(value
);
1116 public void removePcdDataFromLibraryInstance(String moduleKey
, String libInstanceKey
){
1117 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(moduleKey
);
1119 // should better maintain pcd from lib instance only, but maintain all is acceptable now.
1121 maintainDynPcdMap(moduleSa
.getPcdBuildDefinition(), libInstanceKey
);
1125 public BuildOptionsDocument
.BuildOptions
getfpdBuildOpts() {
1126 if (fpdBuildOpts
== null) {
1127 fpdBuildOpts
= fpdRoot
.addNewBuildOptions();
1129 return fpdBuildOpts
;
1132 public void genBuildOptionsUserDefAntTask (String id
, String fileName
, String execOrder
) {
1133 UserDefinedAntTasksDocument
.UserDefinedAntTasks udats
= getfpdBuildOpts().getUserDefinedAntTasks();
1134 if (udats
== null) {
1135 udats
= getfpdBuildOpts().addNewUserDefinedAntTasks();
1138 AntTaskDocument
.AntTask at
= udats
.addNewAntTask();
1139 setBuildOptionsUserDefAntTask(id
, fileName
, execOrder
, at
);
1142 private void setBuildOptionsUserDefAntTask(String id
, String fileName
, String execOrder
, AntTaskDocument
.AntTask at
) {
1143 at
.setId(new Integer(id
));
1144 if (fileName
!= null){
1145 at
.setFilename(fileName
);
1147 if (execOrder
!= null) {
1148 at
.setAntCmdOptions(execOrder
);
1152 public void removeBuildOptionsUserDefAntTask(int i
) {
1153 XmlObject o
= getfpdBuildOpts().getUserDefinedAntTasks();
1157 XmlCursor cursor
= o
.newCursor();
1158 if (cursor
.toFirstChild()) {
1159 for (int j
= 0; j
< i
; ++j
) {
1160 cursor
.toNextSibling();
1167 public void updateBuildOptionsUserDefAntTask(int i
, String id
, String fileName
, String execOrder
){
1168 XmlObject o
= getfpdBuildOpts().getUserDefinedAntTasks();
1172 XmlCursor cursor
= o
.newCursor();
1173 if (cursor
.toFirstChild()) {
1174 for (int j
= 0; j
< i
; ++j
) {
1175 cursor
.toNextSibling();
1177 AntTaskDocument
.AntTask at
= (AntTaskDocument
.AntTask
)cursor
.getObject();
1178 setBuildOptionsUserDefAntTask(id
, fileName
, execOrder
, at
);
1183 public int getBuildOptionsUserDefAntTaskCount() {
1184 UserDefinedAntTasksDocument
.UserDefinedAntTasks udats
= getfpdBuildOpts().getUserDefinedAntTasks();
1185 if (udats
== null || udats
.getAntTaskList() == null) {
1189 return udats
.getAntTaskList().size();
1192 public void getBuildOptionsUserDefAntTasks(String
[][] saa
) {
1193 UserDefinedAntTasksDocument
.UserDefinedAntTasks udats
= getfpdBuildOpts().getUserDefinedAntTasks();
1194 if (udats
== null || udats
.getAntTaskList() == null) {
1198 List
<AntTaskDocument
.AntTask
> l
= udats
.getAntTaskList();
1199 ListIterator li
= l
.listIterator();
1201 while (li
.hasNext()) {
1202 AntTaskDocument
.AntTask at
= (AntTaskDocument
.AntTask
)li
.next();
1203 saa
[i
][0] = at
.getId() + "";
1204 saa
[i
][1] = saa
[i
][2] = "";
1205 if (at
.getFilename() != null){
1206 saa
[i
][1] = at
.getFilename();
1208 if (at
.getAntCmdOptions() != null) {
1209 saa
[i
][2] = at
.getAntCmdOptions();
1214 public void genBuildOptionsOpt(Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
) {
1215 OptionsDocument
.Options opts
= getfpdBuildOpts().getOptions();
1217 opts
= getfpdBuildOpts().addNewOptions();
1219 OptionDocument
.Option opt
= opts
.addNewOption();
1220 setBuildOptionsOpt(buildTargets
, toolChain
, tagName
, toolCmd
, archList
, contents
, opt
);
1223 private void setBuildOptionsOpt(Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
, OptionDocument
.Option opt
){
1224 opt
.setStringValue(contents
);
1226 opt
.setBuildTargets(buildTargets
);
1227 opt
.setToolChainFamily(toolChain
);
1228 opt
.setTagName(tagName
);
1229 opt
.setToolCode(toolCmd
);
1231 opt
.setSupArchList(archList
);
1234 public void removeBuildOptionsOpt(int i
){
1236 XmlObject o
= getfpdBuildOpts().getOptions();
1241 XmlCursor cursor
= o
.newCursor();
1242 if (cursor
.toFirstChild()) {
1243 for (int j
= 0; j
< i
; ++j
) {
1244 cursor
.toNextSibling();
1251 public void updateBuildOptionsOpt(int i
, Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
) {
1252 XmlObject o
= getfpdBuildOpts().getOptions();
1257 XmlCursor cursor
= o
.newCursor();
1258 if (cursor
.toFirstChild()) {
1259 for (int j
= 0; j
< i
; ++j
) {
1260 cursor
.toNextSibling();
1262 OptionDocument
.Option opt
= (OptionDocument
.Option
)cursor
.getObject();
1263 setBuildOptionsOpt(buildTargets
, toolChain
, tagName
, toolCmd
, archList
, contents
, opt
);
1268 public int getBuildOptionsOptCount(){
1269 if (getfpdBuildOpts().getOptions() == null || getfpdBuildOpts().getOptions().getOptionList() == null) {
1272 return getfpdBuildOpts().getOptions().getOptionList().size();
1275 public void getBuildOptionsOpts(String
[][] saa
) {
1276 if (getfpdBuildOpts().getOptions() == null || getfpdBuildOpts().getOptions().getOptionList() == null) {
1280 List
<OptionDocument
.Option
> lOpt
= getfpdBuildOpts().getOptions().getOptionList();
1281 ListIterator li
= lOpt
.listIterator();
1283 while(li
.hasNext()) {
1284 OptionDocument
.Option opt
= (OptionDocument
.Option
)li
.next();
1285 if (opt
.getBuildTargets() != null) {
1286 saa
[i
][0] = listToString(opt
.getBuildTargets());
1288 saa
[i
][1] = opt
.getToolChainFamily();
1289 if (opt
.getSupArchList() != null){
1290 saa
[i
][2] = listToString(opt
.getSupArchList());
1293 saa
[i
][3] = opt
.getToolCode();
1294 saa
[i
][4] = opt
.getTagName();
1295 saa
[i
][5] = opt
.getStringValue();
1301 public void genBuildOptionsFfs(String ffsKey
, String type
) {
1302 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getfpdBuildOpts().addNewFfs();
1303 ffs
.setFfsKey(ffsKey
);
1305 ffs
.addNewSections().setEncapsulationType(type
);
1309 public void updateBuildOptionsFfsSectionsType(int i
, String type
) {
1310 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getfpdBuildOpts().addNewFfs();
1312 ffs
.addNewSections().setEncapsulationType(type
);
1316 public void genBuildOptionsFfsAttribute(int i
, String name
, String value
) {
1317 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1318 BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute attrib
= ffs
.addNewAttribute();
1319 attrib
.setName(name
);
1320 attrib
.setValue(value
);
1323 /**update jth attribute of ith ffs.
1327 public void updateBuildOptionsFfsAttribute(int i
, int j
, String name
, String value
){
1328 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1329 XmlCursor cursor
= ffs
.newCursor();
1330 QName qAttrib
= new QName(xmlNs
, "Attribute");
1331 if (cursor
.toChild(qAttrib
)) {
1332 for (int k
= 0; k
< j
; ++k
) {
1333 cursor
.toNextSibling(qAttrib
);
1335 BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute attrib
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute
)cursor
.getObject();
1336 attrib
.setName(name
);
1337 attrib
.setValue(value
);
1342 public void removeBuildOptionsFfsAttribute(int i
, int j
){
1343 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1344 XmlCursor cursor
= ffs
.newCursor();
1345 QName qAttrib
= new QName(xmlNs
, "Attribute");
1346 if (cursor
.toChild(qAttrib
)) {
1347 for (int k
= 0; k
< j
; ++k
) {
1348 cursor
.toNextSibling(qAttrib
);
1355 public void genBuildOptionsFfsSectionsSection(int i
, String sectionType
) {
1356 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1360 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1362 if (sections
== null){
1363 sections
= ffs
.addNewSections();
1365 sections
.addNewSection().setSectionType(EfiSectionType
.Enum
.forString(sectionType
));
1368 public void removeBuildOptionsFfsSectionsSection(int i
, int j
) {
1369 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1370 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1371 if (sections
== null) {
1374 XmlCursor cursor
= sections
.newCursor();
1375 QName qSection
= new QName(xmlNs
, "Section");
1376 if (cursor
.toChild(qSection
)) {
1377 for (int k
= 0; k
< j
; ++k
) {
1378 cursor
.toNextSibling(qSection
);
1385 public void updateBuildOptionsFfsSectionsSection(int i
, int j
, String type
){
1386 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1387 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1388 if (sections
== null) {
1391 XmlCursor cursor
= sections
.newCursor();
1392 QName qSection
= new QName(xmlNs
, "Section");
1393 if (cursor
.toChild(qSection
)) {
1394 for (int k
= 0; k
< j
; ++k
) {
1395 cursor
.toNextSibling(qSection
);
1397 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Section section
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Section
)cursor
.getObject();
1398 section
.setSectionType(EfiSectionType
.Enum
.forString(type
));
1403 public void genBuildOptionsFfsSectionsSections(int i
, String encapType
) {
1404 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1408 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1410 if (sections
== null){
1411 sections
= ffs
.addNewSections();
1413 sections
.addNewSections().setEncapsulationType(encapType
);
1416 public void removeBuildOptionsFfsSectionsSections(int i
, int j
) {
1417 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1418 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1419 if (sections
== null) {
1422 XmlCursor cursor
= sections
.newCursor();
1423 QName qSections
= new QName(xmlNs
, "Sections");
1424 if (cursor
.toChild(qSections
)) {
1425 for (int k
= 0; k
< j
; ++k
) {
1426 cursor
.toNextSibling(qSections
);
1433 public void updateBuildOptionsFfsSectionsSections(int i
, int j
, String type
) {
1434 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1435 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1436 if (sections
== null) {
1439 XmlCursor cursor
= sections
.newCursor();
1440 QName qSections
= new QName(xmlNs
, "Sections");
1441 if (cursor
.toChild(qSections
)) {
1442 for (int k
= 0; k
< j
; ++k
) {
1443 cursor
.toNextSibling(qSections
);
1445 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2 sections2
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
)cursor
.getObject();
1446 sections2
.setEncapsulationType(type
);
1451 public void genBuildOptionsFfsSectionsSectionsSection(int i
, int j
, String type
) {
1452 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1456 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1457 XmlCursor cursor
= sections
.newCursor();
1458 QName qSections
= new QName(xmlNs
, "Sections");
1459 if (cursor
.toChild(qSections
)){
1460 for (int k
= 0; k
< j
; ++k
) {
1461 cursor
.toNextSibling(qSections
);
1463 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2 sections2
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
)cursor
.getObject();
1464 sections2
.addNewSection().setSectionType(EfiSectionType
.Enum
.forString(type
));
1469 public void removeBuildOptionsFfsSectionsSectionsSection(int i
, int j
, int k
) {
1470 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1471 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1472 if (sections
== null) {
1475 XmlCursor cursor
= sections
.newCursor();
1476 QName qSections
= new QName(xmlNs
, "Sections");
1477 if (cursor
.toChild(qSections
)) {
1478 for (int l
= 0; l
< j
; ++l
) {
1479 cursor
.toNextSibling(qSections
);
1481 if (cursor
.toFirstChild()) {
1482 for (int m
= 0; m
< k
; ++m
) {
1483 cursor
.toNextSibling();
1491 public void updateBuildOptionsFfsSectionsSectionsSection(int i
, int j
, int k
, String type
) {
1492 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1493 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1494 if (sections
== null) {
1497 XmlCursor cursor
= sections
.newCursor();
1498 QName qSections
= new QName(xmlNs
, "Sections");
1499 if (cursor
.toChild(qSections
)) {
1500 for (int l
= 0; l
< j
; ++l
) {
1501 cursor
.toNextSibling(qSections
);
1503 if (cursor
.toFirstChild()) {
1504 for (int m
= 0; m
< k
; ++m
) {
1505 cursor
.toNextSibling();
1507 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section section
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section
)cursor
.getObject();
1508 section
.setSectionType(EfiSectionType
.Enum
.forString(type
));
1514 public void getBuildOptionsFfsSectionsSectionsSection(int i
, int j
, ArrayList
<String
> al
) {
1515 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1519 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1520 XmlCursor cursor
= sections
.newCursor();
1521 QName qSections
= new QName(xmlNs
, "Sections");
1522 if (cursor
.toChild(qSections
)){
1523 for (int k
= 0; k
< j
; ++k
) {
1524 cursor
.toNextSibling(qSections
);
1526 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2 sections2
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
)cursor
.getObject();
1527 if (sections2
.getSectionList() == null){
1531 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section
> li
= sections2
.getSectionList().listIterator();
1532 while(li
.hasNext()) {
1533 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section section
= li
.next();
1534 if (section
.isSetSectionType()) {
1535 al
.add(section
.getSectionType().toString());
1544 public int getBuildOptionsFfsCount(){
1545 if (getfpdBuildOpts().getFfsList() == null) {
1548 return getfpdBuildOpts().getFfsList().size();
1551 public void getBuildOptionsFfsKey(String
[][] saa
) {
1552 if (getfpdBuildOpts().getFfsList() == null) {
1555 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
> li
= getfpdBuildOpts().getFfsList().listIterator();
1557 while(li
.hasNext()){
1558 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= li
.next();
1559 saa
[i
][0] = ffs
.getFfsKey();
1564 public void updateBuildOptionsFfsKey(int i
, String key
) {
1565 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1569 /**Get ith FFS key and contents.
1572 public void getBuildOptionsFfs(int i
, String
[] sa
, LinkedHashMap
<String
, String
> ffsAttribMap
, ArrayList
<String
> firstLevelSections
, ArrayList
<String
> firstLevelSection
) {
1573 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1577 sa
[0] = ffs
.getFfsKey();
1578 if (ffs
.getSections() != null) {
1579 if(ffs
.getSections().getEncapsulationType() != null){
1580 sa
[1] = ffs
.getSections().getEncapsulationType();
1582 if (ffs
.getSections().getSectionList() != null){
1583 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Section
> li
= ffs
.getSections().getSectionList().listIterator();
1584 while (li
.hasNext()) {
1585 firstLevelSection
.add(li
.next().getSectionType().toString());
1588 if (ffs
.getSections().getSectionsList() != null) {
1589 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
> li
= ffs
.getSections().getSectionsList().listIterator();
1590 while(li
.hasNext()) {
1591 firstLevelSections
.add(li
.next().getEncapsulationType());
1595 if (ffs
.getAttributeList() != null) {
1596 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute
> li
= ffs
.getAttributeList().listIterator();
1597 while(li
.hasNext()) {
1598 BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute attrib
= li
.next();
1599 ffsAttribMap
.put(attrib
.getName(), attrib
.getValue());
1608 private BuildOptionsDocument
.BuildOptions
.Ffs
getFfs(int i
) {
1609 XmlObject o
= getfpdBuildOpts();
1610 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= null;
1612 XmlCursor cursor
= o
.newCursor();
1613 QName qFfs
= new QName(xmlNs
, "Ffs");
1614 if (cursor
.toChild(qFfs
)) {
1615 for (int j
= 0; j
< i
; ++j
) {
1616 cursor
.toNextSibling(qFfs
);
1618 ffs
= (BuildOptionsDocument
.BuildOptions
.Ffs
)cursor
.getObject();
1624 public void removeBuildOptionsFfs(int i
) {
1625 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1630 XmlCursor cursor
= ffs
.newCursor();
1637 public PlatformDefinitionsDocument
.PlatformDefinitions
getfpdPlatformDefs(){
1638 if (fpdPlatformDefs
== null){
1639 fpdPlatformDefs
= fpdRoot
.addNewPlatformDefinitions();
1641 return fpdPlatformDefs
;
1644 public void getPlatformDefsSupportedArchs(Vector
<Object
> archs
){
1645 if (getfpdPlatformDefs().getSupportedArchitectures() == null) {
1648 ListIterator li
= getfpdPlatformDefs().getSupportedArchitectures().listIterator();
1649 while(li
.hasNext()) {
1650 archs
.add(li
.next());
1654 public void setPlatformDefsSupportedArchs(Vector
<Object
> archs
) {
1655 getfpdPlatformDefs().setSupportedArchitectures(archs
);
1658 public void getPlatformDefsBuildTargets(Vector
<Object
> targets
) {
1659 if (getfpdPlatformDefs().getBuildTargets() == null) {
1662 ListIterator li
= getfpdPlatformDefs().getBuildTargets().listIterator();
1663 while(li
.hasNext()) {
1664 targets
.add(li
.next());
1668 public void setPlatformDefsBuildTargets(Vector
<Object
> targets
) {
1669 getfpdPlatformDefs().setBuildTargets(targets
);
1672 public void genPlatformDefsSkuInfo(String id
, String name
) {
1673 SkuInfoDocument
.SkuInfo skuInfo
= null;
1674 if (getfpdPlatformDefs().getSkuInfo() == null) {
1675 skuInfo
= getfpdPlatformDefs().addNewSkuInfo();
1677 skuInfo
= getfpdPlatformDefs().getSkuInfo();
1678 if (skuInfo
.getUiSkuNameList() == null || skuInfo
.getUiSkuNameList().size() == 0) {
1679 SkuInfoDocument
.SkuInfo
.UiSkuName skuName
= skuInfo
.addNewUiSkuName();
1680 skuName
.setSkuID(new BigInteger("0"));
1681 skuName
.setStringValue("DEFAULT");
1683 if (id
.equals("0")) {
1686 SkuInfoDocument
.SkuInfo
.UiSkuName skuName
= skuInfo
.addNewUiSkuName();
1687 skuName
.setSkuID(new BigInteger(id
));
1688 skuName
.setStringValue(name
);
1691 public int getPlatformDefsSkuInfoCount(){
1692 if (getfpdPlatformDefs().getSkuInfo() == null || getfpdPlatformDefs().getSkuInfo().getUiSkuNameList() == null) {
1695 return getfpdPlatformDefs().getSkuInfo().getUiSkuNameList().size();
1698 public void getPlatformDefsSkuInfos(String
[][] saa
){
1699 if (getfpdPlatformDefs().getSkuInfo() == null || getfpdPlatformDefs().getSkuInfo().getUiSkuNameList() == null) {
1703 List
<SkuInfoDocument
.SkuInfo
.UiSkuName
> l
= getfpdPlatformDefs().getSkuInfo().getUiSkuNameList();
1704 ListIterator
<SkuInfoDocument
.SkuInfo
.UiSkuName
> li
= l
.listIterator();
1706 while(li
.hasNext()) {
1707 SkuInfoDocument
.SkuInfo
.UiSkuName sku
= li
.next();
1708 saa
[i
][0] = sku
.getSkuID()+"";
1709 saa
[i
][1] = sku
.getStringValue();
1714 public void removePlatformDefsSkuInfo(int i
) {
1715 SkuInfoDocument
.SkuInfo skuInfo
= getfpdPlatformDefs().getSkuInfo();
1716 if (skuInfo
== null || i
== 0) {
1720 XmlCursor cursor
= skuInfo
.newCursor();
1721 if (cursor
.toFirstChild()) {
1722 for (int j
= 0; j
< i
; ++j
) {
1723 cursor
.toNextSibling();
1730 public void updatePlatformDefsSkuInfo(int i
, String id
, String name
) {
1731 SkuInfoDocument
.SkuInfo skuInfo
= getfpdPlatformDefs().getSkuInfo();
1732 if (skuInfo
== null || i
== 0) {
1736 XmlCursor cursor
= skuInfo
.newCursor();
1737 if (cursor
.toFirstChild()) {
1738 for (int j
= 0; j
< i
; ++j
) {
1739 cursor
.toNextSibling();
1741 SkuInfoDocument
.SkuInfo
.UiSkuName sku
= (SkuInfoDocument
.SkuInfo
.UiSkuName
)cursor
.getObject();
1742 sku
.setSkuID(new BigInteger(id
));
1743 sku
.setStringValue(name
);
1748 public String
getPlatformDefsInterDir(){
1749 if (getfpdPlatformDefs().getIntermediateDirectories() == null) {
1752 return getfpdPlatformDefs().getIntermediateDirectories().toString();
1755 public void setPlatformDefsInterDir(String interDir
){
1756 getfpdPlatformDefs().setIntermediateDirectories(IntermediateOutputType
.Enum
.forString(interDir
));
1759 public String
getPlatformDefsOutputDir() {
1760 return getfpdPlatformDefs().getOutputDirectory();
1763 public void setPlatformDefsOutputDir(String outputDir
) {
1764 getfpdPlatformDefs().setOutputDirectory(outputDir
);
1767 public FlashDocument
.Flash
getfpdFlash() {
1768 if (fpdFlash
== null) {
1769 fpdFlash
= fpdRoot
.addNewFlash();
1774 public void genFlashDefinitionFile(String file
) {
1775 FlashDefinitionFileDocument
.FlashDefinitionFile fdf
= getfpdFlash().getFlashDefinitionFile();
1777 fdf
= getfpdFlash().addNewFlashDefinitionFile();
1780 fdf
.setStringValue(file
);
1783 public String
getFlashDefinitionFile() {
1784 FlashDefinitionFileDocument
.FlashDefinitionFile fdf
= getfpdFlash().getFlashDefinitionFile();
1789 return fdf
.getStringValue();
1794 public void genFvImagesNameValue(String name
, String value
) {
1796 FvImagesDocument
.FvImages fi
= getfpdFlash().getFvImages();
1798 fi
= getfpdFlash().addNewFvImages();
1801 FvImagesDocument
.FvImages
.NameValue nv
= fi
.addNewNameValue();
1806 public void removeFvImagesNameValue(int i
){
1808 XmlObject o
= getfpdFlash().getFvImages();
1813 QName qNameValue
= new QName(xmlNs
, "NameValue");
1814 XmlCursor cursor
= o
.newCursor();
1815 if (cursor
.toChild(qNameValue
)) {
1816 for (int j
= 0; j
< i
; ++j
) {
1817 cursor
.toNextSibling(qNameValue
);
1824 public void updateFvImagesNameValue(int i
, String name
, String value
){
1826 XmlObject o
= getfpdFlash().getFvImages();
1831 QName qNameValue
= new QName(xmlNs
, "NameValue");
1832 XmlCursor cursor
= o
.newCursor();
1833 if (cursor
.toChild(qNameValue
)) {
1834 for (int j
= 0; j
< i
; ++j
) {
1835 cursor
.toNextSibling(qNameValue
);
1837 FvImagesDocument
.FvImages
.NameValue nv
= (FvImagesDocument
.FvImages
.NameValue
)cursor
.getObject();
1844 public int getFvImagesNameValueCount() {
1846 FvImagesDocument
.FvImages fi
= null;
1847 if ((fi
= getfpdFlash().getFvImages()) == null || fi
.getNameValueList() == null) {
1850 return fi
.getNameValueList().size();
1853 public void getFvImagesNameValues(String
[][] nv
) {
1855 FvImagesDocument
.FvImages fi
= getfpdFlash().getFvImages();
1859 List
<FvImagesDocument
.FvImages
.NameValue
> l
= fi
.getNameValueList();
1861 ListIterator li
= l
.listIterator();
1862 while (li
.hasNext()) {
1863 FvImagesDocument
.FvImages
.NameValue e
= (FvImagesDocument
.FvImages
.NameValue
) li
1865 nv
[i
][0] = e
.getName();
1866 nv
[i
][1] = e
.getValue();
1872 public void genFvImagesFvImage(String
[] names
, String types
, Map
<String
, String
> options
) {
1874 FvImagesDocument
.FvImages fis
= null;
1875 if ((fis
= getfpdFlash().getFvImages()) == null) {
1876 fis
= getfpdFlash().addNewFvImages();
1880 //gen FvImage with FvImageNames array
1882 FvImagesDocument
.FvImages
.FvImage fi
= fis
.addNewFvImage();
1883 for (int i
= 0; i
< names
.length
; ++i
) {
1884 fi
.addFvImageNames(names
[i
]);
1886 fi
.setType(FvImageTypes
.Enum
.forString(types
));
1887 if (options
!= null){
1888 setFvImagesFvImageFvImageOptions(options
, fi
);
1892 private void setFvImagesFvImageFvImageOptions(Map
<String
, String
> options
, FvImagesDocument
.FvImages
.FvImage fi
){
1893 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions fio
= fi
.getFvImageOptions();
1895 fio
= fi
.addNewFvImageOptions();
1898 Set
<String
> key
= options
.keySet();
1899 Iterator
<String
> i
= key
.iterator();
1900 while (i
.hasNext()) {
1902 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nv
= fio
.addNewNameValue();
1903 String k
= (String
)i
.next();
1906 nv
.setValue((String
)options
.get(k
));
1913 public void removeFvImagesFvImage(int i
) {
1915 XmlObject o
= getfpdFlash().getFvImages();
1920 QName qFvImage
= new QName(xmlNs
, "FvImage");
1921 XmlCursor cursor
= o
.newCursor();
1922 if (cursor
.toChild(qFvImage
)) {
1923 for (int j
= 0; j
< i
; ++j
) {
1924 cursor
.toNextSibling(qFvImage
);
1931 public void updateFvImagesFvImage(int i
, String
[] names
, String types
, Map
<String
, String
> options
){
1933 XmlObject o
= getfpdFlash().getFvImages();
1937 XmlCursor cursor
= o
.newCursor();
1938 QName qFvImage
= new QName(xmlNs
, "FvImage");
1939 if (cursor
.toChild(qFvImage
)) {
1940 for (int j
= 0; j
< i
; ++j
) {
1941 cursor
.toNextSibling(qFvImage
);
1943 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
1944 fi
.setType(FvImageTypes
.Enum
.forString(types
));
1947 // remove old FvImageNames before adding new ones
1949 QName qFvImageNames
= new QName(xmlNs
, "FvImageNames");
1950 cursor
.toChild(qFvImageNames
);
1952 while (cursor
.toNextSibling(qFvImageNames
)) {
1956 for (int k
= 0; k
< names
.length
; ++k
) {
1957 fi
.addFvImageNames(names
[k
]);
1960 // remove old FvImageOptions before adding new options
1962 QName qFvImageOptions
= new QName(xmlNs
, "FvImageOptions");
1963 cursor
.toNextSibling(qFvImageOptions
);
1966 setFvImagesFvImageFvImageOptions(options
, fi
);
1971 public int getFvImagesFvImageCount() {
1973 if (getfpdFlash().getFvImages() == null || getfpdFlash().getFvImages().getFvImageList() == null) {
1976 return getfpdFlash().getFvImages().getFvImageList().size();
1979 /**Only Get Fv image setting - name and type.
1982 public void getFvImagesFvImages(String
[][] saa
) {
1984 if (getfpdFlash().getFvImages() == null) {
1987 List
<FvImagesDocument
.FvImages
.FvImage
> l
= getfpdFlash().getFvImages().getFvImageList();
1991 ListIterator li
= l
.listIterator();
1993 while(li
.hasNext()) {
1994 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)li
.next();
1996 // get FvImageNames array, space separated
1998 List
<String
> lfn
= fi
.getFvImageNamesList();
1999 ListIterator lfni
= lfn
.listIterator();
2001 while (lfni
.hasNext()) {
2002 saa
[i
][0] += (String
)lfni
.next();
2005 saa
[i
][0] = saa
[i
][0].trim();
2007 saa
[i
][1] = fi
.getType()+"";
2013 /**Get FvImage Options for FvImage i
2014 * @param i the ith FvImage
2016 public void getFvImagesFvImageOptions(int i
, Map
<String
, String
> m
) {
2017 XmlObject o
= getfpdFlash().getFvImages();
2021 XmlCursor cursor
= o
.newCursor();
2022 QName qFvImage
= new QName(xmlNs
, "FvImage");
2023 if (cursor
.toChild(qFvImage
)) {
2024 for (int j
= 0; j
< i
; ++j
) {
2025 cursor
.toNextSibling(qFvImage
);
2027 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
2028 if (fi
.getFvImageOptions() == null || fi
.getFvImageOptions().getNameValueList() == null){
2031 ListIterator
<FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
> li
= fi
.getFvImageOptions().getNameValueList().listIterator();
2032 while(li
.hasNext()){
2033 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nv
= li
.next();
2034 m
.put(nv
.getName(), nv
.getValue());
2040 Get platform header element
2041 @return PlatformHeaderDocument.PlatformHeader
2043 public PlatformHeaderDocument
.PlatformHeader
getFpdHdr() {
2044 if (fpdHdr
== null) {
2045 fpdHdr
= fpdRoot
.addNewPlatformHeader();
2047 genPlatformDefsSkuInfo("0", "DEFAULT");
2051 public String
getFpdHdrPlatformName() {
2052 return getFpdHdr().getPlatformName();
2055 public String
getFpdHdrGuidValue() {
2056 return getFpdHdr().getGuidValue();
2059 public String
getFpdHdrVer() {
2060 return getFpdHdr().getVersion();
2063 public String
getFpdHdrAbs() {
2064 return getFpdHdr().getAbstract();
2067 public String
getFpdHdrDescription() {
2068 return getFpdHdr().getDescription();
2071 public String
getFpdHdrCopyright() {
2072 return getFpdHdr().getCopyright();
2075 public String
getFpdHdrLicense() {
2076 LicenseDocument
.License l
= getFpdHdr().getLicense();
2080 return l
.getStringValue();
2083 public String
getFpdHdrUrl() {
2084 LicenseDocument
.License l
= getFpdHdr().getLicense();
2091 public String
getFpdHdrSpec() {
2093 return "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052";
2094 // return getFpdHdr().getSpecification();
2097 public void setFpdHdrPlatformName(String name
){
2098 getFpdHdr().setPlatformName(name
);
2101 public void setFpdHdrGuidValue(String guid
){
2102 getFpdHdr().setGuidValue(guid
);
2105 public void setFpdHdrVer(String v
){
2106 getFpdHdr().setVersion(v
);
2109 public void setFpdHdrAbs(String abs
) {
2110 getFpdHdr().setAbstract(abs
);
2113 public void setFpdHdrDescription(String desc
){
2114 getFpdHdr().setDescription(desc
);
2117 public void setFpdHdrCopyright(String cr
) {
2118 getFpdHdr().setCopyright(cr
);
2121 public void setFpdHdrLicense(String license
){
2122 LicenseDocument
.License l
= getFpdHdr().getLicense();
2124 getFpdHdr().addNewLicense().setStringValue(license
);
2127 l
.setStringValue(license
);
2131 public void setFpdHdrUrl(String url
){
2132 LicenseDocument
.License l
= getFpdHdr().getLicense();
2138 public void setFpdHdrSpec(String s
){
2139 s
= "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052";
2140 getFpdHdr().setSpecification(s
);
2143 Save the processed xml contents to file
2145 @param fpdFile The file to save xml contents
2146 @throws IOException Exceptions during file operation
2148 public void saveAs(File fpdFile
) throws IOException
{
2150 XmlOptions options
= new XmlOptions();
2152 options
.setCharacterEncoding("UTF-8");
2153 options
.setSavePrettyPrint();
2154 options
.setSavePrettyPrintIndent(2);
2156 fpdd
.save(fpdFile
, options
);
2157 } catch (IOException e
) {
2158 e
.printStackTrace();
2163 private String
listToString(List l
) {
2168 ListIterator li
= l
.listIterator();
2169 while(li
.hasNext()) {