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
>();
94 private String
itemType (String pcdInfo
) {
96 return pcdInfo
.substring(pcdInfo
.lastIndexOf(" ") + 1);
100 * look through all pcd data in all ModuleSA, create pcd -> ModuleSA mappings.
102 public void initDynPcdMap() {
103 if (dynPcdMap
== null) {
104 dynPcdMap
= new HashMap
<String
, ArrayList
<String
>>();
105 List
<ModuleSADocument
.ModuleSA
> l
= getfpdFrameworkModules().getModuleSAList();
107 removeElement(getfpdFrameworkModules());
108 fpdFrameworkModules
= null;
111 ListIterator
<ModuleSADocument
.ModuleSA
> li
= l
.listIterator();
112 while (li
.hasNext()) {
113 ModuleSADocument
.ModuleSA moduleSa
= li
.next();
114 if (moduleSa
.getPcdBuildDefinition() == null || moduleSa
.getPcdBuildDefinition().getPcdDataList() == null) {
117 String ModuleInfo
= moduleSa
.getModuleGuid() + " " + moduleSa
.getModuleVersion() +
118 " " + moduleSa
.getPackageGuid() + " " + moduleSa
.getPackageVersion() + " " + listToString(moduleSa
.getSupArchList());
119 List
<PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
> lp
= moduleSa
.getPcdBuildDefinition().getPcdDataList();
120 ListIterator
<PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
> lpi
= lp
.listIterator();
121 while (lpi
.hasNext()) {
122 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= lpi
.next();
123 String pcdKey
= pcdData
.getCName() + " " + pcdData
.getTokenSpaceGuidCName();
124 if (dynPcdMap
.get(pcdKey
) == null) {
125 ArrayList
<String
> al
= new ArrayList
<String
>();
126 al
.add(ModuleInfo
+ " " + pcdData
.getItemType().toString());
127 dynPcdMap
.put(pcdKey
, al
);
130 dynPcdMap
.get(pcdKey
).add(ModuleInfo
+ " " + pcdData
.getItemType().toString());
137 public ArrayList
<String
> getDynPcdMapValue(String key
) {
138 return dynPcdMap
.get(key
);
141 Constructor to create a new spd file
143 public FpdFileContents() {
145 fpdd
= PlatformSurfaceAreaDocument
.Factory
.newInstance();
146 fpdRoot
= fpdd
.addNewPlatformSurfaceArea();
151 Constructor for existing document object
154 public FpdFileContents(PlatformSurfaceAreaDocument
.PlatformSurfaceArea fpd
) {
156 fpdHdr
= fpdRoot
.getPlatformHeader();
157 fpdPlatformDefs
= fpdRoot
.getPlatformDefinitions();
158 fpdBuildOpts
= fpdRoot
.getBuildOptions();
159 fpdFrameworkModules
= fpdRoot
.getFrameworkModules();
160 fpdDynPcdBuildDefs
= fpdRoot
.getDynamicPcdBuildDefinitions();
161 fpdFlash
= fpdRoot
.getFlash();
165 Constructor based on an existing spd file
167 @param f Existing spd file
169 public FpdFileContents(File f
) {
171 fpdd
= PlatformSurfaceAreaDocument
.Factory
.parse(f
);
172 fpdRoot
= fpdd
.getPlatformSurfaceArea();
173 } catch (Exception e
) {
174 System
.out
.println(e
.toString());
178 public DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
getfpdDynPcdBuildDefs() {
179 if (fpdDynPcdBuildDefs
== null){
180 fpdDynPcdBuildDefs
= fpdRoot
.addNewDynamicPcdBuildDefinitions();
182 return fpdDynPcdBuildDefs
;
185 public FrameworkModulesDocument
.FrameworkModules
getfpdFrameworkModules() {
186 if (fpdFrameworkModules
== null){
187 fpdFrameworkModules
= fpdRoot
.addNewFrameworkModules();
189 return fpdFrameworkModules
;
192 public void getFrameworkModuleGuid (String fvName
, Vector
<String
> vGuid
) {
193 if (getFrameworkModulesCount() == 0){
197 ListIterator li
= getfpdFrameworkModules().getModuleSAList().listIterator();
198 while(li
.hasNext()) {
199 ModuleSADocument
.ModuleSA moduleSa
= (ModuleSADocument
.ModuleSA
)li
.next();
200 if (moduleSa
.getModuleSaBuildOptions() == null) {
203 String fvBinding
= moduleSa
.getModuleSaBuildOptions().getFvBinding();
204 if (fvBinding
== null) {
208 String
[] fvNames
= fvBinding
.split(" ");
209 for (int i
= 0; i
< fvNames
.length
; ++i
) {
210 if (fvNames
[i
].equals(fvName
) || fvNames
[i
].replaceAll("_", "").equals(fvName
)) {
211 vGuid
.add(moduleSa
.getModuleGuid());
218 public int getFrameworkModulesCount() {
219 if (getfpdFrameworkModules().getModuleSAList() == null || getfpdFrameworkModules().getModuleSAList().size() == 0){
220 removeElement(getfpdFrameworkModules());
221 fpdFrameworkModules
= null;
224 return getfpdFrameworkModules().getModuleSAList().size();
227 public void getFrameworkModulesInfo(String
[][] saa
) {
228 if (getFrameworkModulesCount() == 0){
232 ListIterator li
= getfpdFrameworkModules().getModuleSAList().listIterator();
234 while(li
.hasNext()) {
235 ModuleSADocument
.ModuleSA moduleSa
= (ModuleSADocument
.ModuleSA
)li
.next();
236 saa
[i
][0] = moduleSa
.getModuleGuid();
237 saa
[i
][1] = moduleSa
.getModuleVersion();
239 saa
[i
][2] = moduleSa
.getPackageGuid();
240 saa
[i
][3] = moduleSa
.getPackageVersion();
241 saa
[i
][4] = listToString(moduleSa
.getSupArchList());
246 public void getFrameworkModuleInfo(int i
, String
[] sa
) {
247 ModuleSADocument
.ModuleSA msa
= getModuleSA(i
);
251 sa
[0] = msa
.getModuleGuid();
252 sa
[1] = msa
.getModuleVersion();
253 sa
[2] = msa
.getPackageGuid();
254 sa
[3] = msa
.getPackageVersion();
255 sa
[4] = listToString(msa
.getSupArchList());
258 public ModuleSADocument
.ModuleSA
getModuleSA(String key
) {
260 if (getfpdFrameworkModules().getModuleSAList() == null || getfpdFrameworkModules().getModuleSAList().size() == 0) {
261 removeElement(getfpdFrameworkModules());
262 fpdFrameworkModules
= null;
265 String
[] s
= key
.split(" ");
266 String archsInKey
= "";
268 for (int i
= 4; i
< s
.length
; ++i
) {
272 archsInKey
= archsInKey
.trim();
275 ListIterator li
= getfpdFrameworkModules().getModuleSAList().listIterator();
276 while(li
.hasNext()) {
277 ModuleSADocument
.ModuleSA moduleSa
= (ModuleSADocument
.ModuleSA
)li
.next();
278 if (moduleSa
.getModuleGuid().equalsIgnoreCase(s
[0]) && moduleSa
.getPackageGuid().equalsIgnoreCase(s
[2])) {
279 if (moduleSa
.getModuleVersion() != null) {
280 if (!moduleSa
.getModuleVersion().equals(s
[1])) {
284 if (moduleSa
.getPackageVersion() != null) {
285 if (!moduleSa
.getPackageVersion().equals(s
[3])) {
289 //ToDo add arch check .
290 if (moduleSa
.getSupArchList() != null) {
291 if (listToString(moduleSa
.getSupArchList()).equals(archsInKey
)) {
296 if (archsInKey
.length() == 0) {
305 private ModuleSADocument
.ModuleSA
getModuleSA(int i
) {
306 ModuleSADocument
.ModuleSA moduleSa
= null;
307 if (fpdRoot
.getFrameworkModules() == null) {
310 XmlCursor cursor
= fpdRoot
.getFrameworkModules().newCursor();
311 if (cursor
.toFirstChild()) {
312 for (int j
= 0; j
< i
; ++j
) {
313 cursor
.toNextSibling();
315 moduleSa
= (ModuleSADocument
.ModuleSA
)cursor
.getObject();
321 public void removeModuleSA(int i
) {
322 XmlObject o
= fpdRoot
.getFrameworkModules();
327 XmlCursor cursor
= o
.newCursor();
328 if (cursor
.toFirstChild()) {
329 for (int j
= 0; j
< i
; ++j
) {
330 cursor
.toNextSibling();
333 // remove pcd from dynPcdMap, if DynamicPcdBuildData exists, remove them too.
335 ModuleSADocument
.ModuleSA moduleSa
= (ModuleSADocument
.ModuleSA
)cursor
.getObject();
336 String moduleInfo
= moduleSa
.getModuleGuid() + " " + moduleSa
.getModuleVersion() + " " +
337 moduleSa
.getPackageGuid()+ " " + moduleSa
.getPackageVersion() + " " + listToString(moduleSa
.getSupArchList());
338 PcdBuildDefinitionDocument
.PcdBuildDefinition pcdBuildDef
= moduleSa
.getPcdBuildDefinition();
339 if (pcdBuildDef
!= null && pcdBuildDef
.getPcdDataList() != null) {
340 ListIterator
<PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
> li
= pcdBuildDef
.getPcdDataList().listIterator();
341 while(li
.hasNext()) {
342 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= li
.next();
343 maintainDynPcdMap(pcdData
.getCName() + " " + pcdData
.getTokenSpaceGuidCName(), moduleInfo
);
348 cursor
.toPrevToken();
349 if (cursor
.isComment()) {
354 if (getFrameworkModulesCount() == 0) {
362 public boolean adjustPcd (int seqModuleSa
) throws Exception
{
363 boolean dataModified
= false;
364 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(seqModuleSa
);
365 int pcdCount
= getPcdDataCount(seqModuleSa
);
366 String
[][] saaModuleSaPcd
= new String
[pcdCount
][7];
367 getPcdData(seqModuleSa
, saaModuleSaPcd
);
368 String mg
= moduleSa
.getModuleGuid();
369 String mv
= moduleSa
.getModuleVersion();
370 String pg
= moduleSa
.getPackageGuid();
371 String pv
= moduleSa
.getPackageVersion();
372 String arch
= listToString(moduleSa
.getSupArchList());
374 // delete pcd in ModuleSA but not in MSA files any longer.
376 String moduleKey
= mg
+ " " + mv
+ " " + pg
+ " " + pv
+ " " + arch
;
377 int libCount
= getLibraryInstancesCount(moduleKey
);
378 String
[][] saaLib
= new String
[libCount
][5];
379 getLibraryInstances(moduleKey
, saaLib
);
380 ModuleIdentification mi
= WorkspaceProfile
.getModuleId(moduleKey
);
381 Vector
<ModuleIdentification
> vMi
= new Vector
<ModuleIdentification
>();
383 // create vector for module & library instance MIs.
386 for (int j
= 0; j
< saaLib
.length
; ++j
) {
387 String libKey
= saaLib
[j
][1] + " " + saaLib
[j
][2] + " " + saaLib
[j
][3] + " " + saaLib
[j
][4];
388 ModuleIdentification libMi
= WorkspaceProfile
.getModuleId(libKey
);
393 nextPcd
:for (int i
= 0; i
< saaModuleSaPcd
.length
; ++i
) {
395 for (int j
= 0; j
< vMi
.size(); ++j
) {
396 ModuleIdentification nextMi
= vMi
.get(j
);
397 if (WorkspaceProfile
.pcdInMsa(saaModuleSaPcd
[i
][0], saaModuleSaPcd
[i
][1], nextMi
)) {
401 removePcdData(seqModuleSa
, saaModuleSaPcd
[i
][0], saaModuleSaPcd
[i
][1]);
405 catch (Exception e
) {
409 // add new Pcd from MSA file to ModuleSA.
413 for (int i
= 0; i
< vMi
.size(); ++i
) {
414 ModuleSurfaceAreaDocument
.ModuleSurfaceArea msa
= (ModuleSurfaceAreaDocument
.ModuleSurfaceArea
) WorkspaceProfile
415 .getModuleXmlObject(vMi
417 if (msa
.getPcdCoded() == null || msa
.getPcdCoded().getPcdEntryList() == null) {
420 ListIterator li
= msa
.getPcdCoded().getPcdEntryList().listIterator();
421 msaPcdIter
:while (li
.hasNext()) {
422 PcdCodedDocument
.PcdCoded
.PcdEntry msaPcd
= (PcdCodedDocument
.PcdCoded
.PcdEntry
) li
.next();
423 ArrayList
<String
> al
= getDynPcdMapValue(msaPcd
.getCName() + " " + msaPcd
.getTokenSpaceGuidCName());
425 for (int j
= 0; j
< al
.size(); ++j
) {
426 if (al
.get(j
).contains(moduleKey
)) {
432 PackageIdentification
[] depPkgs
= SurfaceAreaQuery
.getDependencePkg(null, vMi
.get(i
));
433 PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry spdPcd
= LookupPcdDeclaration(msaPcd
, depPkgs
);
434 if (spdPcd
== null) {
438 throw new PcdDeclNotFound("No Declaration for PCD Entry " + msaPcd
.getCName() + " in Module "
442 // AddItem to ModuleSA PcdBuildDefinitions
444 String defaultVal
= msaPcd
.getDefaultValue() == null ? spdPcd
.getDefaultValue()
445 : msaPcd
.getDefaultValue();
447 genPcdData(msaPcd
.getCName(), spdPcd
.getToken(), msaPcd
.getTokenSpaceGuidCName(),
448 msaPcd
.getPcdItemType().toString(), spdPcd
.getDatumType() + "", defaultVal
, moduleSa
);
461 private void maintainDynPcdMap(String pcdKey
, String moduleInfo
) {
463 ArrayList
<String
> al
= dynPcdMap
.get(pcdKey
);
467 String
[] s
= moduleInfo
.split(" ");
468 for(int i
= 0; i
< al
.size(); ++i
){
469 String consumer
= al
.get(i
);
470 if (consumer
.contains(s
[0]) && consumer
.contains(s
[2])){
471 String
[] consumerPart
= consumer
.split(" ");
472 if (!consumerPart
[4].equals(s
[4])) {
480 if (al
.size() == 0) {
481 defaultPcdValue
.remove(pcdKey
);
482 dynPcdMap
.remove(pcdKey
);
483 String
[] s1
= pcdKey
.split(" ");
484 removeDynamicPcdBuildData(s1
[0], s1
[1]);
489 // key for ModuleSA : "ModuleGuid ModuleVer PackageGuid PackageVer Arch"
491 public int getPcdDataCount (int i
){
492 ModuleSADocument
.ModuleSA msa
= getModuleSA(i
);
494 if (msa
== null || msa
.getPcdBuildDefinition() == null || msa
.getPcdBuildDefinition().getPcdDataList() == null){
497 return msa
.getPcdBuildDefinition().getPcdDataList().size();
501 public void getPcdData (int i
, String
[][] saa
) {
502 ModuleSADocument
.ModuleSA msa
= getModuleSA(i
);
504 if (msa
== null || msa
.getPcdBuildDefinition() == null || msa
.getPcdBuildDefinition().getPcdDataList() == null){
507 ListIterator
<PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
>li
= msa
.getPcdBuildDefinition().getPcdDataList().listIterator();
508 for (int k
= 0; k
< saa
.length
; ++k
) {
509 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= li
.next();
510 saa
[k
][0] = pcdData
.getCName();
511 saa
[k
][1] = pcdData
.getTokenSpaceGuidCName();
512 saa
[k
][2] = pcdData
.getItemType()+"";
513 saa
[k
][3] = pcdData
.getToken().toString();
514 saa
[k
][4] = pcdData
.getMaxDatumSize()+"";
515 saa
[k
][5] = pcdData
.getDatumType()+"";
516 saa
[k
][6] = pcdData
.getValue();
521 public void removePcdData (int seqModuleSa
, String cName
, String tsGuid
) {
522 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(seqModuleSa
);
523 if (moduleSa
== null || moduleSa
.getPcdBuildDefinition() == null){
527 String mg
= moduleSa
.getModuleGuid();
528 String mv
= moduleSa
.getModuleVersion();
529 String pg
= moduleSa
.getPackageGuid();
530 String pv
= moduleSa
.getPackageVersion();
531 String arch
= listToString(moduleSa
.getSupArchList());
532 String moduleKey
= mg
+ " " + mv
+ " " + pg
+ " " + pv
+ " " + arch
;
534 XmlCursor cursor
= moduleSa
.getPcdBuildDefinition().newCursor();
535 if (cursor
.toFirstChild()){
538 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= (PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
)cursor
.getObject();
539 if (pcdData
.getCName().equals(cName
) && pcdData
.getTokenSpaceGuidCName().equals(tsGuid
)) {
540 maintainDynPcdMap(cName
+ " " + tsGuid
, moduleKey
);
541 if (getPcdDataCount(seqModuleSa
) == 1) {
548 while(cursor
.toNextSibling());
554 public void updatePcdData (String key
, String cName
, String tsGuid
, String itemType
, String maxSize
, String value
){
555 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(key
);
556 if (moduleSa
== null || moduleSa
.getPcdBuildDefinition() == null){
560 XmlCursor cursor
= moduleSa
.getPcdBuildDefinition().newCursor();
561 if (cursor
.toFirstChild()){
563 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= (PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
)cursor
.getObject();
564 if (pcdData
.getCName().equals(cName
) && pcdData
.getTokenSpaceGuidCName().equals(tsGuid
)) {
566 // change item type while not updating dynPcdData????
568 pcdData
.setItemType(PcdItemTypes
.Enum
.forString(itemType
));
569 if(pcdData
.getDatumType().equals("VOID*")) {
570 pcdData
.setMaxDatumSize(new Integer(maxSize
));
572 pcdData
.setValue(value
);
573 defaultPcdValue
.put(cName
+ " " + tsGuid
, value
);
577 while(cursor
.toNextSibling());
582 /**Get original Pcd info from MSA & SPD files.
583 * @param mi ModuleIdentification from which MSA & SPD come
584 * @param cName PCD cName
585 * @param sa Results: HelpText, Original item type.
588 public boolean getPcdBuildDataInfo(ModuleIdentification mi
, String cName
, String tsGuid
, String
[] sa
) throws Exception
{
591 ModuleSurfaceAreaDocument
.ModuleSurfaceArea msa
= (ModuleSurfaceAreaDocument
.ModuleSurfaceArea
)WorkspaceProfile
.getModuleXmlObject(mi
);
592 if (msa
.getPcdCoded() == null) {
596 Map
<String
, XmlObject
> m
= new HashMap
<String
, XmlObject
>();
597 m
.put("ModuleSurfaceArea", msa
);
598 SurfaceAreaQuery
.setDoc(m
);
599 PackageIdentification
[] depPkgs
= SurfaceAreaQuery
.getDependencePkg(null, mi
);
601 // First look through MSA pcd entries.
603 List
<PcdCodedDocument
.PcdCoded
.PcdEntry
> l
= msa
.getPcdCoded().getPcdEntryList();
604 ListIterator li
= l
.listIterator();
605 while(li
.hasNext()) {
606 PcdCodedDocument
.PcdCoded
.PcdEntry msaPcd
= (PcdCodedDocument
.PcdCoded
.PcdEntry
)li
.next();
607 if (!msaPcd
.getCName().equals(cName
)) {
610 if (!msaPcd
.getTokenSpaceGuidCName().equals(tsGuid
)) {
613 PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry spdPcd
= LookupPcdDeclaration(msaPcd
, depPkgs
);
614 if (spdPcd
== null) {
618 throw new PcdDeclNotFound(mi
.getName() + " " + msaPcd
.getCName());
621 // Get Pcd help text and original item type.
623 sa
[0] = spdPcd
.getHelpText() + msaPcd
.getHelpText();
624 sa
[1] = msaPcd
.getPcdItemType()+"";
625 sa
[2] = msa
.getModuleDefinitions().getBinaryModule()+"";
639 /**Remove PCDBuildDefinition entries from ModuleSA
640 * @param moduleKey identifier of ModuleSA.
641 * @param consumer where these entries come from.
643 public void removePcdData(String moduleKey
, ModuleIdentification consumer
) {
645 ModuleSurfaceAreaDocument
.ModuleSurfaceArea msa
= (ModuleSurfaceAreaDocument
.ModuleSurfaceArea
)WorkspaceProfile
.getModuleXmlObject(consumer
);
646 if (msa
.getPcdCoded() == null) {
650 List
<PcdCodedDocument
.PcdCoded
.PcdEntry
> l
= msa
.getPcdCoded().getPcdEntryList();
651 ListIterator li
= l
.listIterator();
653 while(li
.hasNext()) {
654 PcdCodedDocument
.PcdCoded
.PcdEntry msaPcd
= (PcdCodedDocument
.PcdCoded
.PcdEntry
)li
.next();
655 ModuleSADocument
.ModuleSA moduleSA
= getModuleSA(moduleKey
);
656 if (moduleSA
.getPcdBuildDefinition() != null) {
657 XmlCursor cursor
= moduleSA
.getPcdBuildDefinition().newCursor();
658 if (cursor
.toFirstChild()) {
660 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= (PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
) cursor
662 if (msaPcd
.getCName().equals(pcdData
.getCName())
663 && msaPcd
.getTokenSpaceGuidCName().equals(pcdData
.getTokenSpaceGuidCName())) {
665 maintainDynPcdMap(pcdData
.getCName() + " " + pcdData
.getTokenSpaceGuidCName(),
670 } while (cursor
.toNextSibling());
683 // key for ModuleSA : "ModuleGuid ModuleVer PackageGuid PackageVer Arch"
685 public int getLibraryInstancesCount(String key
) {
686 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
687 if (msa
== null || msa
.getLibraries() == null || msa
.getLibraries().getInstanceList() == null){
690 return msa
.getLibraries().getInstanceList().size();
693 public void getLibraryInstances(String key
, String
[][] saa
){
694 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
695 if (msa
== null || msa
.getLibraries() == null || msa
.getLibraries().getInstanceList() == null){
699 ListIterator
<LibrariesDocument
.Libraries
.Instance
> li
= msa
.getLibraries().getInstanceList().listIterator();
700 for (int i
= 0; i
< saa
.length
; ++i
) {
701 LibrariesDocument
.Libraries
.Instance instance
= li
.next();
702 saa
[i
][1] = instance
.getModuleGuid();
703 saa
[i
][2] = instance
.getModuleVersion();
704 saa
[i
][3] = instance
.getPackageGuid();
705 saa
[i
][4] = instance
.getPackageVersion();
709 public void removeLibraryInstance(String key
, int i
) {
710 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
711 if (msa
== null || msa
.getLibraries() == null){
715 XmlCursor cursor
= msa
.getLibraries().newCursor();
716 if (cursor
.toFirstChild()) {
717 for (int j
= 0; j
< i
; ++j
) {
718 cursor
.toNextSibling();
721 cursor
.toPrevToken();
722 if (cursor
.isComment()) {
727 if (getLibraryInstancesCount(key
) == 0) {
736 public void genLibraryInstance(ModuleIdentification libMi
, String key
) {
737 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
739 msa
= getfpdFrameworkModules().addNewModuleSA();
741 LibrariesDocument
.Libraries libs
= msa
.getLibraries();
743 libs
= msa
.addNewLibraries();
746 String mn
= libMi
.getName();
747 String mg
= libMi
.getGuid();
748 String mv
= libMi
.getVersion();
749 String pn
= libMi
.getPackageId().getName();
750 String pg
= libMi
.getPackageId().getGuid();
751 String pv
= libMi
.getPackageId().getVersion();
752 LibrariesDocument
.Libraries
.Instance instance
= libs
.addNewInstance();
753 XmlCursor cursor
= instance
.newCursor();
755 String comment
= "Pkg: " + pn
+ " Mod: " + mn
756 + " Path: " + libMi
.getPath().substring(System
.getenv("WORKSPACE").length() + 1);
757 cursor
.insertComment(comment
);
766 instance
.setModuleGuid(mg
);
767 instance
.setModuleVersion(mv
);
768 instance
.setPackageGuid(pg
);
769 instance
.setPackageVersion(pv
);
773 public String
getFvBinding(String moduleKey
){
774 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(moduleKey
);
775 return getFvBinding (moduleSa
);
778 public String
getFvBinding (ModuleSADocument
.ModuleSA moduleSa
) {
779 if (moduleSa
== null || moduleSa
.getModuleSaBuildOptions() == null) {
782 return moduleSa
.getModuleSaBuildOptions().getFvBinding();
785 public void setFvBinding(ModuleSADocument
.ModuleSA moduleSa
, String fvBinding
) {
786 if (moduleSa
== null ) {
789 if (fvBinding
== null || fvBinding
.length() == 0) {
790 if(moduleSa
.getModuleSaBuildOptions() != null){
791 moduleSa
.getModuleSaBuildOptions().unsetFvBinding();
795 if(moduleSa
.getModuleSaBuildOptions() == null){
796 moduleSa
.addNewModuleSaBuildOptions().setFvBinding(fvBinding
);
799 moduleSa
.getModuleSaBuildOptions().setFvBinding(fvBinding
);
803 public void setFvBinding(String moduleKey
, String fvBinding
){
804 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(moduleKey
);
805 setFvBinding (moduleSa
, fvBinding
);
808 private int fvBindingForModuleSA (ModuleSADocument
.ModuleSA moduleSa
, String fvName
) {
809 if (moduleSa
== null || moduleSa
.getModuleSaBuildOptions() == null || moduleSa
.getModuleSaBuildOptions().getFvBinding() == null) {
813 String fvNameList
= moduleSa
.getModuleSaBuildOptions().getFvBinding();
814 String
[] fvNamesArray
= fvNameList
.split(" ");
816 for (int i
= 0; i
< fvNamesArray
.length
; ++i
) {
817 if (fvNamesArray
[i
].equals(fvName
)) {
825 public void removeFvBinding (ModuleSADocument
.ModuleSA moduleSa
, String fvName
) {
826 if (moduleSa
== null || moduleSa
.getModuleSaBuildOptions() == null || moduleSa
.getModuleSaBuildOptions().getFvBinding() == null) {
830 String fvNameList
= moduleSa
.getModuleSaBuildOptions().getFvBinding();
831 String
[] fvNamesArray
= fvNameList
.split(" ");
833 for (int i
= 0; i
< fvNamesArray
.length
; ++i
) {
834 if (fvNamesArray
[i
].equals(fvName
)) {
839 // jump over where the input fvName occurs in the original Fv list.
840 if (occursAt
!= -1) {
841 String newFvNameList
= " ";
842 for (int i
= 0; i
< fvNamesArray
.length
; ++i
) {
846 newFvNameList
+= fvNamesArray
[i
];
848 setFvBinding (moduleSa
, newFvNameList
.trim());
854 * @param fvName The FV name that to be removed from FvBinding List.
856 public void removeFvBindingAll (String fvName
) {
857 if (getfpdFrameworkModules().getModuleSAList() == null || getfpdFrameworkModules().getModuleSAList().size() == 0){
858 removeElement(getfpdFrameworkModules());
859 fpdFrameworkModules
= null;
863 Iterator
<ModuleSADocument
.ModuleSA
> li
= getfpdFrameworkModules().getModuleSAList().iterator();
864 while (li
.hasNext()) {
865 ModuleSADocument
.ModuleSA moduleSa
= li
.next();
866 removeFvBinding (moduleSa
, fvName
);
870 public void appendFvBindingAll (String fvName
) {
871 if (getfpdFrameworkModules().getModuleSAList() == null || getfpdFrameworkModules().getModuleSAList().size() == 0){
872 removeElement(getfpdFrameworkModules());
873 fpdFrameworkModules
= null;
877 Iterator
<ModuleSADocument
.ModuleSA
> li
= getfpdFrameworkModules().getModuleSAList().iterator();
878 while (li
.hasNext()) {
879 ModuleSADocument
.ModuleSA moduleSa
= li
.next();
880 appendFvBinding (moduleSa
, fvName
);
884 public void appendFvBindingFor (String oldFvName
, String newFvName
) {
885 if (getfpdFrameworkModules().getModuleSAList() == null || getfpdFrameworkModules().getModuleSAList().size() == 0){
886 removeElement(getfpdFrameworkModules());
887 fpdFrameworkModules
= null;
891 Iterator
<ModuleSADocument
.ModuleSA
> li
= getfpdFrameworkModules().getModuleSAList().iterator();
892 while (li
.hasNext()) {
893 ModuleSADocument
.ModuleSA moduleSa
= li
.next();
894 String fvBinding
= getFvBinding (moduleSa
);
895 if (fvBinding
!= null && fvBindingForModuleSA (moduleSa
, oldFvName
) >= 0) {
896 appendFvBinding (moduleSa
, newFvName
);
901 public void appendFvBinding (String moduleKey
, String fvName
) {
902 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(moduleKey
);
903 appendFvBinding (moduleSa
, fvName
);
906 public void appendFvBinding (ModuleSADocument
.ModuleSA moduleSa
, String fvName
) {
907 if (moduleSa
== null) {
911 if (moduleSa
.getModuleSaBuildOptions() == null || moduleSa
.getModuleSaBuildOptions().getFvBinding() == null) {
912 setFvBinding(moduleSa
, fvName
);
916 String fvNameList
= moduleSa
.getModuleSaBuildOptions().getFvBinding();
917 String newFvNameList
= fvNameList
+ " " + fvName
;
918 setFvBinding (moduleSa
, newFvNameList
.trim());
921 public void updateFvBindingInModuleSA (ModuleIdentification mi
, String fvName
) {
922 Vector
<Object
> vSupArchs
= new Vector
<Object
>();
923 getPlatformDefsSupportedArchs(vSupArchs
);
924 String moduleInfo
= mi
.getGuid() + " " + mi
.getVersion() + " " + mi
.getPackageId().getGuid() + " " + mi
.getPackageId().getVersion();
925 for (int i
= 0; i
< vSupArchs
.size(); ++i
) {
926 String moduleKey
= moduleInfo
+ " " + vSupArchs
.get(i
);
927 appendFvBinding (moduleKey
, fvName
);
931 public String
getFfsFileNameGuid(String moduleKey
){
932 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(moduleKey
);
933 if (moduleSa
== null || moduleSa
.getModuleSaBuildOptions() == null) {
936 return moduleSa
.getModuleSaBuildOptions().getFfsFileNameGuid();
939 public void setFfsFileNameGuid(String moduleKey
, String fileGuid
){
940 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
944 if(msa
.getModuleSaBuildOptions() == null){
945 msa
.addNewModuleSaBuildOptions();
948 ModuleSaBuildOptionsDocument
.ModuleSaBuildOptions msaBuildOpts
= msa
.getModuleSaBuildOptions();
949 if (fileGuid
!= null) {
950 msaBuildOpts
.setFfsFileNameGuid(fileGuid
);
953 XmlCursor cursor
= msaBuildOpts
.newCursor();
954 if (cursor
.toChild(xmlNs
, "FfsFileNameGuid")) {
962 public String
getFfsFormatKey(String moduleKey
){
963 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
964 if (msa
== null || msa
.getModuleSaBuildOptions() == null) {
967 return msa
.getModuleSaBuildOptions().getFfsFormatKey();
970 public void setFfsFormatKey(String moduleKey
, String ffsKey
){
971 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
975 if(msa
.getModuleSaBuildOptions() == null){
976 msa
.addNewModuleSaBuildOptions().setFfsFormatKey(ffsKey
);
979 msa
.getModuleSaBuildOptions().setFfsFormatKey(ffsKey
);
982 public void setModuleSAForceDebug(int i
, boolean dbgEnable
) {
983 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(i
);
984 moduleSa
.setForceDebug(dbgEnable
);
987 public boolean getModuleSAForceDebug (int i
) {
988 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(i
);
989 if (moduleSa
.getForceDebug() == true) {
995 public void getModuleSAOptions(String moduleKey
, String
[][] saa
) {
996 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
997 if (msa
== null || msa
.getModuleSaBuildOptions() == null || msa
.getModuleSaBuildOptions().getOptions() == null
998 || msa
.getModuleSaBuildOptions().getOptions().getOptionList() == null) {
1002 List
<OptionDocument
.Option
> lOpt
= msa
.getModuleSaBuildOptions().getOptions().getOptionList();
1003 ListIterator li
= lOpt
.listIterator();
1005 while(li
.hasNext()) {
1006 OptionDocument
.Option opt
= (OptionDocument
.Option
)li
.next();
1007 if (opt
.getBuildTargets() != null) {
1008 saa
[i
][0] = listToString(opt
.getBuildTargets());
1010 saa
[i
][1] = opt
.getToolChainFamily();
1011 saa
[i
][2] = opt
.getTagName();
1012 saa
[i
][3] = opt
.getToolCode();
1014 if (opt
.getSupArchList() != null){
1015 saa
[i
][4] = listToString(opt
.getSupArchList());
1021 saa
[i
][5] = opt
.getStringValue();
1027 public int getModuleSAOptionsCount(String moduleKey
){
1028 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
1029 if (msa
== null || msa
.getModuleSaBuildOptions() == null || msa
.getModuleSaBuildOptions().getOptions() == null
1030 || msa
.getModuleSaBuildOptions().getOptions().getOptionList() == null) {
1033 return msa
.getModuleSaBuildOptions().getOptions().getOptionList().size();
1036 public void genModuleSAOptionsOpt(String moduleKey
, Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
) {
1037 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
1038 if (msa
.getModuleSaBuildOptions() == null) {
1039 msa
.addNewModuleSaBuildOptions();
1041 if (msa
.getModuleSaBuildOptions().getOptions() == null){
1042 msa
.getModuleSaBuildOptions().addNewOptions();
1044 OptionDocument
.Option opt
= msa
.getModuleSaBuildOptions().getOptions().addNewOption();
1045 setBuildOptionsOpt(buildTargets
, toolChain
, tagName
, toolCmd
, archList
, contents
, opt
);
1048 public void removeModuleSAOptionsOpt(String moduleKey
, int i
) {
1049 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
1050 if (msa
.getModuleSaBuildOptions() == null || msa
.getModuleSaBuildOptions().getOptions() == null) {
1053 OptionsDocument
.Options opts
= msa
.getModuleSaBuildOptions().getOptions();
1054 XmlCursor cursor
= opts
.newCursor();
1055 if (cursor
.toFirstChild()) {
1056 for (int j
= 0; j
< i
; ++j
){
1057 cursor
.toNextSibling();
1064 public void updateModuleSAOptionsOpt(String moduleKey
, int i
, Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
) {
1065 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
1066 if (msa
.getModuleSaBuildOptions() == null || msa
.getModuleSaBuildOptions().getOptions() == null) {
1069 OptionsDocument
.Options opts
= msa
.getModuleSaBuildOptions().getOptions();
1070 XmlCursor cursor
= opts
.newCursor();
1071 if (cursor
.toFirstChild()) {
1072 for (int j
= 0; j
< i
; ++j
){
1073 cursor
.toNextSibling();
1075 OptionDocument
.Option opt
= (OptionDocument
.Option
)cursor
.getObject();
1076 setBuildOptionsOpt(buildTargets
, toolChain
, tagName
, toolCmd
, archList
, contents
, opt
);
1081 /**add pcd information of module mi to a ModuleSA.
1083 * @param moduleSa if null, generate a new ModuleSA.
1085 public void addFrameworkModulesPcdBuildDefs(ModuleIdentification mi
, String arch
, ModuleSADocument
.ModuleSA moduleSa
) throws Exception
{
1086 //ToDo add Arch filter
1089 if (moduleSa
== null) {
1090 moduleSa
= genModuleSA(mi
, arch
);
1093 ModuleSurfaceAreaDocument
.ModuleSurfaceArea msa
= (ModuleSurfaceAreaDocument
.ModuleSurfaceArea
)WorkspaceProfile
.getModuleXmlObject(mi
);
1094 if (msa
.getPcdCoded() == null) {
1098 Map
<String
, XmlObject
> m
= new HashMap
<String
, XmlObject
>();
1099 m
.put("ModuleSurfaceArea", msa
);
1100 SurfaceAreaQuery
.setDoc(m
);
1101 PackageIdentification
[] depPkgs
= SurfaceAreaQuery
.getDependencePkg(null, mi
);
1103 // Implementing InitializePlatformPcdBuildDefinitions
1105 List
<PcdCodedDocument
.PcdCoded
.PcdEntry
> l
= msa
.getPcdCoded().getPcdEntryList();
1106 ListIterator li
= l
.listIterator();
1107 while(li
.hasNext()) {
1108 PcdCodedDocument
.PcdCoded
.PcdEntry msaPcd
= (PcdCodedDocument
.PcdCoded
.PcdEntry
)li
.next();
1109 PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry spdPcd
= LookupPcdDeclaration(msaPcd
, depPkgs
);
1110 if (spdPcd
== null) {
1114 throw new PcdDeclNotFound("No Declaration for PCD Entry " + msaPcd
.getCName() + " in Module " + mi
.getName());
1117 // AddItem to ModuleSA PcdBuildDefinitions
1119 String defaultVal
= msaPcd
.getDefaultValue() == null ? spdPcd
.getDefaultValue() : msaPcd
.getDefaultValue();
1121 genPcdData(msaPcd
.getCName(), spdPcd
.getToken(), msaPcd
.getTokenSpaceGuidCName(), msaPcd
.getPcdItemType().toString(), spdPcd
.getDatumType()+"", defaultVal
, moduleSa
);
1125 catch (Exception e
){
1132 private PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry
LookupPcdDeclaration (PcdCodedDocument
.PcdCoded
.PcdEntry msaPcd
, PackageIdentification
[] depPkgs
) {
1134 PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry spdPcd
= null;
1135 for (int i
= 0; i
< depPkgs
.length
; ++i
) {
1137 XmlObject
[] xo
= SurfaceAreaQuery
.getSpdPcdDeclarations(depPkgs
[i
]);
1141 for (int j
= 0; j
< xo
.length
; ++j
) {
1142 spdPcd
= (PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry
)xo
[j
];
1143 if (msaPcd
.getTokenSpaceGuidCName() == null) {
1144 if (spdPcd
.getCName().equals(msaPcd
.getCName())) {
1149 if (spdPcd
.getCName().equals(msaPcd
.getCName()) && spdPcd
.getTokenSpaceGuidCName().equals(msaPcd
.getTokenSpaceGuidCName())) {
1160 private ModuleSADocument
.ModuleSA
genModuleSA (ModuleIdentification mi
, String arch
) {
1161 PackageIdentification pi
= WorkspaceProfile
.getPackageForModule(mi
);
1162 ModuleSADocument
.ModuleSA msa
= getfpdFrameworkModules().addNewModuleSA();
1163 XmlCursor cursor
= msa
.newCursor();
1165 String comment
= "Mod: " + mi
.getName() + " Type: " + SurfaceAreaQuery
.getModuleType(mi
) + " Path: "
1166 + mi
.getPath().substring(System
.getenv("WORKSPACE").length() + 1);
1167 cursor
.insertComment(comment
);
1170 e
.printStackTrace();
1175 msa
.setModuleGuid(mi
.getGuid());
1176 msa
.setModuleVersion(mi
.getVersion());
1177 msa
.setPackageGuid(pi
.getGuid());
1178 msa
.setPackageVersion(pi
.getVersion());
1180 Vector
<String
> v
= new Vector
<String
>();
1182 msa
.setSupArchList(v
);
1188 private void genPcdData (String cName
, Object token
, String tsGuid
, String itemType
, String dataType
, String defaultVal
, ModuleSADocument
.ModuleSA moduleSa
)
1189 throws PcdItemTypeConflictException
, PcdValueMalFormed
{
1190 if (moduleSa
.getPcdBuildDefinition() == null){
1191 moduleSa
.addNewPcdBuildDefinition();
1194 // constructe pcd to modulesa mapping first.
1195 // Attention : for any error condition, remove from map this pcd.
1197 ArrayList
<String
> pcdConsumer
= LookupPlatformPcdData(cName
+ " " + tsGuid
);
1198 if (pcdConsumer
== null) {
1199 pcdConsumer
= new ArrayList
<String
>();
1202 // Using existing Pcd type, if this pcd already exists in other ModuleSA
1204 if (pcdConsumer
.size() > 0) {
1206 itemType
= itemType (pcdConsumer
.get(0));
1208 String listValue
= moduleSa
.getModuleGuid() + " " + moduleSa
.getModuleVersion()
1209 + " " + moduleSa
.getPackageGuid() + " " + moduleSa
.getPackageVersion() + " " + listToString(moduleSa
.getSupArchList())
1211 pcdConsumer
.add(listValue
);
1212 dynPcdMap
.put(cName
+ " " + tsGuid
, pcdConsumer
);
1214 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData fpdPcd
= moduleSa
.getPcdBuildDefinition().addNewPcdData();
1215 fpdPcd
.setCName(cName
);
1216 fpdPcd
.setToken(token
);
1217 fpdPcd
.setTokenSpaceGuidCName(tsGuid
);
1218 fpdPcd
.setDatumType(PcdDataTypes
.Enum
.forString(dataType
));
1219 fpdPcd
.setItemType(PcdItemTypes
.Enum
.forString(itemType
));
1221 if (defaultVal
!= null){
1222 fpdPcd
.setValue(defaultVal
);
1225 if (dataType
.equals("UINT8") || dataType
.equals("UINT16") || dataType
.equals("UINT32") || dataType
.equals("UINT64")) {
1226 fpdPcd
.setValue("0");
1228 if (dataType
.equals("BOOLEAN")){
1229 fpdPcd
.setValue("FALSE");
1231 if (dataType
.equals("VOID*")) {
1232 fpdPcd
.setValue("");
1236 // Using existing pcd value, if this pcd already exists in other moduleSa.
1238 if (defaultPcdValue
.get(cName
+ " " + tsGuid
) == null) {
1239 defaultPcdValue
.put(cName
+ " " + tsGuid
, fpdPcd
.getValue());
1242 fpdPcd
.setValue(defaultPcdValue
.get(cName
+ " " + tsGuid
));
1245 if (dataType
.equals("UINT8")){
1246 fpdPcd
.setMaxDatumSize(1);
1248 if (dataType
.equals("UINT16")) {
1249 fpdPcd
.setMaxDatumSize(2);
1251 if (dataType
.equals("UINT32")) {
1252 fpdPcd
.setMaxDatumSize(4);
1254 if (dataType
.equals("UINT64")){
1255 fpdPcd
.setMaxDatumSize(8);
1257 if (dataType
.equals("BOOLEAN")){
1258 fpdPcd
.setMaxDatumSize(1);
1260 if (dataType
.equals("VOID*")) {
1261 int maxSize
= setMaxSizeForPointer(fpdPcd
.getValue());
1262 fpdPcd
.setMaxDatumSize(maxSize
);
1266 if (itemType
.equals("DYNAMIC") || itemType
.equals("DYNAMIC_EX")) {
1267 ArrayList
<String
> al
= LookupDynamicPcdBuildDefinition(cName
+ " " + tsGuid
);
1269 // if only one module mapped to this pcd, then the one is myself. so no other module mapped.
1270 // so need to add one dyn pcd.
1272 if (al
.size() == 1) {
1273 addDynamicPcdBuildData(cName
, token
, tsGuid
, itemType
, dataType
, defaultVal
);
1279 public int setMaxSizeForPointer(String datum
) throws PcdValueMalFormed
{
1280 if (datum
== null) {
1283 char ch
= datum
.charAt(0);
1287 // For void* type PCD, only three datum is support:
1288 // 1) Unicode: string with start char is "L"
1289 // 2) Ansci: String is ""
1290 // 3) byte array: String start char "{"
1293 start
= datum
.indexOf('\"');
1294 end
= datum
.lastIndexOf('\"');
1295 if ((start
> end
) ||
1296 (end
> datum
.length())||
1297 ((start
== end
) && (datum
.length() > 0))) {
1298 //ToDo Error handling here
1299 throw new PcdValueMalFormed (datum
);
1302 strValue
= datum
.substring(start
+ 1, end
);
1303 return strValue
.length() * 2;
1304 } else if (ch
== '\"'){
1305 start
= datum
.indexOf('\"');
1306 end
= datum
.lastIndexOf('\"');
1307 if ((start
> end
) ||
1308 (end
> datum
.length())||
1309 ((start
== end
) && (datum
.length() > 0))) {
1310 throw new PcdValueMalFormed (datum
);
1312 strValue
= datum
.substring(start
+ 1, end
);
1313 return strValue
.length();
1314 } else if (ch
=='{') {
1315 String
[] strValueArray
;
1317 start
= datum
.indexOf('{');
1318 end
= datum
.lastIndexOf('}');
1319 strValue
= datum
.substring(start
+ 1, end
);
1320 strValue
= strValue
.trim();
1321 if (strValue
.length() == 0) {
1324 strValueArray
= strValue
.split(",");
1325 for (int index
= 0; index
< strValueArray
.length
; index
++) {
1326 Integer value
= Integer
.decode(strValueArray
[index
].trim());
1329 // "[FPD file error] The datum type of PCD %s in %s is VOID*, "+
1330 // "it must be a byte array. But the element of %s exceed the byte range",
1331 throw new PcdValueMalFormed (datum
);
1334 return strValueArray
.length
;
1338 // "[FPD file error] The datum type of PCD %s in %s is VOID*. For VOID* type, you have three format choise:\n "+
1339 // "1) UNICODE string: like L\"xxxx\";\r\n"+
1340 // "2) ANSIC string: like \"xxx\";\r\n"+
1341 // "3) Byte array: like {0x2, 0x45, 0x23}\r\n"+
1342 // "but the datum in seems does not following above format!",
1343 throw new PcdValueMalFormed (datum
);
1348 private ArrayList
<String
> LookupDynamicPcdBuildDefinition(String dynPcdKey
) {
1349 ArrayList
<String
> al
= dynPcdMap
.get(dynPcdKey
);
1354 private ArrayList
<String
> LookupPlatformPcdData(String pcdKey
) {
1356 return dynPcdMap
.get(pcdKey
);
1359 public int getDynamicPcdBuildDataCount() {
1360 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1361 removeElement(getfpdDynPcdBuildDefs());
1362 fpdDynPcdBuildDefs
= null;
1365 return getfpdDynPcdBuildDefs().getPcdBuildDataList().size();
1368 public void getDynamicPcdBuildData(String
[][] saa
) {
1369 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1370 removeElement(getfpdDynPcdBuildDefs());
1371 fpdDynPcdBuildDefs
= null;
1374 List
<DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
> l
= getfpdDynPcdBuildDefs().getPcdBuildDataList();
1375 ListIterator
<DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
> li
= l
.listIterator();
1377 while(li
.hasNext()) {
1378 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData dynPcd
= li
.next();
1379 saa
[i
][0] = dynPcd
.getCName();
1380 saa
[i
][1] = dynPcd
.getToken().toString();
1381 saa
[i
][2] = dynPcd
.getTokenSpaceGuidCName();
1382 saa
[i
][3] = dynPcd
.getMaxDatumSize()+"";
1383 saa
[i
][4] = dynPcd
.getDatumType().toString();
1389 public void addDynamicPcdBuildData(String cName
, Object token
, String tsGuid
, String itemType
, String dataType
, String defaultVal
)
1390 throws PcdValueMalFormed
{
1391 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData dynPcdData
= getfpdDynPcdBuildDefs().addNewPcdBuildData();
1392 dynPcdData
.setItemType(PcdItemTypes
.Enum
.forString(itemType
));
1393 dynPcdData
.setCName(cName
);
1394 dynPcdData
.setToken(token
);
1395 dynPcdData
.setTokenSpaceGuidCName(tsGuid
);
1396 dynPcdData
.setDatumType(PcdDataTypes
.Enum
.forString(dataType
));
1398 BigInteger bigInt
= new BigInteger("0");
1399 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo skuInfo
= dynPcdData
.addNewSkuInfo();
1400 skuInfo
.setSkuId(bigInt
);
1401 if (defaultVal
!= null){
1402 skuInfo
.setValue(defaultVal
);
1405 if (dataType
.equals("UINT8")){
1406 skuInfo
.setValue("0");
1408 if (dataType
.equals("UINT16")) {
1409 skuInfo
.setValue("0");
1411 if (dataType
.equals("UINT32")) {
1412 skuInfo
.setValue("0");
1414 if (dataType
.equals("UINT64")){
1415 skuInfo
.setValue("0");
1417 if (dataType
.equals("BOOLEAN")){
1418 skuInfo
.setValue("false");
1420 if (dataType
.equals("VOID*")) {
1421 skuInfo
.setValue("");
1424 if (dataType
.equals("UINT8")){
1425 dynPcdData
.setMaxDatumSize(1);
1427 if (dataType
.equals("UINT16")) {
1428 dynPcdData
.setMaxDatumSize(2);
1430 if (dataType
.equals("UINT32")) {
1431 dynPcdData
.setMaxDatumSize(4);
1433 if (dataType
.equals("UINT64")){
1434 dynPcdData
.setMaxDatumSize(8);
1436 if (dataType
.equals("BOOLEAN")){
1437 dynPcdData
.setMaxDatumSize(1);
1439 if (dataType
.equals("VOID*")) {
1440 int maxSize
= setMaxSizeForPointer(defaultVal
);
1441 dynPcdData
.setMaxDatumSize(maxSize
);
1445 public void removeDynamicPcdBuildData(String cName
, String tsGuid
) {
1446 XmlObject o
= fpdRoot
.getDynamicPcdBuildDefinitions();
1451 XmlCursor cursor
= o
.newCursor();
1452 if (cursor
.toFirstChild()) {
1454 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdBuildData
=
1455 (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1456 if (pcdBuildData
.getCName().equals(cName
) && pcdBuildData
.getTokenSpaceGuidCName().equals(tsGuid
)) {
1458 if (getDynamicPcdBuildDataCount() == 1) {
1466 while (cursor
.toNextSibling());
1471 // Get the Sku Info count of ith dyn pcd element.
1473 public int getDynamicPcdSkuInfoCount(int i
){
1474 if (fpdRoot
.getDynamicPcdBuildDefinitions() == null || fpdRoot
.getDynamicPcdBuildDefinitions().getPcdBuildDataList() == null
1475 || fpdRoot
.getDynamicPcdBuildDefinitions().getPcdBuildDataList().size() == 0) {
1479 int skuInfoCount
= 0;
1480 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1481 if (cursor
.toFirstChild()) {
1482 for (int j
= 0; j
< i
; ++j
) {
1483 cursor
.toNextSibling();
1485 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1486 if (pcdData
.getSkuInfoList() == null) {
1490 skuInfoCount
= pcdData
.getSkuInfoList().size();
1494 return skuInfoCount
;
1497 public void getDynamicPcdSkuInfos(int i
, String
[][] saa
){
1498 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1499 removeElement(getfpdDynPcdBuildDefs());
1500 fpdDynPcdBuildDefs
= null;
1504 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1505 if (cursor
.toFirstChild()) {
1506 for (int j
= 0; j
< i
; ++j
) {
1507 cursor
.toNextSibling();
1509 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1510 if (pcdData
.getSkuInfoList() == null) {
1515 ListIterator
<DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo
> li
= pcdData
.getSkuInfoList().listIterator();
1517 while (li
.hasNext()) {
1518 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo skuInfo
= li
.next();
1519 saa
[k
][0] = skuInfo
.getSkuId()+"";
1520 saa
[k
][1] = skuInfo
.getVariableName();
1521 saa
[k
][2] = skuInfo
.getVariableGuid();
1522 saa
[k
][3] = skuInfo
.getVariableOffset();
1523 saa
[k
][4] = skuInfo
.getHiiDefaultValue();
1524 saa
[k
][5] = skuInfo
.getVpdOffset();
1525 saa
[k
][6] = skuInfo
.getValue();
1535 public String
getDynamicPcdBuildDataValue(int i
){
1536 String value
= null;
1537 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1538 removeElement(getfpdDynPcdBuildDefs());
1539 fpdDynPcdBuildDefs
= null;
1543 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1544 if (cursor
.toFirstChild()) {
1545 for (int j
= 0; j
< i
; ++j
) {
1546 cursor
.toNextSibling();
1548 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1549 if (pcdData
.getSkuInfoList() == null) {
1553 value
= pcdData
.getSkuInfoArray(0).getValue();
1560 public String
getDynamicPcdBuildDataVpdOffset(int i
){
1561 String vpdOffset
= null;
1562 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1563 removeElement(getfpdDynPcdBuildDefs());
1564 fpdDynPcdBuildDefs
= null;
1568 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1569 if (cursor
.toFirstChild()) {
1570 for (int j
= 0; j
< i
; ++j
) {
1571 cursor
.toNextSibling();
1573 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1574 if (pcdData
.getSkuInfoList() == null) {
1578 vpdOffset
= pcdData
.getSkuInfoArray(0).getVpdOffset();
1585 public void removeDynamicPcdBuildDataSkuInfo(int i
) {
1586 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1587 removeElement(getfpdDynPcdBuildDefs());
1588 fpdDynPcdBuildDefs
= null;
1592 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1593 if (cursor
.toFirstChild()) {
1594 for (int j
= 0; j
< i
; ++j
) {
1595 cursor
.toNextSibling();
1597 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1598 if (pcdData
.getSkuInfoList() == null) {
1603 QName qSkuInfo
= new QName(xmlNs
, "SkuInfo");
1604 cursor
.toChild(qSkuInfo
);
1611 // generate sku info for ith dyn pcd build data.
1613 public void genDynamicPcdBuildDataSkuInfo(String id
, String varName
, String varGuid
, String varOffset
,
1614 String hiiDefault
, String vpdOffset
, String value
, int i
) {
1615 // if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1619 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1620 if (cursor
.toFirstChild()) {
1621 for (int j
= 0; j
< i
; ++j
) {
1622 cursor
.toNextSibling();
1624 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1625 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo skuInfo
= pcdData
.addNewSkuInfo();
1626 skuInfo
.setSkuId(new BigInteger(id
));
1627 if (varName
!= null){
1628 skuInfo
.setVariableName(varName
);
1629 skuInfo
.setVariableGuid(varGuid
);
1630 skuInfo
.setVariableOffset(varOffset
);
1631 skuInfo
.setHiiDefaultValue(hiiDefault
);
1633 else if (vpdOffset
!= null){
1634 skuInfo
.setVpdOffset(vpdOffset
);
1637 skuInfo
.setValue(value
);
1642 public void updateDynamicPcdBuildDataSkuInfo(String id
, String varName
, String varGuid
, String varOffset
,
1643 String hiiDefault
, String vpdOffset
, String value
, int i
){
1644 // if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1648 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1649 if (cursor
.toFirstChild()) {
1650 for (int j
= 0; j
< i
; ++j
) {
1651 cursor
.toNextSibling();
1653 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1654 ListIterator
<DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo
> li
= pcdData
.getSkuInfoList().listIterator();
1655 while (li
.hasNext()) {
1656 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo skuInfo
= li
.next();
1657 if (skuInfo
.getSkuId().toString().equals(id
)){
1658 if (varName
!= null){
1659 skuInfo
.setVariableName(varName
);
1660 skuInfo
.setVariableGuid(varGuid
);
1661 skuInfo
.setVariableOffset(varOffset
);
1662 skuInfo
.setHiiDefaultValue(hiiDefault
);
1664 else if (vpdOffset
!= null){
1665 skuInfo
.setVpdOffset(vpdOffset
);
1668 skuInfo
.setValue(value
);
1676 public BuildOptionsDocument
.BuildOptions
getfpdBuildOpts() {
1677 if (fpdBuildOpts
== null) {
1678 fpdBuildOpts
= fpdRoot
.addNewBuildOptions();
1680 return fpdBuildOpts
;
1683 public void genBuildOptionsUserExtensions(String fvName
, String outputFileName
, Vector
<String
[]> includeModules
) {
1684 QName elementFvName
= new QName (xmlNs
, "FvName");
1685 QName elementIncludeModules
= new QName(xmlNs
, "IncludeModules");
1686 QName elementInfFileName
= new QName(xmlNs
, "InfFileName");
1687 QName elementModule
= new QName(xmlNs
, "Module");
1689 UserExtensionsDocument
.UserExtensions userExts
= getfpdBuildOpts().addNewUserExtensions();
1690 userExts
.setUserID("IMAGES");
1691 userExts
.setIdentifier(new BigInteger("1"));
1692 XmlCursor cursor
= userExts
.newCursor();
1693 cursor
.toEndToken();
1695 cursor
.beginElement(elementFvName
);
1696 cursor
.insertChars(fvName
);
1697 cursor
.toNextToken();
1699 cursor
.beginElement(elementInfFileName
);
1700 cursor
.insertChars(fvName
+ ".inf");
1701 cursor
.toNextToken();
1703 cursor
.beginElement(elementIncludeModules
);
1704 for (int i
= 0; i
< includeModules
.size(); ++i
) {
1705 cursor
.beginElement(elementModule
);
1706 cursor
.insertAttributeWithValue("ModuleGuid", includeModules
.get(i
)[0]);
1707 cursor
.insertAttributeWithValue("BaseName", includeModules
.get(i
)[1]);
1708 cursor
.toEndToken();
1709 cursor
.toNextToken();
1714 public int getUserExtsIncModCount (String fvName
) {
1715 if (getfpdBuildOpts().getUserExtensionsList() == null) {
1718 ListIterator
<UserExtensionsDocument
.UserExtensions
> li
= getfpdBuildOpts().getUserExtensionsList().listIterator();
1719 QName elementIncludeModules
= new QName(xmlNs
, "IncludeModules");
1720 while (li
.hasNext()) {
1721 UserExtensionsDocument
.UserExtensions ues
= li
.next();
1722 if (!ues
.getUserID().equals("IMAGES")) {
1725 XmlCursor cursor
= ues
.newCursor();
1726 cursor
.toFirstChild();
1727 String elementName
= cursor
.getTextValue();
1728 if (elementName
.equals(fvName
)) {
1729 cursor
.toNextSibling(elementIncludeModules
);
1730 if (cursor
.toFirstChild()) {
1732 for (i
= 1; cursor
.toNextSibling(); ++i
);
1744 public void getUserExtsIncMods(String fvName
, String
[][] saa
) {
1745 if (getfpdBuildOpts().getUserExtensionsList() == null) {
1749 XmlCursor cursor
= getfpdBuildOpts().newCursor();
1750 QName elementUserExts
= new QName (xmlNs
, "UserExtensions");
1751 QName attribUserId
= new QName ("UserID");
1752 QName elementFvName
= new QName (xmlNs
, "FvName");
1753 QName elementIncludeModules
= new QName(xmlNs
, "IncludeModules");
1754 QName attribModuleGuid
= new QName("ModuleGuid");
1755 QName attribBaseName
= new QName("BaseName");
1757 if (cursor
.toChild(elementUserExts
)) {
1760 if (cursor
.getAttributeText(attribUserId
).equals("IMAGES")) {
1761 cursor
.toChild(elementFvName
);
1762 String elementName
= cursor
.getTextValue();
1763 if (elementName
.equals(fvName
)) {
1764 cursor
.toNextSibling(elementIncludeModules
);
1765 if (cursor
.toFirstChild()) {
1768 saa
[i
][0] = cursor
.getAttributeText(attribModuleGuid
);
1769 saa
[i
][1] = cursor
.getAttributeText(attribBaseName
);
1771 }while (cursor
.toNextSibling());
1777 }while (cursor
.toNextSibling(elementUserExts
));
1783 public void updateBuildOptionsUserExtensions (String oldFvName
, String newFvName
) {
1784 if (getfpdBuildOpts().getUserExtensionsList() == null) {
1787 ListIterator
<UserExtensionsDocument
.UserExtensions
> li
= getfpdBuildOpts().getUserExtensionsList().listIterator();
1788 while (li
.hasNext()) {
1789 UserExtensionsDocument
.UserExtensions ues
= li
.next();
1790 if (!ues
.getUserID().equals("IMAGES")) {
1793 XmlCursor cursor
= ues
.newCursor();
1794 cursor
.toFirstChild();
1795 String elementName
= cursor
.getTextValue();
1796 if (elementName
.equals(oldFvName
)) {
1797 cursor
.setTextValue(newFvName
);
1804 public void removeBuildOptionsUserExtensions (String fvName
) {
1805 if (getfpdBuildOpts().getUserExtensionsList() == null) {
1809 ListIterator
<UserExtensionsDocument
.UserExtensions
> li
= getfpdBuildOpts().getUserExtensionsList().listIterator();
1810 while (li
.hasNext()) {
1811 UserExtensionsDocument
.UserExtensions ues
= li
.next();
1812 if (!ues
.getUserID().equals("IMAGES")) {
1815 XmlCursor cursor
= ues
.newCursor();
1816 cursor
.toFirstChild();
1817 String elementName
= cursor
.getTextValue();
1818 if (elementName
.equals(fvName
)) {
1830 public void genBuildOptionsUserDefAntTask (String id
, String fileName
, String execOrder
) {
1831 UserDefinedAntTasksDocument
.UserDefinedAntTasks udats
= getfpdBuildOpts().getUserDefinedAntTasks();
1832 if (udats
== null) {
1833 udats
= getfpdBuildOpts().addNewUserDefinedAntTasks();
1836 AntTaskDocument
.AntTask at
= udats
.addNewAntTask();
1837 setBuildOptionsUserDefAntTask(id
, fileName
, execOrder
, at
);
1840 private void setBuildOptionsUserDefAntTask(String id
, String fileName
, String execOrder
, AntTaskDocument
.AntTask at
) {
1841 at
.setId(new Integer(id
));
1842 XmlCursor cursor
= at
.newCursor();
1843 if (fileName
!= null){
1844 at
.setFilename(fileName
);
1846 else if (cursor
.toChild(xmlNs
, "Filename")) {
1849 if (execOrder
!= null) {
1850 at
.setAntCmdOptions(execOrder
);
1852 else if (cursor
.toChild(xmlNs
, "AntCmdOptions")) {
1858 public void removeBuildOptionsUserDefAntTask(int i
) {
1859 XmlObject o
= getfpdBuildOpts().getUserDefinedAntTasks();
1863 XmlCursor cursor
= o
.newCursor();
1864 if (cursor
.toFirstChild()) {
1865 for (int j
= 0; j
< i
; ++j
) {
1866 cursor
.toNextSibling();
1869 if (getBuildOptionsUserDefAntTaskCount() == 0) {
1877 public void updateBuildOptionsUserDefAntTask(int i
, String id
, String fileName
, String execOrder
){
1878 XmlObject o
= getfpdBuildOpts().getUserDefinedAntTasks();
1882 XmlCursor cursor
= o
.newCursor();
1883 if (cursor
.toFirstChild()) {
1884 for (int j
= 0; j
< i
; ++j
) {
1885 cursor
.toNextSibling();
1887 AntTaskDocument
.AntTask at
= (AntTaskDocument
.AntTask
)cursor
.getObject();
1888 setBuildOptionsUserDefAntTask(id
, fileName
, execOrder
, at
);
1893 public int getBuildOptionsUserDefAntTaskCount() {
1894 UserDefinedAntTasksDocument
.UserDefinedAntTasks udats
= getfpdBuildOpts().getUserDefinedAntTasks();
1895 if (udats
== null || udats
.getAntTaskList() == null) {
1899 return udats
.getAntTaskList().size();
1902 public void getBuildOptionsUserDefAntTasks(String
[][] saa
) {
1903 UserDefinedAntTasksDocument
.UserDefinedAntTasks udats
= getfpdBuildOpts().getUserDefinedAntTasks();
1904 if (udats
== null || udats
.getAntTaskList() == null) {
1908 List
<AntTaskDocument
.AntTask
> l
= udats
.getAntTaskList();
1909 ListIterator li
= l
.listIterator();
1911 while (li
.hasNext()) {
1912 AntTaskDocument
.AntTask at
= (AntTaskDocument
.AntTask
)li
.next();
1913 saa
[i
][0] = at
.getId() + "";
1914 saa
[i
][1] = saa
[i
][2] = "";
1915 if (at
.getFilename() != null){
1916 saa
[i
][1] = at
.getFilename();
1918 if (at
.getAntCmdOptions() != null) {
1919 saa
[i
][2] = at
.getAntCmdOptions();
1924 public void genBuildOptionsOpt(Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
) {
1925 OptionsDocument
.Options opts
= getfpdBuildOpts().getOptions();
1927 opts
= getfpdBuildOpts().addNewOptions();
1929 OptionDocument
.Option opt
= opts
.addNewOption();
1930 setBuildOptionsOpt(buildTargets
, toolChain
, tagName
, toolCmd
, archList
, contents
, opt
);
1933 private void setBuildOptionsOpt(Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
, OptionDocument
.Option opt
){
1934 opt
.setStringValue(contents
);
1936 opt
.setBuildTargets(buildTargets
);
1937 opt
.setToolChainFamily(toolChain
);
1938 opt
.setTagName(tagName
);
1939 opt
.setToolCode(toolCmd
);
1941 if (archList
!= null) {
1942 opt
.setSupArchList(archList
);
1945 if (opt
.isSetSupArchList()) {
1946 opt
.unsetSupArchList();
1951 public void removeBuildOptionsOpt(int i
){
1953 XmlObject o
= getfpdBuildOpts().getOptions();
1958 XmlCursor cursor
= o
.newCursor();
1959 if (cursor
.toFirstChild()) {
1960 for (int j
= 0; j
< i
; ++j
) {
1961 cursor
.toNextSibling();
1964 if (getBuildOptionsOptCount() == 0) {
1972 public void updateBuildOptionsOpt(int i
, Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
) {
1973 XmlObject o
= getfpdBuildOpts().getOptions();
1978 XmlCursor cursor
= o
.newCursor();
1979 if (cursor
.toFirstChild()) {
1980 for (int j
= 0; j
< i
; ++j
) {
1981 cursor
.toNextSibling();
1983 OptionDocument
.Option opt
= (OptionDocument
.Option
)cursor
.getObject();
1984 setBuildOptionsOpt(buildTargets
, toolChain
, tagName
, toolCmd
, archList
, contents
, opt
);
1989 public int getBuildOptionsOptCount(){
1990 if (getfpdBuildOpts().getOptions() == null || getfpdBuildOpts().getOptions().getOptionList() == null) {
1993 return getfpdBuildOpts().getOptions().getOptionList().size();
1996 public void getBuildOptionsOpts(String
[][] saa
) {
1997 if (getfpdBuildOpts().getOptions() == null || getfpdBuildOpts().getOptions().getOptionList() == null) {
2001 List
<OptionDocument
.Option
> lOpt
= getfpdBuildOpts().getOptions().getOptionList();
2002 ListIterator li
= lOpt
.listIterator();
2004 while(li
.hasNext()) {
2005 OptionDocument
.Option opt
= (OptionDocument
.Option
)li
.next();
2006 if (opt
.getBuildTargets() != null) {
2007 saa
[i
][0] = listToString(opt
.getBuildTargets());
2009 saa
[i
][1] = opt
.getToolChainFamily();
2010 if (opt
.getSupArchList() != null){
2011 saa
[i
][2] = listToString(opt
.getSupArchList());
2014 saa
[i
][3] = opt
.getToolCode();
2015 saa
[i
][4] = opt
.getTagName();
2016 saa
[i
][5] = opt
.getStringValue();
2022 public void genBuildOptionsFfs(String ffsKey
, String type
) {
2023 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getfpdBuildOpts().addNewFfs();
2024 ffs
.setFfsKey(ffsKey
);
2026 ffs
.addNewSections().setEncapsulationType(type
);
2030 public void updateBuildOptionsFfsSectionsType(int i
, String type
) {
2031 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getfpdBuildOpts().addNewFfs();
2033 ffs
.addNewSections().setEncapsulationType(type
);
2037 public void genBuildOptionsFfsAttribute(int i
, String name
, String value
) {
2038 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2039 BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute attrib
= ffs
.addNewAttribute();
2040 attrib
.setName(name
);
2041 attrib
.setValue(value
);
2044 /**update jth attribute of ith ffs.
2048 public void updateBuildOptionsFfsAttribute(int i
, int j
, String name
, String value
){
2049 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2050 XmlCursor cursor
= ffs
.newCursor();
2051 QName qAttrib
= new QName(xmlNs
, "Attribute");
2052 if (cursor
.toChild(qAttrib
)) {
2053 for (int k
= 0; k
< j
; ++k
) {
2054 cursor
.toNextSibling(qAttrib
);
2056 BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute attrib
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute
)cursor
.getObject();
2057 attrib
.setName(name
);
2058 attrib
.setValue(value
);
2063 public void removeBuildOptionsFfsAttribute(int i
, int j
){
2064 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2065 XmlCursor cursor
= ffs
.newCursor();
2066 QName qAttrib
= new QName(xmlNs
, "Attribute");
2067 if (cursor
.toChild(qAttrib
)) {
2068 for (int k
= 0; k
< j
; ++k
) {
2069 cursor
.toNextSibling(qAttrib
);
2076 public void genBuildOptionsFfsSectionsSection(int i
, String sectionType
) {
2077 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2081 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2083 if (sections
== null){
2084 sections
= ffs
.addNewSections();
2086 sections
.addNewSection().setSectionType(EfiSectionType
.Enum
.forString(sectionType
));
2089 public void removeBuildOptionsFfsSectionsSection(int i
, int j
) {
2090 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2091 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2092 if (sections
== null) {
2095 XmlCursor cursor
= sections
.newCursor();
2096 QName qSection
= new QName(xmlNs
, "Section");
2097 if (cursor
.toChild(qSection
)) {
2098 for (int k
= 0; k
< j
; ++k
) {
2099 cursor
.toNextSibling(qSection
);
2106 public void updateBuildOptionsFfsSectionsSection(int i
, int j
, String type
){
2107 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2108 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2109 if (sections
== null) {
2112 XmlCursor cursor
= sections
.newCursor();
2113 QName qSection
= new QName(xmlNs
, "Section");
2114 if (cursor
.toChild(qSection
)) {
2115 for (int k
= 0; k
< j
; ++k
) {
2116 cursor
.toNextSibling(qSection
);
2118 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Section section
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Section
)cursor
.getObject();
2119 section
.setSectionType(EfiSectionType
.Enum
.forString(type
));
2124 public void genBuildOptionsFfsSectionsSections(int i
, String encapType
) {
2125 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2129 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2131 if (sections
== null){
2132 sections
= ffs
.addNewSections();
2134 sections
.addNewSections().setEncapsulationType(encapType
);
2137 public void removeBuildOptionsFfsSectionsSections(int i
, int j
) {
2138 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2139 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2140 if (sections
== null) {
2143 XmlCursor cursor
= sections
.newCursor();
2144 QName qSections
= new QName(xmlNs
, "Sections");
2145 if (cursor
.toChild(qSections
)) {
2146 for (int k
= 0; k
< j
; ++k
) {
2147 cursor
.toNextSibling(qSections
);
2154 public void updateBuildOptionsFfsSectionsSections(int i
, int j
, String type
) {
2155 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2156 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2157 if (sections
== null) {
2160 XmlCursor cursor
= sections
.newCursor();
2161 QName qSections
= new QName(xmlNs
, "Sections");
2162 if (cursor
.toChild(qSections
)) {
2163 for (int k
= 0; k
< j
; ++k
) {
2164 cursor
.toNextSibling(qSections
);
2166 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2 sections2
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
)cursor
.getObject();
2167 sections2
.setEncapsulationType(type
);
2172 public void genBuildOptionsFfsSectionsSectionsSection(int i
, int j
, String type
) {
2173 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2177 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2178 XmlCursor cursor
= sections
.newCursor();
2179 QName qSections
= new QName(xmlNs
, "Sections");
2180 if (cursor
.toChild(qSections
)){
2181 for (int k
= 0; k
< j
; ++k
) {
2182 cursor
.toNextSibling(qSections
);
2184 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2 sections2
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
)cursor
.getObject();
2185 sections2
.addNewSection().setSectionType(EfiSectionType
.Enum
.forString(type
));
2190 public void removeBuildOptionsFfsSectionsSectionsSection(int i
, int j
, int k
) {
2191 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2192 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2193 if (sections
== null) {
2196 XmlCursor cursor
= sections
.newCursor();
2197 QName qSections
= new QName(xmlNs
, "Sections");
2198 if (cursor
.toChild(qSections
)) {
2199 for (int l
= 0; l
< j
; ++l
) {
2200 cursor
.toNextSibling(qSections
);
2202 if (cursor
.toFirstChild()) {
2204 for (; m
< k
; ++m
) {
2205 cursor
.toNextSibling();
2217 public void updateBuildOptionsFfsSectionsSectionsSection(int i
, int j
, int k
, String type
) {
2218 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2219 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2220 if (sections
== null) {
2223 XmlCursor cursor
= sections
.newCursor();
2224 QName qSections
= new QName(xmlNs
, "Sections");
2225 if (cursor
.toChild(qSections
)) {
2226 for (int l
= 0; l
< j
; ++l
) {
2227 cursor
.toNextSibling(qSections
);
2229 if (cursor
.toFirstChild()) {
2230 for (int m
= 0; m
< k
; ++m
) {
2231 cursor
.toNextSibling();
2233 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section section
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section
)cursor
.getObject();
2234 section
.setSectionType(EfiSectionType
.Enum
.forString(type
));
2240 public void getBuildOptionsFfsSectionsSectionsSection(int i
, int j
, ArrayList
<String
> al
) {
2241 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2245 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2246 XmlCursor cursor
= sections
.newCursor();
2247 QName qSections
= new QName(xmlNs
, "Sections");
2248 if (cursor
.toChild(qSections
)){
2249 for (int k
= 0; k
< j
; ++k
) {
2250 cursor
.toNextSibling(qSections
);
2252 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2 sections2
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
)cursor
.getObject();
2253 if (sections2
.getSectionList() == null){
2257 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section
> li
= sections2
.getSectionList().listIterator();
2258 while(li
.hasNext()) {
2259 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section section
= li
.next();
2260 if (section
.isSetSectionType()) {
2261 al
.add(section
.getSectionType().toString());
2270 public int getBuildOptionsFfsCount(){
2271 if (getfpdBuildOpts().getFfsList() == null) {
2274 return getfpdBuildOpts().getFfsList().size();
2277 public void getBuildOptionsFfsKey(String
[][] saa
) {
2278 if (getfpdBuildOpts().getFfsList() == null) {
2281 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
> li
= getfpdBuildOpts().getFfsList().listIterator();
2283 while(li
.hasNext()){
2284 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= li
.next();
2285 saa
[i
][0] = ffs
.getFfsKey();
2290 public void updateBuildOptionsFfsKey(int i
, String key
) {
2291 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2295 /**Get ith FFS key and contents.
2298 public void getBuildOptionsFfs(int i
, String
[] sa
, LinkedHashMap
<String
, String
> ffsAttribMap
, ArrayList
<String
> firstLevelSections
, ArrayList
<String
> firstLevelSection
) {
2299 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2303 sa
[0] = ffs
.getFfsKey();
2304 if (ffs
.getSections() != null) {
2305 if(ffs
.getSections().getEncapsulationType() != null){
2306 sa
[1] = ffs
.getSections().getEncapsulationType();
2308 if (ffs
.getSections().getSectionList() != null){
2309 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Section
> li
= ffs
.getSections().getSectionList().listIterator();
2310 while (li
.hasNext()) {
2311 firstLevelSection
.add(li
.next().getSectionType().toString());
2314 if (ffs
.getSections().getSectionsList() != null) {
2315 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
> li
= ffs
.getSections().getSectionsList().listIterator();
2316 while(li
.hasNext()) {
2317 firstLevelSections
.add(li
.next().getEncapsulationType());
2321 if (ffs
.getAttributeList() != null) {
2322 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute
> li
= ffs
.getAttributeList().listIterator();
2323 while(li
.hasNext()) {
2324 BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute attrib
= li
.next();
2325 ffsAttribMap
.put(attrib
.getName(), attrib
.getValue());
2334 private BuildOptionsDocument
.BuildOptions
.Ffs
getFfs(int i
) {
2335 XmlObject o
= getfpdBuildOpts();
2336 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= null;
2338 XmlCursor cursor
= o
.newCursor();
2339 QName qFfs
= new QName(xmlNs
, "Ffs");
2340 if (cursor
.toChild(qFfs
)) {
2341 for (int j
= 0; j
< i
; ++j
) {
2342 cursor
.toNextSibling(qFfs
);
2344 ffs
= (BuildOptionsDocument
.BuildOptions
.Ffs
)cursor
.getObject();
2350 public void removeBuildOptionsFfs(int i
) {
2351 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2356 XmlCursor cursor
= ffs
.newCursor();
2363 public PlatformDefinitionsDocument
.PlatformDefinitions
getfpdPlatformDefs(){
2364 if (fpdPlatformDefs
== null){
2365 fpdPlatformDefs
= fpdRoot
.addNewPlatformDefinitions();
2367 return fpdPlatformDefs
;
2370 public void getPlatformDefsSupportedArchs(Vector
<Object
> archs
){
2371 if (getfpdPlatformDefs().getSupportedArchitectures() == null) {
2374 ListIterator li
= getfpdPlatformDefs().getSupportedArchitectures().listIterator();
2375 while(li
.hasNext()) {
2376 archs
.add(li
.next());
2380 public void setPlatformDefsSupportedArchs(Vector
<Object
> archs
) {
2381 if (archs
!= null) {
2382 getfpdPlatformDefs().setSupportedArchitectures(archs
);
2385 // XmlCursor cursor = getfpdPlatformDefs().newCursor();
2386 // if (cursor.toChild(xmlNs, "SupportedArchitectures")) {
2387 // cursor.removeXml();
2389 // cursor.dispose();
2393 public void getPlatformDefsBuildTargets(Vector
<Object
> targets
) {
2394 if (getfpdPlatformDefs().getBuildTargets() == null) {
2397 ListIterator li
= getfpdPlatformDefs().getBuildTargets().listIterator();
2398 while(li
.hasNext()) {
2399 targets
.add(li
.next());
2403 public void setPlatformDefsBuildTargets(Vector
<Object
> targets
) {
2404 getfpdPlatformDefs().setBuildTargets(targets
);
2407 public void genPlatformDefsSkuInfo(String id
, String name
) {
2408 SkuInfoDocument
.SkuInfo skuInfo
= null;
2409 if (getfpdPlatformDefs().getSkuInfo() == null) {
2410 skuInfo
= getfpdPlatformDefs().addNewSkuInfo();
2412 skuInfo
= getfpdPlatformDefs().getSkuInfo();
2413 if (skuInfo
.getUiSkuNameList() == null || skuInfo
.getUiSkuNameList().size() == 0) {
2414 SkuInfoDocument
.SkuInfo
.UiSkuName skuName
= skuInfo
.addNewUiSkuName();
2415 skuName
.setSkuID(new BigInteger("0"));
2416 skuName
.setStringValue("DEFAULT");
2418 if (id
.equals("0")) {
2421 SkuInfoDocument
.SkuInfo
.UiSkuName skuName
= skuInfo
.addNewUiSkuName();
2422 skuName
.setSkuID(new BigInteger(id
));
2423 skuName
.setStringValue(name
);
2426 public int getPlatformDefsSkuInfoCount(){
2427 if (getfpdPlatformDefs().getSkuInfo() == null || getfpdPlatformDefs().getSkuInfo().getUiSkuNameList() == null) {
2430 return getfpdPlatformDefs().getSkuInfo().getUiSkuNameList().size();
2433 public void getPlatformDefsSkuInfos(String
[][] saa
){
2434 if (getfpdPlatformDefs().getSkuInfo() == null || getfpdPlatformDefs().getSkuInfo().getUiSkuNameList() == null) {
2435 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null) {
2436 removeElement(getfpdDynPcdBuildDefs());
2437 fpdDynPcdBuildDefs
= null;
2442 List
<SkuInfoDocument
.SkuInfo
.UiSkuName
> l
= getfpdPlatformDefs().getSkuInfo().getUiSkuNameList();
2443 ListIterator
<SkuInfoDocument
.SkuInfo
.UiSkuName
> li
= l
.listIterator();
2445 while(li
.hasNext()) {
2446 SkuInfoDocument
.SkuInfo
.UiSkuName sku
= li
.next();
2447 saa
[i
][0] = sku
.getSkuID()+"";
2448 saa
[i
][1] = sku
.getStringValue();
2453 public void removePlatformDefsSkuInfo(int i
) {
2454 SkuInfoDocument
.SkuInfo skuInfo
= getfpdPlatformDefs().getSkuInfo();
2455 if (skuInfo
== null || i
== 0) {
2459 XmlCursor cursor
= skuInfo
.newCursor();
2460 if (cursor
.toFirstChild()) {
2461 for (int j
= 0; j
< i
; ++j
) {
2462 cursor
.toNextSibling();
2469 public void updatePlatformDefsSkuInfo(int i
, String id
, String name
) {
2470 SkuInfoDocument
.SkuInfo skuInfo
= getfpdPlatformDefs().getSkuInfo();
2471 if (skuInfo
== null || i
== 0) {
2475 XmlCursor cursor
= skuInfo
.newCursor();
2476 if (cursor
.toFirstChild()) {
2477 for (int j
= 0; j
< i
; ++j
) {
2478 cursor
.toNextSibling();
2480 SkuInfoDocument
.SkuInfo
.UiSkuName sku
= (SkuInfoDocument
.SkuInfo
.UiSkuName
)cursor
.getObject();
2481 sku
.setSkuID(new BigInteger(id
));
2482 sku
.setStringValue(name
);
2487 public String
getPlatformDefsInterDir(){
2488 if (getfpdPlatformDefs().getIntermediateDirectories() == null) {
2491 return getfpdPlatformDefs().getIntermediateDirectories().toString();
2494 public void setPlatformDefsInterDir(String interDir
){
2495 getfpdPlatformDefs().setIntermediateDirectories(IntermediateOutputType
.Enum
.forString(interDir
));
2498 public String
getPlatformDefsOutputDir() {
2499 return getfpdPlatformDefs().getOutputDirectory();
2502 public void setPlatformDefsOutputDir(String outputDir
) {
2503 if (outputDir
!= null && outputDir
.length() > 0) {
2504 getfpdPlatformDefs().setOutputDirectory(outputDir
);
2507 XmlCursor cursor
= getfpdPlatformDefs().newCursor();
2508 if (cursor
.toChild(new QName(xmlNs
, "OutputDirectory"))) {
2515 public FlashDocument
.Flash
getfpdFlash() {
2516 if (fpdFlash
== null) {
2517 fpdFlash
= fpdRoot
.addNewFlash();
2522 public void genFlashDefinitionFile(String file
) {
2523 FlashDefinitionFileDocument
.FlashDefinitionFile fdf
= getfpdFlash().getFlashDefinitionFile();
2525 fdf
= getfpdFlash().addNewFlashDefinitionFile();
2528 fdf
.setStringValue(file
);
2531 public String
getFlashDefinitionFile() {
2532 FlashDefinitionFileDocument
.FlashDefinitionFile fdf
= getfpdFlash().getFlashDefinitionFile();
2537 return fdf
.getStringValue();
2540 public void genFvImagesNameValue(String name
, String value
) {
2542 FvImagesDocument
.FvImages fi
= getfpdFlash().getFvImages();
2544 fi
= getfpdFlash().addNewFvImages();
2547 FvImagesDocument
.FvImages
.NameValue nv
= fi
.addNewNameValue();
2552 public void removeFvImagesNameValue(int i
){
2554 XmlObject o
= getfpdFlash().getFvImages();
2559 QName qNameValue
= new QName(xmlNs
, "NameValue");
2560 XmlCursor cursor
= o
.newCursor();
2561 if (cursor
.toChild(qNameValue
)) {
2562 for (int j
= 0; j
< i
; ++j
) {
2563 cursor
.toNextSibling(qNameValue
);
2570 public void updateFvImagesNameValue(int i
, String name
, String value
){
2572 XmlObject o
= getfpdFlash().getFvImages();
2577 QName qNameValue
= new QName(xmlNs
, "NameValue");
2578 XmlCursor cursor
= o
.newCursor();
2579 if (cursor
.toChild(qNameValue
)) {
2580 for (int j
= 0; j
< i
; ++j
) {
2581 cursor
.toNextSibling(qNameValue
);
2583 FvImagesDocument
.FvImages
.NameValue nv
= (FvImagesDocument
.FvImages
.NameValue
)cursor
.getObject();
2590 public int getFvImagesNameValueCount() {
2592 FvImagesDocument
.FvImages fi
= null;
2593 if ((fi
= getfpdFlash().getFvImages()) == null || fi
.getNameValueList() == null) {
2596 return fi
.getNameValueList().size();
2599 public void getFvImagesNameValues(String
[][] nv
) {
2601 FvImagesDocument
.FvImages fi
= getfpdFlash().getFvImages();
2605 List
<FvImagesDocument
.FvImages
.NameValue
> l
= fi
.getNameValueList();
2607 ListIterator li
= l
.listIterator();
2608 while (li
.hasNext()) {
2609 FvImagesDocument
.FvImages
.NameValue e
= (FvImagesDocument
.FvImages
.NameValue
) li
2611 nv
[i
][0] = e
.getName();
2612 nv
[i
][1] = e
.getValue();
2618 public void getFvImagesFvImageFvImageNames (Vector
<String
> vImageNames
) {
2619 FvImagesDocument
.FvImages fis
= getfpdFlash().getFvImages();
2620 if (fis
== null || fis
.getFvImageList() == null) {
2624 ListIterator
<FvImagesDocument
.FvImages
.FvImage
> li
= fis
.getFvImageList().listIterator();
2625 while (li
.hasNext()) {
2626 FvImagesDocument
.FvImages
.FvImage fi
= li
.next();
2627 if (fi
.getType().toString().equals("ImageName")) {
2628 vImageNames
.addAll(fi
.getFvImageNamesList());
2634 public void addFvImageFvImageNames (String
[] fvNames
) {
2635 FvImagesDocument
.FvImages fis
= getfpdFlash().getFvImages();
2636 if (fis
== null || fis
.getFvImageList() == null) {
2637 genFvImagesFvImage (fvNames
, "ImageName", null);
2641 ListIterator
<FvImagesDocument
.FvImages
.FvImage
> li
= fis
.getFvImageList().listIterator();
2642 while (li
.hasNext()) {
2643 FvImagesDocument
.FvImages
.FvImage fi
= li
.next();
2644 if (fi
.getType().toString().equals("ImageName")) {
2645 addFvImageNamesInFvImage (fi
, fvNames
);
2649 genFvImagesFvImage (fvNames
, "ImageName", null);
2652 public void addFvImageNamesInFvImage (FvImagesDocument
.FvImages
.FvImage fi
, String
[] fvNames
) {
2654 for (int i
= 0; i
< fvNames
.length
; ++i
) {
2655 fi
.addFvImageNames(fvNames
[i
]);
2659 public void addFvImageNamesInFvImage (int i
, String
[] fvNames
) {
2660 XmlObject o
= getfpdFlash().getFvImages();
2664 XmlCursor cursor
= o
.newCursor();
2665 QName qFvImage
= new QName(xmlNs
, "FvImage");
2666 if (cursor
.toChild(qFvImage
)) {
2667 for (int j
= 0; j
< i
; ++j
) {
2668 cursor
.toNextSibling(qFvImage
);
2670 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
2671 addFvImageNamesInFvImage(fi
, fvNames
);
2676 public void genFvImagesFvImage(String
[] names
, String types
, Map
<String
, String
> options
) {
2678 FvImagesDocument
.FvImages fis
= null;
2679 if ((fis
= getfpdFlash().getFvImages()) == null) {
2680 fis
= getfpdFlash().addNewFvImages();
2684 //gen FvImage with FvImageNames array
2686 FvImagesDocument
.FvImages
.FvImage fi
= fis
.addNewFvImage();
2687 for (int i
= 0; i
< names
.length
; ++i
) {
2688 fi
.addFvImageNames(names
[i
]);
2690 fi
.setType(FvImageTypes
.Enum
.forString(types
));
2691 if (options
!= null){
2692 setFvImagesFvImageFvImageOptions(options
, fi
);
2696 private void setFvImagesFvImageFvImageOptions(Map
<String
, String
> options
, FvImagesDocument
.FvImages
.FvImage fi
){
2697 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions fio
= fi
.getFvImageOptions();
2699 fio
= fi
.addNewFvImageOptions();
2702 Set
<String
> key
= options
.keySet();
2703 Iterator
<String
> i
= key
.iterator();
2704 while (i
.hasNext()) {
2706 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nv
= fio
.addNewNameValue();
2707 String k
= (String
)i
.next();
2710 nv
.setValue((String
)options
.get(k
));
2717 public void removeFvImagesFvImage(int i
) {
2719 XmlObject o
= getfpdFlash().getFvImages();
2724 QName qFvImage
= new QName(xmlNs
, "FvImage");
2725 XmlCursor cursor
= o
.newCursor();
2726 if (cursor
.toChild(qFvImage
)) {
2727 for (int j
= 0; j
< i
; ++j
) {
2728 cursor
.toNextSibling(qFvImage
);
2737 * @param newFvName The New FV Name. If null, remove the old FvImageNames entry.
2739 public void updateFvImageNameAll (String oldFvName
, String newFvName
) {
2740 if (getfpdFlash().getFvImages() == null || getfpdFlash().getFvImages().getFvImageList() == null) {
2743 ListIterator
<FvImagesDocument
.FvImages
.FvImage
> li
= getfpdFlash().getFvImages().getFvImageList().listIterator();
2744 while (li
.hasNext()) {
2745 FvImagesDocument
.FvImages
.FvImage fi
= li
.next();
2746 updateFvImageNamesInFvImage (fi
, oldFvName
, newFvName
);
2747 if (fi
.getFvImageNamesList().size() == 0) {
2753 public void updateFvImageNamesInFvImage (int i
, String oldFvName
, String newFvName
) {
2754 XmlObject o
= getfpdFlash().getFvImages();
2758 XmlCursor cursor
= o
.newCursor();
2759 QName qFvImage
= new QName(xmlNs
, "FvImage");
2760 if (cursor
.toChild(qFvImage
)) {
2761 for (int j
= 0; j
< i
; ++j
) {
2762 cursor
.toNextSibling(qFvImage
);
2764 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
2765 updateFvImageNamesInFvImage (fi
, oldFvName
, newFvName
);
2771 * @param oldFvName The FV Name to be replaced.
2772 * @param newFvName The New FV Name. If null, remove the old FvImageNames entry.
2774 public void updateFvImageNamesInFvImage (FvImagesDocument
.FvImages
.FvImage fi
, String oldFvName
, String newFvName
) {
2775 QName qFvImageNames
= new QName(xmlNs
, "FvImageNames");
2776 XmlCursor cursor
= fi
.newCursor();
2778 if (cursor
.toChild(qFvImageNames
)) {
2780 String xmlValue
= cursor
.getTextValue();
2781 if (xmlValue
.equals(oldFvName
)){
2782 if (newFvName
!= null) {
2783 cursor
.setTextValue(newFvName
);
2789 }while (cursor
.toNextSibling(qFvImageNames
));
2795 /**update the Type attribute of ith FvImage with new type.
2799 public void updateFvImagesFvImageType (int i
, String type
) {
2800 XmlObject o
= getfpdFlash().getFvImages();
2804 XmlCursor cursor
= o
.newCursor();
2805 QName qFvImage
= new QName(xmlNs
, "FvImage");
2806 if (cursor
.toChild(qFvImage
)) {
2807 for (int j
= 0; j
< i
; ++j
) {
2808 cursor
.toNextSibling(qFvImage
);
2810 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
2811 fi
.setType(FvImageTypes
.Enum
.forString(type
));
2816 public void updateFvImagesFvImage(int i
, String
[] names
, String types
, Map
<String
, String
> options
){
2818 XmlObject o
= getfpdFlash().getFvImages();
2822 XmlCursor cursor
= o
.newCursor();
2823 QName qFvImage
= new QName(xmlNs
, "FvImage");
2824 if (cursor
.toChild(qFvImage
)) {
2825 for (int j
= 0; j
< i
; ++j
) {
2826 cursor
.toNextSibling(qFvImage
);
2828 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
2829 fi
.setType(FvImageTypes
.Enum
.forString(types
));
2832 // remove old FvImageNames before adding new ones
2834 QName qFvImageNames
= new QName(xmlNs
, "FvImageNames");
2835 cursor
.toChild(qFvImageNames
);
2837 while (cursor
.toNextSibling(qFvImageNames
)) {
2841 for (int k
= 0; k
< names
.length
; ++k
) {
2842 fi
.addFvImageNames(names
[k
]);
2845 // remove old FvImageOptions before adding new options
2847 QName qFvImageOptions
= new QName(xmlNs
, "FvImageOptions");
2848 cursor
.toNextSibling(qFvImageOptions
);
2851 setFvImagesFvImageFvImageOptions(options
, fi
);
2856 public int getFvImagesFvImageCount(String type
) {
2858 if (getfpdFlash().getFvImages() == null || getfpdFlash().getFvImages().getFvImageList() == null) {
2861 List
<FvImagesDocument
.FvImages
.FvImage
> l
= getfpdFlash().getFvImages().getFvImageList();
2862 ListIterator li
= l
.listIterator();
2864 while(li
.hasNext()) {
2865 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)li
.next();
2866 if (!fi
.getType().toString().equals(type
) && !type
.equals("ALL")) {
2876 public Vector
<FvImagesDocument
.FvImages
.FvImage
> getFvImagesFvImageWithName (String fvName
, String type
) {
2877 Vector
<FvImagesDocument
.FvImages
.FvImage
> vFvImage
= new Vector
<FvImagesDocument
.FvImages
.FvImage
>();
2878 if (getfpdFlash().getFvImages() == null || getfpdFlash().getFvImages().getFvImageList() == null) {
2881 List
<FvImagesDocument
.FvImages
.FvImage
> l
= getfpdFlash().getFvImages().getFvImageList();
2882 ListIterator li
= l
.listIterator();
2883 while(li
.hasNext()) {
2884 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)li
.next();
2885 if (!fi
.getType().toString().equals(type
) && !type
.equals("ALL")) {
2888 if (fi
.getFvImageNamesList().contains(fvName
)) {
2897 * @param type "ALL" means all FvImage types: ImageName, Options, Attributes, Components.
2899 public void getFvImagesFvImages(String
[][] saa
, String type
) {
2901 if (getfpdFlash().getFvImages() == null) {
2904 List
<FvImagesDocument
.FvImages
.FvImage
> l
= getfpdFlash().getFvImages().getFvImageList();
2908 ListIterator li
= l
.listIterator();
2910 while(li
.hasNext()) {
2911 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)li
.next();
2912 if (!fi
.getType().toString().equals(type
) && !type
.equals("ALL")) {
2916 // get FvImageNames array, space separated
2918 List
<String
> lfn
= fi
.getFvImageNamesList();
2919 ListIterator lfni
= lfn
.listIterator();
2921 while (lfni
.hasNext()) {
2922 saa
[i
][0] += (String
)lfni
.next();
2925 saa
[i
][0] = saa
[i
][0].trim();
2927 saa
[i
][1] = fi
.getType()+"";
2933 public void removeFvImageNameValue (int i
, String attributeName
) {
2934 XmlObject o
= getfpdFlash().getFvImages();
2938 XmlCursor cursor
= o
.newCursor();
2939 QName qFvImage
= new QName(xmlNs
, "FvImage");
2940 if (cursor
.toChild(qFvImage
)) {
2941 for (int j
= 0; j
< i
; ++j
) {
2942 cursor
.toNextSibling(qFvImage
);
2944 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
2945 removeFvImageNameValue (fi
, attributeName
);
2949 /**Remove from fi the attribute pair with attributeName in FvImageOptions.
2951 * @param attributeName
2953 public void removeFvImageNameValue (FvImagesDocument
.FvImages
.FvImage fi
, String attributeName
) {
2954 if (fi
.getFvImageOptions() != null && fi
.getFvImageOptions().getNameValueList() != null) {
2955 ListIterator
<FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
> li
= fi
.getFvImageOptions().getNameValueList().listIterator();
2956 while (li
.hasNext()) {
2957 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nv
= li
.next();
2958 if (nv
.getName().equals(attributeName
)) {
2965 public void removeTypedNamedFvImageNameValue (String fvName
, String type
, String optName
) {
2966 Vector
<FvImagesDocument
.FvImages
.FvImage
> vFvImage
= getFvImagesFvImageWithName(fvName
, type
);
2967 for (int i
= 0; i
< vFvImage
.size(); ++i
) {
2968 FvImagesDocument
.FvImages
.FvImage fi
= vFvImage
.get(i
);
2969 removeFvImageNameValue (fi
, optName
);
2973 /**Add name-value pair to FvImage element with type.
2974 * @param fvName FV name to add name-value pair.
2975 * @param type FvImage attribute.
2979 public void setTypedNamedFvImageNameValue (String fvName
, String type
, String name
, String value
) {
2980 boolean fvImageExists
= false;
2981 if (getfpdFlash().getFvImages() == null) {
2984 List
<FvImagesDocument
.FvImages
.FvImage
> l
= getfpdFlash().getFvImages().getFvImageList();
2988 ListIterator li
= l
.listIterator();
2989 while(li
.hasNext()) {
2990 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)li
.next();
2991 if (!fi
.getType().toString().equals(type
) && !type
.equals("ALL")) {
2994 if (!fi
.getFvImageNamesList().contains(fvName
)) {
2997 fvImageExists
= true;
2998 setFvImagesFvImageNameValue (fi
, name
, value
, null);
3001 if (!fvImageExists
) {
3002 HashMap
<String
, String
> map
= new HashMap
<String
, String
>();
3003 map
.put(name
, value
);
3004 genFvImagesFvImage(new String
[]{fvName
}, type
, map
);
3008 /**Add to all FvImage elements with type, the name-value pair.
3013 public void setTypedFvImageNameValue (String type
, String name
, String value
) {
3014 if (getfpdFlash().getFvImages() == null) {
3017 List
<FvImagesDocument
.FvImages
.FvImage
> l
= getfpdFlash().getFvImages().getFvImageList();
3021 ListIterator li
= l
.listIterator();
3022 while(li
.hasNext()) {
3023 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)li
.next();
3024 if (!fi
.getType().toString().equals(type
) && !type
.equals("ALL")) {
3027 setFvImagesFvImageNameValue (fi
, name
, value
, null);
3032 public void setFvImagesFvImageNameValue (int i
, String name
, String value
) {
3033 XmlObject o
= getfpdFlash().getFvImages();
3037 XmlCursor cursor
= o
.newCursor();
3038 QName qFvImage
= new QName(xmlNs
, "FvImage");
3039 if (cursor
.toChild(qFvImage
)) {
3040 for (int j
= 0; j
< i
; ++j
) {
3041 cursor
.toNextSibling(qFvImage
);
3043 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
3044 setFvImagesFvImageNameValue (fi
, name
, value
, null);
3049 /**Add to FvImage the name-value pair, or replace old name with newName, or generate new name-value pair if not exists before.
3055 public void setFvImagesFvImageNameValue (FvImagesDocument
.FvImages
.FvImage fi
, String name
, String value
, String newName
) {
3056 if (fi
.getFvImageOptions() == null || fi
.getFvImageOptions().getNameValueList() == null) {
3057 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nv
= fi
.addNewFvImageOptions().addNewNameValue();
3060 if (newName
!= null) {
3061 nv
.setName(newName
);
3066 XmlCursor cursor
= fi
.getFvImageOptions().newCursor();
3067 if (cursor
.toFirstChild()) {
3069 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nv
= (FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
)cursor
.getObject();
3070 if (nv
.getName().equals(name
)) {
3072 if (newName
!= null) {
3073 nv
.setName(newName
);
3078 }while (cursor
.toNextSibling());
3081 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nv
= fi
.getFvImageOptions().addNewNameValue();
3084 if (newName
!= null) {
3085 nv
.setName(newName
);
3090 public void getFvImagesFvImageOptions (String fvName
, Map
<String
, String
> m
) {
3091 Vector
<FvImagesDocument
.FvImages
.FvImage
> vFvImage
= getFvImagesFvImageWithName (fvName
, "Options");
3092 for (int i
= 0; i
< vFvImage
.size(); ++i
) {
3093 FvImagesDocument
.FvImages
.FvImage fi
= vFvImage
.get(i
);
3094 if (fi
== null || fi
.getFvImageOptions() == null || fi
.getFvImageOptions().getNameValueList() == null) {
3098 ListIterator
<FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
> li
= fi
.getFvImageOptions()
3101 while (li
.hasNext()) {
3102 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nv
= li
.next();
3103 m
.put(nv
.getName(), nv
.getValue());
3108 public int getFvImagePosInFvImages (String fvNameList
, String type
) {
3109 XmlObject o
= getfpdFlash().getFvImages();
3115 String
[] fvNameArray
= fvNameList
.trim().split(" ");
3116 Vector
<String
> vFvNames
= new Vector
<String
>();
3119 XmlCursor cursor
= o
.newCursor();
3120 QName qFvImage
= new QName(xmlNs
, "FvImage");
3121 if (cursor
.toChild(qFvImage
)) {
3124 vFvNames
.removeAllElements();
3125 for (int i
= 0; i
< fvNameArray
.length
; ++i
) {
3126 vFvNames
.add(fvNameArray
[i
]);
3128 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
3129 if (!fi
.getType().toString().equals(type
)) {
3132 if (fi
.getFvImageNamesList() == null || fi
.getFvImageNamesList().size() != vFvNames
.size()) {
3135 ListIterator
<String
> li
= fi
.getFvImageNamesList().listIterator();
3136 while (li
.hasNext()) {
3137 String name
= li
.next();
3138 vFvNames
.remove(name
);
3140 if (vFvNames
.size() == 0) {
3145 }while (cursor
.toNextSibling(qFvImage
));
3151 /**Get FvImage Options for FvImage i
3152 * @param i the ith FvImage
3154 public void getFvImagesFvImageOptions(int i
, Map
<String
, String
> m
) {
3155 XmlObject o
= getfpdFlash().getFvImages();
3159 XmlCursor cursor
= o
.newCursor();
3160 QName qFvImage
= new QName(xmlNs
, "FvImage");
3161 if (cursor
.toChild(qFvImage
)) {
3162 for (int j
= 0; j
< i
; ++j
) {
3163 cursor
.toNextSibling(qFvImage
);
3165 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
3166 if (fi
.getFvImageOptions() == null || fi
.getFvImageOptions().getNameValueList() == null){
3170 ListIterator
<FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
> li
= fi
.getFvImageOptions().getNameValueList().listIterator();
3171 while(li
.hasNext()){
3172 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nv
= li
.next();
3173 m
.put(nv
.getName(), nv
.getValue());
3180 Get platform header element
3181 @return PlatformHeaderDocument.PlatformHeader
3183 public PlatformHeaderDocument
.PlatformHeader
getFpdHdr() {
3184 if (fpdHdr
== null) {
3185 fpdHdr
= fpdRoot
.addNewPlatformHeader();
3191 public String
getFpdHdrPlatformName() {
3192 return getFpdHdr().getPlatformName();
3195 public String
getFpdHdrGuidValue() {
3196 return getFpdHdr().getGuidValue();
3199 public String
getFpdHdrVer() {
3200 return getFpdHdr().getVersion();
3203 public String
getFpdHdrAbs() {
3204 return getFpdHdr().getAbstract();
3207 public String
getFpdHdrDescription() {
3208 return getFpdHdr().getDescription();
3211 public String
getFpdHdrCopyright() {
3212 return getFpdHdr().getCopyright();
3215 public String
getFpdHdrLicense() {
3216 LicenseDocument
.License l
= getFpdHdr().getLicense();
3220 return l
.getStringValue();
3223 public String
getFpdHdrUrl() {
3224 LicenseDocument
.License l
= getFpdHdr().getLicense();
3231 public String
getFpdHdrSpec() {
3233 return "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052";
3234 // return getFpdHdr().getSpecification();
3237 public void setFpdHdrPlatformName(String name
){
3238 getFpdHdr().setPlatformName(name
);
3241 public void setFpdHdrGuidValue(String guid
){
3242 getFpdHdr().setGuidValue(guid
);
3245 public void setFpdHdrVer(String v
){
3246 getFpdHdr().setVersion(v
);
3249 public void setFpdHdrAbs(String abs
) {
3250 getFpdHdr().setAbstract(abs
);
3253 public void setFpdHdrDescription(String desc
){
3254 getFpdHdr().setDescription(desc
);
3257 public void setFpdHdrCopyright(String cr
) {
3258 getFpdHdr().setCopyright(cr
);
3261 public void setFpdHdrLicense(String license
){
3262 LicenseDocument
.License l
= getFpdHdr().getLicense();
3264 getFpdHdr().addNewLicense().setStringValue(license
);
3267 l
.setStringValue(license
);
3271 public void setFpdHdrUrl(String url
){
3272 LicenseDocument
.License l
= getFpdHdr().getLicense();
3278 public void setFpdHdrSpec(String s
){
3279 s
= "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052";
3280 getFpdHdr().setSpecification(s
);
3283 Save the processed xml contents to file
3285 @param fpdFile The file to save xml contents
3286 @throws IOException Exceptions during file operation
3288 public void saveAs(File fpdFile
) throws IOException
{
3290 XmlOptions options
= new XmlOptions();
3292 options
.setCharacterEncoding("UTF-8");
3293 options
.setSavePrettyPrint();
3294 options
.setSavePrettyPrintIndent(2);
3296 fpdd
.save(fpdFile
, options
);
3297 } catch (IOException e
) {
3298 e
.printStackTrace();
3303 private String
listToString(List l
) {
3308 ListIterator li
= l
.listIterator();
3309 while(li
.hasNext()) {
3316 private void removeElement(XmlObject o
) {
3317 XmlCursor cursor
= o
.newCursor();
3323 class PcdItemTypeConflictException
extends Exception
{
3328 private static final long serialVersionUID
= 1L;
3329 private String details
= null;
3331 PcdItemTypeConflictException(String pcdName
, String info
){
3332 ModuleIdentification mi
= WorkspaceProfile
.getModuleId(info
);
3333 details
= pcdName
+ " ItemType Conflicts with " + mi
.getName() + " in Pkg " + mi
.getPackageId().getName();
3336 public String
getMessage() {
3341 class PcdDeclNotFound
extends Exception
{
3346 private static final long serialVersionUID
= 1L;
3347 private String details
= null;
3349 PcdDeclNotFound(String info
) {
3350 details
= "PcdDeclNotFound: " + info
;
3353 public String
getMessage() {
3358 class PcdValueMalFormed
extends Exception
{
3363 private static final long serialVersionUID
= 1L;
3364 private String details
= null;
3366 PcdValueMalFormed(String info
) {
3367 details
= "PcdValueMalFormed: " + info
;
3370 public String
getMessage() {