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
.getModuleVersion().equals(s
[1])
212 && msa
.getPackageGuid().equals(s
[2]) && msa
.getPackageVersion().equals(s
[3])) {
219 public void removeModuleSA(int i
) {
220 XmlObject o
= getfpdFrameworkModules();
225 XmlCursor cursor
= o
.newCursor();
226 if (cursor
.toFirstChild()) {
227 for (int j
= 0; j
< i
; ++j
) {
228 cursor
.toNextSibling();
231 // remove pcd from dynPcdMap, if DynamicPcdBuildData exists, remove them too.
233 ModuleSADocument
.ModuleSA moduleSa
= (ModuleSADocument
.ModuleSA
)cursor
.getObject();
234 String moduleInfo
= moduleSa
.getModuleGuid() + " " + moduleSa
.getModuleVersion() + " " +
235 moduleSa
.getPackageGuid()+ " " + moduleSa
.getPackageVersion();
236 PcdBuildDefinitionDocument
.PcdBuildDefinition pcdBuildDef
= moduleSa
.getPcdBuildDefinition();
237 if (pcdBuildDef
!= null) {
238 maintainDynPcdMap(pcdBuildDef
, moduleInfo
);
245 private void maintainDynPcdMap(PcdBuildDefinitionDocument
.PcdBuildDefinition o
, String moduleInfo
) {
246 XmlCursor cursor
= o
.newCursor();
247 boolean fromLibInstance
= false;
248 if (!cursor
.toFirstChild()){
252 // deal with first child, same process in the while loop below for siblings.
254 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= (PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
)cursor
.getObject();
255 String pcdKey
= pcdData
.getCName() + " " + pcdData
.getTokenSpaceGuidCName();
256 ArrayList
<String
> al
= dynPcdMap
.get(pcdKey
);
257 for(int i
= 0; i
< al
.size(); ++i
){
258 if (al
.get(i
).startsWith(moduleInfo
)){
259 fromLibInstance
= true;
263 al
.remove(moduleInfo
+ " " + pcdData
.getItemType().toString());
264 if (al
.size() == 0) {
265 dynPcdMap
.remove(pcdKey
);
268 if (pcdData
.getItemType().toString().equals("DYNAMIC")) {
269 if (dynPcdMap
.get(pcdKey
) == null) {
270 removeDynamicPcdBuildData(pcdData
.getCName(), pcdData
.getTokenSpaceGuidCName());
273 if (fromLibInstance
){
276 while(cursor
.toNextSibling()) {
277 fromLibInstance
= false;
278 pcdData
= (PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
)cursor
.getObject();
280 // remove each pcd record from dynPcdMap
282 pcdKey
= pcdData
.getCName() + " " + pcdData
.getTokenSpaceGuidCName();
283 al
= dynPcdMap
.get(pcdKey
);
284 for(int i
= 0; i
< al
.size(); ++i
){
285 if (al
.get(i
).startsWith(moduleInfo
)){
286 fromLibInstance
= true;
290 al
.remove(moduleInfo
+ " " + pcdData
.getItemType().toString());
291 if (al
.size() == 0) {
292 dynPcdMap
.remove(pcdKey
);
295 if (pcdData
.getItemType().toString().equals("DYNAMIC")) {
297 // First check whether this is the only consumer of this dyn pcd.
299 if (dynPcdMap
.get(pcdKey
) == null) {
301 // delete corresponding entry in DynamicPcdBuildData
303 removeDynamicPcdBuildData(pcdData
.getCName(), pcdData
.getTokenSpaceGuidCName());
306 if (fromLibInstance
){
312 // key for ModuleSA : "ModuleGuid ModuleVer PackageGuid PackageVer"
314 public int getPcdDataCount(String key
){
315 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
316 if (msa
== null || msa
.getPcdBuildDefinition() == null || msa
.getPcdBuildDefinition().getPcdDataList() == null){
319 return msa
.getPcdBuildDefinition().getPcdDataList().size();
322 public void getPcdData(String key
, String
[][] saa
) {
323 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
324 if (msa
== null || msa
.getPcdBuildDefinition() == null || msa
.getPcdBuildDefinition().getPcdDataList() == null){
327 ListIterator
<PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
>li
= msa
.getPcdBuildDefinition().getPcdDataList().listIterator();
328 for (int i
= 0; i
< saa
.length
; ++i
) {
329 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= li
.next();
330 saa
[i
][0] = pcdData
.getCName();
331 saa
[i
][1] = pcdData
.getTokenSpaceGuidCName();
332 saa
[i
][2] = pcdData
.getItemType().toString();
333 saa
[i
][3] = pcdData
.getToken().toString();
334 saa
[i
][4] = pcdData
.getDatumType().toString();
335 saa
[i
][5] = pcdData
.getValue();
340 // key for ModuleSA : "ModuleGuid ModuleVer PackageGuid PackageVer"
342 public int getLibraryInstancesCount(String key
) {
343 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
344 if (msa
== null || msa
.getLibraries() == null || msa
.getLibraries().getInstanceList() == null){
347 return msa
.getLibraries().getInstanceList().size();
350 public void getLibraryInstances(String key
, String
[][] saa
){
351 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
352 if (msa
== null || msa
.getLibraries() == null || msa
.getLibraries().getInstanceList() == null){
356 ListIterator
<LibrariesDocument
.Libraries
.Instance
> li
= msa
.getLibraries().getInstanceList().listIterator();
357 for (int i
= 0; i
< saa
.length
; ++i
) {
358 LibrariesDocument
.Libraries
.Instance instance
= li
.next();
359 saa
[i
][1] = instance
.getModuleGuid();
360 saa
[i
][2] = instance
.getModuleVersion();
361 saa
[i
][3] = instance
.getPackageGuid();
362 saa
[i
][4] = instance
.getPackageVersion();
366 public void removeLibraryInstances(String key
) {
367 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
368 if (msa
== null || msa
.getLibraries() == null){
372 XmlCursor cursor
= msa
.getLibraries().newCursor();
377 public void genLibraryInstance(String mg
, String mv
, String pg
, String pv
, String key
) {
378 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
380 msa
= getfpdFrameworkModules().addNewModuleSA();
382 LibrariesDocument
.Libraries libs
= msa
.getLibraries();
384 libs
= msa
.addNewLibraries();
387 LibrariesDocument
.Libraries
.Instance instance
= libs
.addNewInstance();
388 instance
.setModuleGuid(mg
);
389 instance
.setModuleVersion(mv
);
390 instance
.setPackageGuid(pg
);
391 instance
.setPackageVersion(pv
);
395 public String
getFvBinding(String moduleKey
){
396 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
397 if (msa
== null || msa
.getModuleSaBuildOptions() == null) {
400 return msa
.getModuleSaBuildOptions().getFvBinding();
403 public void setFvBinding(String moduleKey
, String fvBinding
){
404 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
408 if(msa
.getModuleSaBuildOptions() == null){
409 msa
.addNewModuleSaBuildOptions().setFvBinding(fvBinding
);
412 msa
.getModuleSaBuildOptions().setFvBinding(fvBinding
);
415 public String
getFfsFileNameGuid(String moduleKey
){
416 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
417 if (msa
== null || msa
.getModuleSaBuildOptions() == null) {
420 return msa
.getModuleSaBuildOptions().getFfsFileNameGuid();
423 public void setFfsFileNameGuid(String moduleKey
, String fileGuid
){
424 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
428 if(msa
.getModuleSaBuildOptions() == null){
429 msa
.addNewModuleSaBuildOptions().setFfsFileNameGuid(fileGuid
);
432 msa
.getModuleSaBuildOptions().setFfsFileNameGuid(fileGuid
);
435 public String
getFfsFormatKey(String moduleKey
){
436 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
437 if (msa
== null || msa
.getModuleSaBuildOptions() == null) {
440 return msa
.getModuleSaBuildOptions().getFfsFormatKey();
443 public void setFfsFormatKey(String moduleKey
, String ffsKey
){
444 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
448 if(msa
.getModuleSaBuildOptions() == null){
449 msa
.addNewModuleSaBuildOptions().setFfsFormatKey(ffsKey
);
452 msa
.getModuleSaBuildOptions().setFvBinding(ffsKey
);
455 public void getModuleSAOptions(String moduleKey
, String
[][] saa
) {
456 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
457 if (msa
.getModuleSaBuildOptions() == null || msa
.getModuleSaBuildOptions().getOptions() == null
458 || msa
.getModuleSaBuildOptions().getOptions().getOptionList() == null) {
462 List
<OptionDocument
.Option
> lOpt
= msa
.getModuleSaBuildOptions().getOptions().getOptionList();
463 ListIterator li
= lOpt
.listIterator();
465 while(li
.hasNext()) {
466 OptionDocument
.Option opt
= (OptionDocument
.Option
)li
.next();
467 if (opt
.getBuildTargets() != null) {
468 saa
[i
][0] = listToString(opt
.getBuildTargets());
470 saa
[i
][1] = opt
.getToolChainFamily();
471 if (opt
.getSupArchList() != null){
472 saa
[i
][2] = listToString(opt
.getSupArchList());
475 saa
[i
][3] = opt
.getToolCode();
476 saa
[i
][4] = opt
.getTagName();
477 saa
[i
][5] = opt
.getStringValue();
483 public int getModuleSAOptionsCount(String moduleKey
){
484 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
485 if (msa
.getModuleSaBuildOptions() == null || msa
.getModuleSaBuildOptions().getOptions() == null
486 || msa
.getModuleSaBuildOptions().getOptions().getOptionList() == null) {
489 return msa
.getModuleSaBuildOptions().getOptions().getOptionList().size();
492 public void genModuleSAOptionsOpt(String moduleKey
, Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
) {
493 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
494 if (msa
.getModuleSaBuildOptions() == null) {
495 msa
.addNewModuleSaBuildOptions();
497 if (msa
.getModuleSaBuildOptions().getOptions() == null){
498 msa
.getModuleSaBuildOptions().addNewOptions();
500 OptionDocument
.Option opt
= msa
.getModuleSaBuildOptions().getOptions().addNewOption();
501 setBuildOptionsOpt(buildTargets
, toolChain
, tagName
, toolCmd
, archList
, contents
, opt
);
504 public void removeModuleSAOptionsOpt(String moduleKey
, int i
) {
505 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
506 if (msa
.getModuleSaBuildOptions() == null || msa
.getModuleSaBuildOptions().getOptions() == null) {
509 OptionsDocument
.Options opts
= msa
.getModuleSaBuildOptions().getOptions();
510 XmlCursor cursor
= opts
.newCursor();
511 if (cursor
.toFirstChild()) {
512 for (int j
= 0; j
< i
; ++j
){
513 cursor
.toNextSibling();
520 public void updateModuleSAOptionsOpt(String moduleKey
, int i
, Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
) {
521 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
522 if (msa
.getModuleSaBuildOptions() == null || msa
.getModuleSaBuildOptions().getOptions() == null) {
525 OptionsDocument
.Options opts
= msa
.getModuleSaBuildOptions().getOptions();
526 XmlCursor cursor
= opts
.newCursor();
527 if (cursor
.toFirstChild()) {
528 for (int j
= 0; j
< i
; ++j
){
529 cursor
.toNextSibling();
531 OptionDocument
.Option opt
= (OptionDocument
.Option
)cursor
.getObject();
532 setBuildOptionsOpt(buildTargets
, toolChain
, tagName
, toolCmd
, archList
, contents
, opt
);
537 /**add pcd information of module mi to a ModuleSA.
539 * @param moduleSa if null, generate a new ModuleSA.
541 public void addFrameworkModulesPcdBuildDefs(ModuleIdentification mi
, ModuleSADocument
.ModuleSA moduleSa
){
542 //ToDo add Arch filter
545 ModuleSurfaceAreaDocument
.ModuleSurfaceArea msa
= (ModuleSurfaceAreaDocument
.ModuleSurfaceArea
)GlobalData
.getModuleXmlObject(mi
);
546 if (msa
.getPcdCoded() == null) {
549 if (moduleSa
== null) {
550 moduleSa
= genModuleSA(mi
);
552 Map
<String
, XmlObject
> m
= new HashMap
<String
, XmlObject
>();
553 m
.put("ModuleSurfaceArea", msa
);
554 SurfaceAreaQuery
.setDoc(m
);
555 PackageIdentification
[] depPkgs
= SurfaceAreaQuery
.getDependencePkg(null);
557 // Implementing InitializePlatformPcdBuildDefinitions
559 List
<PcdCodedDocument
.PcdCoded
.PcdEntry
> l
= msa
.getPcdCoded().getPcdEntryList();
560 ListIterator li
= l
.listIterator();
561 while(li
.hasNext()) {
562 PcdCodedDocument
.PcdCoded
.PcdEntry msaPcd
= (PcdCodedDocument
.PcdCoded
.PcdEntry
)li
.next();
563 PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry spdPcd
= LookupPcdDeclaration(msaPcd
, depPkgs
);
564 if (spdPcd
== null) {
571 // AddItem to ModuleSA PcdBuildDefinitions
573 String defaultVal
= msaPcd
.getDefaultValue() == null ? spdPcd
.getDefaultValue() : msaPcd
.getDefaultValue();
574 genPcdData(msaPcd
.getCName(), spdPcd
.getToken(), msaPcd
.getTokenSpaceGuidCName(), msaPcd
.getPcdItemType().toString(), spdPcd
.getDatumType()+"", defaultVal
, moduleSa
);
584 private PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry
LookupPcdDeclaration (PcdCodedDocument
.PcdCoded
.PcdEntry msaPcd
, PackageIdentification
[] depPkgs
) {
586 Map
<String
, XmlObject
> m
= new HashMap
<String
, XmlObject
>();
587 PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry spdPcd
= null;
588 for (int i
= 0; i
< depPkgs
.length
; ++i
) {
589 m
.put("PackageSurfaceArea", GlobalData
.getPackageXmlObject(depPkgs
[i
]));
590 SurfaceAreaQuery
.setDoc(m
);
591 XmlObject
[] xo
= SurfaceAreaQuery
.getSpdPcdDeclarations();
595 for (int j
= 0; j
< xo
.length
; ++j
) {
596 spdPcd
= (PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry
)xo
[j
];
597 if (msaPcd
.getTokenSpaceGuidCName() == null) {
598 if (spdPcd
.getCName().equals(msaPcd
.getCName())) {
603 if (spdPcd
.getCName().equals(msaPcd
.getCName()) && spdPcd
.getTokenSpaceGuidCName().equals(msaPcd
.getTokenSpaceGuidCName())) {
614 private ModuleSADocument
.ModuleSA
genModuleSA (ModuleIdentification mi
) {
615 PackageIdentification pi
= GlobalData
.getPackageForModule(mi
);
616 ModuleSADocument
.ModuleSA msa
= getfpdFrameworkModules().addNewModuleSA();
617 msa
.setModuleGuid(mi
.getGuid());
618 msa
.setModuleVersion(mi
.getVersion());
619 msa
.setPackageGuid(pi
.getGuid());
620 msa
.setPackageVersion(pi
.getVersion());
625 private void genPcdData (String cName
, Object token
, String tsGuid
, String itemType
, String dataType
, String defaultVal
, ModuleSADocument
.ModuleSA moduleSa
) {
626 if (moduleSa
.getPcdBuildDefinition() == null){
627 moduleSa
.addNewPcdBuildDefinition();
630 // constructe pcd to modulesa mapping first.
631 // Attention : for any error condition, remove from map this pcd.
633 ArrayList
<String
> pcdConsumer
= LookupPlatformPcdData(cName
+ " " + tsGuid
);
634 if (pcdConsumer
== null) {
635 pcdConsumer
= new ArrayList
<String
>();
637 String listValue
= moduleSa
.getModuleGuid() + " " + moduleSa
.getModuleVersion()
638 + " " + moduleSa
.getPackageGuid() + " " + moduleSa
.getPackageVersion()
640 pcdConsumer
.add(listValue
);
641 dynPcdMap
.put(cName
+ " " + tsGuid
, pcdConsumer
);
643 // Special dynamic type, if this pcd already exists in other ModuleSA
645 if (itemType
.equals("DYNAMIC")) {
647 ListIterator li
= pcdConsumer
.listIterator();
648 while(li
.hasNext()) {
649 String value
= li
.next().toString();
650 String
[] valuePart
= value
.split(" ");
651 if (!valuePart
[4].equals("DYNAMIC")) {
652 //ToDo error for same pcd, other type than dynamic
653 pcdConsumer
.remove(listValue
);
659 ListIterator li
= pcdConsumer
.listIterator();
660 while(li
.hasNext()) {
661 String value
= li
.next().toString();
662 String
[] valuePart
= value
.split(" ");
663 if (valuePart
[4].equals("DYNAMIC")) {
664 //ToDo error for same pcd, other type than non-dynamic
665 pcdConsumer
.remove(listValue
);
671 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData fpdPcd
= moduleSa
.getPcdBuildDefinition().addNewPcdData();
672 fpdPcd
.setCName(cName
);
673 fpdPcd
.setToken(token
);
674 fpdPcd
.setTokenSpaceGuidCName(tsGuid
);
675 fpdPcd
.setDatumType(PcdDataTypes
.Enum
.forString(dataType
));
676 fpdPcd
.setItemType(PcdItemTypes
.Enum
.forString(itemType
));
678 if (itemType
.equals("DYNAMIC") || itemType
.equals("DYNAMIC_EX")) {
679 ArrayList
<String
> al
= LookupDynamicPcdBuildDefinition(cName
+ " " + tsGuid
);
681 // if only one module mapped to this pcd, then the one is myself. so no other module mapped.
682 // so need to add one dyn pcd.
684 if (al
.size() == 1) {
685 addDynamicPcdBuildData(cName
, token
, tsGuid
, itemType
, dataType
, defaultVal
);
689 if (defaultVal
!= null){
690 fpdPcd
.setValue(defaultVal
);
693 if (dataType
.equals("UINT8") || dataType
.equals("UINT16") || dataType
.equals("UINT32") || dataType
.equals("UINT64")) {
694 fpdPcd
.setValue("0");
696 if (dataType
.equals("BOOLEAN")){
697 fpdPcd
.setValue("false");
699 if (dataType
.equals("VOID*")) {
703 if (dataType
.equals("UINT8")){
704 fpdPcd
.setMaxDatumSize(1);
706 if (dataType
.equals("UINT16")) {
707 fpdPcd
.setMaxDatumSize(2);
709 if (dataType
.equals("UINT32")) {
710 fpdPcd
.setMaxDatumSize(4);
712 if (dataType
.equals("UINT64")){
713 fpdPcd
.setMaxDatumSize(8);
715 if (dataType
.equals("BOOLEAN")){
716 fpdPcd
.setMaxDatumSize(1);
718 if (dataType
.equals("VOID*")) {
719 int maxSize
= setMaxSizeForPointer(fpdPcd
.getValue());
720 fpdPcd
.setMaxDatumSize(maxSize
);
725 private int setMaxSizeForPointer(String datum
) {
729 char ch
= datum
.charAt(0);
733 // For void* type PCD, only three datum is support:
734 // 1) Unicode: string with start char is "L"
735 // 2) Ansci: String is ""
736 // 3) byte array: String start char "{"
739 start
= datum
.indexOf('\"');
740 end
= datum
.lastIndexOf('\"');
742 (end
> datum
.length())||
743 ((start
== end
) && (datum
.length() > 0))) {
744 //ToDo Error handling here
747 strValue
= datum
.substring(start
+ 1, end
);
748 return strValue
.length() * 2;
749 } else if (ch
== '\"'){
750 start
= datum
.indexOf('\"');
751 end
= datum
.lastIndexOf('\"');
753 (end
> datum
.length())||
754 ((start
== end
) && (datum
.length() > 0))) {
757 strValue
= datum
.substring(start
+ 1, end
);
758 return strValue
.length();
759 } else if (ch
=='{') {
760 String
[] strValueArray
;
762 start
= datum
.indexOf('{');
763 end
= datum
.lastIndexOf('}');
764 strValue
= datum
.substring(start
+ 1, end
);
765 strValue
= strValue
.trim();
766 if (strValue
.length() == 0) {
769 strValueArray
= strValue
.split(",");
770 for (int index
= 0; index
< strValueArray
.length
; index
++) {
771 Integer value
= Integer
.decode(strValueArray
[index
].trim());
774 // "[FPD file error] The datum type of PCD %s in %s is VOID*, "+
775 // "it is byte array in fact. But the element of %s exceed the byte range",
779 return strValueArray
.length
;
783 // "[FPD file error] The datum type of PCD %s in %s is VOID*. For VOID* type, you have three format choise:\n "+
784 // "1) UNICODE string: like L\"xxxx\";\r\n"+
785 // "2) ANSIC string: like \"xxx\";\r\n"+
786 // "3) Byte array: like {0x2, 0x45, 0x23}\r\n"+
787 // "but the datum in seems does not following above format!",
793 private ArrayList
<String
> LookupDynamicPcdBuildDefinition(String dynPcdKey
) {
794 ArrayList
<String
> al
= dynPcdMap
.get(dynPcdKey
);
799 private ArrayList
<String
> LookupPlatformPcdData(String pcdKey
) {
801 return dynPcdMap
.get("pcdKey");
804 public int getDynamicPcdBuildDataCount() {
805 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null) {
808 return getfpdDynPcdBuildDefs().getPcdBuildDataList().size();
811 public void getDynamicPcdBuildData(String
[][] saa
) {
812 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null) {
815 List
<DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
> l
= getfpdDynPcdBuildDefs().getPcdBuildDataList();
816 ListIterator
<DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
> li
= l
.listIterator();
818 while(li
.hasNext()) {
819 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData dynPcd
= li
.next();
820 saa
[i
][0] = dynPcd
.getCName();
821 saa
[i
][1] = dynPcd
.getToken().toString();
822 saa
[i
][2] = dynPcd
.getTokenSpaceGuidCName();
823 saa
[i
][3] = dynPcd
.getMaxDatumSize()+"";
824 saa
[i
][4] = dynPcd
.getDatumType().toString();
830 private void addDynamicPcdBuildData(String cName
, Object token
, String tsGuid
, String itemType
, String dataType
, String defaultVal
) {
831 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData dynPcdData
= getfpdDynPcdBuildDefs().addNewPcdBuildData();
832 dynPcdData
.setItemType(PcdItemTypes
.Enum
.forString(itemType
));
833 dynPcdData
.setCName(cName
);
834 dynPcdData
.setToken(token
);
835 dynPcdData
.setTokenSpaceGuidCName(tsGuid
);
836 dynPcdData
.setDatumType(PcdDataTypes
.Enum
.forString(dataType
));
838 BigInteger bigInt
= new BigInteger("0");
839 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo skuInfo
= dynPcdData
.addNewSkuInfo();
840 skuInfo
.setSkuId(bigInt
);
841 if (defaultVal
!= null){
842 skuInfo
.setValue(defaultVal
);
845 if (dataType
.equals("UINT8")){
846 skuInfo
.setValue("0");
848 if (dataType
.equals("UINT16")) {
849 skuInfo
.setValue("0");
851 if (dataType
.equals("UINT32")) {
852 skuInfo
.setValue("0");
854 if (dataType
.equals("UINT64")){
855 skuInfo
.setValue("0");
857 if (dataType
.equals("BOOLEAN")){
858 skuInfo
.setValue("false");
860 if (dataType
.equals("VOID*")) {
861 skuInfo
.setValue("");
864 if (dataType
.equals("UINT8")){
865 dynPcdData
.setMaxDatumSize(1);
867 if (dataType
.equals("UINT16")) {
868 dynPcdData
.setMaxDatumSize(2);
870 if (dataType
.equals("UINT32")) {
871 dynPcdData
.setMaxDatumSize(4);
873 if (dataType
.equals("UINT64")){
874 dynPcdData
.setMaxDatumSize(8);
876 if (dataType
.equals("BOOLEAN")){
877 dynPcdData
.setMaxDatumSize(1);
879 if (dataType
.equals("VOID*")) {
880 int maxSize
= setMaxSizeForPointer(defaultVal
);
881 dynPcdData
.setMaxDatumSize(maxSize
);
885 private void removeDynamicPcdBuildData(String cName
, String tsGuid
) {
886 XmlObject o
= getfpdDynPcdBuildDefs();
888 XmlCursor cursor
= o
.newCursor();
889 if (cursor
.toFirstChild()) {
890 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdBuildData
=
891 (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
892 while (!(pcdBuildData
.getCName().equals(cName
) && pcdBuildData
.getTokenSpaceGuidCName().equals(tsGuid
))) {
893 cursor
.toNextSibling();
894 pcdBuildData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
902 // Get the Sku Info count of ith dyn pcd element.
904 public int getDynamicPcdSkuInfoCount(int i
){
905 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
909 int skuInfoCount
= 0;
910 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
911 if (cursor
.toFirstChild()) {
912 for (int j
= 0; j
< i
; ++j
) {
913 cursor
.toNextSibling();
915 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
916 if (pcdData
.getSkuInfoList() == null) {
920 skuInfoCount
= pcdData
.getSkuInfoList().size();
927 public void getDynamicPcdSkuInfos(int i
, String
[][] saa
){
928 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
932 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
933 if (cursor
.toFirstChild()) {
934 for (int j
= 0; j
< i
; ++j
) {
935 cursor
.toNextSibling();
937 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
938 if (pcdData
.getSkuInfoList() == null) {
943 ListIterator
<DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo
> li
= pcdData
.getSkuInfoList().listIterator();
945 while (li
.hasNext()) {
946 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo skuInfo
= li
.next();
947 saa
[k
][0] = skuInfo
.getSkuId()+"";
948 saa
[k
][1] = skuInfo
.getVariableName();
949 saa
[k
][2] = skuInfo
.getVariableGuid();
950 saa
[k
][3] = skuInfo
.getVariableOffset();
951 saa
[k
][4] = skuInfo
.getHiiDefaultValue();
952 saa
[k
][5] = skuInfo
.getVpdOffset();
953 saa
[k
][6] = skuInfo
.getValue();
963 public String
getDynamicPcdBuildDataValue(int i
){
965 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
969 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
970 if (cursor
.toFirstChild()) {
971 for (int j
= 0; j
< i
; ++j
) {
972 cursor
.toNextSibling();
974 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
975 if (pcdData
.getSkuInfoList() == null) {
979 value
= pcdData
.getSkuInfoArray(0).getValue();
986 public String
getDynamicPcdBuildDataVpdOffset(int i
){
987 String vpdOffset
= null;
988 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
992 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
993 if (cursor
.toFirstChild()) {
994 for (int j
= 0; j
< i
; ++j
) {
995 cursor
.toNextSibling();
997 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
998 if (pcdData
.getSkuInfoList() == null) {
1002 vpdOffset
= pcdData
.getSkuInfoArray(0).getVpdOffset();
1009 public void removeDynamicPcdBuildDataSkuInfo(int i
) {
1010 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1014 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1015 if (cursor
.toFirstChild()) {
1016 for (int j
= 0; j
< i
; ++j
) {
1017 cursor
.toNextSibling();
1019 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1020 if (pcdData
.getSkuInfoList() == null) {
1025 QName qSkuInfo
= new QName(xmlNs
, "SkuInfo");
1026 cursor
.toChild(qSkuInfo
);
1033 // generate sku info for ith dyn pcd build data.
1035 public void genDynamicPcdBuildDataSkuInfo(String id
, String varName
, String varGuid
, String varOffset
,
1036 String hiiDefault
, String vpdOffset
, String value
, int i
) {
1037 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1041 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1042 if (cursor
.toFirstChild()) {
1043 for (int j
= 0; j
< i
; ++j
) {
1044 cursor
.toNextSibling();
1046 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1047 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo skuInfo
= pcdData
.addNewSkuInfo();
1048 skuInfo
.setSkuId(new BigInteger(id
));
1049 if (varName
!= null){
1050 skuInfo
.setVariableName(varName
);
1051 skuInfo
.setVariableGuid(varGuid
);
1052 skuInfo
.setVariableOffset(varOffset
);
1053 skuInfo
.setHiiDefaultValue(hiiDefault
);
1055 else if (vpdOffset
!= null){
1056 skuInfo
.setVpdOffset(vpdOffset
);
1059 skuInfo
.setValue(value
);
1064 public void updateDynamicPcdBuildDataSkuInfo(String id
, String varName
, String varGuid
, String varOffset
,
1065 String hiiDefault
, String vpdOffset
, String value
, int i
){
1066 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1070 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1071 if (cursor
.toFirstChild()) {
1072 for (int j
= 0; j
< i
; ++j
) {
1073 cursor
.toNextSibling();
1075 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1076 ListIterator
<DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo
> li
= pcdData
.getSkuInfoList().listIterator();
1077 while (li
.hasNext()) {
1078 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo skuInfo
= li
.next();
1079 if (skuInfo
.getSkuId().toString().equals(id
)){
1080 if (varName
!= null){
1081 skuInfo
.setVariableName(varName
);
1082 skuInfo
.setVariableGuid(varGuid
);
1083 skuInfo
.setVariableOffset(varOffset
);
1084 skuInfo
.setHiiDefaultValue(hiiDefault
);
1086 else if (vpdOffset
!= null){
1087 skuInfo
.setVpdOffset(vpdOffset
);
1090 skuInfo
.setValue(value
);
1098 public void removePcdDataFromLibraryInstance(String moduleKey
, String libInstanceKey
){
1099 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(moduleKey
);
1101 // should better maintain pcd from lib instance only, but maintain all is acceptable now.
1103 maintainDynPcdMap(moduleSa
.getPcdBuildDefinition(), libInstanceKey
);
1107 public BuildOptionsDocument
.BuildOptions
getfpdBuildOpts() {
1108 if (fpdBuildOpts
== null) {
1109 fpdBuildOpts
= fpdRoot
.addNewBuildOptions();
1111 return fpdBuildOpts
;
1114 public void genBuildOptionsUserDefAntTask (String id
, String fileName
, String execOrder
) {
1115 UserDefinedAntTasksDocument
.UserDefinedAntTasks udats
= getfpdBuildOpts().getUserDefinedAntTasks();
1116 if (udats
== null) {
1117 udats
= getfpdBuildOpts().addNewUserDefinedAntTasks();
1120 AntTaskDocument
.AntTask at
= udats
.addNewAntTask();
1121 setBuildOptionsUserDefAntTask(id
, fileName
, execOrder
, at
);
1124 private void setBuildOptionsUserDefAntTask(String id
, String fileName
, String execOrder
, AntTaskDocument
.AntTask at
) {
1125 at
.setId(new Integer(id
));
1126 if (fileName
!= null){
1127 at
.setFilename(fileName
);
1129 if (execOrder
!= null) {
1130 at
.setAntCmdOptions(execOrder
);
1134 public void removeBuildOptionsUserDefAntTask(int i
) {
1135 XmlObject o
= getfpdBuildOpts().getUserDefinedAntTasks();
1139 XmlCursor cursor
= o
.newCursor();
1140 if (cursor
.toFirstChild()) {
1141 for (int j
= 0; j
< i
; ++j
) {
1142 cursor
.toNextSibling();
1149 public void updateBuildOptionsUserDefAntTask(int i
, String id
, String fileName
, String execOrder
){
1150 XmlObject o
= getfpdBuildOpts().getUserDefinedAntTasks();
1154 XmlCursor cursor
= o
.newCursor();
1155 if (cursor
.toFirstChild()) {
1156 for (int j
= 0; j
< i
; ++j
) {
1157 cursor
.toNextSibling();
1159 AntTaskDocument
.AntTask at
= (AntTaskDocument
.AntTask
)cursor
.getObject();
1160 setBuildOptionsUserDefAntTask(id
, fileName
, execOrder
, at
);
1165 public int getBuildOptionsUserDefAntTaskCount() {
1166 UserDefinedAntTasksDocument
.UserDefinedAntTasks udats
= getfpdBuildOpts().getUserDefinedAntTasks();
1167 if (udats
== null || udats
.getAntTaskList() == null) {
1171 return udats
.getAntTaskList().size();
1174 public void getBuildOptionsUserDefAntTasks(String
[][] saa
) {
1175 UserDefinedAntTasksDocument
.UserDefinedAntTasks udats
= getfpdBuildOpts().getUserDefinedAntTasks();
1176 if (udats
== null || udats
.getAntTaskList() == null) {
1180 List
<AntTaskDocument
.AntTask
> l
= udats
.getAntTaskList();
1181 ListIterator li
= l
.listIterator();
1183 while (li
.hasNext()) {
1184 AntTaskDocument
.AntTask at
= (AntTaskDocument
.AntTask
)li
.next();
1185 saa
[i
][0] = at
.getId() + "";
1186 saa
[i
][1] = saa
[i
][2] = "";
1187 if (at
.getFilename() != null){
1188 saa
[i
][1] = at
.getFilename();
1190 if (at
.getAntCmdOptions() != null) {
1191 saa
[i
][2] = at
.getAntCmdOptions();
1196 public void genBuildOptionsOpt(Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
) {
1197 OptionsDocument
.Options opts
= getfpdBuildOpts().getOptions();
1199 opts
= getfpdBuildOpts().addNewOptions();
1201 OptionDocument
.Option opt
= opts
.addNewOption();
1202 setBuildOptionsOpt(buildTargets
, toolChain
, tagName
, toolCmd
, archList
, contents
, opt
);
1205 private void setBuildOptionsOpt(Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
, OptionDocument
.Option opt
){
1206 opt
.setStringValue(contents
);
1208 opt
.setBuildTargets(buildTargets
);
1209 opt
.setToolChainFamily(toolChain
);
1210 opt
.setTagName(tagName
);
1211 opt
.setToolCode(toolCmd
);
1213 opt
.setSupArchList(archList
);
1216 public void removeBuildOptionsOpt(int i
){
1218 XmlObject o
= getfpdBuildOpts().getOptions();
1223 XmlCursor cursor
= o
.newCursor();
1224 if (cursor
.toFirstChild()) {
1225 for (int j
= 0; j
< i
; ++j
) {
1226 cursor
.toNextSibling();
1233 public void updateBuildOptionsOpt(int i
, Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
) {
1234 XmlObject o
= getfpdBuildOpts().getOptions();
1239 XmlCursor cursor
= o
.newCursor();
1240 if (cursor
.toFirstChild()) {
1241 for (int j
= 0; j
< i
; ++j
) {
1242 cursor
.toNextSibling();
1244 OptionDocument
.Option opt
= (OptionDocument
.Option
)cursor
.getObject();
1245 setBuildOptionsOpt(buildTargets
, toolChain
, tagName
, toolCmd
, archList
, contents
, opt
);
1250 public int getBuildOptionsOptCount(){
1251 if (getfpdBuildOpts().getOptions() == null || getfpdBuildOpts().getOptions().getOptionList() == null) {
1254 return getfpdBuildOpts().getOptions().getOptionList().size();
1257 public void getBuildOptionsOpts(String
[][] saa
) {
1258 if (getfpdBuildOpts().getOptions() == null || getfpdBuildOpts().getOptions().getOptionList() == null) {
1262 List
<OptionDocument
.Option
> lOpt
= getfpdBuildOpts().getOptions().getOptionList();
1263 ListIterator li
= lOpt
.listIterator();
1265 while(li
.hasNext()) {
1266 OptionDocument
.Option opt
= (OptionDocument
.Option
)li
.next();
1267 if (opt
.getBuildTargets() != null) {
1268 saa
[i
][0] = listToString(opt
.getBuildTargets());
1270 saa
[i
][1] = opt
.getToolChainFamily();
1271 if (opt
.getSupArchList() != null){
1272 saa
[i
][2] = listToString(opt
.getSupArchList());
1275 saa
[i
][3] = opt
.getToolCode();
1276 saa
[i
][4] = opt
.getTagName();
1277 saa
[i
][5] = opt
.getStringValue();
1283 public void genBuildOptionsFfs(String ffsKey
, String type
) {
1284 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getfpdBuildOpts().addNewFfs();
1285 ffs
.setFfsKey(ffsKey
);
1287 ffs
.addNewSections().setEncapsulationType(type
);
1291 public void updateBuildOptionsFfsSectionsType(int i
, String type
) {
1292 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getfpdBuildOpts().addNewFfs();
1294 ffs
.addNewSections().setEncapsulationType(type
);
1298 public void genBuildOptionsFfsAttribute(int i
, String name
, String value
) {
1299 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1300 BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute attrib
= ffs
.addNewAttribute();
1301 attrib
.setName(name
);
1302 attrib
.setValue(value
);
1305 /**update jth attribute of ith ffs.
1309 public void updateBuildOptionsFfsAttribute(int i
, int j
, String name
, String value
){
1310 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1311 XmlCursor cursor
= ffs
.newCursor();
1312 QName qAttrib
= new QName(xmlNs
, "Attribute");
1313 if (cursor
.toChild(qAttrib
)) {
1314 for (int k
= 0; k
< j
; ++k
) {
1315 cursor
.toNextSibling(qAttrib
);
1317 BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute attrib
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute
)cursor
.getObject();
1318 attrib
.setName(name
);
1319 attrib
.setValue(value
);
1324 public void removeBuildOptionsFfsAttribute(int i
, int j
){
1325 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1326 XmlCursor cursor
= ffs
.newCursor();
1327 QName qAttrib
= new QName(xmlNs
, "Attribute");
1328 if (cursor
.toChild(qAttrib
)) {
1329 for (int k
= 0; k
< j
; ++k
) {
1330 cursor
.toNextSibling(qAttrib
);
1337 public void genBuildOptionsFfsSectionsSection(int i
, String sectionType
) {
1338 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1342 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1344 if (sections
== null){
1345 sections
= ffs
.addNewSections();
1347 sections
.addNewSection().setSectionType(EfiSectionType
.Enum
.forString(sectionType
));
1350 public void removeBuildOptionsFfsSectionsSection(int i
, int j
) {
1351 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1352 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1353 if (sections
== null) {
1356 XmlCursor cursor
= sections
.newCursor();
1357 QName qSection
= new QName(xmlNs
, "Section");
1358 if (cursor
.toChild(qSection
)) {
1359 for (int k
= 0; k
< j
; ++k
) {
1360 cursor
.toNextSibling(qSection
);
1367 public void updateBuildOptionsFfsSectionsSection(int i
, int j
, String type
){
1368 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1369 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1370 if (sections
== null) {
1373 XmlCursor cursor
= sections
.newCursor();
1374 QName qSection
= new QName(xmlNs
, "Section");
1375 if (cursor
.toChild(qSection
)) {
1376 for (int k
= 0; k
< j
; ++k
) {
1377 cursor
.toNextSibling(qSection
);
1379 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Section section
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Section
)cursor
.getObject();
1380 section
.setSectionType(EfiSectionType
.Enum
.forString(type
));
1385 public void genBuildOptionsFfsSectionsSections(int i
, String encapType
) {
1386 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1390 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1392 if (sections
== null){
1393 sections
= ffs
.addNewSections();
1395 sections
.addNewSections().setEncapsulationType(encapType
);
1398 public void removeBuildOptionsFfsSectionsSections(int i
, int j
) {
1399 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1400 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1401 if (sections
== null) {
1404 XmlCursor cursor
= sections
.newCursor();
1405 QName qSections
= new QName(xmlNs
, "Sections");
1406 if (cursor
.toChild(qSections
)) {
1407 for (int k
= 0; k
< j
; ++k
) {
1408 cursor
.toNextSibling(qSections
);
1415 public void updateBuildOptionsFfsSectionsSections(int i
, int j
, String type
) {
1416 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1417 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1418 if (sections
== null) {
1421 XmlCursor cursor
= sections
.newCursor();
1422 QName qSections
= new QName(xmlNs
, "Sections");
1423 if (cursor
.toChild(qSections
)) {
1424 for (int k
= 0; k
< j
; ++k
) {
1425 cursor
.toNextSibling(qSections
);
1427 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2 sections2
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
)cursor
.getObject();
1428 sections2
.setEncapsulationType(type
);
1433 public void genBuildOptionsFfsSectionsSectionsSection(int i
, int j
, String type
) {
1434 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1438 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
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
.addNewSection().setSectionType(EfiSectionType
.Enum
.forString(type
));
1451 public void removeBuildOptionsFfsSectionsSectionsSection(int i
, int j
, int k
) {
1452 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1453 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1454 if (sections
== null) {
1457 XmlCursor cursor
= sections
.newCursor();
1458 QName qSections
= new QName(xmlNs
, "Sections");
1459 if (cursor
.toChild(qSections
)) {
1460 for (int l
= 0; l
< j
; ++l
) {
1461 cursor
.toNextSibling(qSections
);
1463 if (cursor
.toFirstChild()) {
1464 for (int m
= 0; m
< k
; ++m
) {
1465 cursor
.toNextSibling();
1473 public void updateBuildOptionsFfsSectionsSectionsSection(int i
, int j
, int k
, String type
) {
1474 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1475 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1476 if (sections
== null) {
1479 XmlCursor cursor
= sections
.newCursor();
1480 QName qSections
= new QName(xmlNs
, "Sections");
1481 if (cursor
.toChild(qSections
)) {
1482 for (int l
= 0; l
< j
; ++l
) {
1483 cursor
.toNextSibling(qSections
);
1485 if (cursor
.toFirstChild()) {
1486 for (int m
= 0; m
< k
; ++m
) {
1487 cursor
.toNextSibling();
1489 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section section
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section
)cursor
.getObject();
1490 section
.setSectionType(EfiSectionType
.Enum
.forString(type
));
1496 public void getBuildOptionsFfsSectionsSectionsSection(int i
, int j
, ArrayList
<String
> al
) {
1497 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1501 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1502 XmlCursor cursor
= sections
.newCursor();
1503 QName qSections
= new QName(xmlNs
, "Sections");
1504 if (cursor
.toChild(qSections
)){
1505 for (int k
= 0; k
< j
; ++k
) {
1506 cursor
.toNextSibling(qSections
);
1508 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2 sections2
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
)cursor
.getObject();
1509 if (sections2
.getSectionList() == null){
1513 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section
> li
= sections2
.getSectionList().listIterator();
1514 while(li
.hasNext()) {
1515 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section section
= li
.next();
1516 if (section
.isSetSectionType()) {
1517 al
.add(section
.getSectionType().toString());
1526 public int getBuildOptionsFfsCount(){
1527 if (getfpdBuildOpts().getFfsList() == null) {
1530 return getfpdBuildOpts().getFfsList().size();
1533 public void getBuildOptionsFfsKey(String
[][] saa
) {
1534 if (getfpdBuildOpts().getFfsList() == null) {
1537 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
> li
= getfpdBuildOpts().getFfsList().listIterator();
1539 while(li
.hasNext()){
1540 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= li
.next();
1541 saa
[i
][0] = ffs
.getFfsKey();
1546 public void updateBuildOptionsFfsKey(int i
, String key
) {
1547 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1551 /**Get ith FFS key and contents.
1554 public void getBuildOptionsFfs(int i
, String
[] sa
, LinkedHashMap
<String
, String
> ffsAttribMap
, ArrayList
<String
> firstLevelSections
, ArrayList
<String
> firstLevelSection
) {
1555 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1559 sa
[0] = ffs
.getFfsKey();
1560 if (ffs
.getSections() != null) {
1561 if(ffs
.getSections().getEncapsulationType() != null){
1562 sa
[1] = ffs
.getSections().getEncapsulationType();
1564 if (ffs
.getSections().getSectionList() != null){
1565 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Section
> li
= ffs
.getSections().getSectionList().listIterator();
1566 while (li
.hasNext()) {
1567 firstLevelSection
.add(li
.next().getSectionType().toString());
1570 if (ffs
.getSections().getSectionsList() != null) {
1571 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
> li
= ffs
.getSections().getSectionsList().listIterator();
1572 while(li
.hasNext()) {
1573 firstLevelSections
.add(li
.next().getEncapsulationType());
1577 if (ffs
.getAttributeList() != null) {
1578 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute
> li
= ffs
.getAttributeList().listIterator();
1579 while(li
.hasNext()) {
1580 BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute attrib
= li
.next();
1581 ffsAttribMap
.put(attrib
.getName(), attrib
.getValue());
1590 private BuildOptionsDocument
.BuildOptions
.Ffs
getFfs(int i
) {
1591 XmlObject o
= getfpdBuildOpts();
1592 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= null;
1594 XmlCursor cursor
= o
.newCursor();
1595 QName qFfs
= new QName(xmlNs
, "Ffs");
1596 if (cursor
.toChild(qFfs
)) {
1597 for (int j
= 0; j
< i
; ++j
) {
1598 cursor
.toNextSibling(qFfs
);
1600 ffs
= (BuildOptionsDocument
.BuildOptions
.Ffs
)cursor
.getObject();
1606 public void removeBuildOptionsFfs(int i
) {
1607 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1612 XmlCursor cursor
= ffs
.newCursor();
1619 public PlatformDefinitionsDocument
.PlatformDefinitions
getfpdPlatformDefs(){
1620 if (fpdPlatformDefs
== null){
1621 fpdPlatformDefs
= fpdRoot
.addNewPlatformDefinitions();
1623 return fpdPlatformDefs
;
1626 public void getPlatformDefsSupportedArchs(Vector
<Object
> archs
){
1627 if (getfpdPlatformDefs().getSupportedArchitectures() == null) {
1630 ListIterator li
= getfpdPlatformDefs().getSupportedArchitectures().listIterator();
1631 while(li
.hasNext()) {
1632 archs
.add(li
.next());
1636 public void setPlatformDefsSupportedArchs(Vector
<Object
> archs
) {
1637 getfpdPlatformDefs().setSupportedArchitectures(archs
);
1640 public void getPlatformDefsBuildTargets(Vector
<Object
> targets
) {
1641 if (getfpdPlatformDefs().getBuildTargets() == null) {
1644 ListIterator li
= getfpdPlatformDefs().getBuildTargets().listIterator();
1645 while(li
.hasNext()) {
1646 targets
.add(li
.next());
1650 public void setPlatformDefsBuildTargets(Vector
<Object
> targets
) {
1651 getfpdPlatformDefs().setBuildTargets(targets
);
1654 public void genPlatformDefsSkuInfo(String id
, String name
) {
1655 SkuInfoDocument
.SkuInfo skuInfo
= null;
1656 if (getfpdPlatformDefs().getSkuInfo() == null) {
1657 skuInfo
= getfpdPlatformDefs().addNewSkuInfo();
1659 skuInfo
= getfpdPlatformDefs().getSkuInfo();
1660 if (skuInfo
.getUiSkuNameList() == null || skuInfo
.getUiSkuNameList().size() == 0) {
1661 SkuInfoDocument
.SkuInfo
.UiSkuName skuName
= skuInfo
.addNewUiSkuName();
1662 skuName
.setSkuID(new BigInteger("0"));
1663 skuName
.setStringValue("DEFAULT");
1665 if (id
.equals("0")) {
1668 SkuInfoDocument
.SkuInfo
.UiSkuName skuName
= skuInfo
.addNewUiSkuName();
1669 skuName
.setSkuID(new BigInteger(id
));
1670 skuName
.setStringValue(name
);
1673 public int getPlatformDefsSkuInfoCount(){
1674 if (getfpdPlatformDefs().getSkuInfo() == null || getfpdPlatformDefs().getSkuInfo().getUiSkuNameList() == null) {
1677 return getfpdPlatformDefs().getSkuInfo().getUiSkuNameList().size();
1680 public void getPlatformDefsSkuInfos(String
[][] saa
){
1681 if (getfpdPlatformDefs().getSkuInfo() == null || getfpdPlatformDefs().getSkuInfo().getUiSkuNameList() == null) {
1685 List
<SkuInfoDocument
.SkuInfo
.UiSkuName
> l
= getfpdPlatformDefs().getSkuInfo().getUiSkuNameList();
1686 ListIterator
<SkuInfoDocument
.SkuInfo
.UiSkuName
> li
= l
.listIterator();
1688 while(li
.hasNext()) {
1689 SkuInfoDocument
.SkuInfo
.UiSkuName sku
= li
.next();
1690 saa
[i
][0] = sku
.getSkuID()+"";
1691 saa
[i
][1] = sku
.getStringValue();
1696 public void removePlatformDefsSkuInfo(int i
) {
1697 SkuInfoDocument
.SkuInfo skuInfo
= getfpdPlatformDefs().getSkuInfo();
1698 if (skuInfo
== null || i
== 0) {
1702 XmlCursor cursor
= skuInfo
.newCursor();
1703 if (cursor
.toFirstChild()) {
1704 for (int j
= 0; j
< i
; ++j
) {
1705 cursor
.toNextSibling();
1712 public void updatePlatformDefsSkuInfo(int i
, String id
, String name
) {
1713 SkuInfoDocument
.SkuInfo skuInfo
= getfpdPlatformDefs().getSkuInfo();
1714 if (skuInfo
== null || i
== 0) {
1718 XmlCursor cursor
= skuInfo
.newCursor();
1719 if (cursor
.toFirstChild()) {
1720 for (int j
= 0; j
< i
; ++j
) {
1721 cursor
.toNextSibling();
1723 SkuInfoDocument
.SkuInfo
.UiSkuName sku
= (SkuInfoDocument
.SkuInfo
.UiSkuName
)cursor
.getObject();
1724 sku
.setSkuID(new BigInteger(id
));
1725 sku
.setStringValue(name
);
1730 public String
getPlatformDefsInterDir(){
1731 if (getfpdPlatformDefs().getIntermediateDirectories() == null) {
1734 return getfpdPlatformDefs().getIntermediateDirectories().toString();
1737 public void setPlatformDefsInterDir(String interDir
){
1738 getfpdPlatformDefs().setIntermediateDirectories(IntermediateOutputType
.Enum
.forString(interDir
));
1741 public String
getPlatformDefsOutputDir() {
1742 return getfpdPlatformDefs().getOutputDirectory();
1745 public void setPlatformDefsOutputDir(String outputDir
) {
1746 getfpdPlatformDefs().setOutputDirectory(outputDir
);
1749 public FlashDocument
.Flash
getfpdFlash() {
1750 if (fpdFlash
== null) {
1751 fpdFlash
= fpdRoot
.addNewFlash();
1756 public void genFlashDefinitionFile(String file
) {
1757 FlashDefinitionFileDocument
.FlashDefinitionFile fdf
= getfpdFlash().getFlashDefinitionFile();
1759 fdf
= getfpdFlash().addNewFlashDefinitionFile();
1762 fdf
.setStringValue(file
);
1765 public String
getFlashDefinitionFile() {
1766 FlashDefinitionFileDocument
.FlashDefinitionFile fdf
= getfpdFlash().getFlashDefinitionFile();
1771 return fdf
.getStringValue();
1776 public void genFvImagesNameValue(String name
, String value
) {
1778 FvImagesDocument
.FvImages fi
= getfpdFlash().getFvImages();
1780 fi
= getfpdFlash().addNewFvImages();
1783 FvImagesDocument
.FvImages
.NameValue nv
= fi
.addNewNameValue();
1788 public void removeFvImagesNameValue(int i
){
1790 XmlObject o
= getfpdFlash().getFvImages();
1795 QName qNameValue
= new QName(xmlNs
, "NameValue");
1796 XmlCursor cursor
= o
.newCursor();
1797 if (cursor
.toChild(qNameValue
)) {
1798 for (int j
= 0; j
< i
; ++j
) {
1799 cursor
.toNextSibling(qNameValue
);
1806 public void updateFvImagesNameValue(int i
, String name
, String value
){
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
);
1819 FvImagesDocument
.FvImages
.NameValue nv
= (FvImagesDocument
.FvImages
.NameValue
)cursor
.getObject();
1826 public int getFvImagesNameValueCount() {
1828 FvImagesDocument
.FvImages fi
= null;
1829 if ((fi
= getfpdFlash().getFvImages()) == null || fi
.getNameValueList() == null) {
1832 return fi
.getNameValueList().size();
1835 public void getFvImagesNameValues(String
[][] nv
) {
1837 FvImagesDocument
.FvImages fi
= getfpdFlash().getFvImages();
1841 List
<FvImagesDocument
.FvImages
.NameValue
> l
= fi
.getNameValueList();
1843 ListIterator li
= l
.listIterator();
1844 while (li
.hasNext()) {
1845 FvImagesDocument
.FvImages
.NameValue e
= (FvImagesDocument
.FvImages
.NameValue
) li
1847 nv
[i
][0] = e
.getName();
1848 nv
[i
][1] = e
.getValue();
1854 public void genFvImagesFvImage(String
[] names
, String types
, Map
<String
, String
> options
) {
1856 FvImagesDocument
.FvImages fis
= null;
1857 if ((fis
= getfpdFlash().getFvImages()) == null) {
1858 fis
= getfpdFlash().addNewFvImages();
1862 //gen FvImage with FvImageNames array
1864 FvImagesDocument
.FvImages
.FvImage fi
= fis
.addNewFvImage();
1865 for (int i
= 0; i
< names
.length
; ++i
) {
1866 fi
.addFvImageNames(names
[i
]);
1868 fi
.setType(FvImageTypes
.Enum
.forString(types
));
1869 if (options
!= null){
1870 setFvImagesFvImageFvImageOptions(options
, fi
);
1874 private void setFvImagesFvImageFvImageOptions(Map
<String
, String
> options
, FvImagesDocument
.FvImages
.FvImage fi
){
1875 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions fio
= fi
.getFvImageOptions();
1877 fio
= fi
.addNewFvImageOptions();
1880 Set
<String
> key
= options
.keySet();
1881 Iterator
<String
> i
= key
.iterator();
1882 while (i
.hasNext()) {
1884 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nv
= fio
.addNewNameValue();
1885 String k
= (String
)i
.next();
1888 nv
.setValue((String
)options
.get(k
));
1895 public void removeFvImagesFvImage(int i
) {
1897 XmlObject o
= getfpdFlash().getFvImages();
1902 QName qFvImage
= new QName(xmlNs
, "FvImage");
1903 XmlCursor cursor
= o
.newCursor();
1904 if (cursor
.toChild(qFvImage
)) {
1905 for (int j
= 0; j
< i
; ++j
) {
1906 cursor
.toNextSibling(qFvImage
);
1913 public void updateFvImagesFvImage(int i
, String
[] names
, String types
, Map
<String
, String
> options
){
1915 XmlObject o
= getfpdFlash().getFvImages();
1919 XmlCursor cursor
= o
.newCursor();
1920 QName qFvImage
= new QName(xmlNs
, "FvImage");
1921 if (cursor
.toChild(qFvImage
)) {
1922 for (int j
= 0; j
< i
; ++j
) {
1923 cursor
.toNextSibling(qFvImage
);
1925 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
1926 fi
.setType(FvImageTypes
.Enum
.forString(types
));
1929 // remove old FvImageNames before adding new ones
1931 QName qFvImageNames
= new QName(xmlNs
, "FvImageNames");
1932 cursor
.toChild(qFvImageNames
);
1934 while (cursor
.toNextSibling(qFvImageNames
)) {
1938 for (int k
= 0; k
< names
.length
; ++k
) {
1939 fi
.addFvImageNames(names
[k
]);
1942 // remove old FvImageOptions before adding new options
1944 QName qFvImageOptions
= new QName(xmlNs
, "FvImageOptions");
1945 cursor
.toNextSibling(qFvImageOptions
);
1948 setFvImagesFvImageFvImageOptions(options
, fi
);
1953 public int getFvImagesFvImageCount() {
1955 if (getfpdFlash().getFvImages() == null || getfpdFlash().getFvImages().getFvImageList() == null) {
1958 return getfpdFlash().getFvImages().getFvImageList().size();
1961 /**Only Get Fv image setting - name and type.
1964 public void getFvImagesFvImages(String
[][] saa
) {
1966 if (getfpdFlash().getFvImages() == null) {
1969 List
<FvImagesDocument
.FvImages
.FvImage
> l
= getfpdFlash().getFvImages().getFvImageList();
1973 ListIterator li
= l
.listIterator();
1975 while(li
.hasNext()) {
1976 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)li
.next();
1978 // get FvImageNames array, space separated
1980 List
<String
> lfn
= fi
.getFvImageNamesList();
1981 ListIterator lfni
= lfn
.listIterator();
1983 while (lfni
.hasNext()) {
1984 saa
[i
][0] += (String
)lfni
.next();
1987 saa
[i
][0] = saa
[i
][0].trim();
1989 saa
[i
][1] = fi
.getType()+"";
1995 /**Get FvImage Options for FvImage i
1996 * @param i the ith FvImage
1998 public void getFvImagesFvImageOptions(int i
, Map
<String
, String
> m
) {
1999 XmlObject o
= getfpdFlash().getFvImages();
2003 XmlCursor cursor
= o
.newCursor();
2004 QName qFvImage
= new QName(xmlNs
, "FvImage");
2005 if (cursor
.toChild(qFvImage
)) {
2006 for (int j
= 0; j
< i
; ++j
) {
2007 cursor
.toNextSibling(qFvImage
);
2009 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
2010 if (fi
.getFvImageOptions() == null || fi
.getFvImageOptions().getNameValueList() == null){
2013 ListIterator
<FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
> li
= fi
.getFvImageOptions().getNameValueList().listIterator();
2014 while(li
.hasNext()){
2015 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nv
= li
.next();
2016 m
.put(nv
.getName(), nv
.getValue());
2022 Get platform header element
2023 @return PlatformHeaderDocument.PlatformHeader
2025 public PlatformHeaderDocument
.PlatformHeader
getFpdHdr() {
2026 if (fpdHdr
== null) {
2027 fpdHdr
= fpdRoot
.addNewPlatformHeader();
2029 genPlatformDefsSkuInfo("0", "DEFAULT");
2033 public String
getFpdHdrPlatformName() {
2034 return getFpdHdr().getPlatformName();
2037 public String
getFpdHdrGuidValue() {
2038 return getFpdHdr().getGuidValue();
2041 public String
getFpdHdrVer() {
2042 return getFpdHdr().getVersion();
2045 public String
getFpdHdrAbs() {
2046 return getFpdHdr().getAbstract();
2049 public String
getFpdHdrDescription() {
2050 return getFpdHdr().getDescription();
2053 public String
getFpdHdrCopyright() {
2054 return getFpdHdr().getCopyright();
2057 public String
getFpdHdrLicense() {
2058 LicenseDocument
.License l
= getFpdHdr().getLicense();
2062 return l
.getStringValue();
2065 public String
getFpdHdrUrl() {
2066 LicenseDocument
.License l
= getFpdHdr().getLicense();
2073 public String
getFpdHdrSpec() {
2075 return "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052";
2076 // return getFpdHdr().getSpecification();
2079 public void setFpdHdrPlatformName(String name
){
2080 getFpdHdr().setPlatformName(name
);
2083 public void setFpdHdrGuidValue(String guid
){
2084 getFpdHdr().setGuidValue(guid
);
2087 public void setFpdHdrVer(String v
){
2088 getFpdHdr().setVersion(v
);
2091 public void setFpdHdrAbs(String abs
) {
2092 getFpdHdr().setAbstract(abs
);
2095 public void setFpdHdrDescription(String desc
){
2096 getFpdHdr().setDescription(desc
);
2099 public void setFpdHdrCopyright(String cr
) {
2100 getFpdHdr().setCopyright(cr
);
2103 public void setFpdHdrLicense(String license
){
2104 LicenseDocument
.License l
= getFpdHdr().getLicense();
2106 getFpdHdr().addNewLicense().setStringValue(license
);
2109 l
.setStringValue(license
);
2113 public void setFpdHdrUrl(String url
){
2114 LicenseDocument
.License l
= getFpdHdr().getLicense();
2120 public void setFpdHdrSpec(String s
){
2121 s
= "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052";
2122 getFpdHdr().setSpecification(s
);
2125 Save the processed xml contents to file
2127 @param fpdFile The file to save xml contents
2128 @throws IOException Exceptions during file operation
2130 public void saveAs(File fpdFile
) throws IOException
{
2132 XmlOptions options
= new XmlOptions();
2134 options
.setCharacterEncoding("UTF-8");
2135 options
.setSavePrettyPrint();
2136 options
.setSavePrettyPrintIndent(2);
2138 fpdd
.save(fpdFile
, options
);
2139 } catch (IOException e
) {
2140 e
.printStackTrace();
2145 private String
listToString(List l
) {
2150 ListIterator li
= l
.listIterator();
2151 while(li
.hasNext()) {