2 Java class FpdFileContents is used to parse fpd xml file.
4 Copyright (c) 2006, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13 package org
.tianocore
.frameworkwizard
.platform
.ui
;
16 import java
.io
.IOException
;
17 import java
.math
.BigInteger
;
18 import java
.util
.ArrayList
;
19 import java
.util
.HashMap
;
20 import java
.util
.Iterator
;
21 import java
.util
.LinkedHashMap
;
22 import java
.util
.List
;
23 import java
.util
.ListIterator
;
26 import java
.util
.Vector
;
28 import javax
.xml
.namespace
.QName
;
30 import org
.apache
.xmlbeans
.XmlCursor
;
31 import org
.apache
.xmlbeans
.XmlObject
;
32 import org
.apache
.xmlbeans
.XmlOptions
;
33 import org
.tianocore
.AntTaskDocument
;
34 import org
.tianocore
.BuildOptionsDocument
;
35 import org
.tianocore
.DynamicPcdBuildDefinitionsDocument
;
36 import org
.tianocore
.EfiSectionType
;
37 import org
.tianocore
.FlashDefinitionFileDocument
;
38 import org
.tianocore
.FlashDocument
;
39 import org
.tianocore
.FrameworkModulesDocument
;
40 import org
.tianocore
.IntermediateOutputType
;
41 import org
.tianocore
.LibrariesDocument
;
42 import org
.tianocore
.ModuleSADocument
;
43 import org
.tianocore
.ModuleSaBuildOptionsDocument
;
44 import org
.tianocore
.ModuleSurfaceAreaDocument
;
45 import org
.tianocore
.OptionDocument
;
46 import org
.tianocore
.OptionsDocument
;
47 import org
.tianocore
.PcdBuildDefinitionDocument
;
48 import org
.tianocore
.PcdCodedDocument
;
49 import org
.tianocore
.PcdDataTypes
;
50 import org
.tianocore
.PcdDeclarationsDocument
;
51 import org
.tianocore
.PcdItemTypes
;
52 import org
.tianocore
.PlatformDefinitionsDocument
;
53 import org
.tianocore
.PlatformSurfaceAreaDocument
;
54 import org
.tianocore
.FvImageTypes
;
55 import org
.tianocore
.FvImagesDocument
;
56 import org
.tianocore
.LicenseDocument
;
57 import org
.tianocore
.PlatformHeaderDocument
;
58 import org
.tianocore
.SkuInfoDocument
;
59 import org
.tianocore
.UserDefinedAntTasksDocument
;
60 import org
.tianocore
.UserExtensionsDocument
;
61 import org
.tianocore
.frameworkwizard
.platform
.ui
.global
.WorkspaceProfile
;
62 import org
.tianocore
.frameworkwizard
.platform
.ui
.global
.SurfaceAreaQuery
;
63 import org
.tianocore
.frameworkwizard
.module
.Identifications
.ModuleIdentification
;
64 import org
.tianocore
.frameworkwizard
.packaging
.PackageIdentification
;
67 This class processes fpd file contents such as add remove xml elements.
68 @since PackageEditor 1.0
70 public class FpdFileContents
{
72 static final String xmlNs
= "http://www.TianoCore.org/2006/Edk2.0";
74 private PlatformSurfaceAreaDocument fpdd
= null;
76 private PlatformSurfaceAreaDocument
.PlatformSurfaceArea fpdRoot
= null;
78 private PlatformHeaderDocument
.PlatformHeader fpdHdr
= null;
80 private PlatformDefinitionsDocument
.PlatformDefinitions fpdPlatformDefs
= null;
82 private FlashDocument
.Flash fpdFlash
= null;
84 private BuildOptionsDocument
.BuildOptions fpdBuildOpts
= null;
86 private FrameworkModulesDocument
.FrameworkModules fpdFrameworkModules
= null;
88 private DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions fpdDynPcdBuildDefs
= null;
90 private HashMap
<String
, ArrayList
<String
>> dynPcdMap
= null;
92 private HashMap
<String
, String
> defaultPcdValue
= new HashMap
<String
, String
>();
95 * look through all pcd data in all ModuleSA, create pcd -> ModuleSA mappings.
97 public void initDynPcdMap() {
98 if (dynPcdMap
== null) {
99 dynPcdMap
= new HashMap
<String
, ArrayList
<String
>>();
100 List
<ModuleSADocument
.ModuleSA
> l
= getfpdFrameworkModules().getModuleSAList();
102 removeElement(getfpdFrameworkModules());
103 fpdFrameworkModules
= null;
106 ListIterator
<ModuleSADocument
.ModuleSA
> li
= l
.listIterator();
107 while (li
.hasNext()) {
108 ModuleSADocument
.ModuleSA moduleSa
= li
.next();
109 if (moduleSa
.getPcdBuildDefinition() == null || moduleSa
.getPcdBuildDefinition().getPcdDataList() == null) {
112 String ModuleInfo
= moduleSa
.getModuleGuid() + " " + moduleSa
.getModuleVersion() +
113 " " + moduleSa
.getPackageGuid() + " " + moduleSa
.getPackageVersion() + " " + listToString(moduleSa
.getSupArchList());
114 List
<PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
> lp
= moduleSa
.getPcdBuildDefinition().getPcdDataList();
115 ListIterator
<PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
> lpi
= lp
.listIterator();
116 while (lpi
.hasNext()) {
117 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= lpi
.next();
118 String pcdKey
= pcdData
.getCName() + " " + pcdData
.getTokenSpaceGuidCName();
119 if (dynPcdMap
.get(pcdKey
) == null) {
120 ArrayList
<String
> al
= new ArrayList
<String
>();
121 al
.add(ModuleInfo
+ " " + pcdData
.getItemType().toString());
122 dynPcdMap
.put(pcdKey
, al
);
125 dynPcdMap
.get(pcdKey
).add(ModuleInfo
+ " " + pcdData
.getItemType().toString());
132 public ArrayList
<String
> getDynPcdMapValue(String key
) {
133 return dynPcdMap
.get(key
);
136 Constructor to create a new spd file
138 public FpdFileContents() {
140 fpdd
= PlatformSurfaceAreaDocument
.Factory
.newInstance();
141 fpdRoot
= fpdd
.addNewPlatformSurfaceArea();
146 Constructor for existing document object
149 public FpdFileContents(PlatformSurfaceAreaDocument
.PlatformSurfaceArea fpd
) {
151 fpdHdr
= fpdRoot
.getPlatformHeader();
152 fpdPlatformDefs
= fpdRoot
.getPlatformDefinitions();
153 fpdBuildOpts
= fpdRoot
.getBuildOptions();
154 fpdFrameworkModules
= fpdRoot
.getFrameworkModules();
155 fpdDynPcdBuildDefs
= fpdRoot
.getDynamicPcdBuildDefinitions();
156 fpdFlash
= fpdRoot
.getFlash();
160 Constructor based on an existing spd file
162 @param f Existing spd file
164 public FpdFileContents(File f
) {
166 fpdd
= PlatformSurfaceAreaDocument
.Factory
.parse(f
);
167 fpdRoot
= fpdd
.getPlatformSurfaceArea();
168 } catch (Exception e
) {
169 System
.out
.println(e
.toString());
173 public DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
getfpdDynPcdBuildDefs() {
174 if (fpdDynPcdBuildDefs
== null){
175 fpdDynPcdBuildDefs
= fpdRoot
.addNewDynamicPcdBuildDefinitions();
177 return fpdDynPcdBuildDefs
;
180 public FrameworkModulesDocument
.FrameworkModules
getfpdFrameworkModules() {
181 if (fpdFrameworkModules
== null){
182 fpdFrameworkModules
= fpdRoot
.addNewFrameworkModules();
184 return fpdFrameworkModules
;
187 public void getFrameworkModuleGuid (String fvName
, Vector
<String
> vGuid
) {
188 if (getFrameworkModulesCount() == 0){
192 ListIterator li
= getfpdFrameworkModules().getModuleSAList().listIterator();
193 while(li
.hasNext()) {
194 ModuleSADocument
.ModuleSA moduleSa
= (ModuleSADocument
.ModuleSA
)li
.next();
195 if (moduleSa
.getModuleSaBuildOptions() == null) {
198 String fvBinding
= moduleSa
.getModuleSaBuildOptions().getFvBinding();
199 if (fvBinding
== null) {
203 String
[] fvNames
= fvBinding
.split(" ");
204 for (int i
= 0; i
< fvNames
.length
; ++i
) {
205 if (fvNames
[i
].equals(fvName
) || fvNames
[i
].replaceAll("_", "").equals(fvName
)) {
206 vGuid
.add(moduleSa
.getModuleGuid());
213 public int getFrameworkModulesCount() {
214 if (getfpdFrameworkModules().getModuleSAList() == null || getfpdFrameworkModules().getModuleSAList().size() == 0){
215 removeElement(getfpdFrameworkModules());
216 fpdFrameworkModules
= null;
219 return getfpdFrameworkModules().getModuleSAList().size();
222 public void getFrameworkModulesInfo(String
[][] saa
) {
223 if (getFrameworkModulesCount() == 0){
227 ListIterator li
= getfpdFrameworkModules().getModuleSAList().listIterator();
229 while(li
.hasNext()) {
230 ModuleSADocument
.ModuleSA moduleSa
= (ModuleSADocument
.ModuleSA
)li
.next();
231 saa
[i
][0] = moduleSa
.getModuleGuid();
232 saa
[i
][1] = moduleSa
.getModuleVersion();
234 saa
[i
][2] = moduleSa
.getPackageGuid();
235 saa
[i
][3] = moduleSa
.getPackageVersion();
236 saa
[i
][4] = listToString(moduleSa
.getSupArchList());
241 public void getFrameworkModuleInfo(int i
, String
[] sa
) {
242 ModuleSADocument
.ModuleSA msa
= getModuleSA(i
);
246 sa
[0] = msa
.getModuleGuid();
247 sa
[1] = msa
.getModuleVersion();
248 sa
[2] = msa
.getPackageGuid();
249 sa
[3] = msa
.getPackageVersion();
250 sa
[4] = listToString(msa
.getSupArchList());
253 public ModuleSADocument
.ModuleSA
getModuleSA(String key
) {
255 if (getfpdFrameworkModules().getModuleSAList() == null || getfpdFrameworkModules().getModuleSAList().size() == 0) {
256 removeElement(getfpdFrameworkModules());
257 fpdFrameworkModules
= null;
260 String
[] s
= key
.split(" ");
261 String archsInKey
= "";
263 for (int i
= 4; i
< s
.length
; ++i
) {
267 archsInKey
= archsInKey
.trim();
270 ListIterator li
= getfpdFrameworkModules().getModuleSAList().listIterator();
271 while(li
.hasNext()) {
272 ModuleSADocument
.ModuleSA moduleSa
= (ModuleSADocument
.ModuleSA
)li
.next();
273 if (moduleSa
.getModuleGuid().equalsIgnoreCase(s
[0]) && moduleSa
.getPackageGuid().equalsIgnoreCase(s
[2])) {
274 if (moduleSa
.getModuleVersion() != null) {
275 if (!moduleSa
.getModuleVersion().equals(s
[1])) {
279 if (moduleSa
.getPackageVersion() != null) {
280 if (!moduleSa
.getPackageVersion().equals(s
[3])) {
284 //ToDo add arch check .
285 if (moduleSa
.getSupArchList() != null) {
286 if (listToString(moduleSa
.getSupArchList()).equals(archsInKey
)) {
291 if (archsInKey
.length() == 0) {
300 private ModuleSADocument
.ModuleSA
getModuleSA(int i
) {
301 ModuleSADocument
.ModuleSA moduleSa
= null;
302 if (fpdRoot
.getFrameworkModules() == null) {
305 XmlCursor cursor
= fpdRoot
.getFrameworkModules().newCursor();
306 if (cursor
.toFirstChild()) {
307 for (int j
= 0; j
< i
; ++j
) {
308 cursor
.toNextSibling();
310 moduleSa
= (ModuleSADocument
.ModuleSA
)cursor
.getObject();
316 public void removeModuleSA(int i
) {
317 XmlObject o
= fpdRoot
.getFrameworkModules();
322 XmlCursor cursor
= o
.newCursor();
323 if (cursor
.toFirstChild()) {
324 for (int j
= 0; j
< i
; ++j
) {
325 cursor
.toNextSibling();
328 // remove pcd from dynPcdMap, if DynamicPcdBuildData exists, remove them too.
330 ModuleSADocument
.ModuleSA moduleSa
= (ModuleSADocument
.ModuleSA
)cursor
.getObject();
331 String moduleInfo
= moduleSa
.getModuleGuid() + " " + moduleSa
.getModuleVersion() + " " +
332 moduleSa
.getPackageGuid()+ " " + moduleSa
.getPackageVersion() + " " + listToString(moduleSa
.getSupArchList());
333 PcdBuildDefinitionDocument
.PcdBuildDefinition pcdBuildDef
= moduleSa
.getPcdBuildDefinition();
334 if (pcdBuildDef
!= null && pcdBuildDef
.getPcdDataList() != null) {
335 ListIterator
<PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
> li
= pcdBuildDef
.getPcdDataList().listIterator();
336 while(li
.hasNext()) {
337 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= li
.next();
338 maintainDynPcdMap(pcdData
.getCName() + " " + pcdData
.getTokenSpaceGuidCName(), moduleInfo
);
343 cursor
.toPrevToken();
344 if (cursor
.isComment()) {
349 if (getFrameworkModulesCount() == 0) {
357 public boolean adjustPcd (int seqModuleSa
) throws Exception
{
358 boolean dataModified
= false;
359 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(seqModuleSa
);
360 int pcdCount
= getPcdDataCount(seqModuleSa
);
361 String
[][] saaModuleSaPcd
= new String
[pcdCount
][7];
362 getPcdData(seqModuleSa
, saaModuleSaPcd
);
363 String mg
= moduleSa
.getModuleGuid();
364 String mv
= moduleSa
.getModuleVersion();
365 String pg
= moduleSa
.getPackageGuid();
366 String pv
= moduleSa
.getPackageVersion();
367 String arch
= listToString(moduleSa
.getSupArchList());
369 // delete pcd in ModuleSA but not in MSA files any longer.
371 String moduleKey
= mg
+ " " + mv
+ " " + pg
+ " " + pv
+ " " + arch
;
372 int libCount
= getLibraryInstancesCount(moduleKey
);
373 String
[][] saaLib
= new String
[libCount
][5];
374 getLibraryInstances(moduleKey
, saaLib
);
375 ModuleIdentification mi
= WorkspaceProfile
.getModuleId(moduleKey
);
376 Vector
<ModuleIdentification
> vMi
= new Vector
<ModuleIdentification
>();
378 // create vector for module & library instance MIs.
381 for (int j
= 0; j
< saaLib
.length
; ++j
) {
382 String libKey
= saaLib
[j
][1] + " " + saaLib
[j
][2] + " " + saaLib
[j
][3] + " " + saaLib
[j
][4];
383 ModuleIdentification libMi
= WorkspaceProfile
.getModuleId(libKey
);
388 nextPcd
:for (int i
= 0; i
< saaModuleSaPcd
.length
; ++i
) {
390 for (int j
= 0; j
< vMi
.size(); ++j
) {
391 ModuleIdentification nextMi
= vMi
.get(j
);
392 if (WorkspaceProfile
.pcdInMsa(saaModuleSaPcd
[i
][0], saaModuleSaPcd
[i
][1], nextMi
)) {
396 removePcdData(seqModuleSa
, saaModuleSaPcd
[i
][0], saaModuleSaPcd
[i
][1]);
400 catch (Exception e
) {
404 // add new Pcd from MSA file to ModuleSA.
408 for (int i
= 0; i
< vMi
.size(); ++i
) {
409 ModuleSurfaceAreaDocument
.ModuleSurfaceArea msa
= (ModuleSurfaceAreaDocument
.ModuleSurfaceArea
) WorkspaceProfile
410 .getModuleXmlObject(vMi
412 if (msa
.getPcdCoded() == null || msa
.getPcdCoded().getPcdEntryList() == null) {
415 ListIterator li
= msa
.getPcdCoded().getPcdEntryList().listIterator();
416 msaPcdIter
:while (li
.hasNext()) {
417 PcdCodedDocument
.PcdCoded
.PcdEntry msaPcd
= (PcdCodedDocument
.PcdCoded
.PcdEntry
) li
.next();
418 ArrayList
<String
> al
= getDynPcdMapValue(msaPcd
.getCName() + " " + msaPcd
.getTokenSpaceGuidCName());
420 for (int j
= 0; j
< al
.size(); ++j
) {
421 if (al
.get(j
).contains(moduleKey
)) {
427 PackageIdentification
[] depPkgs
= SurfaceAreaQuery
.getDependencePkg(null, vMi
.get(i
));
428 PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry spdPcd
= LookupPcdDeclaration(msaPcd
, depPkgs
);
429 if (spdPcd
== null) {
433 throw new PcdDeclNotFound("No Declaration for PCD Entry " + msaPcd
.getCName() + " in Module "
437 // AddItem to ModuleSA PcdBuildDefinitions
439 String defaultVal
= msaPcd
.getDefaultValue() == null ? spdPcd
.getDefaultValue()
440 : msaPcd
.getDefaultValue();
442 genPcdData(msaPcd
.getCName(), spdPcd
.getToken(), msaPcd
.getTokenSpaceGuidCName(),
443 msaPcd
.getPcdItemType().toString(), spdPcd
.getDatumType() + "", defaultVal
, moduleSa
);
456 private void maintainDynPcdMap(String pcdKey
, String moduleInfo
) {
458 ArrayList
<String
> al
= dynPcdMap
.get(pcdKey
);
462 String
[] s
= moduleInfo
.split(" ");
463 for(int i
= 0; i
< al
.size(); ++i
){
464 String consumer
= al
.get(i
);
465 if (consumer
.contains(s
[0]) && consumer
.contains(s
[2])){
466 String
[] consumerPart
= consumer
.split(" ");
467 if (!consumerPart
[4].equals(s
[4])) {
475 if (al
.size() == 0) {
476 defaultPcdValue
.remove(pcdKey
);
477 dynPcdMap
.remove(pcdKey
);
478 String
[] s1
= pcdKey
.split(" ");
479 removeDynamicPcdBuildData(s1
[0], s1
[1]);
484 // key for ModuleSA : "ModuleGuid ModuleVer PackageGuid PackageVer Arch"
486 public int getPcdDataCount (int i
){
487 ModuleSADocument
.ModuleSA msa
= getModuleSA(i
);
489 if (msa
== null || msa
.getPcdBuildDefinition() == null || msa
.getPcdBuildDefinition().getPcdDataList() == null){
492 return msa
.getPcdBuildDefinition().getPcdDataList().size();
496 public void getPcdData (int i
, String
[][] saa
) {
497 ModuleSADocument
.ModuleSA msa
= getModuleSA(i
);
499 if (msa
== null || msa
.getPcdBuildDefinition() == null || msa
.getPcdBuildDefinition().getPcdDataList() == null){
502 ListIterator
<PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
>li
= msa
.getPcdBuildDefinition().getPcdDataList().listIterator();
503 for (int k
= 0; k
< saa
.length
; ++k
) {
504 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= li
.next();
505 saa
[k
][0] = pcdData
.getCName();
506 saa
[k
][1] = pcdData
.getTokenSpaceGuidCName();
507 saa
[k
][2] = pcdData
.getItemType()+"";
508 saa
[k
][3] = pcdData
.getToken().toString();
509 saa
[k
][4] = pcdData
.getMaxDatumSize()+"";
510 saa
[k
][5] = pcdData
.getDatumType()+"";
511 saa
[k
][6] = pcdData
.getValue();
516 public void removePcdData (int seqModuleSa
, String cName
, String tsGuid
) {
517 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(seqModuleSa
);
518 if (moduleSa
== null || moduleSa
.getPcdBuildDefinition() == null){
522 String mg
= moduleSa
.getModuleGuid();
523 String mv
= moduleSa
.getModuleVersion();
524 String pg
= moduleSa
.getPackageGuid();
525 String pv
= moduleSa
.getPackageVersion();
526 String arch
= listToString(moduleSa
.getSupArchList());
527 String moduleKey
= mg
+ " " + mv
+ " " + pg
+ " " + pv
+ " " + arch
;
529 XmlCursor cursor
= moduleSa
.getPcdBuildDefinition().newCursor();
530 if (cursor
.toFirstChild()){
533 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= (PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
)cursor
.getObject();
534 if (pcdData
.getCName().equals(cName
) && pcdData
.getTokenSpaceGuidCName().equals(tsGuid
)) {
535 maintainDynPcdMap(cName
+ " " + tsGuid
, moduleKey
);
536 if (getPcdDataCount(seqModuleSa
) == 1) {
543 while(cursor
.toNextSibling());
549 public void updatePcdData (String key
, String cName
, String tsGuid
, String itemType
, String maxSize
, String value
){
550 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(key
);
551 if (moduleSa
== null || moduleSa
.getPcdBuildDefinition() == null){
555 XmlCursor cursor
= moduleSa
.getPcdBuildDefinition().newCursor();
556 if (cursor
.toFirstChild()){
558 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= (PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
)cursor
.getObject();
559 if (pcdData
.getCName().equals(cName
) && pcdData
.getTokenSpaceGuidCName().equals(tsGuid
)) {
560 pcdData
.setItemType(PcdItemTypes
.Enum
.forString(itemType
));
561 if(pcdData
.getDatumType().equals("VOID*")) {
562 pcdData
.setMaxDatumSize(new Integer(maxSize
));
564 pcdData
.setValue(value
);
565 defaultPcdValue
.put(cName
+ " " + tsGuid
, value
);
569 while(cursor
.toNextSibling());
574 /**Get original Pcd info from MSA & SPD files.
575 * @param mi ModuleIdentification from which MSA & SPD come
576 * @param cName PCD cName
577 * @param sa Results: HelpText, Original item type.
580 public boolean getPcdBuildDataInfo(ModuleIdentification mi
, String cName
, String tsGuid
, String
[] sa
) throws Exception
{
583 ModuleSurfaceAreaDocument
.ModuleSurfaceArea msa
= (ModuleSurfaceAreaDocument
.ModuleSurfaceArea
)WorkspaceProfile
.getModuleXmlObject(mi
);
584 if (msa
.getPcdCoded() == null) {
588 Map
<String
, XmlObject
> m
= new HashMap
<String
, XmlObject
>();
589 m
.put("ModuleSurfaceArea", msa
);
590 SurfaceAreaQuery
.setDoc(m
);
591 PackageIdentification
[] depPkgs
= SurfaceAreaQuery
.getDependencePkg(null, mi
);
593 // First look through MSA pcd entries.
595 List
<PcdCodedDocument
.PcdCoded
.PcdEntry
> l
= msa
.getPcdCoded().getPcdEntryList();
596 ListIterator li
= l
.listIterator();
597 while(li
.hasNext()) {
598 PcdCodedDocument
.PcdCoded
.PcdEntry msaPcd
= (PcdCodedDocument
.PcdCoded
.PcdEntry
)li
.next();
599 if (!msaPcd
.getCName().equals(cName
)) {
602 if (!msaPcd
.getTokenSpaceGuidCName().equals(tsGuid
)) {
605 PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry spdPcd
= LookupPcdDeclaration(msaPcd
, depPkgs
);
606 if (spdPcd
== null) {
610 throw new PcdDeclNotFound(mi
.getName() + " " + msaPcd
.getCName());
613 // Get Pcd help text and original item type.
615 sa
[0] = spdPcd
.getHelpText() + msaPcd
.getHelpText();
616 sa
[1] = msaPcd
.getPcdItemType()+"";
630 /**Remove PCDBuildDefinition entries from ModuleSA
631 * @param moduleKey identifier of ModuleSA.
632 * @param consumer where these entries come from.
634 public void removePcdData(String moduleKey
, ModuleIdentification consumer
) {
636 ModuleSurfaceAreaDocument
.ModuleSurfaceArea msa
= (ModuleSurfaceAreaDocument
.ModuleSurfaceArea
)WorkspaceProfile
.getModuleXmlObject(consumer
);
637 if (msa
.getPcdCoded() == null) {
641 List
<PcdCodedDocument
.PcdCoded
.PcdEntry
> l
= msa
.getPcdCoded().getPcdEntryList();
642 ListIterator li
= l
.listIterator();
644 while(li
.hasNext()) {
645 PcdCodedDocument
.PcdCoded
.PcdEntry msaPcd
= (PcdCodedDocument
.PcdCoded
.PcdEntry
)li
.next();
646 ModuleSADocument
.ModuleSA moduleSA
= getModuleSA(moduleKey
);
647 if (moduleSA
.getPcdBuildDefinition() != null) {
648 XmlCursor cursor
= moduleSA
.getPcdBuildDefinition().newCursor();
649 if (cursor
.toFirstChild()) {
651 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= (PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
) cursor
653 if (msaPcd
.getCName().equals(pcdData
.getCName())
654 && msaPcd
.getTokenSpaceGuidCName().equals(pcdData
.getTokenSpaceGuidCName())) {
656 maintainDynPcdMap(pcdData
.getCName() + " " + pcdData
.getTokenSpaceGuidCName(),
661 } while (cursor
.toNextSibling());
674 // key for ModuleSA : "ModuleGuid ModuleVer PackageGuid PackageVer Arch"
676 public int getLibraryInstancesCount(String key
) {
677 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
678 if (msa
== null || msa
.getLibraries() == null || msa
.getLibraries().getInstanceList() == null){
681 return msa
.getLibraries().getInstanceList().size();
684 public void getLibraryInstances(String key
, String
[][] saa
){
685 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
686 if (msa
== null || msa
.getLibraries() == null || msa
.getLibraries().getInstanceList() == null){
690 ListIterator
<LibrariesDocument
.Libraries
.Instance
> li
= msa
.getLibraries().getInstanceList().listIterator();
691 for (int i
= 0; i
< saa
.length
; ++i
) {
692 LibrariesDocument
.Libraries
.Instance instance
= li
.next();
693 saa
[i
][1] = instance
.getModuleGuid();
694 saa
[i
][2] = instance
.getModuleVersion();
695 saa
[i
][3] = instance
.getPackageGuid();
696 saa
[i
][4] = instance
.getPackageVersion();
700 public void removeLibraryInstance(String key
, int i
) {
701 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
702 if (msa
== null || msa
.getLibraries() == null){
706 XmlCursor cursor
= msa
.getLibraries().newCursor();
707 if (cursor
.toFirstChild()) {
708 for (int j
= 0; j
< i
; ++j
) {
709 cursor
.toNextSibling();
712 cursor
.toPrevToken();
713 if (cursor
.isComment()) {
718 if (getLibraryInstancesCount(key
) == 0) {
727 public void genLibraryInstance(ModuleIdentification libMi
, String key
) {
728 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
730 msa
= getfpdFrameworkModules().addNewModuleSA();
732 LibrariesDocument
.Libraries libs
= msa
.getLibraries();
734 libs
= msa
.addNewLibraries();
737 String mn
= libMi
.getName();
738 String mg
= libMi
.getGuid();
739 String mv
= libMi
.getVersion();
740 String pn
= libMi
.getPackageId().getName();
741 String pg
= libMi
.getPackageId().getGuid();
742 String pv
= libMi
.getPackageId().getVersion();
743 LibrariesDocument
.Libraries
.Instance instance
= libs
.addNewInstance();
744 XmlCursor cursor
= instance
.newCursor();
746 String comment
= "Pkg: " + pn
+ " Mod: " + mn
747 + " Path: " + libMi
.getPath().substring(System
.getenv("WORKSPACE").length() + 1);
748 cursor
.insertComment(comment
);
757 instance
.setModuleGuid(mg
);
758 instance
.setModuleVersion(mv
);
759 instance
.setPackageGuid(pg
);
760 instance
.setPackageVersion(pv
);
764 public String
getFvBinding(String moduleKey
){
765 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(moduleKey
);
766 return getFvBinding (moduleSa
);
769 public String
getFvBinding (ModuleSADocument
.ModuleSA moduleSa
) {
770 if (moduleSa
== null || moduleSa
.getModuleSaBuildOptions() == null) {
773 return moduleSa
.getModuleSaBuildOptions().getFvBinding();
776 public void setFvBinding(ModuleSADocument
.ModuleSA moduleSa
, String fvBinding
) {
777 if (moduleSa
== null ) {
780 if (fvBinding
== null || fvBinding
.length() == 0) {
781 if(moduleSa
.getModuleSaBuildOptions() != null){
782 moduleSa
.getModuleSaBuildOptions().unsetFvBinding();
786 if(moduleSa
.getModuleSaBuildOptions() == null){
787 moduleSa
.addNewModuleSaBuildOptions().setFvBinding(fvBinding
);
790 moduleSa
.getModuleSaBuildOptions().setFvBinding(fvBinding
);
794 public void setFvBinding(String moduleKey
, String fvBinding
){
795 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(moduleKey
);
796 setFvBinding (moduleSa
, fvBinding
);
799 private int fvBindingForModuleSA (ModuleSADocument
.ModuleSA moduleSa
, String fvName
) {
800 if (moduleSa
== null || moduleSa
.getModuleSaBuildOptions() == null || moduleSa
.getModuleSaBuildOptions().getFvBinding() == null) {
804 String fvNameList
= moduleSa
.getModuleSaBuildOptions().getFvBinding();
805 String
[] fvNamesArray
= fvNameList
.split(" ");
807 for (int i
= 0; i
< fvNamesArray
.length
; ++i
) {
808 if (fvNamesArray
[i
].equals(fvName
)) {
816 public void removeFvBinding (ModuleSADocument
.ModuleSA moduleSa
, String fvName
) {
817 if (moduleSa
== null || moduleSa
.getModuleSaBuildOptions() == null || moduleSa
.getModuleSaBuildOptions().getFvBinding() == null) {
821 String fvNameList
= moduleSa
.getModuleSaBuildOptions().getFvBinding();
822 String
[] fvNamesArray
= fvNameList
.split(" ");
824 for (int i
= 0; i
< fvNamesArray
.length
; ++i
) {
825 if (fvNamesArray
[i
].equals(fvName
)) {
830 // jump over where the input fvName occurs in the original Fv list.
831 if (occursAt
!= -1) {
832 String newFvNameList
= " ";
833 for (int i
= 0; i
< fvNamesArray
.length
; ++i
) {
837 newFvNameList
+= fvNamesArray
[i
];
839 setFvBinding (moduleSa
, newFvNameList
.trim());
845 * @param fvName The FV name that to be removed from FvBinding List.
847 public void removeFvBindingAll (String fvName
) {
848 if (getfpdFrameworkModules().getModuleSAList() == null || getfpdFrameworkModules().getModuleSAList().size() == 0){
849 removeElement(getfpdFrameworkModules());
850 fpdFrameworkModules
= null;
854 Iterator
<ModuleSADocument
.ModuleSA
> li
= getfpdFrameworkModules().getModuleSAList().iterator();
855 while (li
.hasNext()) {
856 ModuleSADocument
.ModuleSA moduleSa
= li
.next();
857 removeFvBinding (moduleSa
, fvName
);
861 public void appendFvBindingAll (String fvName
) {
862 if (getfpdFrameworkModules().getModuleSAList() == null || getfpdFrameworkModules().getModuleSAList().size() == 0){
863 removeElement(getfpdFrameworkModules());
864 fpdFrameworkModules
= null;
868 Iterator
<ModuleSADocument
.ModuleSA
> li
= getfpdFrameworkModules().getModuleSAList().iterator();
869 while (li
.hasNext()) {
870 ModuleSADocument
.ModuleSA moduleSa
= li
.next();
871 appendFvBinding (moduleSa
, fvName
);
875 public void appendFvBindingFor (String oldFvName
, String newFvName
) {
876 if (getfpdFrameworkModules().getModuleSAList() == null || getfpdFrameworkModules().getModuleSAList().size() == 0){
877 removeElement(getfpdFrameworkModules());
878 fpdFrameworkModules
= null;
882 Iterator
<ModuleSADocument
.ModuleSA
> li
= getfpdFrameworkModules().getModuleSAList().iterator();
883 while (li
.hasNext()) {
884 ModuleSADocument
.ModuleSA moduleSa
= li
.next();
885 String fvBinding
= getFvBinding (moduleSa
);
886 if (fvBinding
!= null && fvBindingForModuleSA (moduleSa
, oldFvName
) >= 0) {
887 appendFvBinding (moduleSa
, newFvName
);
892 public void appendFvBinding (String moduleKey
, String fvName
) {
893 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(moduleKey
);
894 appendFvBinding (moduleSa
, fvName
);
897 public void appendFvBinding (ModuleSADocument
.ModuleSA moduleSa
, String fvName
) {
898 if (moduleSa
== null) {
902 if (moduleSa
.getModuleSaBuildOptions() == null || moduleSa
.getModuleSaBuildOptions().getFvBinding() == null) {
903 setFvBinding(moduleSa
, fvName
);
907 String fvNameList
= moduleSa
.getModuleSaBuildOptions().getFvBinding();
908 String newFvNameList
= fvNameList
+ " " + fvName
;
909 setFvBinding (moduleSa
, newFvNameList
.trim());
912 public void updateFvBindingInModuleSA (ModuleIdentification mi
, String fvName
) {
913 Vector
<Object
> vSupArchs
= new Vector
<Object
>();
914 getPlatformDefsSupportedArchs(vSupArchs
);
915 String moduleInfo
= mi
.getGuid() + " " + mi
.getVersion() + " " + mi
.getPackageId().getGuid() + " " + mi
.getPackageId().getVersion();
916 for (int i
= 0; i
< vSupArchs
.size(); ++i
) {
917 String moduleKey
= moduleInfo
+ " " + vSupArchs
.get(i
);
918 appendFvBinding (moduleKey
, fvName
);
922 public String
getFfsFileNameGuid(String moduleKey
){
923 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(moduleKey
);
924 if (moduleSa
== null || moduleSa
.getModuleSaBuildOptions() == null) {
927 return moduleSa
.getModuleSaBuildOptions().getFfsFileNameGuid();
930 public void setFfsFileNameGuid(String moduleKey
, String fileGuid
){
931 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
935 if(msa
.getModuleSaBuildOptions() == null){
936 msa
.addNewModuleSaBuildOptions();
939 ModuleSaBuildOptionsDocument
.ModuleSaBuildOptions msaBuildOpts
= msa
.getModuleSaBuildOptions();
940 if (fileGuid
!= null) {
941 msaBuildOpts
.setFfsFileNameGuid(fileGuid
);
944 XmlCursor cursor
= msaBuildOpts
.newCursor();
945 if (cursor
.toChild(xmlNs
, "FfsFileNameGuid")) {
953 public String
getFfsFormatKey(String moduleKey
){
954 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
955 if (msa
== null || msa
.getModuleSaBuildOptions() == null) {
958 return msa
.getModuleSaBuildOptions().getFfsFormatKey();
961 public void setFfsFormatKey(String moduleKey
, String ffsKey
){
962 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
966 if(msa
.getModuleSaBuildOptions() == null){
967 msa
.addNewModuleSaBuildOptions().setFfsFormatKey(ffsKey
);
970 msa
.getModuleSaBuildOptions().setFfsFormatKey(ffsKey
);
973 public void setModuleSAForceDebug(int i
, boolean dbgEnable
) {
974 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(i
);
975 moduleSa
.setForceDebug(dbgEnable
);
978 public boolean getModuleSAForceDebug (int i
) {
979 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(i
);
980 if (moduleSa
.getForceDebug() == true) {
986 public void getModuleSAOptions(String moduleKey
, String
[][] saa
) {
987 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
988 if (msa
== null || msa
.getModuleSaBuildOptions() == null || msa
.getModuleSaBuildOptions().getOptions() == null
989 || msa
.getModuleSaBuildOptions().getOptions().getOptionList() == null) {
993 List
<OptionDocument
.Option
> lOpt
= msa
.getModuleSaBuildOptions().getOptions().getOptionList();
994 ListIterator li
= lOpt
.listIterator();
996 while(li
.hasNext()) {
997 OptionDocument
.Option opt
= (OptionDocument
.Option
)li
.next();
998 if (opt
.getBuildTargets() != null) {
999 saa
[i
][0] = listToString(opt
.getBuildTargets());
1001 saa
[i
][1] = opt
.getToolChainFamily();
1002 saa
[i
][2] = opt
.getTagName();
1003 saa
[i
][3] = opt
.getToolCode();
1005 if (opt
.getSupArchList() != null){
1006 saa
[i
][4] = listToString(opt
.getSupArchList());
1012 saa
[i
][5] = opt
.getStringValue();
1018 public int getModuleSAOptionsCount(String moduleKey
){
1019 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
1020 if (msa
== null || msa
.getModuleSaBuildOptions() == null || msa
.getModuleSaBuildOptions().getOptions() == null
1021 || msa
.getModuleSaBuildOptions().getOptions().getOptionList() == null) {
1024 return msa
.getModuleSaBuildOptions().getOptions().getOptionList().size();
1027 public void genModuleSAOptionsOpt(String moduleKey
, Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
) {
1028 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
1029 if (msa
.getModuleSaBuildOptions() == null) {
1030 msa
.addNewModuleSaBuildOptions();
1032 if (msa
.getModuleSaBuildOptions().getOptions() == null){
1033 msa
.getModuleSaBuildOptions().addNewOptions();
1035 OptionDocument
.Option opt
= msa
.getModuleSaBuildOptions().getOptions().addNewOption();
1036 setBuildOptionsOpt(buildTargets
, toolChain
, tagName
, toolCmd
, archList
, contents
, opt
);
1039 public void removeModuleSAOptionsOpt(String moduleKey
, int i
) {
1040 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
1041 if (msa
.getModuleSaBuildOptions() == null || msa
.getModuleSaBuildOptions().getOptions() == null) {
1044 OptionsDocument
.Options opts
= msa
.getModuleSaBuildOptions().getOptions();
1045 XmlCursor cursor
= opts
.newCursor();
1046 if (cursor
.toFirstChild()) {
1047 for (int j
= 0; j
< i
; ++j
){
1048 cursor
.toNextSibling();
1055 public void updateModuleSAOptionsOpt(String moduleKey
, int i
, Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
) {
1056 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
1057 if (msa
.getModuleSaBuildOptions() == null || msa
.getModuleSaBuildOptions().getOptions() == null) {
1060 OptionsDocument
.Options opts
= msa
.getModuleSaBuildOptions().getOptions();
1061 XmlCursor cursor
= opts
.newCursor();
1062 if (cursor
.toFirstChild()) {
1063 for (int j
= 0; j
< i
; ++j
){
1064 cursor
.toNextSibling();
1066 OptionDocument
.Option opt
= (OptionDocument
.Option
)cursor
.getObject();
1067 setBuildOptionsOpt(buildTargets
, toolChain
, tagName
, toolCmd
, archList
, contents
, opt
);
1072 /**add pcd information of module mi to a ModuleSA.
1074 * @param moduleSa if null, generate a new ModuleSA.
1076 public void addFrameworkModulesPcdBuildDefs(ModuleIdentification mi
, String arch
, ModuleSADocument
.ModuleSA moduleSa
) throws Exception
{
1077 //ToDo add Arch filter
1080 if (moduleSa
== null) {
1081 moduleSa
= genModuleSA(mi
, arch
);
1084 ModuleSurfaceAreaDocument
.ModuleSurfaceArea msa
= (ModuleSurfaceAreaDocument
.ModuleSurfaceArea
)WorkspaceProfile
.getModuleXmlObject(mi
);
1085 if (msa
.getPcdCoded() == null) {
1089 Map
<String
, XmlObject
> m
= new HashMap
<String
, XmlObject
>();
1090 m
.put("ModuleSurfaceArea", msa
);
1091 SurfaceAreaQuery
.setDoc(m
);
1092 PackageIdentification
[] depPkgs
= SurfaceAreaQuery
.getDependencePkg(null, mi
);
1094 // Implementing InitializePlatformPcdBuildDefinitions
1096 List
<PcdCodedDocument
.PcdCoded
.PcdEntry
> l
= msa
.getPcdCoded().getPcdEntryList();
1097 ListIterator li
= l
.listIterator();
1098 while(li
.hasNext()) {
1099 PcdCodedDocument
.PcdCoded
.PcdEntry msaPcd
= (PcdCodedDocument
.PcdCoded
.PcdEntry
)li
.next();
1100 PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry spdPcd
= LookupPcdDeclaration(msaPcd
, depPkgs
);
1101 if (spdPcd
== null) {
1105 throw new PcdDeclNotFound("No Declaration for PCD Entry " + msaPcd
.getCName() + " in Module " + mi
.getName());
1108 // AddItem to ModuleSA PcdBuildDefinitions
1110 String defaultVal
= msaPcd
.getDefaultValue() == null ? spdPcd
.getDefaultValue() : msaPcd
.getDefaultValue();
1112 genPcdData(msaPcd
.getCName(), spdPcd
.getToken(), msaPcd
.getTokenSpaceGuidCName(), msaPcd
.getPcdItemType().toString(), spdPcd
.getDatumType()+"", defaultVal
, moduleSa
);
1116 catch (Exception e
){
1123 private PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry
LookupPcdDeclaration (PcdCodedDocument
.PcdCoded
.PcdEntry msaPcd
, PackageIdentification
[] depPkgs
) {
1125 PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry spdPcd
= null;
1126 for (int i
= 0; i
< depPkgs
.length
; ++i
) {
1128 XmlObject
[] xo
= SurfaceAreaQuery
.getSpdPcdDeclarations(depPkgs
[i
]);
1132 for (int j
= 0; j
< xo
.length
; ++j
) {
1133 spdPcd
= (PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry
)xo
[j
];
1134 if (msaPcd
.getTokenSpaceGuidCName() == null) {
1135 if (spdPcd
.getCName().equals(msaPcd
.getCName())) {
1140 if (spdPcd
.getCName().equals(msaPcd
.getCName()) && spdPcd
.getTokenSpaceGuidCName().equals(msaPcd
.getTokenSpaceGuidCName())) {
1151 private ModuleSADocument
.ModuleSA
genModuleSA (ModuleIdentification mi
, String arch
) {
1152 PackageIdentification pi
= WorkspaceProfile
.getPackageForModule(mi
);
1153 ModuleSADocument
.ModuleSA msa
= getfpdFrameworkModules().addNewModuleSA();
1154 XmlCursor cursor
= msa
.newCursor();
1156 String comment
= "Mod: " + mi
.getName() + " Type: " + SurfaceAreaQuery
.getModuleType(mi
) + " Path: "
1157 + mi
.getPath().substring(System
.getenv("WORKSPACE").length() + 1);
1158 cursor
.insertComment(comment
);
1161 e
.printStackTrace();
1166 msa
.setModuleGuid(mi
.getGuid());
1167 msa
.setModuleVersion(mi
.getVersion());
1168 msa
.setPackageGuid(pi
.getGuid());
1169 msa
.setPackageVersion(pi
.getVersion());
1171 Vector
<String
> v
= new Vector
<String
>();
1173 msa
.setSupArchList(v
);
1179 private void genPcdData (String cName
, Object token
, String tsGuid
, String itemType
, String dataType
, String defaultVal
, ModuleSADocument
.ModuleSA moduleSa
)
1180 throws PcdItemTypeConflictException
, PcdValueMalFormed
{
1181 if (moduleSa
.getPcdBuildDefinition() == null){
1182 moduleSa
.addNewPcdBuildDefinition();
1185 // constructe pcd to modulesa mapping first.
1186 // Attention : for any error condition, remove from map this pcd.
1188 ArrayList
<String
> pcdConsumer
= LookupPlatformPcdData(cName
+ " " + tsGuid
);
1189 if (pcdConsumer
== null) {
1190 pcdConsumer
= new ArrayList
<String
>();
1193 // Using existing Pcd type, if this pcd already exists in other ModuleSA
1195 if (pcdConsumer
.size() > 0) {
1196 String
[] valPart
= pcdConsumer
.get(0).split(" ");
1197 itemType
= valPart
[5];
1199 String listValue
= moduleSa
.getModuleGuid() + " " + moduleSa
.getModuleVersion()
1200 + " " + moduleSa
.getPackageGuid() + " " + moduleSa
.getPackageVersion() + " " + listToString(moduleSa
.getSupArchList())
1202 pcdConsumer
.add(listValue
);
1203 dynPcdMap
.put(cName
+ " " + tsGuid
, pcdConsumer
);
1205 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData fpdPcd
= moduleSa
.getPcdBuildDefinition().addNewPcdData();
1206 fpdPcd
.setCName(cName
);
1207 fpdPcd
.setToken(token
);
1208 fpdPcd
.setTokenSpaceGuidCName(tsGuid
);
1209 fpdPcd
.setDatumType(PcdDataTypes
.Enum
.forString(dataType
));
1210 fpdPcd
.setItemType(PcdItemTypes
.Enum
.forString(itemType
));
1212 if (defaultVal
!= null){
1213 fpdPcd
.setValue(defaultVal
);
1216 if (dataType
.equals("UINT8") || dataType
.equals("UINT16") || dataType
.equals("UINT32") || dataType
.equals("UINT64")) {
1217 fpdPcd
.setValue("0");
1219 if (dataType
.equals("BOOLEAN")){
1220 fpdPcd
.setValue("FALSE");
1222 if (dataType
.equals("VOID*")) {
1223 fpdPcd
.setValue("");
1227 // Using existing pcd value, if this pcd already exists in other moduleSa.
1229 if (defaultPcdValue
.get(cName
+ " " + tsGuid
) == null) {
1230 defaultPcdValue
.put(cName
+ " " + tsGuid
, fpdPcd
.getValue());
1233 fpdPcd
.setValue(defaultPcdValue
.get(cName
+ " " + tsGuid
));
1236 if (dataType
.equals("UINT8")){
1237 fpdPcd
.setMaxDatumSize(1);
1239 if (dataType
.equals("UINT16")) {
1240 fpdPcd
.setMaxDatumSize(2);
1242 if (dataType
.equals("UINT32")) {
1243 fpdPcd
.setMaxDatumSize(4);
1245 if (dataType
.equals("UINT64")){
1246 fpdPcd
.setMaxDatumSize(8);
1248 if (dataType
.equals("BOOLEAN")){
1249 fpdPcd
.setMaxDatumSize(1);
1251 if (dataType
.equals("VOID*")) {
1252 int maxSize
= setMaxSizeForPointer(fpdPcd
.getValue());
1253 fpdPcd
.setMaxDatumSize(maxSize
);
1257 if (itemType
.equals("DYNAMIC") || itemType
.equals("DYNAMIC_EX")) {
1258 ArrayList
<String
> al
= LookupDynamicPcdBuildDefinition(cName
+ " " + tsGuid
);
1260 // if only one module mapped to this pcd, then the one is myself. so no other module mapped.
1261 // so need to add one dyn pcd.
1263 if (al
.size() == 1) {
1264 addDynamicPcdBuildData(cName
, token
, tsGuid
, itemType
, dataType
, defaultVal
);
1270 public int setMaxSizeForPointer(String datum
) throws PcdValueMalFormed
{
1271 if (datum
== null) {
1274 char ch
= datum
.charAt(0);
1278 // For void* type PCD, only three datum is support:
1279 // 1) Unicode: string with start char is "L"
1280 // 2) Ansci: String is ""
1281 // 3) byte array: String start char "{"
1284 start
= datum
.indexOf('\"');
1285 end
= datum
.lastIndexOf('\"');
1286 if ((start
> end
) ||
1287 (end
> datum
.length())||
1288 ((start
== end
) && (datum
.length() > 0))) {
1289 //ToDo Error handling here
1290 throw new PcdValueMalFormed (datum
);
1293 strValue
= datum
.substring(start
+ 1, end
);
1294 return strValue
.length() * 2;
1295 } else if (ch
== '\"'){
1296 start
= datum
.indexOf('\"');
1297 end
= datum
.lastIndexOf('\"');
1298 if ((start
> end
) ||
1299 (end
> datum
.length())||
1300 ((start
== end
) && (datum
.length() > 0))) {
1301 throw new PcdValueMalFormed (datum
);
1303 strValue
= datum
.substring(start
+ 1, end
);
1304 return strValue
.length();
1305 } else if (ch
=='{') {
1306 String
[] strValueArray
;
1308 start
= datum
.indexOf('{');
1309 end
= datum
.lastIndexOf('}');
1310 strValue
= datum
.substring(start
+ 1, end
);
1311 strValue
= strValue
.trim();
1312 if (strValue
.length() == 0) {
1315 strValueArray
= strValue
.split(",");
1316 for (int index
= 0; index
< strValueArray
.length
; index
++) {
1317 Integer value
= Integer
.decode(strValueArray
[index
].trim());
1320 // "[FPD file error] The datum type of PCD %s in %s is VOID*, "+
1321 // "it must be a byte array. But the element of %s exceed the byte range",
1322 throw new PcdValueMalFormed (datum
);
1325 return strValueArray
.length
;
1329 // "[FPD file error] The datum type of PCD %s in %s is VOID*. For VOID* type, you have three format choise:\n "+
1330 // "1) UNICODE string: like L\"xxxx\";\r\n"+
1331 // "2) ANSIC string: like \"xxx\";\r\n"+
1332 // "3) Byte array: like {0x2, 0x45, 0x23}\r\n"+
1333 // "but the datum in seems does not following above format!",
1334 throw new PcdValueMalFormed (datum
);
1339 private ArrayList
<String
> LookupDynamicPcdBuildDefinition(String dynPcdKey
) {
1340 ArrayList
<String
> al
= dynPcdMap
.get(dynPcdKey
);
1345 private ArrayList
<String
> LookupPlatformPcdData(String pcdKey
) {
1347 return dynPcdMap
.get(pcdKey
);
1350 public int getDynamicPcdBuildDataCount() {
1351 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1352 removeElement(getfpdDynPcdBuildDefs());
1353 fpdDynPcdBuildDefs
= null;
1356 return getfpdDynPcdBuildDefs().getPcdBuildDataList().size();
1359 public void getDynamicPcdBuildData(String
[][] saa
) {
1360 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1361 removeElement(getfpdDynPcdBuildDefs());
1362 fpdDynPcdBuildDefs
= null;
1365 List
<DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
> l
= getfpdDynPcdBuildDefs().getPcdBuildDataList();
1366 ListIterator
<DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
> li
= l
.listIterator();
1368 while(li
.hasNext()) {
1369 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData dynPcd
= li
.next();
1370 saa
[i
][0] = dynPcd
.getCName();
1371 saa
[i
][1] = dynPcd
.getToken().toString();
1372 saa
[i
][2] = dynPcd
.getTokenSpaceGuidCName();
1373 saa
[i
][3] = dynPcd
.getMaxDatumSize()+"";
1374 saa
[i
][4] = dynPcd
.getDatumType().toString();
1380 public void addDynamicPcdBuildData(String cName
, Object token
, String tsGuid
, String itemType
, String dataType
, String defaultVal
)
1381 throws PcdValueMalFormed
{
1382 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData dynPcdData
= getfpdDynPcdBuildDefs().addNewPcdBuildData();
1383 dynPcdData
.setItemType(PcdItemTypes
.Enum
.forString(itemType
));
1384 dynPcdData
.setCName(cName
);
1385 dynPcdData
.setToken(token
);
1386 dynPcdData
.setTokenSpaceGuidCName(tsGuid
);
1387 dynPcdData
.setDatumType(PcdDataTypes
.Enum
.forString(dataType
));
1389 BigInteger bigInt
= new BigInteger("0");
1390 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo skuInfo
= dynPcdData
.addNewSkuInfo();
1391 skuInfo
.setSkuId(bigInt
);
1392 if (defaultVal
!= null){
1393 skuInfo
.setValue(defaultVal
);
1396 if (dataType
.equals("UINT8")){
1397 skuInfo
.setValue("0");
1399 if (dataType
.equals("UINT16")) {
1400 skuInfo
.setValue("0");
1402 if (dataType
.equals("UINT32")) {
1403 skuInfo
.setValue("0");
1405 if (dataType
.equals("UINT64")){
1406 skuInfo
.setValue("0");
1408 if (dataType
.equals("BOOLEAN")){
1409 skuInfo
.setValue("false");
1411 if (dataType
.equals("VOID*")) {
1412 skuInfo
.setValue("");
1415 if (dataType
.equals("UINT8")){
1416 dynPcdData
.setMaxDatumSize(1);
1418 if (dataType
.equals("UINT16")) {
1419 dynPcdData
.setMaxDatumSize(2);
1421 if (dataType
.equals("UINT32")) {
1422 dynPcdData
.setMaxDatumSize(4);
1424 if (dataType
.equals("UINT64")){
1425 dynPcdData
.setMaxDatumSize(8);
1427 if (dataType
.equals("BOOLEAN")){
1428 dynPcdData
.setMaxDatumSize(1);
1430 if (dataType
.equals("VOID*")) {
1431 int maxSize
= setMaxSizeForPointer(defaultVal
);
1432 dynPcdData
.setMaxDatumSize(maxSize
);
1436 public void removeDynamicPcdBuildData(String cName
, String tsGuid
) {
1437 XmlObject o
= fpdRoot
.getDynamicPcdBuildDefinitions();
1442 XmlCursor cursor
= o
.newCursor();
1443 if (cursor
.toFirstChild()) {
1445 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdBuildData
=
1446 (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1447 if (pcdBuildData
.getCName().equals(cName
) && pcdBuildData
.getTokenSpaceGuidCName().equals(tsGuid
)) {
1449 if (getDynamicPcdBuildDataCount() == 1) {
1457 while (cursor
.toNextSibling());
1462 // Get the Sku Info count of ith dyn pcd element.
1464 public int getDynamicPcdSkuInfoCount(int i
){
1465 if (fpdRoot
.getDynamicPcdBuildDefinitions() == null || fpdRoot
.getDynamicPcdBuildDefinitions().getPcdBuildDataList() == null
1466 || fpdRoot
.getDynamicPcdBuildDefinitions().getPcdBuildDataList().size() == 0) {
1470 int skuInfoCount
= 0;
1471 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1472 if (cursor
.toFirstChild()) {
1473 for (int j
= 0; j
< i
; ++j
) {
1474 cursor
.toNextSibling();
1476 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1477 if (pcdData
.getSkuInfoList() == null) {
1481 skuInfoCount
= pcdData
.getSkuInfoList().size();
1485 return skuInfoCount
;
1488 public void getDynamicPcdSkuInfos(int i
, String
[][] saa
){
1489 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1490 removeElement(getfpdDynPcdBuildDefs());
1491 fpdDynPcdBuildDefs
= null;
1495 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1496 if (cursor
.toFirstChild()) {
1497 for (int j
= 0; j
< i
; ++j
) {
1498 cursor
.toNextSibling();
1500 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1501 if (pcdData
.getSkuInfoList() == null) {
1506 ListIterator
<DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo
> li
= pcdData
.getSkuInfoList().listIterator();
1508 while (li
.hasNext()) {
1509 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo skuInfo
= li
.next();
1510 saa
[k
][0] = skuInfo
.getSkuId()+"";
1511 saa
[k
][1] = skuInfo
.getVariableName();
1512 saa
[k
][2] = skuInfo
.getVariableGuid();
1513 saa
[k
][3] = skuInfo
.getVariableOffset();
1514 saa
[k
][4] = skuInfo
.getHiiDefaultValue();
1515 saa
[k
][5] = skuInfo
.getVpdOffset();
1516 saa
[k
][6] = skuInfo
.getValue();
1526 public String
getDynamicPcdBuildDataValue(int i
){
1527 String value
= null;
1528 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1529 removeElement(getfpdDynPcdBuildDefs());
1530 fpdDynPcdBuildDefs
= null;
1534 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1535 if (cursor
.toFirstChild()) {
1536 for (int j
= 0; j
< i
; ++j
) {
1537 cursor
.toNextSibling();
1539 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1540 if (pcdData
.getSkuInfoList() == null) {
1544 value
= pcdData
.getSkuInfoArray(0).getValue();
1551 public String
getDynamicPcdBuildDataVpdOffset(int i
){
1552 String vpdOffset
= null;
1553 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1554 removeElement(getfpdDynPcdBuildDefs());
1555 fpdDynPcdBuildDefs
= null;
1559 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1560 if (cursor
.toFirstChild()) {
1561 for (int j
= 0; j
< i
; ++j
) {
1562 cursor
.toNextSibling();
1564 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1565 if (pcdData
.getSkuInfoList() == null) {
1569 vpdOffset
= pcdData
.getSkuInfoArray(0).getVpdOffset();
1576 public void removeDynamicPcdBuildDataSkuInfo(int i
) {
1577 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1578 removeElement(getfpdDynPcdBuildDefs());
1579 fpdDynPcdBuildDefs
= null;
1583 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1584 if (cursor
.toFirstChild()) {
1585 for (int j
= 0; j
< i
; ++j
) {
1586 cursor
.toNextSibling();
1588 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1589 if (pcdData
.getSkuInfoList() == null) {
1594 QName qSkuInfo
= new QName(xmlNs
, "SkuInfo");
1595 cursor
.toChild(qSkuInfo
);
1602 // generate sku info for ith dyn pcd build data.
1604 public void genDynamicPcdBuildDataSkuInfo(String id
, String varName
, String varGuid
, String varOffset
,
1605 String hiiDefault
, String vpdOffset
, String value
, int i
) {
1606 // if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1610 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1611 if (cursor
.toFirstChild()) {
1612 for (int j
= 0; j
< i
; ++j
) {
1613 cursor
.toNextSibling();
1615 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1616 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo skuInfo
= pcdData
.addNewSkuInfo();
1617 skuInfo
.setSkuId(new BigInteger(id
));
1618 if (varName
!= null){
1619 skuInfo
.setVariableName(varName
);
1620 skuInfo
.setVariableGuid(varGuid
);
1621 skuInfo
.setVariableOffset(varOffset
);
1622 skuInfo
.setHiiDefaultValue(hiiDefault
);
1624 else if (vpdOffset
!= null){
1625 skuInfo
.setVpdOffset(vpdOffset
);
1628 skuInfo
.setValue(value
);
1633 public void updateDynamicPcdBuildDataSkuInfo(String id
, String varName
, String varGuid
, String varOffset
,
1634 String hiiDefault
, String vpdOffset
, String value
, int i
){
1635 // if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1639 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1640 if (cursor
.toFirstChild()) {
1641 for (int j
= 0; j
< i
; ++j
) {
1642 cursor
.toNextSibling();
1644 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1645 ListIterator
<DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo
> li
= pcdData
.getSkuInfoList().listIterator();
1646 while (li
.hasNext()) {
1647 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo skuInfo
= li
.next();
1648 if (skuInfo
.getSkuId().toString().equals(id
)){
1649 if (varName
!= null){
1650 skuInfo
.setVariableName(varName
);
1651 skuInfo
.setVariableGuid(varGuid
);
1652 skuInfo
.setVariableOffset(varOffset
);
1653 skuInfo
.setHiiDefaultValue(hiiDefault
);
1655 else if (vpdOffset
!= null){
1656 skuInfo
.setVpdOffset(vpdOffset
);
1659 skuInfo
.setValue(value
);
1667 public BuildOptionsDocument
.BuildOptions
getfpdBuildOpts() {
1668 if (fpdBuildOpts
== null) {
1669 fpdBuildOpts
= fpdRoot
.addNewBuildOptions();
1671 return fpdBuildOpts
;
1674 public void genBuildOptionsUserExtensions(String fvName
, String outputFileName
, Vector
<String
[]> includeModules
) {
1675 QName elementFvName
= new QName (xmlNs
, "FvName");
1676 QName elementIncludeModules
= new QName(xmlNs
, "IncludeModules");
1677 QName elementInfFileName
= new QName(xmlNs
, "InfFileName");
1678 QName elementModule
= new QName(xmlNs
, "Module");
1680 UserExtensionsDocument
.UserExtensions userExts
= getfpdBuildOpts().addNewUserExtensions();
1681 userExts
.setUserID("IMAGES");
1682 userExts
.setIdentifier(new BigInteger("1"));
1683 XmlCursor cursor
= userExts
.newCursor();
1684 cursor
.toEndToken();
1686 cursor
.beginElement(elementFvName
);
1687 cursor
.insertChars(fvName
);
1688 cursor
.toNextToken();
1690 cursor
.beginElement(elementInfFileName
);
1691 cursor
.insertChars(fvName
+ ".inf");
1692 cursor
.toNextToken();
1694 cursor
.beginElement(elementIncludeModules
);
1695 for (int i
= 0; i
< includeModules
.size(); ++i
) {
1696 cursor
.beginElement(elementModule
);
1697 cursor
.insertAttributeWithValue("ModuleGuid", includeModules
.get(i
)[0]);
1698 cursor
.insertAttributeWithValue("BaseName", includeModules
.get(i
)[1]);
1699 cursor
.toEndToken();
1700 cursor
.toNextToken();
1705 public int getUserExtsIncModCount (String fvName
) {
1706 if (getfpdBuildOpts().getUserExtensionsList() == null) {
1709 ListIterator
<UserExtensionsDocument
.UserExtensions
> li
= getfpdBuildOpts().getUserExtensionsList().listIterator();
1710 QName elementIncludeModules
= new QName(xmlNs
, "IncludeModules");
1711 while (li
.hasNext()) {
1712 UserExtensionsDocument
.UserExtensions ues
= li
.next();
1713 if (!ues
.getUserID().equals("IMAGES")) {
1716 XmlCursor cursor
= ues
.newCursor();
1717 cursor
.toFirstChild();
1718 String elementName
= cursor
.getTextValue();
1719 if (elementName
.equals(fvName
)) {
1720 cursor
.toNextSibling(elementIncludeModules
);
1721 if (cursor
.toFirstChild()) {
1723 for (i
= 1; cursor
.toNextSibling(); ++i
);
1735 public void getUserExtsIncMods(String fvName
, String
[][] saa
) {
1736 if (getfpdBuildOpts().getUserExtensionsList() == null) {
1740 XmlCursor cursor
= getfpdBuildOpts().newCursor();
1741 QName elementUserExts
= new QName (xmlNs
, "UserExtensions");
1742 QName attribUserId
= new QName ("UserID");
1743 QName elementFvName
= new QName (xmlNs
, "FvName");
1744 QName elementIncludeModules
= new QName(xmlNs
, "IncludeModules");
1745 QName attribModuleGuid
= new QName("ModuleGuid");
1746 QName attribBaseName
= new QName("BaseName");
1748 if (cursor
.toChild(elementUserExts
)) {
1751 if (cursor
.getAttributeText(attribUserId
).equals("IMAGES")) {
1752 cursor
.toChild(elementFvName
);
1753 String elementName
= cursor
.getTextValue();
1754 if (elementName
.equals(fvName
)) {
1755 cursor
.toNextSibling(elementIncludeModules
);
1756 if (cursor
.toFirstChild()) {
1759 saa
[i
][0] = cursor
.getAttributeText(attribModuleGuid
);
1760 saa
[i
][1] = cursor
.getAttributeText(attribBaseName
);
1762 }while (cursor
.toNextSibling());
1768 }while (cursor
.toNextSibling(elementUserExts
));
1774 public void updateBuildOptionsUserExtensions (String oldFvName
, String newFvName
) {
1775 if (getfpdBuildOpts().getUserExtensionsList() == null) {
1778 ListIterator
<UserExtensionsDocument
.UserExtensions
> li
= getfpdBuildOpts().getUserExtensionsList().listIterator();
1779 while (li
.hasNext()) {
1780 UserExtensionsDocument
.UserExtensions ues
= li
.next();
1781 if (!ues
.getUserID().equals("IMAGES")) {
1784 XmlCursor cursor
= ues
.newCursor();
1785 cursor
.toFirstChild();
1786 String elementName
= cursor
.getTextValue();
1787 if (elementName
.equals(oldFvName
)) {
1788 cursor
.setTextValue(newFvName
);
1795 public void removeBuildOptionsUserExtensions (String fvName
) {
1796 if (getfpdBuildOpts().getUserExtensionsList() == null) {
1800 ListIterator
<UserExtensionsDocument
.UserExtensions
> li
= getfpdBuildOpts().getUserExtensionsList().listIterator();
1801 while (li
.hasNext()) {
1802 UserExtensionsDocument
.UserExtensions ues
= li
.next();
1803 if (!ues
.getUserID().equals("IMAGES")) {
1806 XmlCursor cursor
= ues
.newCursor();
1807 cursor
.toFirstChild();
1808 String elementName
= cursor
.getTextValue();
1809 if (elementName
.equals(fvName
)) {
1821 public void genBuildOptionsUserDefAntTask (String id
, String fileName
, String execOrder
) {
1822 UserDefinedAntTasksDocument
.UserDefinedAntTasks udats
= getfpdBuildOpts().getUserDefinedAntTasks();
1823 if (udats
== null) {
1824 udats
= getfpdBuildOpts().addNewUserDefinedAntTasks();
1827 AntTaskDocument
.AntTask at
= udats
.addNewAntTask();
1828 setBuildOptionsUserDefAntTask(id
, fileName
, execOrder
, at
);
1831 private void setBuildOptionsUserDefAntTask(String id
, String fileName
, String execOrder
, AntTaskDocument
.AntTask at
) {
1832 at
.setId(new Integer(id
));
1833 XmlCursor cursor
= at
.newCursor();
1834 if (fileName
!= null){
1835 at
.setFilename(fileName
);
1837 else if (cursor
.toChild(xmlNs
, "Filename")) {
1840 if (execOrder
!= null) {
1841 at
.setAntCmdOptions(execOrder
);
1843 else if (cursor
.toChild(xmlNs
, "AntCmdOptions")) {
1849 public void removeBuildOptionsUserDefAntTask(int i
) {
1850 XmlObject o
= getfpdBuildOpts().getUserDefinedAntTasks();
1854 XmlCursor cursor
= o
.newCursor();
1855 if (cursor
.toFirstChild()) {
1856 for (int j
= 0; j
< i
; ++j
) {
1857 cursor
.toNextSibling();
1860 if (getBuildOptionsUserDefAntTaskCount() == 0) {
1868 public void updateBuildOptionsUserDefAntTask(int i
, String id
, String fileName
, String execOrder
){
1869 XmlObject o
= getfpdBuildOpts().getUserDefinedAntTasks();
1873 XmlCursor cursor
= o
.newCursor();
1874 if (cursor
.toFirstChild()) {
1875 for (int j
= 0; j
< i
; ++j
) {
1876 cursor
.toNextSibling();
1878 AntTaskDocument
.AntTask at
= (AntTaskDocument
.AntTask
)cursor
.getObject();
1879 setBuildOptionsUserDefAntTask(id
, fileName
, execOrder
, at
);
1884 public int getBuildOptionsUserDefAntTaskCount() {
1885 UserDefinedAntTasksDocument
.UserDefinedAntTasks udats
= getfpdBuildOpts().getUserDefinedAntTasks();
1886 if (udats
== null || udats
.getAntTaskList() == null) {
1890 return udats
.getAntTaskList().size();
1893 public void getBuildOptionsUserDefAntTasks(String
[][] saa
) {
1894 UserDefinedAntTasksDocument
.UserDefinedAntTasks udats
= getfpdBuildOpts().getUserDefinedAntTasks();
1895 if (udats
== null || udats
.getAntTaskList() == null) {
1899 List
<AntTaskDocument
.AntTask
> l
= udats
.getAntTaskList();
1900 ListIterator li
= l
.listIterator();
1902 while (li
.hasNext()) {
1903 AntTaskDocument
.AntTask at
= (AntTaskDocument
.AntTask
)li
.next();
1904 saa
[i
][0] = at
.getId() + "";
1905 saa
[i
][1] = saa
[i
][2] = "";
1906 if (at
.getFilename() != null){
1907 saa
[i
][1] = at
.getFilename();
1909 if (at
.getAntCmdOptions() != null) {
1910 saa
[i
][2] = at
.getAntCmdOptions();
1915 public void genBuildOptionsOpt(Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
) {
1916 OptionsDocument
.Options opts
= getfpdBuildOpts().getOptions();
1918 opts
= getfpdBuildOpts().addNewOptions();
1920 OptionDocument
.Option opt
= opts
.addNewOption();
1921 setBuildOptionsOpt(buildTargets
, toolChain
, tagName
, toolCmd
, archList
, contents
, opt
);
1924 private void setBuildOptionsOpt(Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
, OptionDocument
.Option opt
){
1925 opt
.setStringValue(contents
);
1927 opt
.setBuildTargets(buildTargets
);
1928 opt
.setToolChainFamily(toolChain
);
1929 opt
.setTagName(tagName
);
1930 opt
.setToolCode(toolCmd
);
1932 if (archList
!= null) {
1933 opt
.setSupArchList(archList
);
1936 if (opt
.isSetSupArchList()) {
1937 opt
.unsetSupArchList();
1942 public void removeBuildOptionsOpt(int i
){
1944 XmlObject o
= getfpdBuildOpts().getOptions();
1949 XmlCursor cursor
= o
.newCursor();
1950 if (cursor
.toFirstChild()) {
1951 for (int j
= 0; j
< i
; ++j
) {
1952 cursor
.toNextSibling();
1955 if (getBuildOptionsOptCount() == 0) {
1963 public void updateBuildOptionsOpt(int i
, Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
) {
1964 XmlObject o
= getfpdBuildOpts().getOptions();
1969 XmlCursor cursor
= o
.newCursor();
1970 if (cursor
.toFirstChild()) {
1971 for (int j
= 0; j
< i
; ++j
) {
1972 cursor
.toNextSibling();
1974 OptionDocument
.Option opt
= (OptionDocument
.Option
)cursor
.getObject();
1975 setBuildOptionsOpt(buildTargets
, toolChain
, tagName
, toolCmd
, archList
, contents
, opt
);
1980 public int getBuildOptionsOptCount(){
1981 if (getfpdBuildOpts().getOptions() == null || getfpdBuildOpts().getOptions().getOptionList() == null) {
1984 return getfpdBuildOpts().getOptions().getOptionList().size();
1987 public void getBuildOptionsOpts(String
[][] saa
) {
1988 if (getfpdBuildOpts().getOptions() == null || getfpdBuildOpts().getOptions().getOptionList() == null) {
1992 List
<OptionDocument
.Option
> lOpt
= getfpdBuildOpts().getOptions().getOptionList();
1993 ListIterator li
= lOpt
.listIterator();
1995 while(li
.hasNext()) {
1996 OptionDocument
.Option opt
= (OptionDocument
.Option
)li
.next();
1997 if (opt
.getBuildTargets() != null) {
1998 saa
[i
][0] = listToString(opt
.getBuildTargets());
2000 saa
[i
][1] = opt
.getToolChainFamily();
2001 if (opt
.getSupArchList() != null){
2002 saa
[i
][2] = listToString(opt
.getSupArchList());
2005 saa
[i
][3] = opt
.getToolCode();
2006 saa
[i
][4] = opt
.getTagName();
2007 saa
[i
][5] = opt
.getStringValue();
2013 public void genBuildOptionsFfs(String ffsKey
, String type
) {
2014 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getfpdBuildOpts().addNewFfs();
2015 ffs
.setFfsKey(ffsKey
);
2017 ffs
.addNewSections().setEncapsulationType(type
);
2021 public void updateBuildOptionsFfsSectionsType(int i
, String type
) {
2022 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getfpdBuildOpts().addNewFfs();
2024 ffs
.addNewSections().setEncapsulationType(type
);
2028 public void genBuildOptionsFfsAttribute(int i
, String name
, String value
) {
2029 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2030 BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute attrib
= ffs
.addNewAttribute();
2031 attrib
.setName(name
);
2032 attrib
.setValue(value
);
2035 /**update jth attribute of ith ffs.
2039 public void updateBuildOptionsFfsAttribute(int i
, int j
, String name
, String value
){
2040 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2041 XmlCursor cursor
= ffs
.newCursor();
2042 QName qAttrib
= new QName(xmlNs
, "Attribute");
2043 if (cursor
.toChild(qAttrib
)) {
2044 for (int k
= 0; k
< j
; ++k
) {
2045 cursor
.toNextSibling(qAttrib
);
2047 BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute attrib
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute
)cursor
.getObject();
2048 attrib
.setName(name
);
2049 attrib
.setValue(value
);
2054 public void removeBuildOptionsFfsAttribute(int i
, int j
){
2055 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2056 XmlCursor cursor
= ffs
.newCursor();
2057 QName qAttrib
= new QName(xmlNs
, "Attribute");
2058 if (cursor
.toChild(qAttrib
)) {
2059 for (int k
= 0; k
< j
; ++k
) {
2060 cursor
.toNextSibling(qAttrib
);
2067 public void genBuildOptionsFfsSectionsSection(int i
, String sectionType
) {
2068 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2072 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2074 if (sections
== null){
2075 sections
= ffs
.addNewSections();
2077 sections
.addNewSection().setSectionType(EfiSectionType
.Enum
.forString(sectionType
));
2080 public void removeBuildOptionsFfsSectionsSection(int i
, int j
) {
2081 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2082 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2083 if (sections
== null) {
2086 XmlCursor cursor
= sections
.newCursor();
2087 QName qSection
= new QName(xmlNs
, "Section");
2088 if (cursor
.toChild(qSection
)) {
2089 for (int k
= 0; k
< j
; ++k
) {
2090 cursor
.toNextSibling(qSection
);
2097 public void updateBuildOptionsFfsSectionsSection(int i
, int j
, String type
){
2098 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2099 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2100 if (sections
== null) {
2103 XmlCursor cursor
= sections
.newCursor();
2104 QName qSection
= new QName(xmlNs
, "Section");
2105 if (cursor
.toChild(qSection
)) {
2106 for (int k
= 0; k
< j
; ++k
) {
2107 cursor
.toNextSibling(qSection
);
2109 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Section section
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Section
)cursor
.getObject();
2110 section
.setSectionType(EfiSectionType
.Enum
.forString(type
));
2115 public void genBuildOptionsFfsSectionsSections(int i
, String encapType
) {
2116 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2120 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2122 if (sections
== null){
2123 sections
= ffs
.addNewSections();
2125 sections
.addNewSections().setEncapsulationType(encapType
);
2128 public void removeBuildOptionsFfsSectionsSections(int i
, int j
) {
2129 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2130 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2131 if (sections
== null) {
2134 XmlCursor cursor
= sections
.newCursor();
2135 QName qSections
= new QName(xmlNs
, "Sections");
2136 if (cursor
.toChild(qSections
)) {
2137 for (int k
= 0; k
< j
; ++k
) {
2138 cursor
.toNextSibling(qSections
);
2145 public void updateBuildOptionsFfsSectionsSections(int i
, int j
, String type
) {
2146 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2147 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2148 if (sections
== null) {
2151 XmlCursor cursor
= sections
.newCursor();
2152 QName qSections
= new QName(xmlNs
, "Sections");
2153 if (cursor
.toChild(qSections
)) {
2154 for (int k
= 0; k
< j
; ++k
) {
2155 cursor
.toNextSibling(qSections
);
2157 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2 sections2
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
)cursor
.getObject();
2158 sections2
.setEncapsulationType(type
);
2163 public void genBuildOptionsFfsSectionsSectionsSection(int i
, int j
, String type
) {
2164 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2168 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2169 XmlCursor cursor
= sections
.newCursor();
2170 QName qSections
= new QName(xmlNs
, "Sections");
2171 if (cursor
.toChild(qSections
)){
2172 for (int k
= 0; k
< j
; ++k
) {
2173 cursor
.toNextSibling(qSections
);
2175 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2 sections2
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
)cursor
.getObject();
2176 sections2
.addNewSection().setSectionType(EfiSectionType
.Enum
.forString(type
));
2181 public void removeBuildOptionsFfsSectionsSectionsSection(int i
, int j
, int k
) {
2182 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2183 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2184 if (sections
== null) {
2187 XmlCursor cursor
= sections
.newCursor();
2188 QName qSections
= new QName(xmlNs
, "Sections");
2189 if (cursor
.toChild(qSections
)) {
2190 for (int l
= 0; l
< j
; ++l
) {
2191 cursor
.toNextSibling(qSections
);
2193 if (cursor
.toFirstChild()) {
2195 for (; m
< k
; ++m
) {
2196 cursor
.toNextSibling();
2208 public void updateBuildOptionsFfsSectionsSectionsSection(int i
, int j
, int k
, String type
) {
2209 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2210 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2211 if (sections
== null) {
2214 XmlCursor cursor
= sections
.newCursor();
2215 QName qSections
= new QName(xmlNs
, "Sections");
2216 if (cursor
.toChild(qSections
)) {
2217 for (int l
= 0; l
< j
; ++l
) {
2218 cursor
.toNextSibling(qSections
);
2220 if (cursor
.toFirstChild()) {
2221 for (int m
= 0; m
< k
; ++m
) {
2222 cursor
.toNextSibling();
2224 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section section
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section
)cursor
.getObject();
2225 section
.setSectionType(EfiSectionType
.Enum
.forString(type
));
2231 public void getBuildOptionsFfsSectionsSectionsSection(int i
, int j
, ArrayList
<String
> al
) {
2232 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2236 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2237 XmlCursor cursor
= sections
.newCursor();
2238 QName qSections
= new QName(xmlNs
, "Sections");
2239 if (cursor
.toChild(qSections
)){
2240 for (int k
= 0; k
< j
; ++k
) {
2241 cursor
.toNextSibling(qSections
);
2243 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2 sections2
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
)cursor
.getObject();
2244 if (sections2
.getSectionList() == null){
2248 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section
> li
= sections2
.getSectionList().listIterator();
2249 while(li
.hasNext()) {
2250 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section section
= li
.next();
2251 if (section
.isSetSectionType()) {
2252 al
.add(section
.getSectionType().toString());
2261 public int getBuildOptionsFfsCount(){
2262 if (getfpdBuildOpts().getFfsList() == null) {
2265 return getfpdBuildOpts().getFfsList().size();
2268 public void getBuildOptionsFfsKey(String
[][] saa
) {
2269 if (getfpdBuildOpts().getFfsList() == null) {
2272 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
> li
= getfpdBuildOpts().getFfsList().listIterator();
2274 while(li
.hasNext()){
2275 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= li
.next();
2276 saa
[i
][0] = ffs
.getFfsKey();
2281 public void updateBuildOptionsFfsKey(int i
, String key
) {
2282 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2286 /**Get ith FFS key and contents.
2289 public void getBuildOptionsFfs(int i
, String
[] sa
, LinkedHashMap
<String
, String
> ffsAttribMap
, ArrayList
<String
> firstLevelSections
, ArrayList
<String
> firstLevelSection
) {
2290 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2294 sa
[0] = ffs
.getFfsKey();
2295 if (ffs
.getSections() != null) {
2296 if(ffs
.getSections().getEncapsulationType() != null){
2297 sa
[1] = ffs
.getSections().getEncapsulationType();
2299 if (ffs
.getSections().getSectionList() != null){
2300 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Section
> li
= ffs
.getSections().getSectionList().listIterator();
2301 while (li
.hasNext()) {
2302 firstLevelSection
.add(li
.next().getSectionType().toString());
2305 if (ffs
.getSections().getSectionsList() != null) {
2306 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
> li
= ffs
.getSections().getSectionsList().listIterator();
2307 while(li
.hasNext()) {
2308 firstLevelSections
.add(li
.next().getEncapsulationType());
2312 if (ffs
.getAttributeList() != null) {
2313 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute
> li
= ffs
.getAttributeList().listIterator();
2314 while(li
.hasNext()) {
2315 BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute attrib
= li
.next();
2316 ffsAttribMap
.put(attrib
.getName(), attrib
.getValue());
2325 private BuildOptionsDocument
.BuildOptions
.Ffs
getFfs(int i
) {
2326 XmlObject o
= getfpdBuildOpts();
2327 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= null;
2329 XmlCursor cursor
= o
.newCursor();
2330 QName qFfs
= new QName(xmlNs
, "Ffs");
2331 if (cursor
.toChild(qFfs
)) {
2332 for (int j
= 0; j
< i
; ++j
) {
2333 cursor
.toNextSibling(qFfs
);
2335 ffs
= (BuildOptionsDocument
.BuildOptions
.Ffs
)cursor
.getObject();
2341 public void removeBuildOptionsFfs(int i
) {
2342 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2347 XmlCursor cursor
= ffs
.newCursor();
2354 public PlatformDefinitionsDocument
.PlatformDefinitions
getfpdPlatformDefs(){
2355 if (fpdPlatformDefs
== null){
2356 fpdPlatformDefs
= fpdRoot
.addNewPlatformDefinitions();
2358 return fpdPlatformDefs
;
2361 public void getPlatformDefsSupportedArchs(Vector
<Object
> archs
){
2362 if (getfpdPlatformDefs().getSupportedArchitectures() == null) {
2365 ListIterator li
= getfpdPlatformDefs().getSupportedArchitectures().listIterator();
2366 while(li
.hasNext()) {
2367 archs
.add(li
.next());
2371 public void setPlatformDefsSupportedArchs(Vector
<Object
> archs
) {
2372 if (archs
!= null) {
2373 getfpdPlatformDefs().setSupportedArchitectures(archs
);
2376 // XmlCursor cursor = getfpdPlatformDefs().newCursor();
2377 // if (cursor.toChild(xmlNs, "SupportedArchitectures")) {
2378 // cursor.removeXml();
2380 // cursor.dispose();
2384 public void getPlatformDefsBuildTargets(Vector
<Object
> targets
) {
2385 if (getfpdPlatformDefs().getBuildTargets() == null) {
2388 ListIterator li
= getfpdPlatformDefs().getBuildTargets().listIterator();
2389 while(li
.hasNext()) {
2390 targets
.add(li
.next());
2394 public void setPlatformDefsBuildTargets(Vector
<Object
> targets
) {
2395 getfpdPlatformDefs().setBuildTargets(targets
);
2398 public void genPlatformDefsSkuInfo(String id
, String name
) {
2399 SkuInfoDocument
.SkuInfo skuInfo
= null;
2400 if (getfpdPlatformDefs().getSkuInfo() == null) {
2401 skuInfo
= getfpdPlatformDefs().addNewSkuInfo();
2403 skuInfo
= getfpdPlatformDefs().getSkuInfo();
2404 if (skuInfo
.getUiSkuNameList() == null || skuInfo
.getUiSkuNameList().size() == 0) {
2405 SkuInfoDocument
.SkuInfo
.UiSkuName skuName
= skuInfo
.addNewUiSkuName();
2406 skuName
.setSkuID(new BigInteger("0"));
2407 skuName
.setStringValue("DEFAULT");
2409 if (id
.equals("0")) {
2412 SkuInfoDocument
.SkuInfo
.UiSkuName skuName
= skuInfo
.addNewUiSkuName();
2413 skuName
.setSkuID(new BigInteger(id
));
2414 skuName
.setStringValue(name
);
2417 public int getPlatformDefsSkuInfoCount(){
2418 if (getfpdPlatformDefs().getSkuInfo() == null || getfpdPlatformDefs().getSkuInfo().getUiSkuNameList() == null) {
2421 return getfpdPlatformDefs().getSkuInfo().getUiSkuNameList().size();
2424 public void getPlatformDefsSkuInfos(String
[][] saa
){
2425 if (getfpdPlatformDefs().getSkuInfo() == null || getfpdPlatformDefs().getSkuInfo().getUiSkuNameList() == null) {
2426 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null) {
2427 removeElement(getfpdDynPcdBuildDefs());
2428 fpdDynPcdBuildDefs
= null;
2433 List
<SkuInfoDocument
.SkuInfo
.UiSkuName
> l
= getfpdPlatformDefs().getSkuInfo().getUiSkuNameList();
2434 ListIterator
<SkuInfoDocument
.SkuInfo
.UiSkuName
> li
= l
.listIterator();
2436 while(li
.hasNext()) {
2437 SkuInfoDocument
.SkuInfo
.UiSkuName sku
= li
.next();
2438 saa
[i
][0] = sku
.getSkuID()+"";
2439 saa
[i
][1] = sku
.getStringValue();
2444 public void removePlatformDefsSkuInfo(int i
) {
2445 SkuInfoDocument
.SkuInfo skuInfo
= getfpdPlatformDefs().getSkuInfo();
2446 if (skuInfo
== null || i
== 0) {
2450 XmlCursor cursor
= skuInfo
.newCursor();
2451 if (cursor
.toFirstChild()) {
2452 for (int j
= 0; j
< i
; ++j
) {
2453 cursor
.toNextSibling();
2460 public void updatePlatformDefsSkuInfo(int i
, String id
, String name
) {
2461 SkuInfoDocument
.SkuInfo skuInfo
= getfpdPlatformDefs().getSkuInfo();
2462 if (skuInfo
== null || i
== 0) {
2466 XmlCursor cursor
= skuInfo
.newCursor();
2467 if (cursor
.toFirstChild()) {
2468 for (int j
= 0; j
< i
; ++j
) {
2469 cursor
.toNextSibling();
2471 SkuInfoDocument
.SkuInfo
.UiSkuName sku
= (SkuInfoDocument
.SkuInfo
.UiSkuName
)cursor
.getObject();
2472 sku
.setSkuID(new BigInteger(id
));
2473 sku
.setStringValue(name
);
2478 public String
getPlatformDefsInterDir(){
2479 if (getfpdPlatformDefs().getIntermediateDirectories() == null) {
2482 return getfpdPlatformDefs().getIntermediateDirectories().toString();
2485 public void setPlatformDefsInterDir(String interDir
){
2486 getfpdPlatformDefs().setIntermediateDirectories(IntermediateOutputType
.Enum
.forString(interDir
));
2489 public String
getPlatformDefsOutputDir() {
2490 return getfpdPlatformDefs().getOutputDirectory();
2493 public void setPlatformDefsOutputDir(String outputDir
) {
2494 if (outputDir
!= null && outputDir
.length() > 0) {
2495 getfpdPlatformDefs().setOutputDirectory(outputDir
);
2498 XmlCursor cursor
= getfpdPlatformDefs().newCursor();
2499 if (cursor
.toChild(new QName(xmlNs
, "OutputDirectory"))) {
2506 public FlashDocument
.Flash
getfpdFlash() {
2507 if (fpdFlash
== null) {
2508 fpdFlash
= fpdRoot
.addNewFlash();
2513 public void genFlashDefinitionFile(String file
) {
2514 FlashDefinitionFileDocument
.FlashDefinitionFile fdf
= getfpdFlash().getFlashDefinitionFile();
2516 fdf
= getfpdFlash().addNewFlashDefinitionFile();
2519 fdf
.setStringValue(file
);
2522 public String
getFlashDefinitionFile() {
2523 FlashDefinitionFileDocument
.FlashDefinitionFile fdf
= getfpdFlash().getFlashDefinitionFile();
2528 return fdf
.getStringValue();
2531 public void genFvImagesNameValue(String name
, String value
) {
2533 FvImagesDocument
.FvImages fi
= getfpdFlash().getFvImages();
2535 fi
= getfpdFlash().addNewFvImages();
2538 FvImagesDocument
.FvImages
.NameValue nv
= fi
.addNewNameValue();
2543 public void removeFvImagesNameValue(int i
){
2545 XmlObject o
= getfpdFlash().getFvImages();
2550 QName qNameValue
= new QName(xmlNs
, "NameValue");
2551 XmlCursor cursor
= o
.newCursor();
2552 if (cursor
.toChild(qNameValue
)) {
2553 for (int j
= 0; j
< i
; ++j
) {
2554 cursor
.toNextSibling(qNameValue
);
2561 public void updateFvImagesNameValue(int i
, String name
, String value
){
2563 XmlObject o
= getfpdFlash().getFvImages();
2568 QName qNameValue
= new QName(xmlNs
, "NameValue");
2569 XmlCursor cursor
= o
.newCursor();
2570 if (cursor
.toChild(qNameValue
)) {
2571 for (int j
= 0; j
< i
; ++j
) {
2572 cursor
.toNextSibling(qNameValue
);
2574 FvImagesDocument
.FvImages
.NameValue nv
= (FvImagesDocument
.FvImages
.NameValue
)cursor
.getObject();
2581 public int getFvImagesNameValueCount() {
2583 FvImagesDocument
.FvImages fi
= null;
2584 if ((fi
= getfpdFlash().getFvImages()) == null || fi
.getNameValueList() == null) {
2587 return fi
.getNameValueList().size();
2590 public void getFvImagesNameValues(String
[][] nv
) {
2592 FvImagesDocument
.FvImages fi
= getfpdFlash().getFvImages();
2596 List
<FvImagesDocument
.FvImages
.NameValue
> l
= fi
.getNameValueList();
2598 ListIterator li
= l
.listIterator();
2599 while (li
.hasNext()) {
2600 FvImagesDocument
.FvImages
.NameValue e
= (FvImagesDocument
.FvImages
.NameValue
) li
2602 nv
[i
][0] = e
.getName();
2603 nv
[i
][1] = e
.getValue();
2609 public void getFvImagesFvImageFvImageNames (Vector
<String
> vImageNames
) {
2610 FvImagesDocument
.FvImages fis
= getfpdFlash().getFvImages();
2611 if (fis
== null || fis
.getFvImageList() == null) {
2615 ListIterator
<FvImagesDocument
.FvImages
.FvImage
> li
= fis
.getFvImageList().listIterator();
2616 while (li
.hasNext()) {
2617 FvImagesDocument
.FvImages
.FvImage fi
= li
.next();
2618 if (fi
.getType().toString().equals("ImageName")) {
2619 vImageNames
.addAll(fi
.getFvImageNamesList());
2625 public void addFvImageFvImageNames (String
[] fvNames
) {
2626 FvImagesDocument
.FvImages fis
= getfpdFlash().getFvImages();
2627 if (fis
== null || fis
.getFvImageList() == null) {
2628 genFvImagesFvImage (fvNames
, "ImageName", null);
2632 ListIterator
<FvImagesDocument
.FvImages
.FvImage
> li
= fis
.getFvImageList().listIterator();
2633 while (li
.hasNext()) {
2634 FvImagesDocument
.FvImages
.FvImage fi
= li
.next();
2635 if (fi
.getType().toString().equals("ImageName")) {
2636 addFvImageNamesInFvImage (fi
, fvNames
);
2640 genFvImagesFvImage (fvNames
, "ImageName", null);
2643 public void addFvImageNamesInFvImage (FvImagesDocument
.FvImages
.FvImage fi
, String
[] fvNames
) {
2645 for (int i
= 0; i
< fvNames
.length
; ++i
) {
2646 fi
.addFvImageNames(fvNames
[i
]);
2650 public void addFvImageNamesInFvImage (int i
, String
[] fvNames
) {
2651 XmlObject o
= getfpdFlash().getFvImages();
2655 XmlCursor cursor
= o
.newCursor();
2656 QName qFvImage
= new QName(xmlNs
, "FvImage");
2657 if (cursor
.toChild(qFvImage
)) {
2658 for (int j
= 0; j
< i
; ++j
) {
2659 cursor
.toNextSibling(qFvImage
);
2661 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
2662 addFvImageNamesInFvImage(fi
, fvNames
);
2667 public void genFvImagesFvImage(String
[] names
, String types
, Map
<String
, String
> options
) {
2669 FvImagesDocument
.FvImages fis
= null;
2670 if ((fis
= getfpdFlash().getFvImages()) == null) {
2671 fis
= getfpdFlash().addNewFvImages();
2675 //gen FvImage with FvImageNames array
2677 FvImagesDocument
.FvImages
.FvImage fi
= fis
.addNewFvImage();
2678 for (int i
= 0; i
< names
.length
; ++i
) {
2679 fi
.addFvImageNames(names
[i
]);
2681 fi
.setType(FvImageTypes
.Enum
.forString(types
));
2682 if (options
!= null){
2683 setFvImagesFvImageFvImageOptions(options
, fi
);
2687 private void setFvImagesFvImageFvImageOptions(Map
<String
, String
> options
, FvImagesDocument
.FvImages
.FvImage fi
){
2688 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions fio
= fi
.getFvImageOptions();
2690 fio
= fi
.addNewFvImageOptions();
2693 Set
<String
> key
= options
.keySet();
2694 Iterator
<String
> i
= key
.iterator();
2695 while (i
.hasNext()) {
2697 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nv
= fio
.addNewNameValue();
2698 String k
= (String
)i
.next();
2701 nv
.setValue((String
)options
.get(k
));
2708 public void removeFvImagesFvImage(int i
) {
2710 XmlObject o
= getfpdFlash().getFvImages();
2715 QName qFvImage
= new QName(xmlNs
, "FvImage");
2716 XmlCursor cursor
= o
.newCursor();
2717 if (cursor
.toChild(qFvImage
)) {
2718 for (int j
= 0; j
< i
; ++j
) {
2719 cursor
.toNextSibling(qFvImage
);
2728 * @param newFvName The New FV Name. If null, remove the old FvImageNames entry.
2730 public void updateFvImageNameAll (String oldFvName
, String newFvName
) {
2731 if (getfpdFlash().getFvImages() == null || getfpdFlash().getFvImages().getFvImageList() == null) {
2734 ListIterator
<FvImagesDocument
.FvImages
.FvImage
> li
= getfpdFlash().getFvImages().getFvImageList().listIterator();
2735 while (li
.hasNext()) {
2736 FvImagesDocument
.FvImages
.FvImage fi
= li
.next();
2737 updateFvImageNamesInFvImage (fi
, oldFvName
, newFvName
);
2738 if (fi
.getFvImageNamesList().size() == 0) {
2744 public void updateFvImageNamesInFvImage (int i
, String oldFvName
, String newFvName
) {
2745 XmlObject o
= getfpdFlash().getFvImages();
2749 XmlCursor cursor
= o
.newCursor();
2750 QName qFvImage
= new QName(xmlNs
, "FvImage");
2751 if (cursor
.toChild(qFvImage
)) {
2752 for (int j
= 0; j
< i
; ++j
) {
2753 cursor
.toNextSibling(qFvImage
);
2755 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
2756 updateFvImageNamesInFvImage (fi
, oldFvName
, newFvName
);
2762 * @param oldFvName The FV Name to be replaced.
2763 * @param newFvName The New FV Name. If null, remove the old FvImageNames entry.
2765 public void updateFvImageNamesInFvImage (FvImagesDocument
.FvImages
.FvImage fi
, String oldFvName
, String newFvName
) {
2766 QName qFvImageNames
= new QName(xmlNs
, "FvImageNames");
2767 XmlCursor cursor
= fi
.newCursor();
2769 if (cursor
.toChild(qFvImageNames
)) {
2771 String xmlValue
= cursor
.getTextValue();
2772 if (xmlValue
.equals(oldFvName
)){
2773 if (newFvName
!= null) {
2774 cursor
.setTextValue(newFvName
);
2780 }while (cursor
.toNextSibling(qFvImageNames
));
2786 /**update the Type attribute of ith FvImage with new type.
2790 public void updateFvImagesFvImageType (int i
, String type
) {
2791 XmlObject o
= getfpdFlash().getFvImages();
2795 XmlCursor cursor
= o
.newCursor();
2796 QName qFvImage
= new QName(xmlNs
, "FvImage");
2797 if (cursor
.toChild(qFvImage
)) {
2798 for (int j
= 0; j
< i
; ++j
) {
2799 cursor
.toNextSibling(qFvImage
);
2801 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
2802 fi
.setType(FvImageTypes
.Enum
.forString(type
));
2807 public void updateFvImagesFvImage(int i
, String
[] names
, String types
, Map
<String
, String
> options
){
2809 XmlObject o
= getfpdFlash().getFvImages();
2813 XmlCursor cursor
= o
.newCursor();
2814 QName qFvImage
= new QName(xmlNs
, "FvImage");
2815 if (cursor
.toChild(qFvImage
)) {
2816 for (int j
= 0; j
< i
; ++j
) {
2817 cursor
.toNextSibling(qFvImage
);
2819 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
2820 fi
.setType(FvImageTypes
.Enum
.forString(types
));
2823 // remove old FvImageNames before adding new ones
2825 QName qFvImageNames
= new QName(xmlNs
, "FvImageNames");
2826 cursor
.toChild(qFvImageNames
);
2828 while (cursor
.toNextSibling(qFvImageNames
)) {
2832 for (int k
= 0; k
< names
.length
; ++k
) {
2833 fi
.addFvImageNames(names
[k
]);
2836 // remove old FvImageOptions before adding new options
2838 QName qFvImageOptions
= new QName(xmlNs
, "FvImageOptions");
2839 cursor
.toNextSibling(qFvImageOptions
);
2842 setFvImagesFvImageFvImageOptions(options
, fi
);
2847 public int getFvImagesFvImageCount(String type
) {
2849 if (getfpdFlash().getFvImages() == null || getfpdFlash().getFvImages().getFvImageList() == null) {
2852 List
<FvImagesDocument
.FvImages
.FvImage
> l
= getfpdFlash().getFvImages().getFvImageList();
2853 ListIterator li
= l
.listIterator();
2855 while(li
.hasNext()) {
2856 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)li
.next();
2857 if (!fi
.getType().toString().equals(type
) && !type
.equals("ALL")) {
2867 public Vector
<FvImagesDocument
.FvImages
.FvImage
> getFvImagesFvImageWithName (String fvName
, String type
) {
2868 Vector
<FvImagesDocument
.FvImages
.FvImage
> vFvImage
= new Vector
<FvImagesDocument
.FvImages
.FvImage
>();
2869 if (getfpdFlash().getFvImages() == null || getfpdFlash().getFvImages().getFvImageList() == null) {
2872 List
<FvImagesDocument
.FvImages
.FvImage
> l
= getfpdFlash().getFvImages().getFvImageList();
2873 ListIterator li
= l
.listIterator();
2874 while(li
.hasNext()) {
2875 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)li
.next();
2876 if (!fi
.getType().toString().equals(type
) && !type
.equals("ALL")) {
2879 if (fi
.getFvImageNamesList().contains(fvName
)) {
2888 * @param type "ALL" means all FvImage types: ImageName, Options, Attributes, Components.
2890 public void getFvImagesFvImages(String
[][] saa
, String type
) {
2892 if (getfpdFlash().getFvImages() == null) {
2895 List
<FvImagesDocument
.FvImages
.FvImage
> l
= getfpdFlash().getFvImages().getFvImageList();
2899 ListIterator li
= l
.listIterator();
2901 while(li
.hasNext()) {
2902 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)li
.next();
2903 if (!fi
.getType().toString().equals(type
) && !type
.equals("ALL")) {
2907 // get FvImageNames array, space separated
2909 List
<String
> lfn
= fi
.getFvImageNamesList();
2910 ListIterator lfni
= lfn
.listIterator();
2912 while (lfni
.hasNext()) {
2913 saa
[i
][0] += (String
)lfni
.next();
2916 saa
[i
][0] = saa
[i
][0].trim();
2918 saa
[i
][1] = fi
.getType()+"";
2924 public void removeFvImageNameValue (int i
, String attributeName
) {
2925 XmlObject o
= getfpdFlash().getFvImages();
2929 XmlCursor cursor
= o
.newCursor();
2930 QName qFvImage
= new QName(xmlNs
, "FvImage");
2931 if (cursor
.toChild(qFvImage
)) {
2932 for (int j
= 0; j
< i
; ++j
) {
2933 cursor
.toNextSibling(qFvImage
);
2935 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
2936 removeFvImageNameValue (fi
, attributeName
);
2940 /**Remove from fi the attribute pair with attributeName in FvImageOptions.
2942 * @param attributeName
2944 public void removeFvImageNameValue (FvImagesDocument
.FvImages
.FvImage fi
, String attributeName
) {
2945 if (fi
.getFvImageOptions() != null && fi
.getFvImageOptions().getNameValueList() != null) {
2946 ListIterator
<FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
> li
= fi
.getFvImageOptions().getNameValueList().listIterator();
2947 while (li
.hasNext()) {
2948 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nv
= li
.next();
2949 if (nv
.getName().equals(attributeName
)) {
2956 public void removeTypedNamedFvImageNameValue (String fvName
, String type
, String optName
) {
2957 Vector
<FvImagesDocument
.FvImages
.FvImage
> vFvImage
= getFvImagesFvImageWithName(fvName
, type
);
2958 for (int i
= 0; i
< vFvImage
.size(); ++i
) {
2959 FvImagesDocument
.FvImages
.FvImage fi
= vFvImage
.get(i
);
2960 removeFvImageNameValue (fi
, optName
);
2964 /**Add name-value pair to FvImage element with type.
2965 * @param fvName FV name to add name-value pair.
2966 * @param type FvImage attribute.
2970 public void setTypedNamedFvImageNameValue (String fvName
, String type
, String name
, String value
) {
2971 boolean fvImageExists
= false;
2972 if (getfpdFlash().getFvImages() == null) {
2975 List
<FvImagesDocument
.FvImages
.FvImage
> l
= getfpdFlash().getFvImages().getFvImageList();
2979 ListIterator li
= l
.listIterator();
2980 while(li
.hasNext()) {
2981 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)li
.next();
2982 if (!fi
.getType().toString().equals(type
) && !type
.equals("ALL")) {
2985 if (!fi
.getFvImageNamesList().contains(fvName
)) {
2988 fvImageExists
= true;
2989 setFvImagesFvImageNameValue (fi
, name
, value
, null);
2992 if (!fvImageExists
) {
2993 HashMap
<String
, String
> map
= new HashMap
<String
, String
>();
2994 map
.put(name
, value
);
2995 genFvImagesFvImage(new String
[]{fvName
}, type
, map
);
2999 /**Add to all FvImage elements with type, the name-value pair.
3004 public void setTypedFvImageNameValue (String type
, String name
, String value
) {
3005 if (getfpdFlash().getFvImages() == null) {
3008 List
<FvImagesDocument
.FvImages
.FvImage
> l
= getfpdFlash().getFvImages().getFvImageList();
3012 ListIterator li
= l
.listIterator();
3013 while(li
.hasNext()) {
3014 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)li
.next();
3015 if (!fi
.getType().toString().equals(type
) && !type
.equals("ALL")) {
3018 setFvImagesFvImageNameValue (fi
, name
, value
, null);
3023 public void setFvImagesFvImageNameValue (int i
, String name
, String value
) {
3024 XmlObject o
= getfpdFlash().getFvImages();
3028 XmlCursor cursor
= o
.newCursor();
3029 QName qFvImage
= new QName(xmlNs
, "FvImage");
3030 if (cursor
.toChild(qFvImage
)) {
3031 for (int j
= 0; j
< i
; ++j
) {
3032 cursor
.toNextSibling(qFvImage
);
3034 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
3035 setFvImagesFvImageNameValue (fi
, name
, value
, null);
3040 /**Add to FvImage the name-value pair, or replace old name with newName, or generate new name-value pair if not exists before.
3046 public void setFvImagesFvImageNameValue (FvImagesDocument
.FvImages
.FvImage fi
, String name
, String value
, String newName
) {
3047 if (fi
.getFvImageOptions() == null || fi
.getFvImageOptions().getNameValueList() == null) {
3048 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nv
= fi
.addNewFvImageOptions().addNewNameValue();
3051 if (newName
!= null) {
3052 nv
.setName(newName
);
3057 XmlCursor cursor
= fi
.getFvImageOptions().newCursor();
3058 if (cursor
.toFirstChild()) {
3060 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nv
= (FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
)cursor
.getObject();
3061 if (nv
.getName().equals(name
)) {
3063 if (newName
!= null) {
3064 nv
.setName(newName
);
3069 }while (cursor
.toNextSibling());
3072 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nv
= fi
.getFvImageOptions().addNewNameValue();
3075 if (newName
!= null) {
3076 nv
.setName(newName
);
3081 public void getFvImagesFvImageOptions (String fvName
, Map
<String
, String
> m
) {
3082 Vector
<FvImagesDocument
.FvImages
.FvImage
> vFvImage
= getFvImagesFvImageWithName (fvName
, "Options");
3083 for (int i
= 0; i
< vFvImage
.size(); ++i
) {
3084 FvImagesDocument
.FvImages
.FvImage fi
= vFvImage
.get(i
);
3085 if (fi
== null || fi
.getFvImageOptions() == null || fi
.getFvImageOptions().getNameValueList() == null) {
3089 ListIterator
<FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
> li
= fi
.getFvImageOptions()
3092 while (li
.hasNext()) {
3093 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nv
= li
.next();
3094 m
.put(nv
.getName(), nv
.getValue());
3099 public int getFvImagePosInFvImages (String fvNameList
, String type
) {
3100 XmlObject o
= getfpdFlash().getFvImages();
3106 String
[] fvNameArray
= fvNameList
.trim().split(" ");
3107 Vector
<String
> vFvNames
= new Vector
<String
>();
3110 XmlCursor cursor
= o
.newCursor();
3111 QName qFvImage
= new QName(xmlNs
, "FvImage");
3112 if (cursor
.toChild(qFvImage
)) {
3115 vFvNames
.removeAllElements();
3116 for (int i
= 0; i
< fvNameArray
.length
; ++i
) {
3117 vFvNames
.add(fvNameArray
[i
]);
3119 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
3120 if (!fi
.getType().toString().equals(type
)) {
3123 if (fi
.getFvImageNamesList() == null || fi
.getFvImageNamesList().size() != vFvNames
.size()) {
3126 ListIterator
<String
> li
= fi
.getFvImageNamesList().listIterator();
3127 while (li
.hasNext()) {
3128 String name
= li
.next();
3129 vFvNames
.remove(name
);
3131 if (vFvNames
.size() == 0) {
3136 }while (cursor
.toNextSibling(qFvImage
));
3142 /**Get FvImage Options for FvImage i
3143 * @param i the ith FvImage
3145 public void getFvImagesFvImageOptions(int i
, Map
<String
, String
> m
) {
3146 XmlObject o
= getfpdFlash().getFvImages();
3150 XmlCursor cursor
= o
.newCursor();
3151 QName qFvImage
= new QName(xmlNs
, "FvImage");
3152 if (cursor
.toChild(qFvImage
)) {
3153 for (int j
= 0; j
< i
; ++j
) {
3154 cursor
.toNextSibling(qFvImage
);
3156 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
3157 if (fi
.getFvImageOptions() == null || fi
.getFvImageOptions().getNameValueList() == null){
3161 ListIterator
<FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
> li
= fi
.getFvImageOptions().getNameValueList().listIterator();
3162 while(li
.hasNext()){
3163 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nv
= li
.next();
3164 m
.put(nv
.getName(), nv
.getValue());
3171 Get platform header element
3172 @return PlatformHeaderDocument.PlatformHeader
3174 public PlatformHeaderDocument
.PlatformHeader
getFpdHdr() {
3175 if (fpdHdr
== null) {
3176 fpdHdr
= fpdRoot
.addNewPlatformHeader();
3182 public String
getFpdHdrPlatformName() {
3183 return getFpdHdr().getPlatformName();
3186 public String
getFpdHdrGuidValue() {
3187 return getFpdHdr().getGuidValue();
3190 public String
getFpdHdrVer() {
3191 return getFpdHdr().getVersion();
3194 public String
getFpdHdrAbs() {
3195 return getFpdHdr().getAbstract();
3198 public String
getFpdHdrDescription() {
3199 return getFpdHdr().getDescription();
3202 public String
getFpdHdrCopyright() {
3203 return getFpdHdr().getCopyright();
3206 public String
getFpdHdrLicense() {
3207 LicenseDocument
.License l
= getFpdHdr().getLicense();
3211 return l
.getStringValue();
3214 public String
getFpdHdrUrl() {
3215 LicenseDocument
.License l
= getFpdHdr().getLicense();
3222 public String
getFpdHdrSpec() {
3224 return "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052";
3225 // return getFpdHdr().getSpecification();
3228 public void setFpdHdrPlatformName(String name
){
3229 getFpdHdr().setPlatformName(name
);
3232 public void setFpdHdrGuidValue(String guid
){
3233 getFpdHdr().setGuidValue(guid
);
3236 public void setFpdHdrVer(String v
){
3237 getFpdHdr().setVersion(v
);
3240 public void setFpdHdrAbs(String abs
) {
3241 getFpdHdr().setAbstract(abs
);
3244 public void setFpdHdrDescription(String desc
){
3245 getFpdHdr().setDescription(desc
);
3248 public void setFpdHdrCopyright(String cr
) {
3249 getFpdHdr().setCopyright(cr
);
3252 public void setFpdHdrLicense(String license
){
3253 LicenseDocument
.License l
= getFpdHdr().getLicense();
3255 getFpdHdr().addNewLicense().setStringValue(license
);
3258 l
.setStringValue(license
);
3262 public void setFpdHdrUrl(String url
){
3263 LicenseDocument
.License l
= getFpdHdr().getLicense();
3269 public void setFpdHdrSpec(String s
){
3270 s
= "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052";
3271 getFpdHdr().setSpecification(s
);
3274 Save the processed xml contents to file
3276 @param fpdFile The file to save xml contents
3277 @throws IOException Exceptions during file operation
3279 public void saveAs(File fpdFile
) throws IOException
{
3281 XmlOptions options
= new XmlOptions();
3283 options
.setCharacterEncoding("UTF-8");
3284 options
.setSavePrettyPrint();
3285 options
.setSavePrettyPrintIndent(2);
3287 fpdd
.save(fpdFile
, options
);
3288 } catch (IOException e
) {
3289 e
.printStackTrace();
3294 private String
listToString(List l
) {
3299 ListIterator li
= l
.listIterator();
3300 while(li
.hasNext()) {
3307 private void removeElement(XmlObject o
) {
3308 XmlCursor cursor
= o
.newCursor();
3314 class PcdItemTypeConflictException
extends Exception
{
3319 private static final long serialVersionUID
= 1L;
3320 private String details
= null;
3322 PcdItemTypeConflictException(String pcdName
, String info
){
3323 ModuleIdentification mi
= WorkspaceProfile
.getModuleId(info
);
3324 details
= pcdName
+ " ItemType Conflicts with " + mi
.getName() + " in Pkg " + mi
.getPackageId().getName();
3327 public String
getMessage() {
3332 class PcdDeclNotFound
extends Exception
{
3337 private static final long serialVersionUID
= 1L;
3338 private String details
= null;
3340 PcdDeclNotFound(String info
) {
3341 details
= "PcdDeclNotFound: " + info
;
3344 public String
getMessage() {
3349 class PcdValueMalFormed
extends Exception
{
3354 private static final long serialVersionUID
= 1L;
3355 private String details
= null;
3357 PcdValueMalFormed(String info
) {
3358 details
= "PcdValueMalFormed: " + info
;
3361 public String
getMessage() {