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()+"";
638 /**Remove PCDBuildDefinition entries from ModuleSA
639 * @param moduleKey identifier of ModuleSA.
640 * @param consumer where these entries come from.
642 public void removePcdData(String moduleKey
, ModuleIdentification consumer
) {
644 ModuleSurfaceAreaDocument
.ModuleSurfaceArea msa
= (ModuleSurfaceAreaDocument
.ModuleSurfaceArea
)WorkspaceProfile
.getModuleXmlObject(consumer
);
645 if (msa
.getPcdCoded() == null) {
649 List
<PcdCodedDocument
.PcdCoded
.PcdEntry
> l
= msa
.getPcdCoded().getPcdEntryList();
650 ListIterator li
= l
.listIterator();
652 while(li
.hasNext()) {
653 PcdCodedDocument
.PcdCoded
.PcdEntry msaPcd
= (PcdCodedDocument
.PcdCoded
.PcdEntry
)li
.next();
654 ModuleSADocument
.ModuleSA moduleSA
= getModuleSA(moduleKey
);
655 if (moduleSA
.getPcdBuildDefinition() != null) {
656 XmlCursor cursor
= moduleSA
.getPcdBuildDefinition().newCursor();
657 if (cursor
.toFirstChild()) {
659 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= (PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
) cursor
661 if (msaPcd
.getCName().equals(pcdData
.getCName())
662 && msaPcd
.getTokenSpaceGuidCName().equals(pcdData
.getTokenSpaceGuidCName())) {
664 maintainDynPcdMap(pcdData
.getCName() + " " + pcdData
.getTokenSpaceGuidCName(),
669 } while (cursor
.toNextSibling());
682 // key for ModuleSA : "ModuleGuid ModuleVer PackageGuid PackageVer Arch"
684 public int getLibraryInstancesCount(String key
) {
685 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
686 if (msa
== null || msa
.getLibraries() == null || msa
.getLibraries().getInstanceList() == null){
689 return msa
.getLibraries().getInstanceList().size();
692 public void getLibraryInstances(String key
, String
[][] saa
){
693 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
694 if (msa
== null || msa
.getLibraries() == null || msa
.getLibraries().getInstanceList() == null){
698 ListIterator
<LibrariesDocument
.Libraries
.Instance
> li
= msa
.getLibraries().getInstanceList().listIterator();
699 for (int i
= 0; i
< saa
.length
; ++i
) {
700 LibrariesDocument
.Libraries
.Instance instance
= li
.next();
701 saa
[i
][1] = instance
.getModuleGuid();
702 saa
[i
][2] = instance
.getModuleVersion();
703 saa
[i
][3] = instance
.getPackageGuid();
704 saa
[i
][4] = instance
.getPackageVersion();
708 public void removeLibraryInstance(String key
, int i
) {
709 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
710 if (msa
== null || msa
.getLibraries() == null){
714 XmlCursor cursor
= msa
.getLibraries().newCursor();
715 if (cursor
.toFirstChild()) {
716 for (int j
= 0; j
< i
; ++j
) {
717 cursor
.toNextSibling();
720 cursor
.toPrevToken();
721 if (cursor
.isComment()) {
726 if (getLibraryInstancesCount(key
) == 0) {
735 public void genLibraryInstance(ModuleIdentification libMi
, String key
) {
736 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
738 msa
= getfpdFrameworkModules().addNewModuleSA();
740 LibrariesDocument
.Libraries libs
= msa
.getLibraries();
742 libs
= msa
.addNewLibraries();
745 String mn
= libMi
.getName();
746 String mg
= libMi
.getGuid();
747 String mv
= libMi
.getVersion();
748 String pn
= libMi
.getPackageId().getName();
749 String pg
= libMi
.getPackageId().getGuid();
750 String pv
= libMi
.getPackageId().getVersion();
751 LibrariesDocument
.Libraries
.Instance instance
= libs
.addNewInstance();
752 XmlCursor cursor
= instance
.newCursor();
754 String comment
= "Pkg: " + pn
+ " Mod: " + mn
755 + " Path: " + libMi
.getPath().substring(System
.getenv("WORKSPACE").length() + 1);
756 cursor
.insertComment(comment
);
765 instance
.setModuleGuid(mg
);
766 instance
.setModuleVersion(mv
);
767 instance
.setPackageGuid(pg
);
768 instance
.setPackageVersion(pv
);
772 public String
getFvBinding(String moduleKey
){
773 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(moduleKey
);
774 return getFvBinding (moduleSa
);
777 public String
getFvBinding (ModuleSADocument
.ModuleSA moduleSa
) {
778 if (moduleSa
== null || moduleSa
.getModuleSaBuildOptions() == null) {
781 return moduleSa
.getModuleSaBuildOptions().getFvBinding();
784 public void setFvBinding(ModuleSADocument
.ModuleSA moduleSa
, String fvBinding
) {
785 if (moduleSa
== null ) {
788 if (fvBinding
== null || fvBinding
.length() == 0) {
789 if(moduleSa
.getModuleSaBuildOptions() != null){
790 moduleSa
.getModuleSaBuildOptions().unsetFvBinding();
794 if(moduleSa
.getModuleSaBuildOptions() == null){
795 moduleSa
.addNewModuleSaBuildOptions().setFvBinding(fvBinding
);
798 moduleSa
.getModuleSaBuildOptions().setFvBinding(fvBinding
);
802 public void setFvBinding(String moduleKey
, String fvBinding
){
803 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(moduleKey
);
804 setFvBinding (moduleSa
, fvBinding
);
807 private int fvBindingForModuleSA (ModuleSADocument
.ModuleSA moduleSa
, String fvName
) {
808 if (moduleSa
== null || moduleSa
.getModuleSaBuildOptions() == null || moduleSa
.getModuleSaBuildOptions().getFvBinding() == null) {
812 String fvNameList
= moduleSa
.getModuleSaBuildOptions().getFvBinding();
813 String
[] fvNamesArray
= fvNameList
.split(" ");
815 for (int i
= 0; i
< fvNamesArray
.length
; ++i
) {
816 if (fvNamesArray
[i
].equals(fvName
)) {
824 public void removeFvBinding (ModuleSADocument
.ModuleSA moduleSa
, String fvName
) {
825 if (moduleSa
== null || moduleSa
.getModuleSaBuildOptions() == null || moduleSa
.getModuleSaBuildOptions().getFvBinding() == null) {
829 String fvNameList
= moduleSa
.getModuleSaBuildOptions().getFvBinding();
830 String
[] fvNamesArray
= fvNameList
.split(" ");
832 for (int i
= 0; i
< fvNamesArray
.length
; ++i
) {
833 if (fvNamesArray
[i
].equals(fvName
)) {
838 // jump over where the input fvName occurs in the original Fv list.
839 if (occursAt
!= -1) {
840 String newFvNameList
= " ";
841 for (int i
= 0; i
< fvNamesArray
.length
; ++i
) {
845 newFvNameList
+= fvNamesArray
[i
];
847 setFvBinding (moduleSa
, newFvNameList
.trim());
853 * @param fvName The FV name that to be removed from FvBinding List.
855 public void removeFvBindingAll (String fvName
) {
856 if (getfpdFrameworkModules().getModuleSAList() == null || getfpdFrameworkModules().getModuleSAList().size() == 0){
857 removeElement(getfpdFrameworkModules());
858 fpdFrameworkModules
= null;
862 Iterator
<ModuleSADocument
.ModuleSA
> li
= getfpdFrameworkModules().getModuleSAList().iterator();
863 while (li
.hasNext()) {
864 ModuleSADocument
.ModuleSA moduleSa
= li
.next();
865 removeFvBinding (moduleSa
, fvName
);
869 public void appendFvBindingAll (String fvName
) {
870 if (getfpdFrameworkModules().getModuleSAList() == null || getfpdFrameworkModules().getModuleSAList().size() == 0){
871 removeElement(getfpdFrameworkModules());
872 fpdFrameworkModules
= null;
876 Iterator
<ModuleSADocument
.ModuleSA
> li
= getfpdFrameworkModules().getModuleSAList().iterator();
877 while (li
.hasNext()) {
878 ModuleSADocument
.ModuleSA moduleSa
= li
.next();
879 appendFvBinding (moduleSa
, fvName
);
883 public void appendFvBindingFor (String oldFvName
, String newFvName
) {
884 if (getfpdFrameworkModules().getModuleSAList() == null || getfpdFrameworkModules().getModuleSAList().size() == 0){
885 removeElement(getfpdFrameworkModules());
886 fpdFrameworkModules
= null;
890 Iterator
<ModuleSADocument
.ModuleSA
> li
= getfpdFrameworkModules().getModuleSAList().iterator();
891 while (li
.hasNext()) {
892 ModuleSADocument
.ModuleSA moduleSa
= li
.next();
893 String fvBinding
= getFvBinding (moduleSa
);
894 if (fvBinding
!= null && fvBindingForModuleSA (moduleSa
, oldFvName
) >= 0) {
895 appendFvBinding (moduleSa
, newFvName
);
900 public void appendFvBinding (String moduleKey
, String fvName
) {
901 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(moduleKey
);
902 appendFvBinding (moduleSa
, fvName
);
905 public void appendFvBinding (ModuleSADocument
.ModuleSA moduleSa
, String fvName
) {
906 if (moduleSa
== null) {
910 if (moduleSa
.getModuleSaBuildOptions() == null || moduleSa
.getModuleSaBuildOptions().getFvBinding() == null) {
911 setFvBinding(moduleSa
, fvName
);
915 String fvNameList
= moduleSa
.getModuleSaBuildOptions().getFvBinding();
916 String newFvNameList
= fvNameList
+ " " + fvName
;
917 setFvBinding (moduleSa
, newFvNameList
.trim());
920 public void updateFvBindingInModuleSA (ModuleIdentification mi
, String fvName
) {
921 Vector
<Object
> vSupArchs
= new Vector
<Object
>();
922 getPlatformDefsSupportedArchs(vSupArchs
);
923 String moduleInfo
= mi
.getGuid() + " " + mi
.getVersion() + " " + mi
.getPackageId().getGuid() + " " + mi
.getPackageId().getVersion();
924 for (int i
= 0; i
< vSupArchs
.size(); ++i
) {
925 String moduleKey
= moduleInfo
+ " " + vSupArchs
.get(i
);
926 appendFvBinding (moduleKey
, fvName
);
930 public String
getFfsFileNameGuid(String moduleKey
){
931 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(moduleKey
);
932 if (moduleSa
== null || moduleSa
.getModuleSaBuildOptions() == null) {
935 return moduleSa
.getModuleSaBuildOptions().getFfsFileNameGuid();
938 public void setFfsFileNameGuid(String moduleKey
, String fileGuid
){
939 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
943 if(msa
.getModuleSaBuildOptions() == null){
944 msa
.addNewModuleSaBuildOptions();
947 ModuleSaBuildOptionsDocument
.ModuleSaBuildOptions msaBuildOpts
= msa
.getModuleSaBuildOptions();
948 if (fileGuid
!= null) {
949 msaBuildOpts
.setFfsFileNameGuid(fileGuid
);
952 XmlCursor cursor
= msaBuildOpts
.newCursor();
953 if (cursor
.toChild(xmlNs
, "FfsFileNameGuid")) {
961 public String
getFfsFormatKey(String moduleKey
){
962 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
963 if (msa
== null || msa
.getModuleSaBuildOptions() == null) {
966 return msa
.getModuleSaBuildOptions().getFfsFormatKey();
969 public void setFfsFormatKey(String moduleKey
, String ffsKey
){
970 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
974 if(msa
.getModuleSaBuildOptions() == null){
975 msa
.addNewModuleSaBuildOptions().setFfsFormatKey(ffsKey
);
978 msa
.getModuleSaBuildOptions().setFfsFormatKey(ffsKey
);
981 public void setModuleSAForceDebug(int i
, boolean dbgEnable
) {
982 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(i
);
983 moduleSa
.setForceDebug(dbgEnable
);
986 public boolean getModuleSAForceDebug (int i
) {
987 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(i
);
988 if (moduleSa
.getForceDebug() == true) {
994 public void getModuleSAOptions(String moduleKey
, String
[][] saa
) {
995 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
996 if (msa
== null || msa
.getModuleSaBuildOptions() == null || msa
.getModuleSaBuildOptions().getOptions() == null
997 || msa
.getModuleSaBuildOptions().getOptions().getOptionList() == null) {
1001 List
<OptionDocument
.Option
> lOpt
= msa
.getModuleSaBuildOptions().getOptions().getOptionList();
1002 ListIterator li
= lOpt
.listIterator();
1004 while(li
.hasNext()) {
1005 OptionDocument
.Option opt
= (OptionDocument
.Option
)li
.next();
1006 if (opt
.getBuildTargets() != null) {
1007 saa
[i
][0] = listToString(opt
.getBuildTargets());
1009 saa
[i
][1] = opt
.getToolChainFamily();
1010 saa
[i
][2] = opt
.getTagName();
1011 saa
[i
][3] = opt
.getToolCode();
1013 if (opt
.getSupArchList() != null){
1014 saa
[i
][4] = listToString(opt
.getSupArchList());
1020 saa
[i
][5] = opt
.getStringValue();
1026 public int getModuleSAOptionsCount(String moduleKey
){
1027 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
1028 if (msa
== null || msa
.getModuleSaBuildOptions() == null || msa
.getModuleSaBuildOptions().getOptions() == null
1029 || msa
.getModuleSaBuildOptions().getOptions().getOptionList() == null) {
1032 return msa
.getModuleSaBuildOptions().getOptions().getOptionList().size();
1035 public void genModuleSAOptionsOpt(String moduleKey
, Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
) {
1036 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
1037 if (msa
.getModuleSaBuildOptions() == null) {
1038 msa
.addNewModuleSaBuildOptions();
1040 if (msa
.getModuleSaBuildOptions().getOptions() == null){
1041 msa
.getModuleSaBuildOptions().addNewOptions();
1043 OptionDocument
.Option opt
= msa
.getModuleSaBuildOptions().getOptions().addNewOption();
1044 setBuildOptionsOpt(buildTargets
, toolChain
, tagName
, toolCmd
, archList
, contents
, opt
);
1047 public void removeModuleSAOptionsOpt(String moduleKey
, int i
) {
1048 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
1049 if (msa
.getModuleSaBuildOptions() == null || msa
.getModuleSaBuildOptions().getOptions() == null) {
1052 OptionsDocument
.Options opts
= msa
.getModuleSaBuildOptions().getOptions();
1053 XmlCursor cursor
= opts
.newCursor();
1054 if (cursor
.toFirstChild()) {
1055 for (int j
= 0; j
< i
; ++j
){
1056 cursor
.toNextSibling();
1063 public void updateModuleSAOptionsOpt(String moduleKey
, int i
, Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
) {
1064 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
1065 if (msa
.getModuleSaBuildOptions() == null || msa
.getModuleSaBuildOptions().getOptions() == null) {
1068 OptionsDocument
.Options opts
= msa
.getModuleSaBuildOptions().getOptions();
1069 XmlCursor cursor
= opts
.newCursor();
1070 if (cursor
.toFirstChild()) {
1071 for (int j
= 0; j
< i
; ++j
){
1072 cursor
.toNextSibling();
1074 OptionDocument
.Option opt
= (OptionDocument
.Option
)cursor
.getObject();
1075 setBuildOptionsOpt(buildTargets
, toolChain
, tagName
, toolCmd
, archList
, contents
, opt
);
1080 /**add pcd information of module mi to a ModuleSA.
1082 * @param moduleSa if null, generate a new ModuleSA.
1084 public void addFrameworkModulesPcdBuildDefs(ModuleIdentification mi
, String arch
, ModuleSADocument
.ModuleSA moduleSa
) throws Exception
{
1085 //ToDo add Arch filter
1088 if (moduleSa
== null) {
1089 moduleSa
= genModuleSA(mi
, arch
);
1092 ModuleSurfaceAreaDocument
.ModuleSurfaceArea msa
= (ModuleSurfaceAreaDocument
.ModuleSurfaceArea
)WorkspaceProfile
.getModuleXmlObject(mi
);
1093 if (msa
.getPcdCoded() == null) {
1097 Map
<String
, XmlObject
> m
= new HashMap
<String
, XmlObject
>();
1098 m
.put("ModuleSurfaceArea", msa
);
1099 SurfaceAreaQuery
.setDoc(m
);
1100 PackageIdentification
[] depPkgs
= SurfaceAreaQuery
.getDependencePkg(null, mi
);
1102 // Implementing InitializePlatformPcdBuildDefinitions
1104 List
<PcdCodedDocument
.PcdCoded
.PcdEntry
> l
= msa
.getPcdCoded().getPcdEntryList();
1105 ListIterator li
= l
.listIterator();
1106 while(li
.hasNext()) {
1107 PcdCodedDocument
.PcdCoded
.PcdEntry msaPcd
= (PcdCodedDocument
.PcdCoded
.PcdEntry
)li
.next();
1108 PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry spdPcd
= LookupPcdDeclaration(msaPcd
, depPkgs
);
1109 if (spdPcd
== null) {
1113 throw new PcdDeclNotFound("No Declaration for PCD Entry " + msaPcd
.getCName() + " in Module " + mi
.getName());
1116 // AddItem to ModuleSA PcdBuildDefinitions
1118 String defaultVal
= msaPcd
.getDefaultValue() == null ? spdPcd
.getDefaultValue() : msaPcd
.getDefaultValue();
1120 genPcdData(msaPcd
.getCName(), spdPcd
.getToken(), msaPcd
.getTokenSpaceGuidCName(), msaPcd
.getPcdItemType().toString(), spdPcd
.getDatumType()+"", defaultVal
, moduleSa
);
1124 catch (Exception e
){
1131 private PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry
LookupPcdDeclaration (PcdCodedDocument
.PcdCoded
.PcdEntry msaPcd
, PackageIdentification
[] depPkgs
) {
1133 PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry spdPcd
= null;
1134 for (int i
= 0; i
< depPkgs
.length
; ++i
) {
1136 XmlObject
[] xo
= SurfaceAreaQuery
.getSpdPcdDeclarations(depPkgs
[i
]);
1140 for (int j
= 0; j
< xo
.length
; ++j
) {
1141 spdPcd
= (PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry
)xo
[j
];
1142 if (msaPcd
.getTokenSpaceGuidCName() == null) {
1143 if (spdPcd
.getCName().equals(msaPcd
.getCName())) {
1148 if (spdPcd
.getCName().equals(msaPcd
.getCName()) && spdPcd
.getTokenSpaceGuidCName().equals(msaPcd
.getTokenSpaceGuidCName())) {
1159 private ModuleSADocument
.ModuleSA
genModuleSA (ModuleIdentification mi
, String arch
) {
1160 PackageIdentification pi
= WorkspaceProfile
.getPackageForModule(mi
);
1161 ModuleSADocument
.ModuleSA msa
= getfpdFrameworkModules().addNewModuleSA();
1162 XmlCursor cursor
= msa
.newCursor();
1164 String comment
= "Mod: " + mi
.getName() + " Type: " + SurfaceAreaQuery
.getModuleType(mi
) + " Path: "
1165 + mi
.getPath().substring(System
.getenv("WORKSPACE").length() + 1);
1166 cursor
.insertComment(comment
);
1169 e
.printStackTrace();
1174 msa
.setModuleGuid(mi
.getGuid());
1175 msa
.setModuleVersion(mi
.getVersion());
1176 msa
.setPackageGuid(pi
.getGuid());
1177 msa
.setPackageVersion(pi
.getVersion());
1179 Vector
<String
> v
= new Vector
<String
>();
1181 msa
.setSupArchList(v
);
1187 private void genPcdData (String cName
, Object token
, String tsGuid
, String itemType
, String dataType
, String defaultVal
, ModuleSADocument
.ModuleSA moduleSa
)
1188 throws PcdItemTypeConflictException
, PcdValueMalFormed
{
1189 if (moduleSa
.getPcdBuildDefinition() == null){
1190 moduleSa
.addNewPcdBuildDefinition();
1193 // constructe pcd to modulesa mapping first.
1194 // Attention : for any error condition, remove from map this pcd.
1196 ArrayList
<String
> pcdConsumer
= LookupPlatformPcdData(cName
+ " " + tsGuid
);
1197 if (pcdConsumer
== null) {
1198 pcdConsumer
= new ArrayList
<String
>();
1201 // Using existing Pcd type, if this pcd already exists in other ModuleSA
1203 if (pcdConsumer
.size() > 0) {
1205 itemType
= itemType (pcdConsumer
.get(0));
1207 String listValue
= moduleSa
.getModuleGuid() + " " + moduleSa
.getModuleVersion()
1208 + " " + moduleSa
.getPackageGuid() + " " + moduleSa
.getPackageVersion() + " " + listToString(moduleSa
.getSupArchList())
1210 pcdConsumer
.add(listValue
);
1211 dynPcdMap
.put(cName
+ " " + tsGuid
, pcdConsumer
);
1213 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData fpdPcd
= moduleSa
.getPcdBuildDefinition().addNewPcdData();
1214 fpdPcd
.setCName(cName
);
1215 fpdPcd
.setToken(token
);
1216 fpdPcd
.setTokenSpaceGuidCName(tsGuid
);
1217 fpdPcd
.setDatumType(PcdDataTypes
.Enum
.forString(dataType
));
1218 fpdPcd
.setItemType(PcdItemTypes
.Enum
.forString(itemType
));
1220 if (defaultVal
!= null){
1221 fpdPcd
.setValue(defaultVal
);
1224 if (dataType
.equals("UINT8") || dataType
.equals("UINT16") || dataType
.equals("UINT32") || dataType
.equals("UINT64")) {
1225 fpdPcd
.setValue("0");
1227 if (dataType
.equals("BOOLEAN")){
1228 fpdPcd
.setValue("FALSE");
1230 if (dataType
.equals("VOID*")) {
1231 fpdPcd
.setValue("");
1235 // Using existing pcd value, if this pcd already exists in other moduleSa.
1237 if (defaultPcdValue
.get(cName
+ " " + tsGuid
) == null) {
1238 defaultPcdValue
.put(cName
+ " " + tsGuid
, fpdPcd
.getValue());
1241 fpdPcd
.setValue(defaultPcdValue
.get(cName
+ " " + tsGuid
));
1244 if (dataType
.equals("UINT8")){
1245 fpdPcd
.setMaxDatumSize(1);
1247 if (dataType
.equals("UINT16")) {
1248 fpdPcd
.setMaxDatumSize(2);
1250 if (dataType
.equals("UINT32")) {
1251 fpdPcd
.setMaxDatumSize(4);
1253 if (dataType
.equals("UINT64")){
1254 fpdPcd
.setMaxDatumSize(8);
1256 if (dataType
.equals("BOOLEAN")){
1257 fpdPcd
.setMaxDatumSize(1);
1259 if (dataType
.equals("VOID*")) {
1260 int maxSize
= setMaxSizeForPointer(fpdPcd
.getValue());
1261 fpdPcd
.setMaxDatumSize(maxSize
);
1265 if (itemType
.equals("DYNAMIC") || itemType
.equals("DYNAMIC_EX")) {
1266 ArrayList
<String
> al
= LookupDynamicPcdBuildDefinition(cName
+ " " + tsGuid
);
1268 // if only one module mapped to this pcd, then the one is myself. so no other module mapped.
1269 // so need to add one dyn pcd.
1271 if (al
.size() == 1) {
1272 addDynamicPcdBuildData(cName
, token
, tsGuid
, itemType
, dataType
, defaultVal
);
1278 public int setMaxSizeForPointer(String datum
) throws PcdValueMalFormed
{
1279 if (datum
== null) {
1282 char ch
= datum
.charAt(0);
1286 // For void* type PCD, only three datum is support:
1287 // 1) Unicode: string with start char is "L"
1288 // 2) Ansci: String is ""
1289 // 3) byte array: String start char "{"
1292 start
= datum
.indexOf('\"');
1293 end
= datum
.lastIndexOf('\"');
1294 if ((start
> end
) ||
1295 (end
> datum
.length())||
1296 ((start
== end
) && (datum
.length() > 0))) {
1297 //ToDo Error handling here
1298 throw new PcdValueMalFormed (datum
);
1301 strValue
= datum
.substring(start
+ 1, end
);
1302 return strValue
.length() * 2;
1303 } else if (ch
== '\"'){
1304 start
= datum
.indexOf('\"');
1305 end
= datum
.lastIndexOf('\"');
1306 if ((start
> end
) ||
1307 (end
> datum
.length())||
1308 ((start
== end
) && (datum
.length() > 0))) {
1309 throw new PcdValueMalFormed (datum
);
1311 strValue
= datum
.substring(start
+ 1, end
);
1312 return strValue
.length();
1313 } else if (ch
=='{') {
1314 String
[] strValueArray
;
1316 start
= datum
.indexOf('{');
1317 end
= datum
.lastIndexOf('}');
1318 strValue
= datum
.substring(start
+ 1, end
);
1319 strValue
= strValue
.trim();
1320 if (strValue
.length() == 0) {
1323 strValueArray
= strValue
.split(",");
1324 for (int index
= 0; index
< strValueArray
.length
; index
++) {
1325 Integer value
= Integer
.decode(strValueArray
[index
].trim());
1328 // "[FPD file error] The datum type of PCD %s in %s is VOID*, "+
1329 // "it must be a byte array. But the element of %s exceed the byte range",
1330 throw new PcdValueMalFormed (datum
);
1333 return strValueArray
.length
;
1337 // "[FPD file error] The datum type of PCD %s in %s is VOID*. For VOID* type, you have three format choise:\n "+
1338 // "1) UNICODE string: like L\"xxxx\";\r\n"+
1339 // "2) ANSIC string: like \"xxx\";\r\n"+
1340 // "3) Byte array: like {0x2, 0x45, 0x23}\r\n"+
1341 // "but the datum in seems does not following above format!",
1342 throw new PcdValueMalFormed (datum
);
1347 private ArrayList
<String
> LookupDynamicPcdBuildDefinition(String dynPcdKey
) {
1348 ArrayList
<String
> al
= dynPcdMap
.get(dynPcdKey
);
1353 private ArrayList
<String
> LookupPlatformPcdData(String pcdKey
) {
1355 return dynPcdMap
.get(pcdKey
);
1358 public int getDynamicPcdBuildDataCount() {
1359 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1360 removeElement(getfpdDynPcdBuildDefs());
1361 fpdDynPcdBuildDefs
= null;
1364 return getfpdDynPcdBuildDefs().getPcdBuildDataList().size();
1367 public void getDynamicPcdBuildData(String
[][] saa
) {
1368 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1369 removeElement(getfpdDynPcdBuildDefs());
1370 fpdDynPcdBuildDefs
= null;
1373 List
<DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
> l
= getfpdDynPcdBuildDefs().getPcdBuildDataList();
1374 ListIterator
<DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
> li
= l
.listIterator();
1376 while(li
.hasNext()) {
1377 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData dynPcd
= li
.next();
1378 saa
[i
][0] = dynPcd
.getCName();
1379 saa
[i
][1] = dynPcd
.getToken().toString();
1380 saa
[i
][2] = dynPcd
.getTokenSpaceGuidCName();
1381 saa
[i
][3] = dynPcd
.getMaxDatumSize()+"";
1382 saa
[i
][4] = dynPcd
.getDatumType().toString();
1388 public void addDynamicPcdBuildData(String cName
, Object token
, String tsGuid
, String itemType
, String dataType
, String defaultVal
)
1389 throws PcdValueMalFormed
{
1390 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData dynPcdData
= getfpdDynPcdBuildDefs().addNewPcdBuildData();
1391 dynPcdData
.setItemType(PcdItemTypes
.Enum
.forString(itemType
));
1392 dynPcdData
.setCName(cName
);
1393 dynPcdData
.setToken(token
);
1394 dynPcdData
.setTokenSpaceGuidCName(tsGuid
);
1395 dynPcdData
.setDatumType(PcdDataTypes
.Enum
.forString(dataType
));
1397 BigInteger bigInt
= new BigInteger("0");
1398 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo skuInfo
= dynPcdData
.addNewSkuInfo();
1399 skuInfo
.setSkuId(bigInt
);
1400 if (defaultVal
!= null){
1401 skuInfo
.setValue(defaultVal
);
1404 if (dataType
.equals("UINT8")){
1405 skuInfo
.setValue("0");
1407 if (dataType
.equals("UINT16")) {
1408 skuInfo
.setValue("0");
1410 if (dataType
.equals("UINT32")) {
1411 skuInfo
.setValue("0");
1413 if (dataType
.equals("UINT64")){
1414 skuInfo
.setValue("0");
1416 if (dataType
.equals("BOOLEAN")){
1417 skuInfo
.setValue("false");
1419 if (dataType
.equals("VOID*")) {
1420 skuInfo
.setValue("");
1423 if (dataType
.equals("UINT8")){
1424 dynPcdData
.setMaxDatumSize(1);
1426 if (dataType
.equals("UINT16")) {
1427 dynPcdData
.setMaxDatumSize(2);
1429 if (dataType
.equals("UINT32")) {
1430 dynPcdData
.setMaxDatumSize(4);
1432 if (dataType
.equals("UINT64")){
1433 dynPcdData
.setMaxDatumSize(8);
1435 if (dataType
.equals("BOOLEAN")){
1436 dynPcdData
.setMaxDatumSize(1);
1438 if (dataType
.equals("VOID*")) {
1439 int maxSize
= setMaxSizeForPointer(defaultVal
);
1440 dynPcdData
.setMaxDatumSize(maxSize
);
1444 public void removeDynamicPcdBuildData(String cName
, String tsGuid
) {
1445 XmlObject o
= fpdRoot
.getDynamicPcdBuildDefinitions();
1450 XmlCursor cursor
= o
.newCursor();
1451 if (cursor
.toFirstChild()) {
1453 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdBuildData
=
1454 (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1455 if (pcdBuildData
.getCName().equals(cName
) && pcdBuildData
.getTokenSpaceGuidCName().equals(tsGuid
)) {
1457 if (getDynamicPcdBuildDataCount() == 1) {
1465 while (cursor
.toNextSibling());
1470 // Get the Sku Info count of ith dyn pcd element.
1472 public int getDynamicPcdSkuInfoCount(int i
){
1473 if (fpdRoot
.getDynamicPcdBuildDefinitions() == null || fpdRoot
.getDynamicPcdBuildDefinitions().getPcdBuildDataList() == null
1474 || fpdRoot
.getDynamicPcdBuildDefinitions().getPcdBuildDataList().size() == 0) {
1478 int skuInfoCount
= 0;
1479 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1480 if (cursor
.toFirstChild()) {
1481 for (int j
= 0; j
< i
; ++j
) {
1482 cursor
.toNextSibling();
1484 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1485 if (pcdData
.getSkuInfoList() == null) {
1489 skuInfoCount
= pcdData
.getSkuInfoList().size();
1493 return skuInfoCount
;
1496 public void getDynamicPcdSkuInfos(int i
, String
[][] saa
){
1497 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1498 removeElement(getfpdDynPcdBuildDefs());
1499 fpdDynPcdBuildDefs
= null;
1503 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1504 if (cursor
.toFirstChild()) {
1505 for (int j
= 0; j
< i
; ++j
) {
1506 cursor
.toNextSibling();
1508 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1509 if (pcdData
.getSkuInfoList() == null) {
1514 ListIterator
<DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo
> li
= pcdData
.getSkuInfoList().listIterator();
1516 while (li
.hasNext()) {
1517 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo skuInfo
= li
.next();
1518 saa
[k
][0] = skuInfo
.getSkuId()+"";
1519 saa
[k
][1] = skuInfo
.getVariableName();
1520 saa
[k
][2] = skuInfo
.getVariableGuid();
1521 saa
[k
][3] = skuInfo
.getVariableOffset();
1522 saa
[k
][4] = skuInfo
.getHiiDefaultValue();
1523 saa
[k
][5] = skuInfo
.getVpdOffset();
1524 saa
[k
][6] = skuInfo
.getValue();
1534 public String
getDynamicPcdBuildDataValue(int i
){
1535 String value
= null;
1536 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1537 removeElement(getfpdDynPcdBuildDefs());
1538 fpdDynPcdBuildDefs
= null;
1542 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1543 if (cursor
.toFirstChild()) {
1544 for (int j
= 0; j
< i
; ++j
) {
1545 cursor
.toNextSibling();
1547 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1548 if (pcdData
.getSkuInfoList() == null) {
1552 value
= pcdData
.getSkuInfoArray(0).getValue();
1559 public String
getDynamicPcdBuildDataVpdOffset(int i
){
1560 String vpdOffset
= null;
1561 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1562 removeElement(getfpdDynPcdBuildDefs());
1563 fpdDynPcdBuildDefs
= null;
1567 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1568 if (cursor
.toFirstChild()) {
1569 for (int j
= 0; j
< i
; ++j
) {
1570 cursor
.toNextSibling();
1572 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1573 if (pcdData
.getSkuInfoList() == null) {
1577 vpdOffset
= pcdData
.getSkuInfoArray(0).getVpdOffset();
1584 public void removeDynamicPcdBuildDataSkuInfo(int i
) {
1585 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1586 removeElement(getfpdDynPcdBuildDefs());
1587 fpdDynPcdBuildDefs
= null;
1591 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1592 if (cursor
.toFirstChild()) {
1593 for (int j
= 0; j
< i
; ++j
) {
1594 cursor
.toNextSibling();
1596 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1597 if (pcdData
.getSkuInfoList() == null) {
1602 QName qSkuInfo
= new QName(xmlNs
, "SkuInfo");
1603 cursor
.toChild(qSkuInfo
);
1610 // generate sku info for ith dyn pcd build data.
1612 public void genDynamicPcdBuildDataSkuInfo(String id
, String varName
, String varGuid
, String varOffset
,
1613 String hiiDefault
, String vpdOffset
, String value
, int i
) {
1614 // if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1618 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1619 if (cursor
.toFirstChild()) {
1620 for (int j
= 0; j
< i
; ++j
) {
1621 cursor
.toNextSibling();
1623 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1624 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo skuInfo
= pcdData
.addNewSkuInfo();
1625 skuInfo
.setSkuId(new BigInteger(id
));
1626 if (varName
!= null){
1627 skuInfo
.setVariableName(varName
);
1628 skuInfo
.setVariableGuid(varGuid
);
1629 skuInfo
.setVariableOffset(varOffset
);
1630 skuInfo
.setHiiDefaultValue(hiiDefault
);
1632 else if (vpdOffset
!= null){
1633 skuInfo
.setVpdOffset(vpdOffset
);
1636 skuInfo
.setValue(value
);
1641 public void updateDynamicPcdBuildDataSkuInfo(String id
, String varName
, String varGuid
, String varOffset
,
1642 String hiiDefault
, String vpdOffset
, String value
, int i
){
1643 // if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1647 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1648 if (cursor
.toFirstChild()) {
1649 for (int j
= 0; j
< i
; ++j
) {
1650 cursor
.toNextSibling();
1652 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1653 ListIterator
<DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo
> li
= pcdData
.getSkuInfoList().listIterator();
1654 while (li
.hasNext()) {
1655 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo skuInfo
= li
.next();
1656 if (skuInfo
.getSkuId().toString().equals(id
)){
1657 if (varName
!= null){
1658 skuInfo
.setVariableName(varName
);
1659 skuInfo
.setVariableGuid(varGuid
);
1660 skuInfo
.setVariableOffset(varOffset
);
1661 skuInfo
.setHiiDefaultValue(hiiDefault
);
1663 else if (vpdOffset
!= null){
1664 skuInfo
.setVpdOffset(vpdOffset
);
1667 skuInfo
.setValue(value
);
1675 public BuildOptionsDocument
.BuildOptions
getfpdBuildOpts() {
1676 if (fpdBuildOpts
== null) {
1677 fpdBuildOpts
= fpdRoot
.addNewBuildOptions();
1679 return fpdBuildOpts
;
1682 public void genBuildOptionsUserExtensions(String fvName
, String outputFileName
, Vector
<String
[]> includeModules
) {
1683 QName elementFvName
= new QName (xmlNs
, "FvName");
1684 QName elementIncludeModules
= new QName(xmlNs
, "IncludeModules");
1685 QName elementInfFileName
= new QName(xmlNs
, "InfFileName");
1686 QName elementModule
= new QName(xmlNs
, "Module");
1688 UserExtensionsDocument
.UserExtensions userExts
= getfpdBuildOpts().addNewUserExtensions();
1689 userExts
.setUserID("IMAGES");
1690 userExts
.setIdentifier(new BigInteger("1"));
1691 XmlCursor cursor
= userExts
.newCursor();
1692 cursor
.toEndToken();
1694 cursor
.beginElement(elementFvName
);
1695 cursor
.insertChars(fvName
);
1696 cursor
.toNextToken();
1698 cursor
.beginElement(elementInfFileName
);
1699 cursor
.insertChars(fvName
+ ".inf");
1700 cursor
.toNextToken();
1702 cursor
.beginElement(elementIncludeModules
);
1703 for (int i
= 0; i
< includeModules
.size(); ++i
) {
1704 cursor
.beginElement(elementModule
);
1705 cursor
.insertAttributeWithValue("ModuleGuid", includeModules
.get(i
)[0]);
1706 cursor
.insertAttributeWithValue("BaseName", includeModules
.get(i
)[1]);
1707 cursor
.toEndToken();
1708 cursor
.toNextToken();
1713 public int getUserExtsIncModCount (String fvName
) {
1714 if (getfpdBuildOpts().getUserExtensionsList() == null) {
1717 ListIterator
<UserExtensionsDocument
.UserExtensions
> li
= getfpdBuildOpts().getUserExtensionsList().listIterator();
1718 QName elementIncludeModules
= new QName(xmlNs
, "IncludeModules");
1719 while (li
.hasNext()) {
1720 UserExtensionsDocument
.UserExtensions ues
= li
.next();
1721 if (!ues
.getUserID().equals("IMAGES")) {
1724 XmlCursor cursor
= ues
.newCursor();
1725 cursor
.toFirstChild();
1726 String elementName
= cursor
.getTextValue();
1727 if (elementName
.equals(fvName
)) {
1728 cursor
.toNextSibling(elementIncludeModules
);
1729 if (cursor
.toFirstChild()) {
1731 for (i
= 1; cursor
.toNextSibling(); ++i
);
1743 public void getUserExtsIncMods(String fvName
, String
[][] saa
) {
1744 if (getfpdBuildOpts().getUserExtensionsList() == null) {
1748 XmlCursor cursor
= getfpdBuildOpts().newCursor();
1749 QName elementUserExts
= new QName (xmlNs
, "UserExtensions");
1750 QName attribUserId
= new QName ("UserID");
1751 QName elementFvName
= new QName (xmlNs
, "FvName");
1752 QName elementIncludeModules
= new QName(xmlNs
, "IncludeModules");
1753 QName attribModuleGuid
= new QName("ModuleGuid");
1754 QName attribBaseName
= new QName("BaseName");
1756 if (cursor
.toChild(elementUserExts
)) {
1759 if (cursor
.getAttributeText(attribUserId
).equals("IMAGES")) {
1760 cursor
.toChild(elementFvName
);
1761 String elementName
= cursor
.getTextValue();
1762 if (elementName
.equals(fvName
)) {
1763 cursor
.toNextSibling(elementIncludeModules
);
1764 if (cursor
.toFirstChild()) {
1767 saa
[i
][0] = cursor
.getAttributeText(attribModuleGuid
);
1768 saa
[i
][1] = cursor
.getAttributeText(attribBaseName
);
1770 }while (cursor
.toNextSibling());
1776 }while (cursor
.toNextSibling(elementUserExts
));
1782 public void updateBuildOptionsUserExtensions (String oldFvName
, String newFvName
) {
1783 if (getfpdBuildOpts().getUserExtensionsList() == null) {
1786 ListIterator
<UserExtensionsDocument
.UserExtensions
> li
= getfpdBuildOpts().getUserExtensionsList().listIterator();
1787 while (li
.hasNext()) {
1788 UserExtensionsDocument
.UserExtensions ues
= li
.next();
1789 if (!ues
.getUserID().equals("IMAGES")) {
1792 XmlCursor cursor
= ues
.newCursor();
1793 cursor
.toFirstChild();
1794 String elementName
= cursor
.getTextValue();
1795 if (elementName
.equals(oldFvName
)) {
1796 cursor
.setTextValue(newFvName
);
1803 public void removeBuildOptionsUserExtensions (String fvName
) {
1804 if (getfpdBuildOpts().getUserExtensionsList() == null) {
1808 ListIterator
<UserExtensionsDocument
.UserExtensions
> li
= getfpdBuildOpts().getUserExtensionsList().listIterator();
1809 while (li
.hasNext()) {
1810 UserExtensionsDocument
.UserExtensions ues
= li
.next();
1811 if (!ues
.getUserID().equals("IMAGES")) {
1814 XmlCursor cursor
= ues
.newCursor();
1815 cursor
.toFirstChild();
1816 String elementName
= cursor
.getTextValue();
1817 if (elementName
.equals(fvName
)) {
1829 public void genBuildOptionsUserDefAntTask (String id
, String fileName
, String execOrder
) {
1830 UserDefinedAntTasksDocument
.UserDefinedAntTasks udats
= getfpdBuildOpts().getUserDefinedAntTasks();
1831 if (udats
== null) {
1832 udats
= getfpdBuildOpts().addNewUserDefinedAntTasks();
1835 AntTaskDocument
.AntTask at
= udats
.addNewAntTask();
1836 setBuildOptionsUserDefAntTask(id
, fileName
, execOrder
, at
);
1839 private void setBuildOptionsUserDefAntTask(String id
, String fileName
, String execOrder
, AntTaskDocument
.AntTask at
) {
1840 at
.setId(new Integer(id
));
1841 XmlCursor cursor
= at
.newCursor();
1842 if (fileName
!= null){
1843 at
.setFilename(fileName
);
1845 else if (cursor
.toChild(xmlNs
, "Filename")) {
1848 if (execOrder
!= null) {
1849 at
.setAntCmdOptions(execOrder
);
1851 else if (cursor
.toChild(xmlNs
, "AntCmdOptions")) {
1857 public void removeBuildOptionsUserDefAntTask(int i
) {
1858 XmlObject o
= getfpdBuildOpts().getUserDefinedAntTasks();
1862 XmlCursor cursor
= o
.newCursor();
1863 if (cursor
.toFirstChild()) {
1864 for (int j
= 0; j
< i
; ++j
) {
1865 cursor
.toNextSibling();
1868 if (getBuildOptionsUserDefAntTaskCount() == 0) {
1876 public void updateBuildOptionsUserDefAntTask(int i
, String id
, String fileName
, String execOrder
){
1877 XmlObject o
= getfpdBuildOpts().getUserDefinedAntTasks();
1881 XmlCursor cursor
= o
.newCursor();
1882 if (cursor
.toFirstChild()) {
1883 for (int j
= 0; j
< i
; ++j
) {
1884 cursor
.toNextSibling();
1886 AntTaskDocument
.AntTask at
= (AntTaskDocument
.AntTask
)cursor
.getObject();
1887 setBuildOptionsUserDefAntTask(id
, fileName
, execOrder
, at
);
1892 public int getBuildOptionsUserDefAntTaskCount() {
1893 UserDefinedAntTasksDocument
.UserDefinedAntTasks udats
= getfpdBuildOpts().getUserDefinedAntTasks();
1894 if (udats
== null || udats
.getAntTaskList() == null) {
1898 return udats
.getAntTaskList().size();
1901 public void getBuildOptionsUserDefAntTasks(String
[][] saa
) {
1902 UserDefinedAntTasksDocument
.UserDefinedAntTasks udats
= getfpdBuildOpts().getUserDefinedAntTasks();
1903 if (udats
== null || udats
.getAntTaskList() == null) {
1907 List
<AntTaskDocument
.AntTask
> l
= udats
.getAntTaskList();
1908 ListIterator li
= l
.listIterator();
1910 while (li
.hasNext()) {
1911 AntTaskDocument
.AntTask at
= (AntTaskDocument
.AntTask
)li
.next();
1912 saa
[i
][0] = at
.getId() + "";
1913 saa
[i
][1] = saa
[i
][2] = "";
1914 if (at
.getFilename() != null){
1915 saa
[i
][1] = at
.getFilename();
1917 if (at
.getAntCmdOptions() != null) {
1918 saa
[i
][2] = at
.getAntCmdOptions();
1923 public void genBuildOptionsOpt(Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
) {
1924 OptionsDocument
.Options opts
= getfpdBuildOpts().getOptions();
1926 opts
= getfpdBuildOpts().addNewOptions();
1928 OptionDocument
.Option opt
= opts
.addNewOption();
1929 setBuildOptionsOpt(buildTargets
, toolChain
, tagName
, toolCmd
, archList
, contents
, opt
);
1932 private void setBuildOptionsOpt(Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
, OptionDocument
.Option opt
){
1933 opt
.setStringValue(contents
);
1935 opt
.setBuildTargets(buildTargets
);
1936 opt
.setToolChainFamily(toolChain
);
1937 opt
.setTagName(tagName
);
1938 opt
.setToolCode(toolCmd
);
1940 if (archList
!= null) {
1941 opt
.setSupArchList(archList
);
1944 if (opt
.isSetSupArchList()) {
1945 opt
.unsetSupArchList();
1950 public void removeBuildOptionsOpt(int i
){
1952 XmlObject o
= getfpdBuildOpts().getOptions();
1957 XmlCursor cursor
= o
.newCursor();
1958 if (cursor
.toFirstChild()) {
1959 for (int j
= 0; j
< i
; ++j
) {
1960 cursor
.toNextSibling();
1963 if (getBuildOptionsOptCount() == 0) {
1971 public void updateBuildOptionsOpt(int i
, Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
) {
1972 XmlObject o
= getfpdBuildOpts().getOptions();
1977 XmlCursor cursor
= o
.newCursor();
1978 if (cursor
.toFirstChild()) {
1979 for (int j
= 0; j
< i
; ++j
) {
1980 cursor
.toNextSibling();
1982 OptionDocument
.Option opt
= (OptionDocument
.Option
)cursor
.getObject();
1983 setBuildOptionsOpt(buildTargets
, toolChain
, tagName
, toolCmd
, archList
, contents
, opt
);
1988 public int getBuildOptionsOptCount(){
1989 if (getfpdBuildOpts().getOptions() == null || getfpdBuildOpts().getOptions().getOptionList() == null) {
1992 return getfpdBuildOpts().getOptions().getOptionList().size();
1995 public void getBuildOptionsOpts(String
[][] saa
) {
1996 if (getfpdBuildOpts().getOptions() == null || getfpdBuildOpts().getOptions().getOptionList() == null) {
2000 List
<OptionDocument
.Option
> lOpt
= getfpdBuildOpts().getOptions().getOptionList();
2001 ListIterator li
= lOpt
.listIterator();
2003 while(li
.hasNext()) {
2004 OptionDocument
.Option opt
= (OptionDocument
.Option
)li
.next();
2005 if (opt
.getBuildTargets() != null) {
2006 saa
[i
][0] = listToString(opt
.getBuildTargets());
2008 saa
[i
][1] = opt
.getToolChainFamily();
2009 if (opt
.getSupArchList() != null){
2010 saa
[i
][2] = listToString(opt
.getSupArchList());
2013 saa
[i
][3] = opt
.getToolCode();
2014 saa
[i
][4] = opt
.getTagName();
2015 saa
[i
][5] = opt
.getStringValue();
2021 public void genBuildOptionsFfs(String ffsKey
, String type
) {
2022 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getfpdBuildOpts().addNewFfs();
2023 ffs
.setFfsKey(ffsKey
);
2025 ffs
.addNewSections().setEncapsulationType(type
);
2029 public void updateBuildOptionsFfsSectionsType(int i
, String type
) {
2030 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getfpdBuildOpts().addNewFfs();
2032 ffs
.addNewSections().setEncapsulationType(type
);
2036 public void genBuildOptionsFfsAttribute(int i
, String name
, String value
) {
2037 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2038 BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute attrib
= ffs
.addNewAttribute();
2039 attrib
.setName(name
);
2040 attrib
.setValue(value
);
2043 /**update jth attribute of ith ffs.
2047 public void updateBuildOptionsFfsAttribute(int i
, int j
, String name
, String value
){
2048 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2049 XmlCursor cursor
= ffs
.newCursor();
2050 QName qAttrib
= new QName(xmlNs
, "Attribute");
2051 if (cursor
.toChild(qAttrib
)) {
2052 for (int k
= 0; k
< j
; ++k
) {
2053 cursor
.toNextSibling(qAttrib
);
2055 BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute attrib
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute
)cursor
.getObject();
2056 attrib
.setName(name
);
2057 attrib
.setValue(value
);
2062 public void removeBuildOptionsFfsAttribute(int i
, int j
){
2063 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2064 XmlCursor cursor
= ffs
.newCursor();
2065 QName qAttrib
= new QName(xmlNs
, "Attribute");
2066 if (cursor
.toChild(qAttrib
)) {
2067 for (int k
= 0; k
< j
; ++k
) {
2068 cursor
.toNextSibling(qAttrib
);
2075 public void genBuildOptionsFfsSectionsSection(int i
, String sectionType
) {
2076 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2080 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2082 if (sections
== null){
2083 sections
= ffs
.addNewSections();
2085 sections
.addNewSection().setSectionType(EfiSectionType
.Enum
.forString(sectionType
));
2088 public void removeBuildOptionsFfsSectionsSection(int i
, int j
) {
2089 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2090 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2091 if (sections
== null) {
2094 XmlCursor cursor
= sections
.newCursor();
2095 QName qSection
= new QName(xmlNs
, "Section");
2096 if (cursor
.toChild(qSection
)) {
2097 for (int k
= 0; k
< j
; ++k
) {
2098 cursor
.toNextSibling(qSection
);
2105 public void updateBuildOptionsFfsSectionsSection(int i
, int j
, String type
){
2106 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2107 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2108 if (sections
== null) {
2111 XmlCursor cursor
= sections
.newCursor();
2112 QName qSection
= new QName(xmlNs
, "Section");
2113 if (cursor
.toChild(qSection
)) {
2114 for (int k
= 0; k
< j
; ++k
) {
2115 cursor
.toNextSibling(qSection
);
2117 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Section section
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Section
)cursor
.getObject();
2118 section
.setSectionType(EfiSectionType
.Enum
.forString(type
));
2123 public void genBuildOptionsFfsSectionsSections(int i
, String encapType
) {
2124 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2128 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2130 if (sections
== null){
2131 sections
= ffs
.addNewSections();
2133 sections
.addNewSections().setEncapsulationType(encapType
);
2136 public void removeBuildOptionsFfsSectionsSections(int i
, int j
) {
2137 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2138 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2139 if (sections
== null) {
2142 XmlCursor cursor
= sections
.newCursor();
2143 QName qSections
= new QName(xmlNs
, "Sections");
2144 if (cursor
.toChild(qSections
)) {
2145 for (int k
= 0; k
< j
; ++k
) {
2146 cursor
.toNextSibling(qSections
);
2153 public void updateBuildOptionsFfsSectionsSections(int i
, int j
, String type
) {
2154 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2155 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2156 if (sections
== null) {
2159 XmlCursor cursor
= sections
.newCursor();
2160 QName qSections
= new QName(xmlNs
, "Sections");
2161 if (cursor
.toChild(qSections
)) {
2162 for (int k
= 0; k
< j
; ++k
) {
2163 cursor
.toNextSibling(qSections
);
2165 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2 sections2
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
)cursor
.getObject();
2166 sections2
.setEncapsulationType(type
);
2171 public void genBuildOptionsFfsSectionsSectionsSection(int i
, int j
, String type
) {
2172 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2176 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2177 XmlCursor cursor
= sections
.newCursor();
2178 QName qSections
= new QName(xmlNs
, "Sections");
2179 if (cursor
.toChild(qSections
)){
2180 for (int k
= 0; k
< j
; ++k
) {
2181 cursor
.toNextSibling(qSections
);
2183 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2 sections2
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
)cursor
.getObject();
2184 sections2
.addNewSection().setSectionType(EfiSectionType
.Enum
.forString(type
));
2189 public void removeBuildOptionsFfsSectionsSectionsSection(int i
, int j
, int k
) {
2190 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2191 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2192 if (sections
== null) {
2195 XmlCursor cursor
= sections
.newCursor();
2196 QName qSections
= new QName(xmlNs
, "Sections");
2197 if (cursor
.toChild(qSections
)) {
2198 for (int l
= 0; l
< j
; ++l
) {
2199 cursor
.toNextSibling(qSections
);
2201 if (cursor
.toFirstChild()) {
2203 for (; m
< k
; ++m
) {
2204 cursor
.toNextSibling();
2216 public void updateBuildOptionsFfsSectionsSectionsSection(int i
, int j
, int k
, String type
) {
2217 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2218 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2219 if (sections
== null) {
2222 XmlCursor cursor
= sections
.newCursor();
2223 QName qSections
= new QName(xmlNs
, "Sections");
2224 if (cursor
.toChild(qSections
)) {
2225 for (int l
= 0; l
< j
; ++l
) {
2226 cursor
.toNextSibling(qSections
);
2228 if (cursor
.toFirstChild()) {
2229 for (int m
= 0; m
< k
; ++m
) {
2230 cursor
.toNextSibling();
2232 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section section
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section
)cursor
.getObject();
2233 section
.setSectionType(EfiSectionType
.Enum
.forString(type
));
2239 public void getBuildOptionsFfsSectionsSectionsSection(int i
, int j
, ArrayList
<String
> al
) {
2240 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2244 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2245 XmlCursor cursor
= sections
.newCursor();
2246 QName qSections
= new QName(xmlNs
, "Sections");
2247 if (cursor
.toChild(qSections
)){
2248 for (int k
= 0; k
< j
; ++k
) {
2249 cursor
.toNextSibling(qSections
);
2251 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2 sections2
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
)cursor
.getObject();
2252 if (sections2
.getSectionList() == null){
2256 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section
> li
= sections2
.getSectionList().listIterator();
2257 while(li
.hasNext()) {
2258 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section section
= li
.next();
2259 if (section
.isSetSectionType()) {
2260 al
.add(section
.getSectionType().toString());
2269 public int getBuildOptionsFfsCount(){
2270 if (getfpdBuildOpts().getFfsList() == null) {
2273 return getfpdBuildOpts().getFfsList().size();
2276 public void getBuildOptionsFfsKey(String
[][] saa
) {
2277 if (getfpdBuildOpts().getFfsList() == null) {
2280 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
> li
= getfpdBuildOpts().getFfsList().listIterator();
2282 while(li
.hasNext()){
2283 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= li
.next();
2284 saa
[i
][0] = ffs
.getFfsKey();
2289 public void updateBuildOptionsFfsKey(int i
, String key
) {
2290 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2294 /**Get ith FFS key and contents.
2297 public void getBuildOptionsFfs(int i
, String
[] sa
, LinkedHashMap
<String
, String
> ffsAttribMap
, ArrayList
<String
> firstLevelSections
, ArrayList
<String
> firstLevelSection
) {
2298 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2302 sa
[0] = ffs
.getFfsKey();
2303 if (ffs
.getSections() != null) {
2304 if(ffs
.getSections().getEncapsulationType() != null){
2305 sa
[1] = ffs
.getSections().getEncapsulationType();
2307 if (ffs
.getSections().getSectionList() != null){
2308 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Section
> li
= ffs
.getSections().getSectionList().listIterator();
2309 while (li
.hasNext()) {
2310 firstLevelSection
.add(li
.next().getSectionType().toString());
2313 if (ffs
.getSections().getSectionsList() != null) {
2314 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
> li
= ffs
.getSections().getSectionsList().listIterator();
2315 while(li
.hasNext()) {
2316 firstLevelSections
.add(li
.next().getEncapsulationType());
2320 if (ffs
.getAttributeList() != null) {
2321 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute
> li
= ffs
.getAttributeList().listIterator();
2322 while(li
.hasNext()) {
2323 BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute attrib
= li
.next();
2324 ffsAttribMap
.put(attrib
.getName(), attrib
.getValue());
2333 private BuildOptionsDocument
.BuildOptions
.Ffs
getFfs(int i
) {
2334 XmlObject o
= getfpdBuildOpts();
2335 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= null;
2337 XmlCursor cursor
= o
.newCursor();
2338 QName qFfs
= new QName(xmlNs
, "Ffs");
2339 if (cursor
.toChild(qFfs
)) {
2340 for (int j
= 0; j
< i
; ++j
) {
2341 cursor
.toNextSibling(qFfs
);
2343 ffs
= (BuildOptionsDocument
.BuildOptions
.Ffs
)cursor
.getObject();
2349 public void removeBuildOptionsFfs(int i
) {
2350 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2355 XmlCursor cursor
= ffs
.newCursor();
2362 public PlatformDefinitionsDocument
.PlatformDefinitions
getfpdPlatformDefs(){
2363 if (fpdPlatformDefs
== null){
2364 fpdPlatformDefs
= fpdRoot
.addNewPlatformDefinitions();
2366 return fpdPlatformDefs
;
2369 public void getPlatformDefsSupportedArchs(Vector
<Object
> archs
){
2370 if (getfpdPlatformDefs().getSupportedArchitectures() == null) {
2373 ListIterator li
= getfpdPlatformDefs().getSupportedArchitectures().listIterator();
2374 while(li
.hasNext()) {
2375 archs
.add(li
.next());
2379 public void setPlatformDefsSupportedArchs(Vector
<Object
> archs
) {
2380 if (archs
!= null) {
2381 getfpdPlatformDefs().setSupportedArchitectures(archs
);
2384 // XmlCursor cursor = getfpdPlatformDefs().newCursor();
2385 // if (cursor.toChild(xmlNs, "SupportedArchitectures")) {
2386 // cursor.removeXml();
2388 // cursor.dispose();
2392 public void getPlatformDefsBuildTargets(Vector
<Object
> targets
) {
2393 if (getfpdPlatformDefs().getBuildTargets() == null) {
2396 ListIterator li
= getfpdPlatformDefs().getBuildTargets().listIterator();
2397 while(li
.hasNext()) {
2398 targets
.add(li
.next());
2402 public void setPlatformDefsBuildTargets(Vector
<Object
> targets
) {
2403 getfpdPlatformDefs().setBuildTargets(targets
);
2406 public void genPlatformDefsSkuInfo(String id
, String name
) {
2407 SkuInfoDocument
.SkuInfo skuInfo
= null;
2408 if (getfpdPlatformDefs().getSkuInfo() == null) {
2409 skuInfo
= getfpdPlatformDefs().addNewSkuInfo();
2411 skuInfo
= getfpdPlatformDefs().getSkuInfo();
2412 if (skuInfo
.getUiSkuNameList() == null || skuInfo
.getUiSkuNameList().size() == 0) {
2413 SkuInfoDocument
.SkuInfo
.UiSkuName skuName
= skuInfo
.addNewUiSkuName();
2414 skuName
.setSkuID(new BigInteger("0"));
2415 skuName
.setStringValue("DEFAULT");
2417 if (id
.equals("0")) {
2420 SkuInfoDocument
.SkuInfo
.UiSkuName skuName
= skuInfo
.addNewUiSkuName();
2421 skuName
.setSkuID(new BigInteger(id
));
2422 skuName
.setStringValue(name
);
2425 public int getPlatformDefsSkuInfoCount(){
2426 if (getfpdPlatformDefs().getSkuInfo() == null || getfpdPlatformDefs().getSkuInfo().getUiSkuNameList() == null) {
2429 return getfpdPlatformDefs().getSkuInfo().getUiSkuNameList().size();
2432 public void getPlatformDefsSkuInfos(String
[][] saa
){
2433 if (getfpdPlatformDefs().getSkuInfo() == null || getfpdPlatformDefs().getSkuInfo().getUiSkuNameList() == null) {
2434 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null) {
2435 removeElement(getfpdDynPcdBuildDefs());
2436 fpdDynPcdBuildDefs
= null;
2441 List
<SkuInfoDocument
.SkuInfo
.UiSkuName
> l
= getfpdPlatformDefs().getSkuInfo().getUiSkuNameList();
2442 ListIterator
<SkuInfoDocument
.SkuInfo
.UiSkuName
> li
= l
.listIterator();
2444 while(li
.hasNext()) {
2445 SkuInfoDocument
.SkuInfo
.UiSkuName sku
= li
.next();
2446 saa
[i
][0] = sku
.getSkuID()+"";
2447 saa
[i
][1] = sku
.getStringValue();
2452 public void removePlatformDefsSkuInfo(int i
) {
2453 SkuInfoDocument
.SkuInfo skuInfo
= getfpdPlatformDefs().getSkuInfo();
2454 if (skuInfo
== null || i
== 0) {
2458 XmlCursor cursor
= skuInfo
.newCursor();
2459 if (cursor
.toFirstChild()) {
2460 for (int j
= 0; j
< i
; ++j
) {
2461 cursor
.toNextSibling();
2468 public void updatePlatformDefsSkuInfo(int i
, String id
, String name
) {
2469 SkuInfoDocument
.SkuInfo skuInfo
= getfpdPlatformDefs().getSkuInfo();
2470 if (skuInfo
== null || i
== 0) {
2474 XmlCursor cursor
= skuInfo
.newCursor();
2475 if (cursor
.toFirstChild()) {
2476 for (int j
= 0; j
< i
; ++j
) {
2477 cursor
.toNextSibling();
2479 SkuInfoDocument
.SkuInfo
.UiSkuName sku
= (SkuInfoDocument
.SkuInfo
.UiSkuName
)cursor
.getObject();
2480 sku
.setSkuID(new BigInteger(id
));
2481 sku
.setStringValue(name
);
2486 public String
getPlatformDefsInterDir(){
2487 if (getfpdPlatformDefs().getIntermediateDirectories() == null) {
2490 return getfpdPlatformDefs().getIntermediateDirectories().toString();
2493 public void setPlatformDefsInterDir(String interDir
){
2494 getfpdPlatformDefs().setIntermediateDirectories(IntermediateOutputType
.Enum
.forString(interDir
));
2497 public String
getPlatformDefsOutputDir() {
2498 return getfpdPlatformDefs().getOutputDirectory();
2501 public void setPlatformDefsOutputDir(String outputDir
) {
2502 if (outputDir
!= null && outputDir
.length() > 0) {
2503 getfpdPlatformDefs().setOutputDirectory(outputDir
);
2506 XmlCursor cursor
= getfpdPlatformDefs().newCursor();
2507 if (cursor
.toChild(new QName(xmlNs
, "OutputDirectory"))) {
2514 public FlashDocument
.Flash
getfpdFlash() {
2515 if (fpdFlash
== null) {
2516 fpdFlash
= fpdRoot
.addNewFlash();
2521 public void genFlashDefinitionFile(String file
) {
2522 FlashDefinitionFileDocument
.FlashDefinitionFile fdf
= getfpdFlash().getFlashDefinitionFile();
2524 fdf
= getfpdFlash().addNewFlashDefinitionFile();
2527 fdf
.setStringValue(file
);
2530 public String
getFlashDefinitionFile() {
2531 FlashDefinitionFileDocument
.FlashDefinitionFile fdf
= getfpdFlash().getFlashDefinitionFile();
2536 return fdf
.getStringValue();
2539 public void genFvImagesNameValue(String name
, String value
) {
2541 FvImagesDocument
.FvImages fi
= getfpdFlash().getFvImages();
2543 fi
= getfpdFlash().addNewFvImages();
2546 FvImagesDocument
.FvImages
.NameValue nv
= fi
.addNewNameValue();
2551 public void removeFvImagesNameValue(int i
){
2553 XmlObject o
= getfpdFlash().getFvImages();
2558 QName qNameValue
= new QName(xmlNs
, "NameValue");
2559 XmlCursor cursor
= o
.newCursor();
2560 if (cursor
.toChild(qNameValue
)) {
2561 for (int j
= 0; j
< i
; ++j
) {
2562 cursor
.toNextSibling(qNameValue
);
2569 public void updateFvImagesNameValue(int i
, String name
, String value
){
2571 XmlObject o
= getfpdFlash().getFvImages();
2576 QName qNameValue
= new QName(xmlNs
, "NameValue");
2577 XmlCursor cursor
= o
.newCursor();
2578 if (cursor
.toChild(qNameValue
)) {
2579 for (int j
= 0; j
< i
; ++j
) {
2580 cursor
.toNextSibling(qNameValue
);
2582 FvImagesDocument
.FvImages
.NameValue nv
= (FvImagesDocument
.FvImages
.NameValue
)cursor
.getObject();
2589 public int getFvImagesNameValueCount() {
2591 FvImagesDocument
.FvImages fi
= null;
2592 if ((fi
= getfpdFlash().getFvImages()) == null || fi
.getNameValueList() == null) {
2595 return fi
.getNameValueList().size();
2598 public void getFvImagesNameValues(String
[][] nv
) {
2600 FvImagesDocument
.FvImages fi
= getfpdFlash().getFvImages();
2604 List
<FvImagesDocument
.FvImages
.NameValue
> l
= fi
.getNameValueList();
2606 ListIterator li
= l
.listIterator();
2607 while (li
.hasNext()) {
2608 FvImagesDocument
.FvImages
.NameValue e
= (FvImagesDocument
.FvImages
.NameValue
) li
2610 nv
[i
][0] = e
.getName();
2611 nv
[i
][1] = e
.getValue();
2617 public void getFvImagesFvImageFvImageNames (Vector
<String
> vImageNames
) {
2618 FvImagesDocument
.FvImages fis
= getfpdFlash().getFvImages();
2619 if (fis
== null || fis
.getFvImageList() == null) {
2623 ListIterator
<FvImagesDocument
.FvImages
.FvImage
> li
= fis
.getFvImageList().listIterator();
2624 while (li
.hasNext()) {
2625 FvImagesDocument
.FvImages
.FvImage fi
= li
.next();
2626 if (fi
.getType().toString().equals("ImageName")) {
2627 vImageNames
.addAll(fi
.getFvImageNamesList());
2633 public void addFvImageFvImageNames (String
[] fvNames
) {
2634 FvImagesDocument
.FvImages fis
= getfpdFlash().getFvImages();
2635 if (fis
== null || fis
.getFvImageList() == null) {
2636 genFvImagesFvImage (fvNames
, "ImageName", null);
2640 ListIterator
<FvImagesDocument
.FvImages
.FvImage
> li
= fis
.getFvImageList().listIterator();
2641 while (li
.hasNext()) {
2642 FvImagesDocument
.FvImages
.FvImage fi
= li
.next();
2643 if (fi
.getType().toString().equals("ImageName")) {
2644 addFvImageNamesInFvImage (fi
, fvNames
);
2648 genFvImagesFvImage (fvNames
, "ImageName", null);
2651 public void addFvImageNamesInFvImage (FvImagesDocument
.FvImages
.FvImage fi
, String
[] fvNames
) {
2653 for (int i
= 0; i
< fvNames
.length
; ++i
) {
2654 fi
.addFvImageNames(fvNames
[i
]);
2658 public void addFvImageNamesInFvImage (int i
, String
[] fvNames
) {
2659 XmlObject o
= getfpdFlash().getFvImages();
2663 XmlCursor cursor
= o
.newCursor();
2664 QName qFvImage
= new QName(xmlNs
, "FvImage");
2665 if (cursor
.toChild(qFvImage
)) {
2666 for (int j
= 0; j
< i
; ++j
) {
2667 cursor
.toNextSibling(qFvImage
);
2669 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
2670 addFvImageNamesInFvImage(fi
, fvNames
);
2675 public void genFvImagesFvImage(String
[] names
, String types
, Map
<String
, String
> options
) {
2677 FvImagesDocument
.FvImages fis
= null;
2678 if ((fis
= getfpdFlash().getFvImages()) == null) {
2679 fis
= getfpdFlash().addNewFvImages();
2683 //gen FvImage with FvImageNames array
2685 FvImagesDocument
.FvImages
.FvImage fi
= fis
.addNewFvImage();
2686 for (int i
= 0; i
< names
.length
; ++i
) {
2687 fi
.addFvImageNames(names
[i
]);
2689 fi
.setType(FvImageTypes
.Enum
.forString(types
));
2690 if (options
!= null){
2691 setFvImagesFvImageFvImageOptions(options
, fi
);
2695 private void setFvImagesFvImageFvImageOptions(Map
<String
, String
> options
, FvImagesDocument
.FvImages
.FvImage fi
){
2696 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions fio
= fi
.getFvImageOptions();
2698 fio
= fi
.addNewFvImageOptions();
2701 Set
<String
> key
= options
.keySet();
2702 Iterator
<String
> i
= key
.iterator();
2703 while (i
.hasNext()) {
2705 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nv
= fio
.addNewNameValue();
2706 String k
= (String
)i
.next();
2709 nv
.setValue((String
)options
.get(k
));
2716 public void removeFvImagesFvImage(int i
) {
2718 XmlObject o
= getfpdFlash().getFvImages();
2723 QName qFvImage
= new QName(xmlNs
, "FvImage");
2724 XmlCursor cursor
= o
.newCursor();
2725 if (cursor
.toChild(qFvImage
)) {
2726 for (int j
= 0; j
< i
; ++j
) {
2727 cursor
.toNextSibling(qFvImage
);
2736 * @param newFvName The New FV Name. If null, remove the old FvImageNames entry.
2738 public void updateFvImageNameAll (String oldFvName
, String newFvName
) {
2739 if (getfpdFlash().getFvImages() == null || getfpdFlash().getFvImages().getFvImageList() == null) {
2742 ListIterator
<FvImagesDocument
.FvImages
.FvImage
> li
= getfpdFlash().getFvImages().getFvImageList().listIterator();
2743 while (li
.hasNext()) {
2744 FvImagesDocument
.FvImages
.FvImage fi
= li
.next();
2745 updateFvImageNamesInFvImage (fi
, oldFvName
, newFvName
);
2746 if (fi
.getFvImageNamesList().size() == 0) {
2752 public void updateFvImageNamesInFvImage (int i
, String oldFvName
, String newFvName
) {
2753 XmlObject o
= getfpdFlash().getFvImages();
2757 XmlCursor cursor
= o
.newCursor();
2758 QName qFvImage
= new QName(xmlNs
, "FvImage");
2759 if (cursor
.toChild(qFvImage
)) {
2760 for (int j
= 0; j
< i
; ++j
) {
2761 cursor
.toNextSibling(qFvImage
);
2763 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
2764 updateFvImageNamesInFvImage (fi
, oldFvName
, newFvName
);
2770 * @param oldFvName The FV Name to be replaced.
2771 * @param newFvName The New FV Name. If null, remove the old FvImageNames entry.
2773 public void updateFvImageNamesInFvImage (FvImagesDocument
.FvImages
.FvImage fi
, String oldFvName
, String newFvName
) {
2774 QName qFvImageNames
= new QName(xmlNs
, "FvImageNames");
2775 XmlCursor cursor
= fi
.newCursor();
2777 if (cursor
.toChild(qFvImageNames
)) {
2779 String xmlValue
= cursor
.getTextValue();
2780 if (xmlValue
.equals(oldFvName
)){
2781 if (newFvName
!= null) {
2782 cursor
.setTextValue(newFvName
);
2788 }while (cursor
.toNextSibling(qFvImageNames
));
2794 /**update the Type attribute of ith FvImage with new type.
2798 public void updateFvImagesFvImageType (int i
, String type
) {
2799 XmlObject o
= getfpdFlash().getFvImages();
2803 XmlCursor cursor
= o
.newCursor();
2804 QName qFvImage
= new QName(xmlNs
, "FvImage");
2805 if (cursor
.toChild(qFvImage
)) {
2806 for (int j
= 0; j
< i
; ++j
) {
2807 cursor
.toNextSibling(qFvImage
);
2809 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
2810 fi
.setType(FvImageTypes
.Enum
.forString(type
));
2815 public void updateFvImagesFvImage(int i
, String
[] names
, String types
, Map
<String
, String
> options
){
2817 XmlObject o
= getfpdFlash().getFvImages();
2821 XmlCursor cursor
= o
.newCursor();
2822 QName qFvImage
= new QName(xmlNs
, "FvImage");
2823 if (cursor
.toChild(qFvImage
)) {
2824 for (int j
= 0; j
< i
; ++j
) {
2825 cursor
.toNextSibling(qFvImage
);
2827 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
2828 fi
.setType(FvImageTypes
.Enum
.forString(types
));
2831 // remove old FvImageNames before adding new ones
2833 QName qFvImageNames
= new QName(xmlNs
, "FvImageNames");
2834 cursor
.toChild(qFvImageNames
);
2836 while (cursor
.toNextSibling(qFvImageNames
)) {
2840 for (int k
= 0; k
< names
.length
; ++k
) {
2841 fi
.addFvImageNames(names
[k
]);
2844 // remove old FvImageOptions before adding new options
2846 QName qFvImageOptions
= new QName(xmlNs
, "FvImageOptions");
2847 cursor
.toNextSibling(qFvImageOptions
);
2850 setFvImagesFvImageFvImageOptions(options
, fi
);
2855 public int getFvImagesFvImageCount(String type
) {
2857 if (getfpdFlash().getFvImages() == null || getfpdFlash().getFvImages().getFvImageList() == null) {
2860 List
<FvImagesDocument
.FvImages
.FvImage
> l
= getfpdFlash().getFvImages().getFvImageList();
2861 ListIterator li
= l
.listIterator();
2863 while(li
.hasNext()) {
2864 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)li
.next();
2865 if (!fi
.getType().toString().equals(type
) && !type
.equals("ALL")) {
2875 public Vector
<FvImagesDocument
.FvImages
.FvImage
> getFvImagesFvImageWithName (String fvName
, String type
) {
2876 Vector
<FvImagesDocument
.FvImages
.FvImage
> vFvImage
= new Vector
<FvImagesDocument
.FvImages
.FvImage
>();
2877 if (getfpdFlash().getFvImages() == null || getfpdFlash().getFvImages().getFvImageList() == null) {
2880 List
<FvImagesDocument
.FvImages
.FvImage
> l
= getfpdFlash().getFvImages().getFvImageList();
2881 ListIterator li
= l
.listIterator();
2882 while(li
.hasNext()) {
2883 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)li
.next();
2884 if (!fi
.getType().toString().equals(type
) && !type
.equals("ALL")) {
2887 if (fi
.getFvImageNamesList().contains(fvName
)) {
2896 * @param type "ALL" means all FvImage types: ImageName, Options, Attributes, Components.
2898 public void getFvImagesFvImages(String
[][] saa
, String type
) {
2900 if (getfpdFlash().getFvImages() == null) {
2903 List
<FvImagesDocument
.FvImages
.FvImage
> l
= getfpdFlash().getFvImages().getFvImageList();
2907 ListIterator li
= l
.listIterator();
2909 while(li
.hasNext()) {
2910 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)li
.next();
2911 if (!fi
.getType().toString().equals(type
) && !type
.equals("ALL")) {
2915 // get FvImageNames array, space separated
2917 List
<String
> lfn
= fi
.getFvImageNamesList();
2918 ListIterator lfni
= lfn
.listIterator();
2920 while (lfni
.hasNext()) {
2921 saa
[i
][0] += (String
)lfni
.next();
2924 saa
[i
][0] = saa
[i
][0].trim();
2926 saa
[i
][1] = fi
.getType()+"";
2932 public void removeFvImageNameValue (int i
, String attributeName
) {
2933 XmlObject o
= getfpdFlash().getFvImages();
2937 XmlCursor cursor
= o
.newCursor();
2938 QName qFvImage
= new QName(xmlNs
, "FvImage");
2939 if (cursor
.toChild(qFvImage
)) {
2940 for (int j
= 0; j
< i
; ++j
) {
2941 cursor
.toNextSibling(qFvImage
);
2943 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
2944 removeFvImageNameValue (fi
, attributeName
);
2948 /**Remove from fi the attribute pair with attributeName in FvImageOptions.
2950 * @param attributeName
2952 public void removeFvImageNameValue (FvImagesDocument
.FvImages
.FvImage fi
, String attributeName
) {
2953 if (fi
.getFvImageOptions() != null && fi
.getFvImageOptions().getNameValueList() != null) {
2954 ListIterator
<FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
> li
= fi
.getFvImageOptions().getNameValueList().listIterator();
2955 while (li
.hasNext()) {
2956 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nv
= li
.next();
2957 if (nv
.getName().equals(attributeName
)) {
2964 public void removeTypedNamedFvImageNameValue (String fvName
, String type
, String optName
) {
2965 Vector
<FvImagesDocument
.FvImages
.FvImage
> vFvImage
= getFvImagesFvImageWithName(fvName
, type
);
2966 for (int i
= 0; i
< vFvImage
.size(); ++i
) {
2967 FvImagesDocument
.FvImages
.FvImage fi
= vFvImage
.get(i
);
2968 removeFvImageNameValue (fi
, optName
);
2972 /**Add name-value pair to FvImage element with type.
2973 * @param fvName FV name to add name-value pair.
2974 * @param type FvImage attribute.
2978 public void setTypedNamedFvImageNameValue (String fvName
, String type
, String name
, String value
) {
2979 boolean fvImageExists
= false;
2980 if (getfpdFlash().getFvImages() == null) {
2983 List
<FvImagesDocument
.FvImages
.FvImage
> l
= getfpdFlash().getFvImages().getFvImageList();
2987 ListIterator li
= l
.listIterator();
2988 while(li
.hasNext()) {
2989 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)li
.next();
2990 if (!fi
.getType().toString().equals(type
) && !type
.equals("ALL")) {
2993 if (!fi
.getFvImageNamesList().contains(fvName
)) {
2996 fvImageExists
= true;
2997 setFvImagesFvImageNameValue (fi
, name
, value
, null);
3000 if (!fvImageExists
) {
3001 HashMap
<String
, String
> map
= new HashMap
<String
, String
>();
3002 map
.put(name
, value
);
3003 genFvImagesFvImage(new String
[]{fvName
}, type
, map
);
3007 /**Add to all FvImage elements with type, the name-value pair.
3012 public void setTypedFvImageNameValue (String type
, String name
, String value
) {
3013 if (getfpdFlash().getFvImages() == null) {
3016 List
<FvImagesDocument
.FvImages
.FvImage
> l
= getfpdFlash().getFvImages().getFvImageList();
3020 ListIterator li
= l
.listIterator();
3021 while(li
.hasNext()) {
3022 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)li
.next();
3023 if (!fi
.getType().toString().equals(type
) && !type
.equals("ALL")) {
3026 setFvImagesFvImageNameValue (fi
, name
, value
, null);
3031 public void setFvImagesFvImageNameValue (int i
, String name
, String value
) {
3032 XmlObject o
= getfpdFlash().getFvImages();
3036 XmlCursor cursor
= o
.newCursor();
3037 QName qFvImage
= new QName(xmlNs
, "FvImage");
3038 if (cursor
.toChild(qFvImage
)) {
3039 for (int j
= 0; j
< i
; ++j
) {
3040 cursor
.toNextSibling(qFvImage
);
3042 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
3043 setFvImagesFvImageNameValue (fi
, name
, value
, null);
3048 /**Add to FvImage the name-value pair, or replace old name with newName, or generate new name-value pair if not exists before.
3054 public void setFvImagesFvImageNameValue (FvImagesDocument
.FvImages
.FvImage fi
, String name
, String value
, String newName
) {
3055 if (fi
.getFvImageOptions() == null || fi
.getFvImageOptions().getNameValueList() == null) {
3056 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nv
= fi
.addNewFvImageOptions().addNewNameValue();
3059 if (newName
!= null) {
3060 nv
.setName(newName
);
3065 XmlCursor cursor
= fi
.getFvImageOptions().newCursor();
3066 if (cursor
.toFirstChild()) {
3068 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nv
= (FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
)cursor
.getObject();
3069 if (nv
.getName().equals(name
)) {
3071 if (newName
!= null) {
3072 nv
.setName(newName
);
3077 }while (cursor
.toNextSibling());
3080 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nv
= fi
.getFvImageOptions().addNewNameValue();
3083 if (newName
!= null) {
3084 nv
.setName(newName
);
3089 public void getFvImagesFvImageOptions (String fvName
, Map
<String
, String
> m
) {
3090 Vector
<FvImagesDocument
.FvImages
.FvImage
> vFvImage
= getFvImagesFvImageWithName (fvName
, "Options");
3091 for (int i
= 0; i
< vFvImage
.size(); ++i
) {
3092 FvImagesDocument
.FvImages
.FvImage fi
= vFvImage
.get(i
);
3093 if (fi
== null || fi
.getFvImageOptions() == null || fi
.getFvImageOptions().getNameValueList() == null) {
3097 ListIterator
<FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
> li
= fi
.getFvImageOptions()
3100 while (li
.hasNext()) {
3101 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nv
= li
.next();
3102 m
.put(nv
.getName(), nv
.getValue());
3107 public int getFvImagePosInFvImages (String fvNameList
, String type
) {
3108 XmlObject o
= getfpdFlash().getFvImages();
3114 String
[] fvNameArray
= fvNameList
.trim().split(" ");
3115 Vector
<String
> vFvNames
= new Vector
<String
>();
3118 XmlCursor cursor
= o
.newCursor();
3119 QName qFvImage
= new QName(xmlNs
, "FvImage");
3120 if (cursor
.toChild(qFvImage
)) {
3123 vFvNames
.removeAllElements();
3124 for (int i
= 0; i
< fvNameArray
.length
; ++i
) {
3125 vFvNames
.add(fvNameArray
[i
]);
3127 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
3128 if (!fi
.getType().toString().equals(type
)) {
3131 if (fi
.getFvImageNamesList() == null || fi
.getFvImageNamesList().size() != vFvNames
.size()) {
3134 ListIterator
<String
> li
= fi
.getFvImageNamesList().listIterator();
3135 while (li
.hasNext()) {
3136 String name
= li
.next();
3137 vFvNames
.remove(name
);
3139 if (vFvNames
.size() == 0) {
3144 }while (cursor
.toNextSibling(qFvImage
));
3150 /**Get FvImage Options for FvImage i
3151 * @param i the ith FvImage
3153 public void getFvImagesFvImageOptions(int i
, Map
<String
, String
> m
) {
3154 XmlObject o
= getfpdFlash().getFvImages();
3158 XmlCursor cursor
= o
.newCursor();
3159 QName qFvImage
= new QName(xmlNs
, "FvImage");
3160 if (cursor
.toChild(qFvImage
)) {
3161 for (int j
= 0; j
< i
; ++j
) {
3162 cursor
.toNextSibling(qFvImage
);
3164 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
3165 if (fi
.getFvImageOptions() == null || fi
.getFvImageOptions().getNameValueList() == null){
3169 ListIterator
<FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
> li
= fi
.getFvImageOptions().getNameValueList().listIterator();
3170 while(li
.hasNext()){
3171 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nv
= li
.next();
3172 m
.put(nv
.getName(), nv
.getValue());
3179 Get platform header element
3180 @return PlatformHeaderDocument.PlatformHeader
3182 public PlatformHeaderDocument
.PlatformHeader
getFpdHdr() {
3183 if (fpdHdr
== null) {
3184 fpdHdr
= fpdRoot
.addNewPlatformHeader();
3190 public String
getFpdHdrPlatformName() {
3191 return getFpdHdr().getPlatformName();
3194 public String
getFpdHdrGuidValue() {
3195 return getFpdHdr().getGuidValue();
3198 public String
getFpdHdrVer() {
3199 return getFpdHdr().getVersion();
3202 public String
getFpdHdrAbs() {
3203 return getFpdHdr().getAbstract();
3206 public String
getFpdHdrDescription() {
3207 return getFpdHdr().getDescription();
3210 public String
getFpdHdrCopyright() {
3211 return getFpdHdr().getCopyright();
3214 public String
getFpdHdrLicense() {
3215 LicenseDocument
.License l
= getFpdHdr().getLicense();
3219 return l
.getStringValue();
3222 public String
getFpdHdrUrl() {
3223 LicenseDocument
.License l
= getFpdHdr().getLicense();
3230 public String
getFpdHdrSpec() {
3232 return "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052";
3233 // return getFpdHdr().getSpecification();
3236 public void setFpdHdrPlatformName(String name
){
3237 getFpdHdr().setPlatformName(name
);
3240 public void setFpdHdrGuidValue(String guid
){
3241 getFpdHdr().setGuidValue(guid
);
3244 public void setFpdHdrVer(String v
){
3245 getFpdHdr().setVersion(v
);
3248 public void setFpdHdrAbs(String abs
) {
3249 getFpdHdr().setAbstract(abs
);
3252 public void setFpdHdrDescription(String desc
){
3253 getFpdHdr().setDescription(desc
);
3256 public void setFpdHdrCopyright(String cr
) {
3257 getFpdHdr().setCopyright(cr
);
3260 public void setFpdHdrLicense(String license
){
3261 LicenseDocument
.License l
= getFpdHdr().getLicense();
3263 getFpdHdr().addNewLicense().setStringValue(license
);
3266 l
.setStringValue(license
);
3270 public void setFpdHdrUrl(String url
){
3271 LicenseDocument
.License l
= getFpdHdr().getLicense();
3277 public void setFpdHdrSpec(String s
){
3278 s
= "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052";
3279 getFpdHdr().setSpecification(s
);
3282 Save the processed xml contents to file
3284 @param fpdFile The file to save xml contents
3285 @throws IOException Exceptions during file operation
3287 public void saveAs(File fpdFile
) throws IOException
{
3289 XmlOptions options
= new XmlOptions();
3291 options
.setCharacterEncoding("UTF-8");
3292 options
.setSavePrettyPrint();
3293 options
.setSavePrettyPrintIndent(2);
3295 fpdd
.save(fpdFile
, options
);
3296 } catch (IOException e
) {
3297 e
.printStackTrace();
3302 private String
listToString(List l
) {
3307 ListIterator li
= l
.listIterator();
3308 while(li
.hasNext()) {
3315 private void removeElement(XmlObject o
) {
3316 XmlCursor cursor
= o
.newCursor();
3322 class PcdItemTypeConflictException
extends Exception
{
3327 private static final long serialVersionUID
= 1L;
3328 private String details
= null;
3330 PcdItemTypeConflictException(String pcdName
, String info
){
3331 ModuleIdentification mi
= WorkspaceProfile
.getModuleId(info
);
3332 details
= pcdName
+ " ItemType Conflicts with " + mi
.getName() + " in Pkg " + mi
.getPackageId().getName();
3335 public String
getMessage() {
3340 class PcdDeclNotFound
extends Exception
{
3345 private static final long serialVersionUID
= 1L;
3346 private String details
= null;
3348 PcdDeclNotFound(String info
) {
3349 details
= "PcdDeclNotFound: " + info
;
3352 public String
getMessage() {
3357 class PcdValueMalFormed
extends Exception
{
3362 private static final long serialVersionUID
= 1L;
3363 private String details
= null;
3365 PcdValueMalFormed(String info
) {
3366 details
= "PcdValueMalFormed: " + info
;
3369 public String
getMessage() {