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";
73 static final String regExpNewLineAndSpaces
= "((\n)|(\r\n)|(\r)|(\u0085)|(\u2028)|(\u2029))(\\s)*";
75 private PlatformSurfaceAreaDocument fpdd
= null;
77 private PlatformSurfaceAreaDocument
.PlatformSurfaceArea fpdRoot
= null;
79 private PlatformHeaderDocument
.PlatformHeader fpdHdr
= null;
81 private PlatformDefinitionsDocument
.PlatformDefinitions fpdPlatformDefs
= null;
83 private FlashDocument
.Flash fpdFlash
= null;
85 private BuildOptionsDocument
.BuildOptions fpdBuildOpts
= null;
87 private FrameworkModulesDocument
.FrameworkModules fpdFrameworkModules
= null;
89 private DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions fpdDynPcdBuildDefs
= null;
91 private HashMap
<String
, ArrayList
<String
>> dynPcdMap
= null;
93 private HashMap
<String
, String
> defaultPcdValue
= new HashMap
<String
, String
>();
95 private String
itemType (String pcdInfo
) {
97 return pcdInfo
.substring(pcdInfo
.lastIndexOf(" ") + 1);
101 * look through all pcd data in all ModuleSA, create pcd -> ModuleSA mappings.
103 public void initDynPcdMap() {
104 if (dynPcdMap
== null) {
105 dynPcdMap
= new HashMap
<String
, ArrayList
<String
>>();
106 List
<ModuleSADocument
.ModuleSA
> l
= getfpdFrameworkModules().getModuleSAList();
108 removeElement(getfpdFrameworkModules());
109 fpdFrameworkModules
= null;
112 ListIterator
<ModuleSADocument
.ModuleSA
> li
= l
.listIterator();
113 while (li
.hasNext()) {
114 ModuleSADocument
.ModuleSA moduleSa
= li
.next();
115 if (moduleSa
.getPcdBuildDefinition() == null || moduleSa
.getPcdBuildDefinition().getPcdDataList() == null) {
118 String ModuleInfo
= moduleSa
.getModuleGuid() + " " + moduleSa
.getModuleVersion() +
119 " " + moduleSa
.getPackageGuid() + " " + moduleSa
.getPackageVersion() + " " + listToString(moduleSa
.getSupArchList());
120 List
<PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
> lp
= moduleSa
.getPcdBuildDefinition().getPcdDataList();
121 ListIterator
<PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
> lpi
= lp
.listIterator();
122 while (lpi
.hasNext()) {
123 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= lpi
.next();
124 String pcdKey
= pcdData
.getCName() + " " + pcdData
.getTokenSpaceGuidCName();
125 if (dynPcdMap
.get(pcdKey
) == null) {
126 ArrayList
<String
> al
= new ArrayList
<String
>();
127 al
.add(ModuleInfo
+ " " + pcdData
.getItemType().toString());
128 dynPcdMap
.put(pcdKey
, al
);
131 dynPcdMap
.get(pcdKey
).add(ModuleInfo
+ " " + pcdData
.getItemType().toString());
138 public ArrayList
<String
> getDynPcdMapValue(String key
) {
139 return dynPcdMap
.get(key
);
142 Constructor to create a new spd file
144 public FpdFileContents() {
146 fpdd
= PlatformSurfaceAreaDocument
.Factory
.newInstance();
147 fpdRoot
= fpdd
.addNewPlatformSurfaceArea();
152 Constructor for existing document object
155 public FpdFileContents(PlatformSurfaceAreaDocument
.PlatformSurfaceArea fpd
) {
157 fpdHdr
= fpdRoot
.getPlatformHeader();
158 fpdPlatformDefs
= fpdRoot
.getPlatformDefinitions();
159 fpdBuildOpts
= fpdRoot
.getBuildOptions();
160 fpdFrameworkModules
= fpdRoot
.getFrameworkModules();
161 fpdDynPcdBuildDefs
= fpdRoot
.getDynamicPcdBuildDefinitions();
162 fpdFlash
= fpdRoot
.getFlash();
166 Constructor based on an existing spd file
168 @param f Existing spd file
170 public FpdFileContents(File f
) {
172 fpdd
= PlatformSurfaceAreaDocument
.Factory
.parse(f
);
173 fpdRoot
= fpdd
.getPlatformSurfaceArea();
174 } catch (Exception e
) {
175 System
.out
.println(e
.toString());
179 public DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
getfpdDynPcdBuildDefs() {
180 if (fpdDynPcdBuildDefs
== null){
181 fpdDynPcdBuildDefs
= fpdRoot
.addNewDynamicPcdBuildDefinitions();
183 return fpdDynPcdBuildDefs
;
186 public FrameworkModulesDocument
.FrameworkModules
getfpdFrameworkModules() {
187 if (fpdFrameworkModules
== null){
188 fpdFrameworkModules
= fpdRoot
.addNewFrameworkModules();
190 return fpdFrameworkModules
;
193 public void getFrameworkModuleGuid (String fvName
, Vector
<String
> vGuid
) {
194 if (getFrameworkModulesCount() == 0){
198 ListIterator li
= getfpdFrameworkModules().getModuleSAList().listIterator();
199 while(li
.hasNext()) {
200 ModuleSADocument
.ModuleSA moduleSa
= (ModuleSADocument
.ModuleSA
)li
.next();
201 if (moduleSa
.getModuleSaBuildOptions() == null) {
204 String fvBinding
= moduleSa
.getModuleSaBuildOptions().getFvBinding();
205 if (fvBinding
== null) {
209 String
[] fvNames
= fvBinding
.split(" ");
210 for (int i
= 0; i
< fvNames
.length
; ++i
) {
211 if (fvNames
[i
].equals(fvName
) || fvNames
[i
].replaceAll("_", "").equals(fvName
)) {
212 vGuid
.add(moduleSa
.getModuleGuid());
219 public int getFrameworkModulesCount() {
220 if (getfpdFrameworkModules().getModuleSAList() == null || getfpdFrameworkModules().getModuleSAList().size() == 0){
221 removeElement(getfpdFrameworkModules());
222 fpdFrameworkModules
= null;
225 return getfpdFrameworkModules().getModuleSAList().size();
228 public void getFrameworkModulesInfo(String
[][] saa
) {
229 if (getFrameworkModulesCount() == 0){
233 ListIterator li
= getfpdFrameworkModules().getModuleSAList().listIterator();
235 while(li
.hasNext()) {
236 ModuleSADocument
.ModuleSA moduleSa
= (ModuleSADocument
.ModuleSA
)li
.next();
237 saa
[i
][0] = moduleSa
.getModuleGuid();
238 saa
[i
][1] = moduleSa
.getModuleVersion();
240 saa
[i
][2] = moduleSa
.getPackageGuid();
241 saa
[i
][3] = moduleSa
.getPackageVersion();
242 saa
[i
][4] = listToString(moduleSa
.getSupArchList());
247 public void getFrameworkModuleInfo(int i
, String
[] sa
) {
248 ModuleSADocument
.ModuleSA msa
= getModuleSA(i
);
252 sa
[0] = msa
.getModuleGuid();
253 sa
[1] = msa
.getModuleVersion();
254 sa
[2] = msa
.getPackageGuid();
255 sa
[3] = msa
.getPackageVersion();
256 sa
[4] = listToString(msa
.getSupArchList());
259 public ModuleSADocument
.ModuleSA
getModuleSA(String key
) {
261 if (getfpdFrameworkModules().getModuleSAList() == null || getfpdFrameworkModules().getModuleSAList().size() == 0) {
262 removeElement(getfpdFrameworkModules());
263 fpdFrameworkModules
= null;
266 String
[] s
= key
.split(" ");
267 String archsInKey
= "";
269 for (int i
= 4; i
< s
.length
; ++i
) {
273 archsInKey
= archsInKey
.trim();
276 ListIterator li
= getfpdFrameworkModules().getModuleSAList().listIterator();
277 while(li
.hasNext()) {
278 ModuleSADocument
.ModuleSA moduleSa
= (ModuleSADocument
.ModuleSA
)li
.next();
279 if (moduleSa
.getModuleGuid().equalsIgnoreCase(s
[0]) && moduleSa
.getPackageGuid().equalsIgnoreCase(s
[2])) {
280 if (moduleSa
.getModuleVersion() != null) {
281 if (!moduleSa
.getModuleVersion().equals(s
[1])) {
285 if (moduleSa
.getPackageVersion() != null) {
286 if (!moduleSa
.getPackageVersion().equals(s
[3])) {
290 //ToDo add arch check .
291 if (moduleSa
.getSupArchList() != null) {
292 if (listToString(moduleSa
.getSupArchList()).equals(archsInKey
)) {
297 if (archsInKey
.length() == 0) {
306 private ModuleSADocument
.ModuleSA
getModuleSA(int i
) {
307 ModuleSADocument
.ModuleSA moduleSa
= null;
308 if (fpdRoot
.getFrameworkModules() == null) {
311 XmlCursor cursor
= fpdRoot
.getFrameworkModules().newCursor();
312 if (cursor
.toFirstChild()) {
313 for (int j
= 0; j
< i
; ++j
) {
314 cursor
.toNextSibling();
316 moduleSa
= (ModuleSADocument
.ModuleSA
)cursor
.getObject();
322 public void removeModuleSA(int i
) {
323 XmlObject o
= fpdRoot
.getFrameworkModules();
328 XmlCursor cursor
= o
.newCursor();
329 if (cursor
.toFirstChild()) {
330 for (int j
= 0; j
< i
; ++j
) {
331 cursor
.toNextSibling();
334 // remove pcd from dynPcdMap, if DynamicPcdBuildData exists, remove them too.
336 ModuleSADocument
.ModuleSA moduleSa
= (ModuleSADocument
.ModuleSA
)cursor
.getObject();
337 String moduleInfo
= moduleSa
.getModuleGuid() + " " + moduleSa
.getModuleVersion() + " " +
338 moduleSa
.getPackageGuid()+ " " + moduleSa
.getPackageVersion() + " " + listToString(moduleSa
.getSupArchList());
339 PcdBuildDefinitionDocument
.PcdBuildDefinition pcdBuildDef
= moduleSa
.getPcdBuildDefinition();
340 if (pcdBuildDef
!= null && pcdBuildDef
.getPcdDataList() != null) {
341 ListIterator
<PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
> li
= pcdBuildDef
.getPcdDataList().listIterator();
342 while(li
.hasNext()) {
343 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= li
.next();
344 maintainDynPcdMap(pcdData
.getCName() + " " + pcdData
.getTokenSpaceGuidCName(), moduleInfo
);
349 while (cursor
.hasPrevToken()) {
350 cursor
.toPrevToken();
351 if (!cursor
.isText()) {
354 String s
= cursor
.getTextValue();
355 if (s
.matches(regExpNewLineAndSpaces
)) {
360 if (cursor
.isComment()) {
366 if (getFrameworkModulesCount() == 0) {
374 public boolean adjustPcd (int seqModuleSa
) throws Exception
{
375 boolean dataModified
= false;
376 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(seqModuleSa
);
377 int pcdCount
= getPcdDataCount(seqModuleSa
);
378 String
[][] saaModuleSaPcd
= new String
[pcdCount
][7];
379 getPcdData(seqModuleSa
, saaModuleSaPcd
);
380 String mg
= moduleSa
.getModuleGuid();
381 String mv
= moduleSa
.getModuleVersion();
382 String pg
= moduleSa
.getPackageGuid();
383 String pv
= moduleSa
.getPackageVersion();
384 String arch
= listToString(moduleSa
.getSupArchList());
386 // delete pcd in ModuleSA but not in MSA files any longer.
388 String moduleKey
= mg
+ " " + mv
+ " " + pg
+ " " + pv
+ " " + arch
;
389 int libCount
= getLibraryInstancesCount(moduleKey
);
390 String
[][] saaLib
= new String
[libCount
][5];
391 getLibraryInstances(moduleKey
, saaLib
);
392 ModuleIdentification mi
= WorkspaceProfile
.getModuleId(moduleKey
);
393 Vector
<ModuleIdentification
> vMi
= new Vector
<ModuleIdentification
>();
395 // create vector for module & library instance MIs.
398 for (int j
= 0; j
< saaLib
.length
; ++j
) {
399 String libKey
= saaLib
[j
][1] + " " + saaLib
[j
][2] + " " + saaLib
[j
][3] + " " + saaLib
[j
][4];
400 ModuleIdentification libMi
= WorkspaceProfile
.getModuleId(libKey
);
404 nextPcd
:for (int i
= 0; i
< saaModuleSaPcd
.length
; ++i
) {
406 for (int j
= 0; j
< vMi
.size(); ++j
) {
407 ModuleIdentification nextMi
= vMi
.get(j
);
408 if (WorkspaceProfile
.pcdInMsa(saaModuleSaPcd
[i
][0], saaModuleSaPcd
[i
][1], nextMi
)) {
412 removePcdData(seqModuleSa
, saaModuleSaPcd
[i
][0], saaModuleSaPcd
[i
][1]);
416 // add new Pcd from MSA file to ModuleSA.
418 for (int i
= 0; i
< vMi
.size(); ++i
) {
419 ModuleSurfaceAreaDocument
.ModuleSurfaceArea msa
= (ModuleSurfaceAreaDocument
.ModuleSurfaceArea
) WorkspaceProfile
420 .getModuleXmlObject(vMi
422 if (msa
.getPcdCoded() == null || msa
.getPcdCoded().getPcdEntryList() == null) {
425 ListIterator li
= msa
.getPcdCoded().getPcdEntryList().listIterator();
426 msaPcdIter
:while (li
.hasNext()) {
427 PcdCodedDocument
.PcdCoded
.PcdEntry msaPcd
= (PcdCodedDocument
.PcdCoded
.PcdEntry
) li
.next();
428 ArrayList
<String
> al
= getDynPcdMapValue(msaPcd
.getCName() + " " + msaPcd
.getTokenSpaceGuidCName());
430 for (int j
= 0; j
< al
.size(); ++j
) {
431 if (al
.get(j
).contains(moduleKey
)) {
437 PackageIdentification
[] depPkgs
= SurfaceAreaQuery
.getDependencePkg(null, vMi
.get(i
));
438 PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry spdPcd
= LookupPcdDeclaration(msaPcd
, depPkgs
);
439 if (spdPcd
== null) {
443 throw new PcdDeclNotFound("No Declaration for PCD Entry " + msaPcd
.getCName() + " in Module "
447 // AddItem to ModuleSA PcdBuildDefinitions
449 String defaultVal
= msaPcd
.getDefaultValue() == null ? spdPcd
.getDefaultValue()
450 : msaPcd
.getDefaultValue();
452 genPcdData(msaPcd
.getCName(), spdPcd
.getToken(), msaPcd
.getTokenSpaceGuidCName(),
453 msaPcd
.getPcdItemType().toString(), spdPcd
.getDatumType() + "", defaultVal
, moduleSa
);
462 private void maintainDynPcdMap(String pcdKey
, String moduleInfo
) {
464 ArrayList
<String
> al
= dynPcdMap
.get(pcdKey
);
468 String
[] s
= moduleInfo
.split(" ");
469 for(int i
= 0; i
< al
.size(); ++i
){
470 String consumer
= al
.get(i
);
471 if (consumer
.contains(s
[0]) && consumer
.contains(s
[2])){
472 String
[] consumerPart
= consumer
.split(" ");
473 if (!consumerPart
[4].equals(s
[4])) {
481 if (al
.size() == 0) {
482 defaultPcdValue
.remove(pcdKey
);
483 dynPcdMap
.remove(pcdKey
);
484 String
[] s1
= pcdKey
.split(" ");
485 removeDynamicPcdBuildData(s1
[0], s1
[1]);
490 // key for ModuleSA : "ModuleGuid ModuleVer PackageGuid PackageVer Arch"
492 public int getPcdDataCount (int i
){
493 ModuleSADocument
.ModuleSA msa
= getModuleSA(i
);
495 if (msa
== null || msa
.getPcdBuildDefinition() == null || msa
.getPcdBuildDefinition().getPcdDataList() == null){
498 return msa
.getPcdBuildDefinition().getPcdDataList().size();
502 public void getPcdData (int i
, String
[][] saa
) {
503 ModuleSADocument
.ModuleSA msa
= getModuleSA(i
);
505 if (msa
== null || msa
.getPcdBuildDefinition() == null || msa
.getPcdBuildDefinition().getPcdDataList() == null){
508 ListIterator
<PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
>li
= msa
.getPcdBuildDefinition().getPcdDataList().listIterator();
509 for (int k
= 0; k
< saa
.length
; ++k
) {
510 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= li
.next();
511 saa
[k
][0] = pcdData
.getCName();
512 saa
[k
][1] = pcdData
.getTokenSpaceGuidCName();
513 saa
[k
][2] = pcdData
.getItemType()+"";
514 saa
[k
][3] = pcdData
.getToken().toString();
515 saa
[k
][4] = pcdData
.getMaxDatumSize()+"";
516 saa
[k
][5] = pcdData
.getDatumType()+"";
517 saa
[k
][6] = pcdData
.getValue();
522 public void removePcdData (int seqModuleSa
, String cName
, String tsGuid
) {
523 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(seqModuleSa
);
524 if (moduleSa
== null || moduleSa
.getPcdBuildDefinition() == null){
528 String mg
= moduleSa
.getModuleGuid();
529 String mv
= moduleSa
.getModuleVersion();
530 String pg
= moduleSa
.getPackageGuid();
531 String pv
= moduleSa
.getPackageVersion();
532 String arch
= listToString(moduleSa
.getSupArchList());
533 String moduleKey
= mg
+ " " + mv
+ " " + pg
+ " " + pv
+ " " + arch
;
535 XmlCursor cursor
= moduleSa
.getPcdBuildDefinition().newCursor();
536 if (cursor
.toFirstChild()){
539 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= (PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
)cursor
.getObject();
540 if (pcdData
.getCName().equals(cName
) && pcdData
.getTokenSpaceGuidCName().equals(tsGuid
)) {
541 maintainDynPcdMap(cName
+ " " + tsGuid
, moduleKey
);
542 if (getPcdDataCount(seqModuleSa
) == 1) {
549 while(cursor
.toNextSibling());
555 public void updatePcdData (String key
, String cName
, String tsGuid
, String itemType
, String maxSize
, String value
){
556 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(key
);
557 if (moduleSa
== null || moduleSa
.getPcdBuildDefinition() == null){
561 XmlCursor cursor
= moduleSa
.getPcdBuildDefinition().newCursor();
562 if (cursor
.toFirstChild()){
564 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= (PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
)cursor
.getObject();
565 if (pcdData
.getCName().equals(cName
) && pcdData
.getTokenSpaceGuidCName().equals(tsGuid
)) {
567 // change item type while not updating dynPcdData????
569 pcdData
.setItemType(PcdItemTypes
.Enum
.forString(itemType
));
570 if(pcdData
.getDatumType().equals("VOID*")) {
571 pcdData
.setMaxDatumSize(new Integer(maxSize
));
573 pcdData
.setValue(value
);
574 defaultPcdValue
.put(cName
+ " " + tsGuid
, value
);
578 while(cursor
.toNextSibling());
583 /**Get original Pcd info from MSA & SPD files.
584 * @param mi ModuleIdentification from which MSA & SPD come
585 * @param cName PCD cName
586 * @param sa Results: HelpText, Original item type.
589 public boolean getPcdBuildDataInfo(ModuleIdentification mi
, String cName
, String tsGuid
, String
[] sa
) throws Exception
{
592 ModuleSurfaceAreaDocument
.ModuleSurfaceArea msa
= (ModuleSurfaceAreaDocument
.ModuleSurfaceArea
)WorkspaceProfile
.getModuleXmlObject(mi
);
593 if (msa
.getPcdCoded() == null) {
597 Map
<String
, XmlObject
> m
= new HashMap
<String
, XmlObject
>();
598 m
.put("ModuleSurfaceArea", msa
);
599 SurfaceAreaQuery
.setDoc(m
);
600 PackageIdentification
[] depPkgs
= SurfaceAreaQuery
.getDependencePkg(null, mi
);
602 // First look through MSA pcd entries.
604 List
<PcdCodedDocument
.PcdCoded
.PcdEntry
> l
= msa
.getPcdCoded().getPcdEntryList();
605 ListIterator li
= l
.listIterator();
606 while(li
.hasNext()) {
607 PcdCodedDocument
.PcdCoded
.PcdEntry msaPcd
= (PcdCodedDocument
.PcdCoded
.PcdEntry
)li
.next();
608 if (!msaPcd
.getCName().equals(cName
)) {
611 if (!msaPcd
.getTokenSpaceGuidCName().equals(tsGuid
)) {
614 PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry spdPcd
= LookupPcdDeclaration(msaPcd
, depPkgs
);
615 if (spdPcd
== null) {
619 throw new PcdDeclNotFound(mi
.getName() + " " + msaPcd
.getCName());
622 // Get Pcd help text and original item type.
624 sa
[0] = spdPcd
.getHelpText() + msaPcd
.getHelpText();
625 sa
[1] = msaPcd
.getPcdItemType()+"";
626 sa
[2] = msa
.getModuleDefinitions().getBinaryModule()+"";
640 private boolean multiSourcePcd (String cName
, String tsGuidCName
, String moduleKey
) {
641 int libCount
= getLibraryInstancesCount(moduleKey
);
642 String
[][] saaLib
= new String
[libCount
][5];
643 getLibraryInstances(moduleKey
, saaLib
);
644 ModuleIdentification mi
= WorkspaceProfile
.getModuleId(moduleKey
);
645 Vector
<ModuleIdentification
> vMi
= new Vector
<ModuleIdentification
>();
647 // create vector for module & library instance MIs.
650 for (int j
= 0; j
< saaLib
.length
; ++j
) {
651 String libKey
= saaLib
[j
][1] + " " + saaLib
[j
][2] + " " + saaLib
[j
][3] + " " + saaLib
[j
][4];
652 ModuleIdentification libMi
= WorkspaceProfile
.getModuleId(libKey
);
656 int pcdSourceCount
= 0;
657 for (int i
= 0; i
< vMi
.size(); ++i
) {
658 if (WorkspaceProfile
.pcdInMsa(cName
, tsGuidCName
, vMi
.get(i
))) {
663 if (pcdSourceCount
< 2) {
672 /**Remove PCDBuildDefinition entries from ModuleSA
673 * @param moduleKey identifier of ModuleSA.
674 * @param consumer where these entries come from.
676 public void removePcdData(String moduleKey
, ModuleIdentification consumer
) {
678 ModuleSurfaceAreaDocument
.ModuleSurfaceArea msa
= (ModuleSurfaceAreaDocument
.ModuleSurfaceArea
)WorkspaceProfile
.getModuleXmlObject(consumer
);
679 if (msa
.getPcdCoded() == null) {
683 List
<PcdCodedDocument
.PcdCoded
.PcdEntry
> l
= msa
.getPcdCoded().getPcdEntryList();
684 ListIterator li
= l
.listIterator();
686 while(li
.hasNext()) {
687 PcdCodedDocument
.PcdCoded
.PcdEntry msaPcd
= (PcdCodedDocument
.PcdCoded
.PcdEntry
)li
.next();
688 ModuleSADocument
.ModuleSA moduleSA
= getModuleSA(moduleKey
);
689 if (moduleSA
.getPcdBuildDefinition() != null) {
690 XmlCursor cursor
= moduleSA
.getPcdBuildDefinition().newCursor();
692 if (cursor
.toFirstChild()) {
694 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= (PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
) cursor
696 String cName
= msaPcd
.getCName();
697 String tsGuidCName
= msaPcd
.getTokenSpaceGuidCName();
698 if (cName
.equals(pcdData
.getCName())
699 && tsGuidCName
.equals(pcdData
.getTokenSpaceGuidCName()) && !multiSourcePcd(cName
, tsGuidCName
, moduleKey
)) {
701 maintainDynPcdMap(pcdData
.getCName() + " " + pcdData
.getTokenSpaceGuidCName(),
706 } while (cursor
.toNextSibling());
710 if (moduleSA
.getPcdBuildDefinition().getPcdDataList().size() == 0) {
719 // key for ModuleSA : "ModuleGuid ModuleVer PackageGuid PackageVer Arch"
721 public int getLibraryInstancesCount(String key
) {
722 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
723 if (msa
== null || msa
.getLibraries() == null || msa
.getLibraries().getInstanceList() == null){
726 return msa
.getLibraries().getInstanceList().size();
729 public void getLibraryInstances(String key
, String
[][] saa
){
730 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
731 if (msa
== null || msa
.getLibraries() == null || msa
.getLibraries().getInstanceList() == null){
735 ListIterator
<LibrariesDocument
.Libraries
.Instance
> li
= msa
.getLibraries().getInstanceList().listIterator();
736 for (int i
= 0; i
< saa
.length
; ++i
) {
737 LibrariesDocument
.Libraries
.Instance instance
= li
.next();
738 saa
[i
][1] = instance
.getModuleGuid();
739 saa
[i
][2] = instance
.getModuleVersion();
740 saa
[i
][3] = instance
.getPackageGuid();
741 saa
[i
][4] = instance
.getPackageVersion();
745 public void removeLibraryInstance(String key
, int i
) {
746 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
747 if (msa
== null || msa
.getLibraries() == null){
751 XmlCursor cursor
= msa
.getLibraries().newCursor();
752 if (cursor
.toFirstChild()) {
753 for (int j
= 0; j
< i
; ++j
) {
754 cursor
.toNextSibling();
757 while (cursor
.hasPrevToken()) {
758 cursor
.toPrevToken();
759 if (!cursor
.isText()) {
762 String s
= cursor
.getTextValue();
763 if (s
.matches(regExpNewLineAndSpaces
)) {
768 if (cursor
.isComment()) {
773 if (getLibraryInstancesCount(key
) == 0) {
782 public void genLibraryInstance(ModuleIdentification libMi
, String key
) {
783 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
785 msa
= getfpdFrameworkModules().addNewModuleSA();
787 LibrariesDocument
.Libraries libs
= msa
.getLibraries();
789 libs
= msa
.addNewLibraries();
792 String mn
= libMi
.getName();
793 String mg
= libMi
.getGuid();
794 String mv
= libMi
.getVersion();
795 String pn
= libMi
.getPackageId().getName();
796 String pg
= libMi
.getPackageId().getGuid();
797 String pv
= libMi
.getPackageId().getVersion();
798 LibrariesDocument
.Libraries
.Instance instance
= libs
.addNewInstance();
799 XmlCursor cursor
= instance
.newCursor();
801 String comment
= "Pkg: " + pn
+ " Mod: " + mn
802 + " Path: " + libMi
.getPath().substring(System
.getenv("WORKSPACE").length() + 1);
803 cursor
.insertComment(comment
);
812 instance
.setModuleGuid(mg
);
813 instance
.setModuleVersion(mv
);
814 instance
.setPackageGuid(pg
);
815 instance
.setPackageVersion(pv
);
819 public String
getFvBinding(String moduleKey
){
820 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(moduleKey
);
821 return getFvBinding (moduleSa
);
824 public String
getFvBinding (ModuleSADocument
.ModuleSA moduleSa
) {
825 if (moduleSa
== null || moduleSa
.getModuleSaBuildOptions() == null) {
828 return moduleSa
.getModuleSaBuildOptions().getFvBinding();
831 public void setFvBinding(ModuleSADocument
.ModuleSA moduleSa
, String fvBinding
) {
832 if (moduleSa
== null ) {
835 if (fvBinding
== null || fvBinding
.length() == 0) {
836 if(moduleSa
.getModuleSaBuildOptions() != null){
837 moduleSa
.getModuleSaBuildOptions().unsetFvBinding();
841 if(moduleSa
.getModuleSaBuildOptions() == null){
842 moduleSa
.addNewModuleSaBuildOptions().setFvBinding(fvBinding
);
845 moduleSa
.getModuleSaBuildOptions().setFvBinding(fvBinding
);
849 public void setFvBinding(String moduleKey
, String fvBinding
){
850 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(moduleKey
);
851 setFvBinding (moduleSa
, fvBinding
);
854 private int fvBindingForModuleSA (ModuleSADocument
.ModuleSA moduleSa
, String fvName
) {
855 if (moduleSa
== null || moduleSa
.getModuleSaBuildOptions() == null || moduleSa
.getModuleSaBuildOptions().getFvBinding() == null) {
859 String fvNameList
= moduleSa
.getModuleSaBuildOptions().getFvBinding();
860 String
[] fvNamesArray
= fvNameList
.split(" ");
862 for (int i
= 0; i
< fvNamesArray
.length
; ++i
) {
863 if (fvNamesArray
[i
].equals(fvName
)) {
871 public void removeFvBinding (ModuleSADocument
.ModuleSA moduleSa
, String fvName
) {
872 if (moduleSa
== null || moduleSa
.getModuleSaBuildOptions() == null || moduleSa
.getModuleSaBuildOptions().getFvBinding() == null) {
876 String fvNameList
= moduleSa
.getModuleSaBuildOptions().getFvBinding();
877 String
[] fvNamesArray
= fvNameList
.split(" ");
879 for (int i
= 0; i
< fvNamesArray
.length
; ++i
) {
880 if (fvNamesArray
[i
].equals(fvName
)) {
885 // jump over where the input fvName occurs in the original Fv list.
886 if (occursAt
!= -1) {
887 String newFvNameList
= " ";
888 for (int i
= 0; i
< fvNamesArray
.length
; ++i
) {
892 newFvNameList
+= fvNamesArray
[i
];
894 setFvBinding (moduleSa
, newFvNameList
.trim());
900 * @param fvName The FV name that to be removed from FvBinding List.
902 public void removeFvBindingAll (String fvName
) {
903 if (getfpdFrameworkModules().getModuleSAList() == null || getfpdFrameworkModules().getModuleSAList().size() == 0){
904 removeElement(getfpdFrameworkModules());
905 fpdFrameworkModules
= null;
909 Iterator
<ModuleSADocument
.ModuleSA
> li
= getfpdFrameworkModules().getModuleSAList().iterator();
910 while (li
.hasNext()) {
911 ModuleSADocument
.ModuleSA moduleSa
= li
.next();
912 removeFvBinding (moduleSa
, fvName
);
916 public void appendFvBindingAll (String fvName
) {
917 if (getfpdFrameworkModules().getModuleSAList() == null || getfpdFrameworkModules().getModuleSAList().size() == 0){
918 removeElement(getfpdFrameworkModules());
919 fpdFrameworkModules
= null;
923 Iterator
<ModuleSADocument
.ModuleSA
> li
= getfpdFrameworkModules().getModuleSAList().iterator();
924 while (li
.hasNext()) {
925 ModuleSADocument
.ModuleSA moduleSa
= li
.next();
926 appendFvBinding (moduleSa
, fvName
);
930 public void appendFvBindingFor (String oldFvName
, String newFvName
) {
931 if (getfpdFrameworkModules().getModuleSAList() == null || getfpdFrameworkModules().getModuleSAList().size() == 0){
932 removeElement(getfpdFrameworkModules());
933 fpdFrameworkModules
= null;
937 Iterator
<ModuleSADocument
.ModuleSA
> li
= getfpdFrameworkModules().getModuleSAList().iterator();
938 while (li
.hasNext()) {
939 ModuleSADocument
.ModuleSA moduleSa
= li
.next();
940 String fvBinding
= getFvBinding (moduleSa
);
941 if (fvBinding
!= null && fvBindingForModuleSA (moduleSa
, oldFvName
) >= 0) {
942 appendFvBinding (moduleSa
, newFvName
);
947 public void appendFvBinding (String moduleKey
, String fvName
) {
948 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(moduleKey
);
949 appendFvBinding (moduleSa
, fvName
);
952 public void appendFvBinding (ModuleSADocument
.ModuleSA moduleSa
, String fvName
) {
953 if (moduleSa
== null) {
957 if (moduleSa
.getModuleSaBuildOptions() == null || moduleSa
.getModuleSaBuildOptions().getFvBinding() == null) {
958 setFvBinding(moduleSa
, fvName
);
962 String fvNameList
= moduleSa
.getModuleSaBuildOptions().getFvBinding();
963 String newFvNameList
= fvNameList
+ " " + fvName
;
964 setFvBinding (moduleSa
, newFvNameList
.trim());
967 public void updateFvBindingInModuleSA (ModuleIdentification mi
, String fvName
) {
968 Vector
<Object
> vSupArchs
= new Vector
<Object
>();
969 getPlatformDefsSupportedArchs(vSupArchs
);
970 String moduleInfo
= mi
.getGuid() + " " + mi
.getVersion() + " " + mi
.getPackageId().getGuid() + " " + mi
.getPackageId().getVersion();
971 for (int i
= 0; i
< vSupArchs
.size(); ++i
) {
972 String moduleKey
= moduleInfo
+ " " + vSupArchs
.get(i
);
973 appendFvBinding (moduleKey
, fvName
);
977 public String
getFfsFileNameGuid(String moduleKey
){
978 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(moduleKey
);
979 if (moduleSa
== null || moduleSa
.getModuleSaBuildOptions() == null) {
982 return moduleSa
.getModuleSaBuildOptions().getFfsFileNameGuid();
985 public void setFfsFileNameGuid(String moduleKey
, String fileGuid
){
986 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
990 if(msa
.getModuleSaBuildOptions() == null){
991 msa
.addNewModuleSaBuildOptions();
994 ModuleSaBuildOptionsDocument
.ModuleSaBuildOptions msaBuildOpts
= msa
.getModuleSaBuildOptions();
995 if (fileGuid
!= null) {
996 msaBuildOpts
.setFfsFileNameGuid(fileGuid
);
999 XmlCursor cursor
= msaBuildOpts
.newCursor();
1000 if (cursor
.toChild(xmlNs
, "FfsFileNameGuid")) {
1008 public String
getFfsFormatKey(String moduleKey
){
1009 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
1010 if (msa
== null || msa
.getModuleSaBuildOptions() == null) {
1013 return msa
.getModuleSaBuildOptions().getFfsFormatKey();
1016 public void setFfsFormatKey(String moduleKey
, String ffsKey
){
1017 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
1021 if(msa
.getModuleSaBuildOptions() == null){
1022 msa
.addNewModuleSaBuildOptions().setFfsFormatKey(ffsKey
);
1025 msa
.getModuleSaBuildOptions().setFfsFormatKey(ffsKey
);
1028 public void setModuleSAForceDebug(int i
, boolean dbgEnable
) {
1029 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(i
);
1030 moduleSa
.setForceDebug(dbgEnable
);
1033 public boolean getModuleSAForceDebug (int i
) {
1034 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(i
);
1035 if (moduleSa
.getForceDebug() == true) {
1041 public void getModuleSAOptions(String moduleKey
, String
[][] saa
) {
1042 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
1043 if (msa
== null || msa
.getModuleSaBuildOptions() == null || msa
.getModuleSaBuildOptions().getOptions() == null
1044 || msa
.getModuleSaBuildOptions().getOptions().getOptionList() == null) {
1048 List
<OptionDocument
.Option
> lOpt
= msa
.getModuleSaBuildOptions().getOptions().getOptionList();
1049 ListIterator li
= lOpt
.listIterator();
1051 while(li
.hasNext()) {
1052 OptionDocument
.Option opt
= (OptionDocument
.Option
)li
.next();
1053 if (opt
.getBuildTargets() != null) {
1054 saa
[i
][0] = listToString(opt
.getBuildTargets());
1056 saa
[i
][1] = opt
.getToolChainFamily();
1057 saa
[i
][2] = opt
.getTagName();
1058 saa
[i
][3] = opt
.getToolCode();
1060 if (opt
.getSupArchList() != null){
1061 saa
[i
][4] = listToString(opt
.getSupArchList());
1067 saa
[i
][5] = opt
.getStringValue();
1073 public int getModuleSAOptionsCount(String moduleKey
){
1074 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
1075 if (msa
== null || msa
.getModuleSaBuildOptions() == null || msa
.getModuleSaBuildOptions().getOptions() == null
1076 || msa
.getModuleSaBuildOptions().getOptions().getOptionList() == null) {
1079 return msa
.getModuleSaBuildOptions().getOptions().getOptionList().size();
1082 public void genModuleSAOptionsOpt(String moduleKey
, Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
) {
1083 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
1084 if (msa
.getModuleSaBuildOptions() == null) {
1085 msa
.addNewModuleSaBuildOptions();
1087 if (msa
.getModuleSaBuildOptions().getOptions() == null){
1088 msa
.getModuleSaBuildOptions().addNewOptions();
1090 OptionDocument
.Option opt
= msa
.getModuleSaBuildOptions().getOptions().addNewOption();
1091 setBuildOptionsOpt(buildTargets
, toolChain
, tagName
, toolCmd
, archList
, contents
, opt
);
1094 public void removeModuleSAOptionsOpt(String moduleKey
, int i
) {
1095 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
1096 if (msa
.getModuleSaBuildOptions() == null || msa
.getModuleSaBuildOptions().getOptions() == null) {
1099 OptionsDocument
.Options opts
= msa
.getModuleSaBuildOptions().getOptions();
1100 XmlCursor cursor
= opts
.newCursor();
1101 if (cursor
.toFirstChild()) {
1102 for (int j
= 0; j
< i
; ++j
){
1103 cursor
.toNextSibling();
1110 public void updateModuleSAOptionsOpt(String moduleKey
, int i
, Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
) {
1111 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
1112 if (msa
.getModuleSaBuildOptions() == null || msa
.getModuleSaBuildOptions().getOptions() == null) {
1115 OptionsDocument
.Options opts
= msa
.getModuleSaBuildOptions().getOptions();
1116 XmlCursor cursor
= opts
.newCursor();
1117 if (cursor
.toFirstChild()) {
1118 for (int j
= 0; j
< i
; ++j
){
1119 cursor
.toNextSibling();
1121 OptionDocument
.Option opt
= (OptionDocument
.Option
)cursor
.getObject();
1122 setBuildOptionsOpt(buildTargets
, toolChain
, tagName
, toolCmd
, archList
, contents
, opt
);
1127 /**add pcd information of module mi to a ModuleSA.
1129 * @param moduleSa if null, generate a new ModuleSA.
1131 public void addFrameworkModulesPcdBuildDefs(ModuleIdentification mi
, String arch
, ModuleSADocument
.ModuleSA moduleSa
) throws Exception
{
1132 //ToDo add Arch filter
1135 if (moduleSa
== null) {
1136 moduleSa
= genModuleSA(mi
, arch
);
1139 ModuleSurfaceAreaDocument
.ModuleSurfaceArea msa
= (ModuleSurfaceAreaDocument
.ModuleSurfaceArea
)WorkspaceProfile
.getModuleXmlObject(mi
);
1140 if (msa
.getPcdCoded() == null) {
1144 Map
<String
, XmlObject
> m
= new HashMap
<String
, XmlObject
>();
1145 m
.put("ModuleSurfaceArea", msa
);
1146 SurfaceAreaQuery
.setDoc(m
);
1147 PackageIdentification
[] depPkgs
= SurfaceAreaQuery
.getDependencePkg(null, mi
);
1149 // Implementing InitializePlatformPcdBuildDefinitions
1151 List
<PcdCodedDocument
.PcdCoded
.PcdEntry
> l
= msa
.getPcdCoded().getPcdEntryList();
1152 ListIterator li
= l
.listIterator();
1153 while(li
.hasNext()) {
1154 PcdCodedDocument
.PcdCoded
.PcdEntry msaPcd
= (PcdCodedDocument
.PcdCoded
.PcdEntry
)li
.next();
1155 PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry spdPcd
= LookupPcdDeclaration(msaPcd
, depPkgs
);
1156 if (spdPcd
== null) {
1160 throw new PcdDeclNotFound("No Declaration for PCD Entry " + msaPcd
.getCName() + " in Module " + mi
.getName());
1163 // AddItem to ModuleSA PcdBuildDefinitions
1165 String defaultVal
= msaPcd
.getDefaultValue() == null ? spdPcd
.getDefaultValue() : msaPcd
.getDefaultValue();
1167 genPcdData(msaPcd
.getCName(), spdPcd
.getToken(), msaPcd
.getTokenSpaceGuidCName(), msaPcd
.getPcdItemType().toString(), spdPcd
.getDatumType()+"", defaultVal
, moduleSa
);
1171 catch (Exception e
){
1178 private PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry
LookupPcdDeclaration (PcdCodedDocument
.PcdCoded
.PcdEntry msaPcd
, PackageIdentification
[] depPkgs
) {
1180 PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry spdPcd
= null;
1181 for (int i
= 0; i
< depPkgs
.length
; ++i
) {
1183 XmlObject
[] xo
= SurfaceAreaQuery
.getSpdPcdDeclarations(depPkgs
[i
]);
1187 for (int j
= 0; j
< xo
.length
; ++j
) {
1188 spdPcd
= (PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry
)xo
[j
];
1189 if (msaPcd
.getTokenSpaceGuidCName() == null) {
1190 if (spdPcd
.getCName().equals(msaPcd
.getCName())) {
1195 if (spdPcd
.getCName().equals(msaPcd
.getCName()) && spdPcd
.getTokenSpaceGuidCName().equals(msaPcd
.getTokenSpaceGuidCName())) {
1206 private ModuleSADocument
.ModuleSA
genModuleSA (ModuleIdentification mi
, String arch
) {
1207 PackageIdentification pi
= WorkspaceProfile
.getPackageForModule(mi
);
1208 ModuleSADocument
.ModuleSA msa
= getfpdFrameworkModules().addNewModuleSA();
1209 XmlCursor cursor
= msa
.newCursor();
1211 String comment
= "Mod: " + mi
.getName() + " Type: " + SurfaceAreaQuery
.getModuleType(mi
) + " Path: "
1212 + mi
.getPath().substring(System
.getenv("WORKSPACE").length() + 1);
1213 cursor
.insertComment(comment
);
1216 e
.printStackTrace();
1221 msa
.setModuleGuid(mi
.getGuid());
1222 msa
.setModuleVersion(mi
.getVersion());
1223 msa
.setPackageGuid(pi
.getGuid());
1224 msa
.setPackageVersion(pi
.getVersion());
1226 Vector
<String
> v
= new Vector
<String
>();
1228 msa
.setSupArchList(v
);
1234 private void genPcdData (String cName
, Object token
, String tsGuid
, String itemType
, String dataType
, String defaultVal
, ModuleSADocument
.ModuleSA moduleSa
)
1235 throws PcdItemTypeConflictException
, PcdValueMalFormed
{
1236 if (moduleSa
.getPcdBuildDefinition() == null){
1237 moduleSa
.addNewPcdBuildDefinition();
1240 // constructe pcd to modulesa mapping first.
1241 // Attention : for any error condition, remove from map this pcd.
1243 ArrayList
<String
> pcdConsumer
= LookupPlatformPcdData(cName
+ " " + tsGuid
);
1244 if (pcdConsumer
== null) {
1245 pcdConsumer
= new ArrayList
<String
>();
1248 // Check whether this PCD has already added to ModuleSA, if so, just return.
1250 String moduleInfo
= moduleSa
.getModuleGuid().toLowerCase() + " " + moduleSa
.getModuleVersion()
1251 + " " + moduleSa
.getPackageGuid().toLowerCase() + " " + moduleSa
.getPackageVersion() + " " + listToString(moduleSa
.getSupArchList());
1252 for (int i
= 0; i
< pcdConsumer
.size(); ++i
) {
1253 String pcdInfo
= pcdConsumer
.get(i
);
1254 if (moduleInfo
.equals(pcdInfo
.substring(0, pcdInfo
.lastIndexOf(" ")))){
1259 // Using existing Pcd type, if this pcd already exists in other ModuleSA
1261 if (pcdConsumer
.size() > 0) {
1263 itemType
= itemType (pcdConsumer
.get(0));
1265 String listValue
= moduleInfo
+ " " + itemType
;
1266 pcdConsumer
.add(listValue
);
1267 dynPcdMap
.put(cName
+ " " + tsGuid
, pcdConsumer
);
1269 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData fpdPcd
= moduleSa
.getPcdBuildDefinition().addNewPcdData();
1270 fpdPcd
.setCName(cName
);
1271 fpdPcd
.setToken(token
);
1272 fpdPcd
.setTokenSpaceGuidCName(tsGuid
);
1273 fpdPcd
.setDatumType(PcdDataTypes
.Enum
.forString(dataType
));
1274 fpdPcd
.setItemType(PcdItemTypes
.Enum
.forString(itemType
));
1276 if (defaultVal
!= null){
1277 fpdPcd
.setValue(defaultVal
);
1280 if (dataType
.equals("UINT8") || dataType
.equals("UINT16") || dataType
.equals("UINT32") || dataType
.equals("UINT64")) {
1281 fpdPcd
.setValue("0");
1283 if (dataType
.equals("BOOLEAN")){
1284 fpdPcd
.setValue("FALSE");
1286 if (dataType
.equals("VOID*")) {
1287 fpdPcd
.setValue("");
1291 // Using existing pcd value, if this pcd already exists in other moduleSa.
1293 if (defaultPcdValue
.get(cName
+ " " + tsGuid
) == null) {
1294 defaultPcdValue
.put(cName
+ " " + tsGuid
, fpdPcd
.getValue());
1297 fpdPcd
.setValue(defaultPcdValue
.get(cName
+ " " + tsGuid
));
1300 if (dataType
.equals("UINT8")){
1301 fpdPcd
.setMaxDatumSize(1);
1303 if (dataType
.equals("UINT16")) {
1304 fpdPcd
.setMaxDatumSize(2);
1306 if (dataType
.equals("UINT32")) {
1307 fpdPcd
.setMaxDatumSize(4);
1309 if (dataType
.equals("UINT64")){
1310 fpdPcd
.setMaxDatumSize(8);
1312 if (dataType
.equals("BOOLEAN")){
1313 fpdPcd
.setMaxDatumSize(1);
1315 if (dataType
.equals("VOID*")) {
1316 int maxSize
= setMaxSizeForPointer(fpdPcd
.getValue());
1317 fpdPcd
.setMaxDatumSize(maxSize
);
1321 if (itemType
.equals("DYNAMIC") || itemType
.equals("DYNAMIC_EX")) {
1322 ArrayList
<String
> al
= LookupDynamicPcdBuildDefinition(cName
+ " " + tsGuid
);
1324 // if only one module mapped to this pcd, then the one is myself. so no other module mapped.
1325 // so need to add one dyn pcd.
1327 if (al
.size() == 1) {
1328 addDynamicPcdBuildData(cName
, token
, tsGuid
, itemType
, dataType
, defaultVal
);
1334 public int setMaxSizeForPointer(String datum
) throws PcdValueMalFormed
{
1335 if (datum
== null) {
1338 char ch
= datum
.charAt(0);
1342 // For void* type PCD, only three datum is support:
1343 // 1) Unicode: string with start char is "L"
1344 // 2) Ansci: String is ""
1345 // 3) byte array: String start char "{"
1348 start
= datum
.indexOf('\"');
1349 end
= datum
.lastIndexOf('\"');
1350 if ((start
> end
) ||
1351 (end
> datum
.length())||
1352 ((start
== end
) && (datum
.length() > 0))) {
1353 //ToDo Error handling here
1354 throw new PcdValueMalFormed (datum
);
1357 strValue
= datum
.substring(start
+ 1, end
);
1358 return strValue
.length() * 2;
1359 } else if (ch
== '\"'){
1360 start
= datum
.indexOf('\"');
1361 end
= datum
.lastIndexOf('\"');
1362 if ((start
> end
) ||
1363 (end
> datum
.length())||
1364 ((start
== end
) && (datum
.length() > 0))) {
1365 throw new PcdValueMalFormed (datum
);
1367 strValue
= datum
.substring(start
+ 1, end
);
1368 return strValue
.length();
1369 } else if (ch
=='{') {
1370 String
[] strValueArray
;
1372 start
= datum
.indexOf('{');
1373 end
= datum
.lastIndexOf('}');
1374 strValue
= datum
.substring(start
+ 1, end
);
1375 strValue
= strValue
.trim();
1376 if (strValue
.length() == 0) {
1379 strValueArray
= strValue
.split(",");
1380 for (int index
= 0; index
< strValueArray
.length
; index
++) {
1381 Integer value
= Integer
.decode(strValueArray
[index
].trim());
1384 // "[FPD file error] The datum type of PCD %s in %s is VOID*, "+
1385 // "it must be a byte array. But the element of %s exceed the byte range",
1386 throw new PcdValueMalFormed (datum
);
1389 return strValueArray
.length
;
1393 // "[FPD file error] The datum type of PCD %s in %s is VOID*. For VOID* type, you have three format choise:\n "+
1394 // "1) UNICODE string: like L\"xxxx\";\r\n"+
1395 // "2) ANSIC string: like \"xxx\";\r\n"+
1396 // "3) Byte array: like {0x2, 0x45, 0x23}\r\n"+
1397 // "but the datum in seems does not following above format!",
1398 throw new PcdValueMalFormed (datum
);
1403 private ArrayList
<String
> LookupDynamicPcdBuildDefinition(String dynPcdKey
) {
1404 ArrayList
<String
> al
= dynPcdMap
.get(dynPcdKey
);
1409 private ArrayList
<String
> LookupPlatformPcdData(String pcdKey
) {
1411 return dynPcdMap
.get(pcdKey
);
1414 public int getDynamicPcdBuildDataCount() {
1415 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1416 removeElement(getfpdDynPcdBuildDefs());
1417 fpdDynPcdBuildDefs
= null;
1420 return getfpdDynPcdBuildDefs().getPcdBuildDataList().size();
1423 public void getDynamicPcdBuildData(String
[][] saa
) {
1424 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1425 removeElement(getfpdDynPcdBuildDefs());
1426 fpdDynPcdBuildDefs
= null;
1429 List
<DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
> l
= getfpdDynPcdBuildDefs().getPcdBuildDataList();
1430 ListIterator
<DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
> li
= l
.listIterator();
1432 while(li
.hasNext()) {
1433 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData dynPcd
= li
.next();
1434 saa
[i
][0] = dynPcd
.getCName();
1435 saa
[i
][1] = dynPcd
.getToken().toString();
1436 saa
[i
][2] = dynPcd
.getTokenSpaceGuidCName();
1437 saa
[i
][3] = dynPcd
.getMaxDatumSize()+"";
1438 saa
[i
][4] = dynPcd
.getDatumType().toString();
1444 public void addDynamicPcdBuildData(String cName
, Object token
, String tsGuid
, String itemType
, String dataType
, String defaultVal
)
1445 throws PcdValueMalFormed
{
1446 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData dynPcdData
= getfpdDynPcdBuildDefs().addNewPcdBuildData();
1447 dynPcdData
.setItemType(PcdItemTypes
.Enum
.forString(itemType
));
1448 dynPcdData
.setCName(cName
);
1449 dynPcdData
.setToken(token
);
1450 dynPcdData
.setTokenSpaceGuidCName(tsGuid
);
1451 dynPcdData
.setDatumType(PcdDataTypes
.Enum
.forString(dataType
));
1453 BigInteger bigInt
= new BigInteger("0");
1454 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo skuInfo
= dynPcdData
.addNewSkuInfo();
1455 skuInfo
.setSkuId(bigInt
);
1456 if (defaultVal
!= null){
1457 skuInfo
.setValue(defaultVal
);
1460 if (dataType
.equals("UINT8")){
1461 skuInfo
.setValue("0");
1463 if (dataType
.equals("UINT16")) {
1464 skuInfo
.setValue("0");
1466 if (dataType
.equals("UINT32")) {
1467 skuInfo
.setValue("0");
1469 if (dataType
.equals("UINT64")){
1470 skuInfo
.setValue("0");
1472 if (dataType
.equals("BOOLEAN")){
1473 skuInfo
.setValue("false");
1475 if (dataType
.equals("VOID*")) {
1476 skuInfo
.setValue("");
1479 if (dataType
.equals("UINT8")){
1480 dynPcdData
.setMaxDatumSize(1);
1482 if (dataType
.equals("UINT16")) {
1483 dynPcdData
.setMaxDatumSize(2);
1485 if (dataType
.equals("UINT32")) {
1486 dynPcdData
.setMaxDatumSize(4);
1488 if (dataType
.equals("UINT64")){
1489 dynPcdData
.setMaxDatumSize(8);
1491 if (dataType
.equals("BOOLEAN")){
1492 dynPcdData
.setMaxDatumSize(1);
1494 if (dataType
.equals("VOID*")) {
1495 int maxSize
= setMaxSizeForPointer(defaultVal
);
1496 dynPcdData
.setMaxDatumSize(maxSize
);
1500 public void removeDynamicPcdBuildData(String cName
, String tsGuid
) {
1501 XmlObject o
= fpdRoot
.getDynamicPcdBuildDefinitions();
1506 XmlCursor cursor
= o
.newCursor();
1507 if (cursor
.toFirstChild()) {
1509 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdBuildData
=
1510 (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1511 if (pcdBuildData
.getCName().equals(cName
) && pcdBuildData
.getTokenSpaceGuidCName().equals(tsGuid
)) {
1513 if (getDynamicPcdBuildDataCount() == 1) {
1521 while (cursor
.toNextSibling());
1526 // Get the Sku Info count of ith dyn pcd element.
1528 public int getDynamicPcdSkuInfoCount(int i
){
1529 if (fpdRoot
.getDynamicPcdBuildDefinitions() == null || fpdRoot
.getDynamicPcdBuildDefinitions().getPcdBuildDataList() == null
1530 || fpdRoot
.getDynamicPcdBuildDefinitions().getPcdBuildDataList().size() == 0) {
1534 int skuInfoCount
= 0;
1535 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1536 if (cursor
.toFirstChild()) {
1537 for (int j
= 0; j
< i
; ++j
) {
1538 cursor
.toNextSibling();
1540 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1541 if (pcdData
.getSkuInfoList() == null) {
1545 skuInfoCount
= pcdData
.getSkuInfoList().size();
1549 return skuInfoCount
;
1552 public void getDynamicPcdSkuInfos(int i
, String
[][] saa
){
1553 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1554 removeElement(getfpdDynPcdBuildDefs());
1555 fpdDynPcdBuildDefs
= null;
1559 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1560 if (cursor
.toFirstChild()) {
1561 for (int j
= 0; j
< i
; ++j
) {
1562 cursor
.toNextSibling();
1564 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1565 if (pcdData
.getSkuInfoList() == null) {
1570 ListIterator
<DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo
> li
= pcdData
.getSkuInfoList().listIterator();
1572 while (li
.hasNext()) {
1573 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo skuInfo
= li
.next();
1574 saa
[k
][0] = skuInfo
.getSkuId()+"";
1575 saa
[k
][1] = skuInfo
.getVariableName();
1576 saa
[k
][2] = skuInfo
.getVariableGuid();
1577 saa
[k
][3] = skuInfo
.getVariableOffset();
1578 saa
[k
][4] = skuInfo
.getHiiDefaultValue();
1579 saa
[k
][5] = skuInfo
.getVpdOffset();
1580 saa
[k
][6] = skuInfo
.getValue();
1590 public String
getDynamicPcdBuildDataValue(int i
){
1591 String value
= null;
1592 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1593 removeElement(getfpdDynPcdBuildDefs());
1594 fpdDynPcdBuildDefs
= null;
1598 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1599 if (cursor
.toFirstChild()) {
1600 for (int j
= 0; j
< i
; ++j
) {
1601 cursor
.toNextSibling();
1603 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1604 if (pcdData
.getSkuInfoList() == null) {
1608 value
= pcdData
.getSkuInfoArray(0).getValue();
1615 public String
getDynamicPcdBuildDataVpdOffset(int i
){
1616 String vpdOffset
= null;
1617 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1618 removeElement(getfpdDynPcdBuildDefs());
1619 fpdDynPcdBuildDefs
= null;
1623 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1624 if (cursor
.toFirstChild()) {
1625 for (int j
= 0; j
< i
; ++j
) {
1626 cursor
.toNextSibling();
1628 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1629 if (pcdData
.getSkuInfoList() == null) {
1633 vpdOffset
= pcdData
.getSkuInfoArray(0).getVpdOffset();
1640 public void removeDynamicPcdBuildDataSkuInfo(int i
) {
1641 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1642 removeElement(getfpdDynPcdBuildDefs());
1643 fpdDynPcdBuildDefs
= null;
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 if (pcdData
.getSkuInfoList() == null) {
1658 QName qSkuInfo
= new QName(xmlNs
, "SkuInfo");
1659 cursor
.toChild(qSkuInfo
);
1666 // generate sku info for ith dyn pcd build data.
1668 public void genDynamicPcdBuildDataSkuInfo(String id
, String varName
, String varGuid
, String varOffset
,
1669 String hiiDefault
, String vpdOffset
, String value
, int i
) {
1670 // if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1674 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1675 if (cursor
.toFirstChild()) {
1676 for (int j
= 0; j
< i
; ++j
) {
1677 cursor
.toNextSibling();
1679 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1680 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo skuInfo
= pcdData
.addNewSkuInfo();
1681 skuInfo
.setSkuId(new BigInteger(id
));
1682 if (varName
!= null){
1683 skuInfo
.setVariableName(varName
);
1684 skuInfo
.setVariableGuid(varGuid
);
1685 skuInfo
.setVariableOffset(varOffset
);
1686 skuInfo
.setHiiDefaultValue(hiiDefault
);
1688 else if (vpdOffset
!= null){
1689 skuInfo
.setVpdOffset(vpdOffset
);
1692 skuInfo
.setValue(value
);
1697 public void updateDynamicPcdBuildDataSkuInfo(String id
, String varName
, String varGuid
, String varOffset
,
1698 String hiiDefault
, String vpdOffset
, String value
, int i
){
1699 // if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1703 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1704 if (cursor
.toFirstChild()) {
1705 for (int j
= 0; j
< i
; ++j
) {
1706 cursor
.toNextSibling();
1708 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1709 ListIterator
<DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo
> li
= pcdData
.getSkuInfoList().listIterator();
1710 while (li
.hasNext()) {
1711 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo skuInfo
= li
.next();
1712 if (skuInfo
.getSkuId().toString().equals(id
)){
1713 if (varName
!= null){
1714 skuInfo
.setVariableName(varName
);
1715 skuInfo
.setVariableGuid(varGuid
);
1716 skuInfo
.setVariableOffset(varOffset
);
1717 skuInfo
.setHiiDefaultValue(hiiDefault
);
1719 else if (vpdOffset
!= null){
1720 skuInfo
.setVpdOffset(vpdOffset
);
1723 skuInfo
.setValue(value
);
1731 public BuildOptionsDocument
.BuildOptions
getfpdBuildOpts() {
1732 if (fpdBuildOpts
== null) {
1733 fpdBuildOpts
= fpdRoot
.addNewBuildOptions();
1735 return fpdBuildOpts
;
1738 public void genBuildOptionsUserExtensions(String fvName
, String outputFileName
, Vector
<String
[]> includeModules
) {
1739 QName elementFvName
= new QName (xmlNs
, "FvName");
1740 QName elementIncludeModules
= new QName(xmlNs
, "IncludeModules");
1741 QName elementInfFileName
= new QName(xmlNs
, "InfFileName");
1742 QName elementModule
= new QName(xmlNs
, "Module");
1744 UserExtensionsDocument
.UserExtensions userExts
= getfpdBuildOpts().addNewUserExtensions();
1745 userExts
.setUserID("IMAGES");
1746 userExts
.setIdentifier(new BigInteger("1"));
1747 XmlCursor cursor
= userExts
.newCursor();
1748 cursor
.toEndToken();
1750 cursor
.beginElement(elementFvName
);
1751 cursor
.insertChars(fvName
);
1752 cursor
.toNextToken();
1754 cursor
.beginElement(elementInfFileName
);
1755 cursor
.insertChars(fvName
+ ".inf");
1756 cursor
.toNextToken();
1758 cursor
.beginElement(elementIncludeModules
);
1759 for (int i
= 0; i
< includeModules
.size(); ++i
) {
1760 cursor
.beginElement(elementModule
);
1761 cursor
.insertAttributeWithValue("ModuleGuid", includeModules
.get(i
)[0]);
1762 cursor
.insertAttributeWithValue("BaseName", includeModules
.get(i
)[1]);
1763 cursor
.toEndToken();
1764 cursor
.toNextToken();
1769 public int getUserExtsIncModCount (String fvName
) {
1770 if (getfpdBuildOpts().getUserExtensionsList() == null) {
1773 ListIterator
<UserExtensionsDocument
.UserExtensions
> li
= getfpdBuildOpts().getUserExtensionsList().listIterator();
1774 QName elementIncludeModules
= new QName(xmlNs
, "IncludeModules");
1775 while (li
.hasNext()) {
1776 UserExtensionsDocument
.UserExtensions ues
= li
.next();
1777 if (!ues
.getUserID().equals("IMAGES")) {
1780 XmlCursor cursor
= ues
.newCursor();
1781 cursor
.toFirstChild();
1782 String elementName
= cursor
.getTextValue();
1783 if (elementName
.equals(fvName
)) {
1784 cursor
.toNextSibling(elementIncludeModules
);
1785 if (cursor
.toFirstChild()) {
1787 for (i
= 1; cursor
.toNextSibling(); ++i
);
1799 public void getUserExtsIncMods(String fvName
, String
[][] saa
) {
1800 if (getfpdBuildOpts().getUserExtensionsList() == null) {
1804 XmlCursor cursor
= getfpdBuildOpts().newCursor();
1805 QName elementUserExts
= new QName (xmlNs
, "UserExtensions");
1806 QName attribUserId
= new QName ("UserID");
1807 QName elementFvName
= new QName (xmlNs
, "FvName");
1808 QName elementIncludeModules
= new QName(xmlNs
, "IncludeModules");
1809 QName attribModuleGuid
= new QName("ModuleGuid");
1810 QName attribBaseName
= new QName("BaseName");
1812 if (cursor
.toChild(elementUserExts
)) {
1815 if (cursor
.getAttributeText(attribUserId
).equals("IMAGES")) {
1816 cursor
.toChild(elementFvName
);
1817 String elementName
= cursor
.getTextValue();
1818 if (elementName
.equals(fvName
)) {
1819 cursor
.toNextSibling(elementIncludeModules
);
1820 if (cursor
.toFirstChild()) {
1823 saa
[i
][0] = cursor
.getAttributeText(attribModuleGuid
);
1824 saa
[i
][1] = cursor
.getAttributeText(attribBaseName
);
1826 }while (cursor
.toNextSibling());
1832 }while (cursor
.toNextSibling(elementUserExts
));
1838 public void updateBuildOptionsUserExtensions (String oldFvName
, String newFvName
) {
1839 if (getfpdBuildOpts().getUserExtensionsList() == null) {
1842 ListIterator
<UserExtensionsDocument
.UserExtensions
> li
= getfpdBuildOpts().getUserExtensionsList().listIterator();
1843 while (li
.hasNext()) {
1844 UserExtensionsDocument
.UserExtensions ues
= li
.next();
1845 if (!ues
.getUserID().equals("IMAGES")) {
1848 XmlCursor cursor
= ues
.newCursor();
1849 cursor
.toFirstChild();
1850 String elementName
= cursor
.getTextValue();
1851 if (elementName
.equals(oldFvName
)) {
1852 cursor
.setTextValue(newFvName
);
1859 public void removeBuildOptionsUserExtensions (String fvName
) {
1860 if (getfpdBuildOpts().getUserExtensionsList() == null) {
1864 ListIterator
<UserExtensionsDocument
.UserExtensions
> li
= getfpdBuildOpts().getUserExtensionsList().listIterator();
1865 while (li
.hasNext()) {
1866 UserExtensionsDocument
.UserExtensions ues
= li
.next();
1867 if (!ues
.getUserID().equals("IMAGES")) {
1870 XmlCursor cursor
= ues
.newCursor();
1871 cursor
.toFirstChild();
1872 String elementName
= cursor
.getTextValue();
1873 if (elementName
.equals(fvName
)) {
1885 public void genBuildOptionsUserDefAntTask (String id
, String fileName
, String execOrder
) {
1886 UserDefinedAntTasksDocument
.UserDefinedAntTasks udats
= getfpdBuildOpts().getUserDefinedAntTasks();
1887 if (udats
== null) {
1888 udats
= getfpdBuildOpts().addNewUserDefinedAntTasks();
1891 AntTaskDocument
.AntTask at
= udats
.addNewAntTask();
1892 setBuildOptionsUserDefAntTask(id
, fileName
, execOrder
, at
);
1895 private void setBuildOptionsUserDefAntTask(String id
, String fileName
, String execOrder
, AntTaskDocument
.AntTask at
) {
1896 at
.setId(new Integer(id
));
1897 XmlCursor cursor
= at
.newCursor();
1898 if (fileName
!= null){
1899 at
.setFilename(fileName
);
1901 else if (cursor
.toChild(xmlNs
, "Filename")) {
1904 if (execOrder
!= null) {
1905 at
.setAntCmdOptions(execOrder
);
1907 else if (cursor
.toChild(xmlNs
, "AntCmdOptions")) {
1913 public void removeBuildOptionsUserDefAntTask(int i
) {
1914 XmlObject o
= getfpdBuildOpts().getUserDefinedAntTasks();
1918 XmlCursor cursor
= o
.newCursor();
1919 if (cursor
.toFirstChild()) {
1920 for (int j
= 0; j
< i
; ++j
) {
1921 cursor
.toNextSibling();
1924 if (getBuildOptionsUserDefAntTaskCount() == 0) {
1932 public void updateBuildOptionsUserDefAntTask(int i
, String id
, String fileName
, String execOrder
){
1933 XmlObject o
= getfpdBuildOpts().getUserDefinedAntTasks();
1937 XmlCursor cursor
= o
.newCursor();
1938 if (cursor
.toFirstChild()) {
1939 for (int j
= 0; j
< i
; ++j
) {
1940 cursor
.toNextSibling();
1942 AntTaskDocument
.AntTask at
= (AntTaskDocument
.AntTask
)cursor
.getObject();
1943 setBuildOptionsUserDefAntTask(id
, fileName
, execOrder
, at
);
1948 public int getBuildOptionsUserDefAntTaskCount() {
1949 UserDefinedAntTasksDocument
.UserDefinedAntTasks udats
= getfpdBuildOpts().getUserDefinedAntTasks();
1950 if (udats
== null || udats
.getAntTaskList() == null) {
1954 return udats
.getAntTaskList().size();
1957 public void getBuildOptionsUserDefAntTasks(String
[][] saa
) {
1958 UserDefinedAntTasksDocument
.UserDefinedAntTasks udats
= getfpdBuildOpts().getUserDefinedAntTasks();
1959 if (udats
== null || udats
.getAntTaskList() == null) {
1963 List
<AntTaskDocument
.AntTask
> l
= udats
.getAntTaskList();
1964 ListIterator li
= l
.listIterator();
1966 while (li
.hasNext()) {
1967 AntTaskDocument
.AntTask at
= (AntTaskDocument
.AntTask
)li
.next();
1968 saa
[i
][0] = at
.getId() + "";
1969 saa
[i
][1] = saa
[i
][2] = "";
1970 if (at
.getFilename() != null){
1971 saa
[i
][1] = at
.getFilename();
1973 if (at
.getAntCmdOptions() != null) {
1974 saa
[i
][2] = at
.getAntCmdOptions();
1979 public void genBuildOptionsOpt(Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
) {
1980 OptionsDocument
.Options opts
= getfpdBuildOpts().getOptions();
1982 opts
= getfpdBuildOpts().addNewOptions();
1984 OptionDocument
.Option opt
= opts
.addNewOption();
1985 setBuildOptionsOpt(buildTargets
, toolChain
, tagName
, toolCmd
, archList
, contents
, opt
);
1988 private void setBuildOptionsOpt(Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
, OptionDocument
.Option opt
){
1989 opt
.setStringValue(contents
);
1991 opt
.setBuildTargets(buildTargets
);
1992 opt
.setToolChainFamily(toolChain
);
1993 opt
.setTagName(tagName
);
1994 opt
.setToolCode(toolCmd
);
1996 if (archList
!= null) {
1997 opt
.setSupArchList(archList
);
2000 if (opt
.isSetSupArchList()) {
2001 opt
.unsetSupArchList();
2006 public void removeBuildOptionsOpt(int i
){
2008 XmlObject o
= getfpdBuildOpts().getOptions();
2013 XmlCursor cursor
= o
.newCursor();
2014 if (cursor
.toFirstChild()) {
2015 for (int j
= 0; j
< i
; ++j
) {
2016 cursor
.toNextSibling();
2019 if (getBuildOptionsOptCount() == 0) {
2027 public void updateBuildOptionsOpt(int i
, Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
) {
2028 XmlObject o
= getfpdBuildOpts().getOptions();
2033 XmlCursor cursor
= o
.newCursor();
2034 if (cursor
.toFirstChild()) {
2035 for (int j
= 0; j
< i
; ++j
) {
2036 cursor
.toNextSibling();
2038 OptionDocument
.Option opt
= (OptionDocument
.Option
)cursor
.getObject();
2039 setBuildOptionsOpt(buildTargets
, toolChain
, tagName
, toolCmd
, archList
, contents
, opt
);
2044 public int getBuildOptionsOptCount(){
2045 if (getfpdBuildOpts().getOptions() == null || getfpdBuildOpts().getOptions().getOptionList() == null) {
2048 return getfpdBuildOpts().getOptions().getOptionList().size();
2051 public void getBuildOptionsOpts(String
[][] saa
) {
2052 if (getfpdBuildOpts().getOptions() == null || getfpdBuildOpts().getOptions().getOptionList() == null) {
2056 List
<OptionDocument
.Option
> lOpt
= getfpdBuildOpts().getOptions().getOptionList();
2057 ListIterator li
= lOpt
.listIterator();
2059 while(li
.hasNext()) {
2060 OptionDocument
.Option opt
= (OptionDocument
.Option
)li
.next();
2061 if (opt
.getBuildTargets() != null) {
2062 saa
[i
][0] = listToString(opt
.getBuildTargets());
2064 saa
[i
][1] = opt
.getToolChainFamily();
2065 if (opt
.getSupArchList() != null){
2066 saa
[i
][2] = listToString(opt
.getSupArchList());
2069 saa
[i
][3] = opt
.getToolCode();
2070 saa
[i
][4] = opt
.getTagName();
2071 saa
[i
][5] = opt
.getStringValue();
2077 public void genBuildOptionsFfs(String ffsKey
, String type
) {
2078 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getfpdBuildOpts().addNewFfs();
2079 ffs
.setFfsKey(ffsKey
);
2081 ffs
.addNewSections().setEncapsulationType(type
);
2085 public void updateBuildOptionsFfsSectionsType(int i
, String type
) {
2086 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getfpdBuildOpts().addNewFfs();
2088 ffs
.addNewSections().setEncapsulationType(type
);
2092 public void genBuildOptionsFfsAttribute(int i
, String name
, String value
) {
2093 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2094 BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute attrib
= ffs
.addNewAttribute();
2095 attrib
.setName(name
);
2096 attrib
.setValue(value
);
2099 /**update jth attribute of ith ffs.
2103 public void updateBuildOptionsFfsAttribute(int i
, int j
, String name
, String value
){
2104 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2105 XmlCursor cursor
= ffs
.newCursor();
2106 QName qAttrib
= new QName(xmlNs
, "Attribute");
2107 if (cursor
.toChild(qAttrib
)) {
2108 for (int k
= 0; k
< j
; ++k
) {
2109 cursor
.toNextSibling(qAttrib
);
2111 BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute attrib
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute
)cursor
.getObject();
2112 attrib
.setName(name
);
2113 attrib
.setValue(value
);
2118 public void removeBuildOptionsFfsAttribute(int i
, int j
){
2119 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2120 XmlCursor cursor
= ffs
.newCursor();
2121 QName qAttrib
= new QName(xmlNs
, "Attribute");
2122 if (cursor
.toChild(qAttrib
)) {
2123 for (int k
= 0; k
< j
; ++k
) {
2124 cursor
.toNextSibling(qAttrib
);
2131 public void genBuildOptionsFfsSectionsSection(int i
, String sectionType
) {
2132 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2136 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2138 if (sections
== null){
2139 sections
= ffs
.addNewSections();
2141 sections
.addNewSection().setSectionType(EfiSectionType
.Enum
.forString(sectionType
));
2144 public void removeBuildOptionsFfsSectionsSection(int i
, int j
) {
2145 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2146 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2147 if (sections
== null) {
2150 XmlCursor cursor
= sections
.newCursor();
2151 QName qSection
= new QName(xmlNs
, "Section");
2152 if (cursor
.toChild(qSection
)) {
2153 for (int k
= 0; k
< j
; ++k
) {
2154 cursor
.toNextSibling(qSection
);
2161 public void updateBuildOptionsFfsSectionsSection(int i
, int j
, String type
){
2162 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2163 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2164 if (sections
== null) {
2167 XmlCursor cursor
= sections
.newCursor();
2168 QName qSection
= new QName(xmlNs
, "Section");
2169 if (cursor
.toChild(qSection
)) {
2170 for (int k
= 0; k
< j
; ++k
) {
2171 cursor
.toNextSibling(qSection
);
2173 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Section section
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Section
)cursor
.getObject();
2174 section
.setSectionType(EfiSectionType
.Enum
.forString(type
));
2179 public void genBuildOptionsFfsSectionsSections(int i
, String encapType
) {
2180 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2184 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2186 if (sections
== null){
2187 sections
= ffs
.addNewSections();
2189 sections
.addNewSections().setEncapsulationType(encapType
);
2192 public void removeBuildOptionsFfsSectionsSections(int i
, int j
) {
2193 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2194 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2195 if (sections
== null) {
2198 XmlCursor cursor
= sections
.newCursor();
2199 QName qSections
= new QName(xmlNs
, "Sections");
2200 if (cursor
.toChild(qSections
)) {
2201 for (int k
= 0; k
< j
; ++k
) {
2202 cursor
.toNextSibling(qSections
);
2209 public void updateBuildOptionsFfsSectionsSections(int i
, int j
, String type
) {
2210 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2211 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2212 if (sections
== null) {
2215 XmlCursor cursor
= sections
.newCursor();
2216 QName qSections
= new QName(xmlNs
, "Sections");
2217 if (cursor
.toChild(qSections
)) {
2218 for (int k
= 0; k
< j
; ++k
) {
2219 cursor
.toNextSibling(qSections
);
2221 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2 sections2
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
)cursor
.getObject();
2222 sections2
.setEncapsulationType(type
);
2227 public void genBuildOptionsFfsSectionsSectionsSection(int i
, int j
, String type
) {
2228 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2232 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2233 XmlCursor cursor
= sections
.newCursor();
2234 QName qSections
= new QName(xmlNs
, "Sections");
2235 if (cursor
.toChild(qSections
)){
2236 for (int k
= 0; k
< j
; ++k
) {
2237 cursor
.toNextSibling(qSections
);
2239 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2 sections2
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
)cursor
.getObject();
2240 sections2
.addNewSection().setSectionType(EfiSectionType
.Enum
.forString(type
));
2245 public void removeBuildOptionsFfsSectionsSectionsSection(int i
, int j
, int k
) {
2246 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2247 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2248 if (sections
== null) {
2251 XmlCursor cursor
= sections
.newCursor();
2252 QName qSections
= new QName(xmlNs
, "Sections");
2253 if (cursor
.toChild(qSections
)) {
2254 for (int l
= 0; l
< j
; ++l
) {
2255 cursor
.toNextSibling(qSections
);
2257 if (cursor
.toFirstChild()) {
2259 for (; m
< k
; ++m
) {
2260 cursor
.toNextSibling();
2272 public void updateBuildOptionsFfsSectionsSectionsSection(int i
, int j
, int k
, String type
) {
2273 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2274 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2275 if (sections
== null) {
2278 XmlCursor cursor
= sections
.newCursor();
2279 QName qSections
= new QName(xmlNs
, "Sections");
2280 if (cursor
.toChild(qSections
)) {
2281 for (int l
= 0; l
< j
; ++l
) {
2282 cursor
.toNextSibling(qSections
);
2284 if (cursor
.toFirstChild()) {
2285 for (int m
= 0; m
< k
; ++m
) {
2286 cursor
.toNextSibling();
2288 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section section
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section
)cursor
.getObject();
2289 section
.setSectionType(EfiSectionType
.Enum
.forString(type
));
2295 public void getBuildOptionsFfsSectionsSectionsSection(int i
, int j
, ArrayList
<String
> al
) {
2296 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2300 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2301 XmlCursor cursor
= sections
.newCursor();
2302 QName qSections
= new QName(xmlNs
, "Sections");
2303 if (cursor
.toChild(qSections
)){
2304 for (int k
= 0; k
< j
; ++k
) {
2305 cursor
.toNextSibling(qSections
);
2307 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2 sections2
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
)cursor
.getObject();
2308 if (sections2
.getSectionList() == null){
2312 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section
> li
= sections2
.getSectionList().listIterator();
2313 while(li
.hasNext()) {
2314 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section section
= li
.next();
2315 if (section
.isSetSectionType()) {
2316 al
.add(section
.getSectionType().toString());
2325 public int getBuildOptionsFfsCount(){
2326 if (getfpdBuildOpts().getFfsList() == null) {
2329 return getfpdBuildOpts().getFfsList().size();
2332 public void getBuildOptionsFfsKey(String
[][] saa
) {
2333 if (getfpdBuildOpts().getFfsList() == null) {
2336 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
> li
= getfpdBuildOpts().getFfsList().listIterator();
2338 while(li
.hasNext()){
2339 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= li
.next();
2340 saa
[i
][0] = ffs
.getFfsKey();
2345 public void updateBuildOptionsFfsKey(int i
, String key
) {
2346 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2350 /**Get ith FFS key and contents.
2353 public void getBuildOptionsFfs(int i
, String
[] sa
, LinkedHashMap
<String
, String
> ffsAttribMap
, ArrayList
<String
> firstLevelSections
, ArrayList
<String
> firstLevelSection
) {
2354 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2358 sa
[0] = ffs
.getFfsKey();
2359 if (ffs
.getSections() != null) {
2360 if(ffs
.getSections().getEncapsulationType() != null){
2361 sa
[1] = ffs
.getSections().getEncapsulationType();
2363 if (ffs
.getSections().getSectionList() != null){
2364 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Section
> li
= ffs
.getSections().getSectionList().listIterator();
2365 while (li
.hasNext()) {
2366 firstLevelSection
.add(li
.next().getSectionType().toString());
2369 if (ffs
.getSections().getSectionsList() != null) {
2370 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
> li
= ffs
.getSections().getSectionsList().listIterator();
2371 while(li
.hasNext()) {
2372 firstLevelSections
.add(li
.next().getEncapsulationType());
2376 if (ffs
.getAttributeList() != null) {
2377 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute
> li
= ffs
.getAttributeList().listIterator();
2378 while(li
.hasNext()) {
2379 BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute attrib
= li
.next();
2380 ffsAttribMap
.put(attrib
.getName(), attrib
.getValue());
2389 private BuildOptionsDocument
.BuildOptions
.Ffs
getFfs(int i
) {
2390 XmlObject o
= getfpdBuildOpts();
2391 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= null;
2393 XmlCursor cursor
= o
.newCursor();
2394 QName qFfs
= new QName(xmlNs
, "Ffs");
2395 if (cursor
.toChild(qFfs
)) {
2396 for (int j
= 0; j
< i
; ++j
) {
2397 cursor
.toNextSibling(qFfs
);
2399 ffs
= (BuildOptionsDocument
.BuildOptions
.Ffs
)cursor
.getObject();
2405 public void removeBuildOptionsFfs(int i
) {
2406 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2411 XmlCursor cursor
= ffs
.newCursor();
2418 public PlatformDefinitionsDocument
.PlatformDefinitions
getfpdPlatformDefs(){
2419 if (fpdPlatformDefs
== null){
2420 fpdPlatformDefs
= fpdRoot
.addNewPlatformDefinitions();
2422 return fpdPlatformDefs
;
2425 public void getPlatformDefsSupportedArchs(Vector
<Object
> archs
){
2426 if (getfpdPlatformDefs().getSupportedArchitectures() == null) {
2429 ListIterator li
= getfpdPlatformDefs().getSupportedArchitectures().listIterator();
2430 while(li
.hasNext()) {
2431 archs
.add(li
.next());
2435 public void setPlatformDefsSupportedArchs(Vector
<Object
> archs
) {
2436 if (archs
!= null) {
2437 getfpdPlatformDefs().setSupportedArchitectures(archs
);
2440 // XmlCursor cursor = getfpdPlatformDefs().newCursor();
2441 // if (cursor.toChild(xmlNs, "SupportedArchitectures")) {
2442 // cursor.removeXml();
2444 // cursor.dispose();
2448 public void getPlatformDefsBuildTargets(Vector
<Object
> targets
) {
2449 if (getfpdPlatformDefs().getBuildTargets() == null) {
2452 ListIterator li
= getfpdPlatformDefs().getBuildTargets().listIterator();
2453 while(li
.hasNext()) {
2454 targets
.add(li
.next());
2458 public void setPlatformDefsBuildTargets(Vector
<Object
> targets
) {
2459 getfpdPlatformDefs().setBuildTargets(targets
);
2462 public void genPlatformDefsSkuInfo(String id
, String name
) {
2463 SkuInfoDocument
.SkuInfo skuInfo
= null;
2464 if (getfpdPlatformDefs().getSkuInfo() == null) {
2465 skuInfo
= getfpdPlatformDefs().addNewSkuInfo();
2467 skuInfo
= getfpdPlatformDefs().getSkuInfo();
2468 if (skuInfo
.getUiSkuNameList() == null || skuInfo
.getUiSkuNameList().size() == 0) {
2469 SkuInfoDocument
.SkuInfo
.UiSkuName skuName
= skuInfo
.addNewUiSkuName();
2470 skuName
.setSkuID(new BigInteger("0"));
2471 skuName
.setStringValue("DEFAULT");
2473 if (id
.equals("0")) {
2476 SkuInfoDocument
.SkuInfo
.UiSkuName skuName
= skuInfo
.addNewUiSkuName();
2477 skuName
.setSkuID(new BigInteger(id
));
2478 skuName
.setStringValue(name
);
2481 public int getPlatformDefsSkuInfoCount(){
2482 if (getfpdPlatformDefs().getSkuInfo() == null || getfpdPlatformDefs().getSkuInfo().getUiSkuNameList() == null) {
2485 return getfpdPlatformDefs().getSkuInfo().getUiSkuNameList().size();
2488 public void getPlatformDefsSkuInfos(String
[][] saa
){
2489 if (getfpdPlatformDefs().getSkuInfo() == null || getfpdPlatformDefs().getSkuInfo().getUiSkuNameList() == null) {
2490 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null) {
2491 removeElement(getfpdDynPcdBuildDefs());
2492 fpdDynPcdBuildDefs
= null;
2497 List
<SkuInfoDocument
.SkuInfo
.UiSkuName
> l
= getfpdPlatformDefs().getSkuInfo().getUiSkuNameList();
2498 ListIterator
<SkuInfoDocument
.SkuInfo
.UiSkuName
> li
= l
.listIterator();
2500 while(li
.hasNext()) {
2501 SkuInfoDocument
.SkuInfo
.UiSkuName sku
= li
.next();
2502 saa
[i
][0] = sku
.getSkuID()+"";
2503 saa
[i
][1] = sku
.getStringValue();
2508 public void removePlatformDefsSkuInfo(int i
) {
2509 SkuInfoDocument
.SkuInfo skuInfo
= getfpdPlatformDefs().getSkuInfo();
2510 if (skuInfo
== null || i
== 0) {
2514 XmlCursor cursor
= skuInfo
.newCursor();
2515 if (cursor
.toFirstChild()) {
2516 for (int j
= 0; j
< i
; ++j
) {
2517 cursor
.toNextSibling();
2524 public void updatePlatformDefsSkuInfo(int i
, String id
, String name
) {
2525 SkuInfoDocument
.SkuInfo skuInfo
= getfpdPlatformDefs().getSkuInfo();
2526 if (skuInfo
== null || i
== 0) {
2530 XmlCursor cursor
= skuInfo
.newCursor();
2531 if (cursor
.toFirstChild()) {
2532 for (int j
= 0; j
< i
; ++j
) {
2533 cursor
.toNextSibling();
2535 SkuInfoDocument
.SkuInfo
.UiSkuName sku
= (SkuInfoDocument
.SkuInfo
.UiSkuName
)cursor
.getObject();
2536 sku
.setSkuID(new BigInteger(id
));
2537 sku
.setStringValue(name
);
2542 public String
getPlatformDefsInterDir(){
2543 if (getfpdPlatformDefs().getIntermediateDirectories() == null) {
2546 return getfpdPlatformDefs().getIntermediateDirectories().toString();
2549 public void setPlatformDefsInterDir(String interDir
){
2550 getfpdPlatformDefs().setIntermediateDirectories(IntermediateOutputType
.Enum
.forString(interDir
));
2553 public String
getPlatformDefsOutputDir() {
2554 return getfpdPlatformDefs().getOutputDirectory();
2557 public void setPlatformDefsOutputDir(String outputDir
) {
2558 if (outputDir
!= null && outputDir
.length() > 0) {
2559 getfpdPlatformDefs().setOutputDirectory(outputDir
);
2562 XmlCursor cursor
= getfpdPlatformDefs().newCursor();
2563 if (cursor
.toChild(new QName(xmlNs
, "OutputDirectory"))) {
2570 public FlashDocument
.Flash
getfpdFlash() {
2571 if (fpdFlash
== null) {
2572 fpdFlash
= fpdRoot
.addNewFlash();
2577 public void genFlashDefinitionFile(String file
) {
2578 FlashDefinitionFileDocument
.FlashDefinitionFile fdf
= getfpdFlash().getFlashDefinitionFile();
2580 fdf
= getfpdFlash().addNewFlashDefinitionFile();
2583 fdf
.setStringValue(file
);
2586 public String
getFlashDefinitionFile() {
2587 FlashDefinitionFileDocument
.FlashDefinitionFile fdf
= getfpdFlash().getFlashDefinitionFile();
2592 return fdf
.getStringValue();
2595 public void genFvImagesNameValue(String name
, String value
) {
2597 FvImagesDocument
.FvImages fi
= getfpdFlash().getFvImages();
2599 fi
= getfpdFlash().addNewFvImages();
2602 FvImagesDocument
.FvImages
.NameValue nv
= fi
.addNewNameValue();
2607 public void removeFvImagesNameValue(int i
){
2609 XmlObject o
= getfpdFlash().getFvImages();
2614 QName qNameValue
= new QName(xmlNs
, "NameValue");
2615 XmlCursor cursor
= o
.newCursor();
2616 if (cursor
.toChild(qNameValue
)) {
2617 for (int j
= 0; j
< i
; ++j
) {
2618 cursor
.toNextSibling(qNameValue
);
2625 public void updateFvImagesNameValue(int i
, String name
, String value
){
2627 XmlObject o
= getfpdFlash().getFvImages();
2632 QName qNameValue
= new QName(xmlNs
, "NameValue");
2633 XmlCursor cursor
= o
.newCursor();
2634 if (cursor
.toChild(qNameValue
)) {
2635 for (int j
= 0; j
< i
; ++j
) {
2636 cursor
.toNextSibling(qNameValue
);
2638 FvImagesDocument
.FvImages
.NameValue nv
= (FvImagesDocument
.FvImages
.NameValue
)cursor
.getObject();
2645 public int getFvImagesNameValueCount() {
2647 FvImagesDocument
.FvImages fi
= null;
2648 if ((fi
= getfpdFlash().getFvImages()) == null || fi
.getNameValueList() == null) {
2651 return fi
.getNameValueList().size();
2654 public void getFvImagesNameValues(String
[][] nv
) {
2656 FvImagesDocument
.FvImages fi
= getfpdFlash().getFvImages();
2660 List
<FvImagesDocument
.FvImages
.NameValue
> l
= fi
.getNameValueList();
2662 ListIterator li
= l
.listIterator();
2663 while (li
.hasNext()) {
2664 FvImagesDocument
.FvImages
.NameValue e
= (FvImagesDocument
.FvImages
.NameValue
) li
2666 nv
[i
][0] = e
.getName();
2667 nv
[i
][1] = e
.getValue();
2673 public void getFvImagesFvImageFvImageNames (Vector
<String
> vImageNames
) {
2674 FvImagesDocument
.FvImages fis
= getfpdFlash().getFvImages();
2675 if (fis
== null || fis
.getFvImageList() == null) {
2679 ListIterator
<FvImagesDocument
.FvImages
.FvImage
> li
= fis
.getFvImageList().listIterator();
2680 while (li
.hasNext()) {
2681 FvImagesDocument
.FvImages
.FvImage fi
= li
.next();
2682 if (fi
.getType().toString().equals("ImageName")) {
2683 vImageNames
.addAll(fi
.getFvImageNamesList());
2689 public void addFvImageFvImageNames (String
[] fvNames
) {
2690 FvImagesDocument
.FvImages fis
= getfpdFlash().getFvImages();
2691 if (fis
== null || fis
.getFvImageList() == null) {
2692 genFvImagesFvImage (fvNames
, "ImageName", null);
2696 ListIterator
<FvImagesDocument
.FvImages
.FvImage
> li
= fis
.getFvImageList().listIterator();
2697 while (li
.hasNext()) {
2698 FvImagesDocument
.FvImages
.FvImage fi
= li
.next();
2699 if (fi
.getType().toString().equals("ImageName")) {
2700 addFvImageNamesInFvImage (fi
, fvNames
);
2704 genFvImagesFvImage (fvNames
, "ImageName", null);
2707 public void addFvImageNamesInFvImage (FvImagesDocument
.FvImages
.FvImage fi
, String
[] fvNames
) {
2709 for (int i
= 0; i
< fvNames
.length
; ++i
) {
2710 fi
.addFvImageNames(fvNames
[i
]);
2714 public void addFvImageNamesInFvImage (int i
, String
[] fvNames
) {
2715 XmlObject o
= getfpdFlash().getFvImages();
2719 XmlCursor cursor
= o
.newCursor();
2720 QName qFvImage
= new QName(xmlNs
, "FvImage");
2721 if (cursor
.toChild(qFvImage
)) {
2722 for (int j
= 0; j
< i
; ++j
) {
2723 cursor
.toNextSibling(qFvImage
);
2725 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
2726 addFvImageNamesInFvImage(fi
, fvNames
);
2731 public void genFvImagesFvImage(String
[] names
, String types
, Map
<String
, String
> options
) {
2733 FvImagesDocument
.FvImages fis
= null;
2734 if ((fis
= getfpdFlash().getFvImages()) == null) {
2735 fis
= getfpdFlash().addNewFvImages();
2739 //gen FvImage with FvImageNames array
2741 FvImagesDocument
.FvImages
.FvImage fi
= fis
.addNewFvImage();
2742 for (int i
= 0; i
< names
.length
; ++i
) {
2743 fi
.addFvImageNames(names
[i
]);
2745 fi
.setType(FvImageTypes
.Enum
.forString(types
));
2746 if (options
!= null){
2747 setFvImagesFvImageFvImageOptions(options
, fi
);
2751 private void setFvImagesFvImageFvImageOptions(Map
<String
, String
> options
, FvImagesDocument
.FvImages
.FvImage fi
){
2752 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions fio
= fi
.getFvImageOptions();
2754 fio
= fi
.addNewFvImageOptions();
2757 Set
<String
> key
= options
.keySet();
2758 Iterator
<String
> i
= key
.iterator();
2759 while (i
.hasNext()) {
2761 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nv
= fio
.addNewNameValue();
2762 String k
= (String
)i
.next();
2765 nv
.setValue((String
)options
.get(k
));
2772 public void removeFvImagesFvImage(int i
) {
2774 XmlObject o
= getfpdFlash().getFvImages();
2779 QName qFvImage
= new QName(xmlNs
, "FvImage");
2780 XmlCursor cursor
= o
.newCursor();
2781 if (cursor
.toChild(qFvImage
)) {
2782 for (int j
= 0; j
< i
; ++j
) {
2783 cursor
.toNextSibling(qFvImage
);
2792 * @param newFvName The New FV Name. If null, remove the old FvImageNames entry.
2794 public void updateFvImageNameAll (String oldFvName
, String newFvName
) {
2795 if (getfpdFlash().getFvImages() == null || getfpdFlash().getFvImages().getFvImageList() == null) {
2798 ListIterator
<FvImagesDocument
.FvImages
.FvImage
> li
= getfpdFlash().getFvImages().getFvImageList().listIterator();
2799 while (li
.hasNext()) {
2800 FvImagesDocument
.FvImages
.FvImage fi
= li
.next();
2801 updateFvImageNamesInFvImage (fi
, oldFvName
, newFvName
);
2802 if (fi
.getFvImageNamesList().size() == 0) {
2808 public void updateFvImageNamesInFvImage (int i
, String oldFvName
, String newFvName
) {
2809 XmlObject o
= getfpdFlash().getFvImages();
2813 XmlCursor cursor
= o
.newCursor();
2814 QName qFvImage
= new QName(xmlNs
, "FvImage");
2815 if (cursor
.toChild(qFvImage
)) {
2816 for (int j
= 0; j
< i
; ++j
) {
2817 cursor
.toNextSibling(qFvImage
);
2819 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
2820 updateFvImageNamesInFvImage (fi
, oldFvName
, newFvName
);
2826 * @param oldFvName The FV Name to be replaced.
2827 * @param newFvName The New FV Name. If null, remove the old FvImageNames entry.
2829 public void updateFvImageNamesInFvImage (FvImagesDocument
.FvImages
.FvImage fi
, String oldFvName
, String newFvName
) {
2830 QName qFvImageNames
= new QName(xmlNs
, "FvImageNames");
2831 XmlCursor cursor
= fi
.newCursor();
2833 if (cursor
.toChild(qFvImageNames
)) {
2835 String xmlValue
= cursor
.getTextValue();
2836 if (xmlValue
.equals(oldFvName
)){
2837 if (newFvName
!= null) {
2838 cursor
.setTextValue(newFvName
);
2844 }while (cursor
.toNextSibling(qFvImageNames
));
2850 /**update the Type attribute of ith FvImage with new type.
2854 public void updateFvImagesFvImageType (int i
, String type
) {
2855 XmlObject o
= getfpdFlash().getFvImages();
2859 XmlCursor cursor
= o
.newCursor();
2860 QName qFvImage
= new QName(xmlNs
, "FvImage");
2861 if (cursor
.toChild(qFvImage
)) {
2862 for (int j
= 0; j
< i
; ++j
) {
2863 cursor
.toNextSibling(qFvImage
);
2865 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
2866 fi
.setType(FvImageTypes
.Enum
.forString(type
));
2871 public void updateFvImagesFvImage(int i
, String
[] names
, String types
, Map
<String
, String
> options
){
2873 XmlObject o
= getfpdFlash().getFvImages();
2877 XmlCursor cursor
= o
.newCursor();
2878 QName qFvImage
= new QName(xmlNs
, "FvImage");
2879 if (cursor
.toChild(qFvImage
)) {
2880 for (int j
= 0; j
< i
; ++j
) {
2881 cursor
.toNextSibling(qFvImage
);
2883 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
2884 fi
.setType(FvImageTypes
.Enum
.forString(types
));
2887 // remove old FvImageNames before adding new ones
2889 QName qFvImageNames
= new QName(xmlNs
, "FvImageNames");
2890 cursor
.toChild(qFvImageNames
);
2892 while (cursor
.toNextSibling(qFvImageNames
)) {
2896 for (int k
= 0; k
< names
.length
; ++k
) {
2897 fi
.addFvImageNames(names
[k
]);
2900 // remove old FvImageOptions before adding new options
2902 QName qFvImageOptions
= new QName(xmlNs
, "FvImageOptions");
2903 cursor
.toNextSibling(qFvImageOptions
);
2906 setFvImagesFvImageFvImageOptions(options
, fi
);
2911 public int getFvImagesFvImageCount(String type
) {
2913 if (getfpdFlash().getFvImages() == null || getfpdFlash().getFvImages().getFvImageList() == null) {
2916 List
<FvImagesDocument
.FvImages
.FvImage
> l
= getfpdFlash().getFvImages().getFvImageList();
2917 ListIterator li
= l
.listIterator();
2919 while(li
.hasNext()) {
2920 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)li
.next();
2921 if (!fi
.getType().toString().equals(type
) && !type
.equals("ALL")) {
2931 public Vector
<FvImagesDocument
.FvImages
.FvImage
> getFvImagesFvImageWithName (String fvName
, String type
) {
2932 Vector
<FvImagesDocument
.FvImages
.FvImage
> vFvImage
= new Vector
<FvImagesDocument
.FvImages
.FvImage
>();
2933 if (getfpdFlash().getFvImages() == null || getfpdFlash().getFvImages().getFvImageList() == null) {
2936 List
<FvImagesDocument
.FvImages
.FvImage
> l
= getfpdFlash().getFvImages().getFvImageList();
2937 ListIterator li
= l
.listIterator();
2938 while(li
.hasNext()) {
2939 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)li
.next();
2940 if (!fi
.getType().toString().equals(type
) && !type
.equals("ALL")) {
2943 if (fi
.getFvImageNamesList().contains(fvName
)) {
2952 * @param type "ALL" means all FvImage types: ImageName, Options, Attributes, Components.
2954 public void getFvImagesFvImages(String
[][] saa
, String type
) {
2956 if (getfpdFlash().getFvImages() == null) {
2959 List
<FvImagesDocument
.FvImages
.FvImage
> l
= getfpdFlash().getFvImages().getFvImageList();
2963 ListIterator li
= l
.listIterator();
2965 while(li
.hasNext()) {
2966 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)li
.next();
2967 if (!fi
.getType().toString().equals(type
) && !type
.equals("ALL")) {
2971 // get FvImageNames array, space separated
2973 List
<String
> lfn
= fi
.getFvImageNamesList();
2974 ListIterator lfni
= lfn
.listIterator();
2976 while (lfni
.hasNext()) {
2977 saa
[i
][0] += (String
)lfni
.next();
2980 saa
[i
][0] = saa
[i
][0].trim();
2982 saa
[i
][1] = fi
.getType()+"";
2988 public void removeFvImageNameValue (int i
, String attributeName
) {
2989 XmlObject o
= getfpdFlash().getFvImages();
2993 XmlCursor cursor
= o
.newCursor();
2994 QName qFvImage
= new QName(xmlNs
, "FvImage");
2995 if (cursor
.toChild(qFvImage
)) {
2996 for (int j
= 0; j
< i
; ++j
) {
2997 cursor
.toNextSibling(qFvImage
);
2999 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
3000 removeFvImageNameValue (fi
, attributeName
);
3004 /**Remove from fi the attribute pair with attributeName in FvImageOptions.
3006 * @param attributeName
3008 public void removeFvImageNameValue (FvImagesDocument
.FvImages
.FvImage fi
, String attributeName
) {
3009 if (fi
.getFvImageOptions() != null && fi
.getFvImageOptions().getNameValueList() != null) {
3010 ListIterator
<FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
> li
= fi
.getFvImageOptions().getNameValueList().listIterator();
3011 while (li
.hasNext()) {
3012 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nv
= li
.next();
3013 if (nv
.getName().equals(attributeName
)) {
3020 public void removeTypedNamedFvImageNameValue (String fvName
, String type
, String optName
) {
3021 Vector
<FvImagesDocument
.FvImages
.FvImage
> vFvImage
= getFvImagesFvImageWithName(fvName
, type
);
3022 for (int i
= 0; i
< vFvImage
.size(); ++i
) {
3023 FvImagesDocument
.FvImages
.FvImage fi
= vFvImage
.get(i
);
3024 removeFvImageNameValue (fi
, optName
);
3028 /**Add name-value pair to FvImage element with type.
3029 * @param fvName FV name to add name-value pair.
3030 * @param type FvImage attribute.
3034 public void setTypedNamedFvImageNameValue (String fvName
, String type
, String name
, String value
) {
3035 boolean fvImageExists
= false;
3036 if (getfpdFlash().getFvImages() == null) {
3039 List
<FvImagesDocument
.FvImages
.FvImage
> l
= getfpdFlash().getFvImages().getFvImageList();
3043 ListIterator li
= l
.listIterator();
3044 while(li
.hasNext()) {
3045 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)li
.next();
3046 if (!fi
.getType().toString().equals(type
) && !type
.equals("ALL")) {
3049 if (!fi
.getFvImageNamesList().contains(fvName
)) {
3052 fvImageExists
= true;
3053 setFvImagesFvImageNameValue (fi
, name
, value
, null);
3056 if (!fvImageExists
) {
3057 HashMap
<String
, String
> map
= new HashMap
<String
, String
>();
3058 map
.put(name
, value
);
3059 genFvImagesFvImage(new String
[]{fvName
}, type
, map
);
3063 /**Add to all FvImage elements with type, the name-value pair.
3068 public void setTypedFvImageNameValue (String type
, String name
, String value
) {
3069 if (getfpdFlash().getFvImages() == null) {
3072 List
<FvImagesDocument
.FvImages
.FvImage
> l
= getfpdFlash().getFvImages().getFvImageList();
3076 ListIterator li
= l
.listIterator();
3077 while(li
.hasNext()) {
3078 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)li
.next();
3079 if (!fi
.getType().toString().equals(type
) && !type
.equals("ALL")) {
3082 setFvImagesFvImageNameValue (fi
, name
, value
, null);
3087 public void setFvImagesFvImageNameValue (int i
, String name
, String value
) {
3088 XmlObject o
= getfpdFlash().getFvImages();
3092 XmlCursor cursor
= o
.newCursor();
3093 QName qFvImage
= new QName(xmlNs
, "FvImage");
3094 if (cursor
.toChild(qFvImage
)) {
3095 for (int j
= 0; j
< i
; ++j
) {
3096 cursor
.toNextSibling(qFvImage
);
3098 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
3099 setFvImagesFvImageNameValue (fi
, name
, value
, null);
3104 /**Add to FvImage the name-value pair, or replace old name with newName, or generate new name-value pair if not exists before.
3110 public void setFvImagesFvImageNameValue (FvImagesDocument
.FvImages
.FvImage fi
, String name
, String value
, String newName
) {
3111 if (fi
.getFvImageOptions() == null || fi
.getFvImageOptions().getNameValueList() == null) {
3112 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nv
= fi
.addNewFvImageOptions().addNewNameValue();
3115 if (newName
!= null) {
3116 nv
.setName(newName
);
3121 XmlCursor cursor
= fi
.getFvImageOptions().newCursor();
3122 if (cursor
.toFirstChild()) {
3124 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nv
= (FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
)cursor
.getObject();
3125 if (nv
.getName().equals(name
)) {
3127 if (newName
!= null) {
3128 nv
.setName(newName
);
3133 }while (cursor
.toNextSibling());
3136 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nv
= fi
.getFvImageOptions().addNewNameValue();
3139 if (newName
!= null) {
3140 nv
.setName(newName
);
3145 public void getFvImagesFvImageOptions (String fvName
, Map
<String
, String
> m
) {
3146 Vector
<FvImagesDocument
.FvImages
.FvImage
> vFvImage
= getFvImagesFvImageWithName (fvName
, "Options");
3147 for (int i
= 0; i
< vFvImage
.size(); ++i
) {
3148 FvImagesDocument
.FvImages
.FvImage fi
= vFvImage
.get(i
);
3149 if (fi
== null || fi
.getFvImageOptions() == null || fi
.getFvImageOptions().getNameValueList() == null) {
3153 ListIterator
<FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
> li
= fi
.getFvImageOptions()
3156 while (li
.hasNext()) {
3157 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nv
= li
.next();
3158 m
.put(nv
.getName(), nv
.getValue());
3163 public int getFvImagePosInFvImages (String fvNameList
, String type
) {
3164 XmlObject o
= getfpdFlash().getFvImages();
3170 String
[] fvNameArray
= fvNameList
.trim().split(" ");
3171 Vector
<String
> vFvNames
= new Vector
<String
>();
3174 XmlCursor cursor
= o
.newCursor();
3175 QName qFvImage
= new QName(xmlNs
, "FvImage");
3176 if (cursor
.toChild(qFvImage
)) {
3179 vFvNames
.removeAllElements();
3180 for (int i
= 0; i
< fvNameArray
.length
; ++i
) {
3181 vFvNames
.add(fvNameArray
[i
]);
3183 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
3184 if (!fi
.getType().toString().equals(type
)) {
3187 if (fi
.getFvImageNamesList() == null || fi
.getFvImageNamesList().size() != vFvNames
.size()) {
3190 ListIterator
<String
> li
= fi
.getFvImageNamesList().listIterator();
3191 while (li
.hasNext()) {
3192 String name
= li
.next();
3193 vFvNames
.remove(name
);
3195 if (vFvNames
.size() == 0) {
3200 }while (cursor
.toNextSibling(qFvImage
));
3206 /**Get FvImage Options for FvImage i
3207 * @param i the ith FvImage
3209 public void getFvImagesFvImageOptions(int i
, Map
<String
, String
> m
) {
3210 XmlObject o
= getfpdFlash().getFvImages();
3214 XmlCursor cursor
= o
.newCursor();
3215 QName qFvImage
= new QName(xmlNs
, "FvImage");
3216 if (cursor
.toChild(qFvImage
)) {
3217 for (int j
= 0; j
< i
; ++j
) {
3218 cursor
.toNextSibling(qFvImage
);
3220 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
3221 if (fi
.getFvImageOptions() == null || fi
.getFvImageOptions().getNameValueList() == null){
3225 ListIterator
<FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
> li
= fi
.getFvImageOptions().getNameValueList().listIterator();
3226 while(li
.hasNext()){
3227 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nv
= li
.next();
3228 m
.put(nv
.getName(), nv
.getValue());
3235 Get platform header element
3236 @return PlatformHeaderDocument.PlatformHeader
3238 public PlatformHeaderDocument
.PlatformHeader
getFpdHdr() {
3239 if (fpdHdr
== null) {
3240 fpdHdr
= fpdRoot
.addNewPlatformHeader();
3246 public String
getFpdHdrPlatformName() {
3247 return getFpdHdr().getPlatformName();
3250 public String
getFpdHdrGuidValue() {
3251 return getFpdHdr().getGuidValue();
3254 public String
getFpdHdrVer() {
3255 return getFpdHdr().getVersion();
3258 public String
getFpdHdrAbs() {
3259 return getFpdHdr().getAbstract();
3262 public String
getFpdHdrDescription() {
3263 return getFpdHdr().getDescription();
3266 public String
getFpdHdrCopyright() {
3267 return getFpdHdr().getCopyright();
3270 public String
getFpdHdrLicense() {
3271 LicenseDocument
.License l
= getFpdHdr().getLicense();
3275 return l
.getStringValue();
3278 public String
getFpdHdrUrl() {
3279 LicenseDocument
.License l
= getFpdHdr().getLicense();
3286 public String
getFpdHdrSpec() {
3288 return "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052";
3289 // return getFpdHdr().getSpecification();
3292 public void setFpdHdrPlatformName(String name
){
3293 getFpdHdr().setPlatformName(name
);
3296 public void setFpdHdrGuidValue(String guid
){
3297 getFpdHdr().setGuidValue(guid
);
3300 public void setFpdHdrVer(String v
){
3301 getFpdHdr().setVersion(v
);
3304 public void setFpdHdrAbs(String abs
) {
3305 getFpdHdr().setAbstract(abs
);
3308 public void setFpdHdrDescription(String desc
){
3309 getFpdHdr().setDescription(desc
);
3312 public void setFpdHdrCopyright(String cr
) {
3313 getFpdHdr().setCopyright(cr
);
3316 public void setFpdHdrLicense(String license
){
3317 LicenseDocument
.License l
= getFpdHdr().getLicense();
3319 getFpdHdr().addNewLicense().setStringValue(license
);
3322 l
.setStringValue(license
);
3326 public void setFpdHdrUrl(String url
){
3327 LicenseDocument
.License l
= getFpdHdr().getLicense();
3333 public void setFpdHdrSpec(String s
){
3334 s
= "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052";
3335 getFpdHdr().setSpecification(s
);
3338 Save the processed xml contents to file
3340 @param fpdFile The file to save xml contents
3341 @throws IOException Exceptions during file operation
3343 public void saveAs(File fpdFile
) throws IOException
{
3345 XmlOptions options
= new XmlOptions();
3347 options
.setCharacterEncoding("UTF-8");
3348 options
.setSavePrettyPrint();
3349 options
.setSavePrettyPrintIndent(2);
3351 fpdd
.save(fpdFile
, options
);
3352 } catch (IOException e
) {
3353 e
.printStackTrace();
3358 private String
listToString(List l
) {
3363 ListIterator li
= l
.listIterator();
3364 while(li
.hasNext()) {
3371 private void removeElement(XmlObject o
) {
3372 XmlCursor cursor
= o
.newCursor();
3378 class PcdItemTypeConflictException
extends Exception
{
3383 private static final long serialVersionUID
= 1L;
3384 private String details
= null;
3386 PcdItemTypeConflictException(String pcdName
, String info
){
3387 ModuleIdentification mi
= WorkspaceProfile
.getModuleId(info
);
3388 details
= pcdName
+ " ItemType Conflicts with " + mi
.getName() + " in Pkg " + mi
.getPackageId().getName();
3391 public String
getMessage() {
3396 class PcdDeclNotFound
extends Exception
{
3401 private static final long serialVersionUID
= 1L;
3402 private String details
= null;
3404 PcdDeclNotFound(String info
) {
3405 details
= "PcdDeclNotFound: " + info
;
3408 public String
getMessage() {
3413 class PcdValueMalFormed
extends Exception
{
3418 private static final long serialVersionUID
= 1L;
3419 private String details
= null;
3421 PcdValueMalFormed(String info
) {
3422 details
= "PcdValueMalFormed: " + info
;
3425 public String
getMessage() {