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().toLowerCase() + " " + moduleSa
.getModuleVersion() +
119 " " + moduleSa
.getPackageGuid().toLowerCase() + " " + 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 getFrameworkModuleSAByFvBinding (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
) {
212 // BugBug : underscore "_" should not be replaced!!!
213 // But Fv name FVMAIN from fdf file not consist with FV_MAIN in fpd file.
215 if (fvNames
[i
].equals(fvName
) || fvNames
[i
].replaceAll("_", "").equals(fvName
)) {
216 String
[] sa
= new String
[] {moduleSa
.getModuleGuid(), moduleSa
.getModuleVersion(),
217 moduleSa
.getPackageGuid(), moduleSa
.getPackageVersion(),
218 listToString(moduleSa
.getSupArchList())};
226 public int getFrameworkModulesCount() {
227 if (getfpdFrameworkModules().getModuleSAList() == null || getfpdFrameworkModules().getModuleSAList().size() == 0){
228 removeElement(getfpdFrameworkModules());
229 fpdFrameworkModules
= null;
232 return getfpdFrameworkModules().getModuleSAList().size();
235 public void getFrameworkModulesInfo(String
[][] saa
) {
236 if (getFrameworkModulesCount() == 0){
240 ListIterator li
= getfpdFrameworkModules().getModuleSAList().listIterator();
242 while(li
.hasNext()) {
243 ModuleSADocument
.ModuleSA moduleSa
= (ModuleSADocument
.ModuleSA
)li
.next();
244 saa
[i
][0] = moduleSa
.getModuleGuid();
245 saa
[i
][1] = moduleSa
.getModuleVersion();
247 saa
[i
][2] = moduleSa
.getPackageGuid();
248 saa
[i
][3] = moduleSa
.getPackageVersion();
249 saa
[i
][4] = listToString(moduleSa
.getSupArchList());
254 public void getFrameworkModuleInfo(int i
, String
[] sa
) {
255 ModuleSADocument
.ModuleSA msa
= getModuleSA(i
);
259 sa
[0] = msa
.getModuleGuid();
260 sa
[1] = msa
.getModuleVersion();
261 sa
[2] = msa
.getPackageGuid();
262 sa
[3] = msa
.getPackageVersion();
263 sa
[4] = listToString(msa
.getSupArchList());
266 public ModuleSADocument
.ModuleSA
getModuleSA(String key
) {
268 if (getfpdFrameworkModules().getModuleSAList() == null || getfpdFrameworkModules().getModuleSAList().size() == 0) {
269 removeElement(getfpdFrameworkModules());
270 fpdFrameworkModules
= null;
273 String
[] s
= key
.split(" ");
274 String archsInKey
= "";
276 for (int i
= 4; i
< s
.length
; ++i
) {
280 archsInKey
= archsInKey
.trim();
283 ListIterator li
= getfpdFrameworkModules().getModuleSAList().listIterator();
284 while(li
.hasNext()) {
285 ModuleSADocument
.ModuleSA moduleSa
= (ModuleSADocument
.ModuleSA
)li
.next();
286 if (moduleSa
.getModuleGuid().equalsIgnoreCase(s
[0]) && moduleSa
.getPackageGuid().equalsIgnoreCase(s
[2])) {
287 if (moduleSa
.getModuleVersion() != null) {
288 if (!moduleSa
.getModuleVersion().equals(s
[1])) {
292 if (moduleSa
.getPackageVersion() != null) {
293 if (!moduleSa
.getPackageVersion().equals(s
[3])) {
297 //ToDo add arch check .
298 if (moduleSa
.getSupArchList() != null) {
299 if (listToString(moduleSa
.getSupArchList()).equals(archsInKey
)) {
304 if (archsInKey
.length() == 0) {
313 private ModuleSADocument
.ModuleSA
getModuleSA(int i
) {
314 ModuleSADocument
.ModuleSA moduleSa
= null;
315 if (fpdRoot
.getFrameworkModules() == null) {
318 XmlCursor cursor
= fpdRoot
.getFrameworkModules().newCursor();
319 if (cursor
.toFirstChild()) {
320 for (int j
= 0; j
< i
; ++j
) {
321 cursor
.toNextSibling();
323 moduleSa
= (ModuleSADocument
.ModuleSA
)cursor
.getObject();
329 public void removeModuleSA(int i
) {
330 XmlObject o
= fpdRoot
.getFrameworkModules();
335 XmlCursor cursor
= o
.newCursor();
336 if (cursor
.toFirstChild()) {
337 for (int j
= 0; j
< i
; ++j
) {
338 cursor
.toNextSibling();
341 // remove pcd from dynPcdMap, if DynamicPcdBuildData exists, remove them too.
343 ModuleSADocument
.ModuleSA moduleSa
= (ModuleSADocument
.ModuleSA
)cursor
.getObject();
344 String moduleInfo
= moduleSa
.getModuleGuid() + " " + moduleSa
.getModuleVersion() + " " +
345 moduleSa
.getPackageGuid()+ " " + moduleSa
.getPackageVersion() + " " + listToString(moduleSa
.getSupArchList());
346 PcdBuildDefinitionDocument
.PcdBuildDefinition pcdBuildDef
= moduleSa
.getPcdBuildDefinition();
347 if (pcdBuildDef
!= null && pcdBuildDef
.getPcdDataList() != null) {
348 ListIterator
<PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
> li
= pcdBuildDef
.getPcdDataList().listIterator();
349 while(li
.hasNext()) {
350 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= li
.next();
351 maintainDynPcdMap(pcdData
.getCName() + " " + pcdData
.getTokenSpaceGuidCName(), moduleInfo
);
356 while (cursor
.hasPrevToken()) {
357 cursor
.toPrevToken();
358 if (!cursor
.isText()) {
361 if (cursor
.getObject() == null) {
364 String s
= cursor
.getTextValue();
365 if (s
.matches(regExpNewLineAndSpaces
)) {
370 if (cursor
.isComment()) {
376 if (getFrameworkModulesCount() == 0) {
378 removeElement(getfpdFrameworkModules());
379 fpdFrameworkModules
= null;
386 public boolean adjustPcd (int seqModuleSa
) throws Exception
{
387 boolean dataModified
= false;
388 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(seqModuleSa
);
389 int pcdCount
= getPcdDataCount(seqModuleSa
);
390 String
[][] saaModuleSaPcd
= new String
[pcdCount
][7];
391 getPcdData(seqModuleSa
, saaModuleSaPcd
);
392 String mg
= moduleSa
.getModuleGuid();
393 String mv
= moduleSa
.getModuleVersion();
394 String pg
= moduleSa
.getPackageGuid();
395 String pv
= moduleSa
.getPackageVersion();
396 String arch
= listToString(moduleSa
.getSupArchList());
398 // delete pcd in ModuleSA but not in MSA files any longer.
400 String moduleKey
= mg
+ " " + mv
+ " " + pg
+ " " + pv
+ " " + arch
;
401 int libCount
= getLibraryInstancesCount(moduleKey
);
402 String
[][] saaLib
= new String
[libCount
][5];
403 getLibraryInstances(moduleKey
, saaLib
);
404 ModuleIdentification mi
= WorkspaceProfile
.getModuleId(moduleKey
);
405 Vector
<ModuleIdentification
> vMi
= new Vector
<ModuleIdentification
>();
407 // create vector for module & library instance MIs.
410 for (int j
= 0; j
< saaLib
.length
; ++j
) {
411 String libKey
= saaLib
[j
][1] + " " + saaLib
[j
][2] + " " + saaLib
[j
][3] + " " + saaLib
[j
][4];
412 ModuleIdentification libMi
= WorkspaceProfile
.getModuleId(libKey
);
416 nextPcd
:for (int i
= 0; i
< saaModuleSaPcd
.length
; ++i
) {
418 for (int j
= 0; j
< vMi
.size(); ++j
) {
419 ModuleIdentification nextMi
= vMi
.get(j
);
420 if (WorkspaceProfile
.pcdInMsa(saaModuleSaPcd
[i
][0], saaModuleSaPcd
[i
][1], nextMi
)) {
424 removePcdData(seqModuleSa
, saaModuleSaPcd
[i
][0], saaModuleSaPcd
[i
][1]);
428 // add new Pcd from MSA file to ModuleSA.
430 for (int i
= 0; i
< vMi
.size(); ++i
) {
431 ModuleSurfaceAreaDocument
.ModuleSurfaceArea msa
= (ModuleSurfaceAreaDocument
.ModuleSurfaceArea
) WorkspaceProfile
432 .getModuleXmlObject(vMi
434 if (msa
.getPcdCoded() == null || msa
.getPcdCoded().getPcdEntryList() == null) {
437 ListIterator li
= msa
.getPcdCoded().getPcdEntryList().listIterator();
438 msaPcdIter
:while (li
.hasNext()) {
439 PcdCodedDocument
.PcdCoded
.PcdEntry msaPcd
= (PcdCodedDocument
.PcdCoded
.PcdEntry
) li
.next();
440 ArrayList
<String
> al
= getDynPcdMapValue(msaPcd
.getCName() + " " + msaPcd
.getTokenSpaceGuidCName());
442 for (int j
= 0; j
< al
.size(); ++j
) {
443 if (al
.get(j
).contains(moduleKey
)) {
449 PackageIdentification
[] depPkgs
= SurfaceAreaQuery
.getDependencePkg(null, vMi
.get(i
));
450 PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry spdPcd
= LookupPcdDeclaration(msaPcd
, depPkgs
);
451 if (spdPcd
== null) {
455 throw new PcdDeclNotFound("No Declaration for PCD Entry " + msaPcd
.getCName() + " in Module "
459 // AddItem to ModuleSA PcdBuildDefinitions
461 String defaultVal
= msaPcd
.getDefaultValue() == null ? spdPcd
.getDefaultValue()
462 : msaPcd
.getDefaultValue();
464 genPcdData(msaPcd
.getCName(), spdPcd
.getToken(), msaPcd
.getTokenSpaceGuidCName(),
465 msaPcd
.getPcdItemType().toString(), spdPcd
.getDatumType() + "", defaultVal
, moduleSa
);
474 private void maintainDynPcdMap(String pcdKey
, String moduleInfo
) {
476 ArrayList
<String
> al
= dynPcdMap
.get(pcdKey
);
480 String
[] s
= moduleInfo
.split(" ");
481 for(int i
= 0; i
< al
.size(); ++i
){
482 String consumer
= al
.get(i
);
483 if (consumer
.contains(s
[0].toLowerCase()) && consumer
.contains(s
[2].toLowerCase())){
484 String
[] consumerPart
= consumer
.split(" ");
485 if (!consumerPart
[4].equals(s
[4])) {
493 if (al
.size() == 0) {
494 defaultPcdValue
.remove(pcdKey
);
495 dynPcdMap
.remove(pcdKey
);
496 String
[] s1
= pcdKey
.split(" ");
497 removeDynamicPcdBuildData(s1
[0], s1
[1]);
502 // key for ModuleSA : "ModuleGuid ModuleVer PackageGuid PackageVer Arch"
504 public int getPcdDataCount (int i
){
505 ModuleSADocument
.ModuleSA msa
= getModuleSA(i
);
507 if (msa
== null || msa
.getPcdBuildDefinition() == null || msa
.getPcdBuildDefinition().getPcdDataList() == null){
510 return msa
.getPcdBuildDefinition().getPcdDataList().size();
514 public void getPcdData (int i
, String
[][] saa
) {
515 ModuleSADocument
.ModuleSA msa
= getModuleSA(i
);
517 if (msa
== null || msa
.getPcdBuildDefinition() == null || msa
.getPcdBuildDefinition().getPcdDataList() == null){
520 ListIterator
<PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
>li
= msa
.getPcdBuildDefinition().getPcdDataList().listIterator();
521 for (int k
= 0; k
< saa
.length
; ++k
) {
522 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= li
.next();
523 saa
[k
][0] = pcdData
.getCName();
524 saa
[k
][1] = pcdData
.getTokenSpaceGuidCName();
525 saa
[k
][2] = pcdData
.getItemType()+"";
526 saa
[k
][3] = pcdData
.getToken().toString();
527 saa
[k
][4] = pcdData
.getMaxDatumSize()+"";
528 saa
[k
][5] = pcdData
.getDatumType()+"";
529 saa
[k
][6] = pcdData
.getValue();
534 public void removePcdData (int seqModuleSa
, String cName
, String tsGuid
) {
535 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(seqModuleSa
);
536 if (moduleSa
== null || moduleSa
.getPcdBuildDefinition() == null){
540 String mg
= moduleSa
.getModuleGuid();
541 String mv
= moduleSa
.getModuleVersion();
542 String pg
= moduleSa
.getPackageGuid();
543 String pv
= moduleSa
.getPackageVersion();
544 String arch
= listToString(moduleSa
.getSupArchList());
545 String moduleKey
= mg
+ " " + mv
+ " " + pg
+ " " + pv
+ " " + arch
;
547 XmlCursor cursor
= moduleSa
.getPcdBuildDefinition().newCursor();
548 if (cursor
.toFirstChild()){
551 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= (PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
)cursor
.getObject();
552 if (pcdData
.getCName().equals(cName
) && pcdData
.getTokenSpaceGuidCName().equals(tsGuid
)) {
553 maintainDynPcdMap(cName
+ " " + tsGuid
, moduleKey
);
554 if (getPcdDataCount(seqModuleSa
) == 1) {
561 while(cursor
.toNextSibling());
567 public void updatePcdData (String key
, String cName
, String tsGuid
, String itemType
, String maxSize
, String value
){
568 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(key
);
569 if (moduleSa
== null || moduleSa
.getPcdBuildDefinition() == null){
573 XmlCursor cursor
= moduleSa
.getPcdBuildDefinition().newCursor();
574 if (cursor
.toFirstChild()){
576 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= (PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
)cursor
.getObject();
577 if (pcdData
.getCName().equals(cName
) && pcdData
.getTokenSpaceGuidCName().equals(tsGuid
)) {
579 // change item type while not updating dynPcdData????
581 pcdData
.setItemType(PcdItemTypes
.Enum
.forString(itemType
));
582 if(pcdData
.getDatumType().equals("VOID*")) {
583 pcdData
.setMaxDatumSize(new Integer(maxSize
));
585 pcdData
.setValue(value
);
586 defaultPcdValue
.put(cName
+ " " + tsGuid
, value
);
590 while(cursor
.toNextSibling());
595 /**Get original Pcd info from MSA & SPD files.
596 * @param mi ModuleIdentification from which MSA & SPD come
597 * @param cName PCD cName
598 * @param sa Results: HelpText, Original item type.
601 public boolean getPcdBuildDataInfo(ModuleIdentification mi
, String cName
, String tsGuid
, String
[] sa
) throws Exception
{
604 ModuleSurfaceAreaDocument
.ModuleSurfaceArea msa
= (ModuleSurfaceAreaDocument
.ModuleSurfaceArea
)WorkspaceProfile
.getModuleXmlObject(mi
);
605 if (msa
.getPcdCoded() == null) {
609 Map
<String
, XmlObject
> m
= new HashMap
<String
, XmlObject
>();
610 m
.put("ModuleSurfaceArea", msa
);
611 SurfaceAreaQuery
.setDoc(m
);
612 PackageIdentification
[] depPkgs
= SurfaceAreaQuery
.getDependencePkg(null, mi
);
614 // First look through MSA pcd entries.
616 List
<PcdCodedDocument
.PcdCoded
.PcdEntry
> l
= msa
.getPcdCoded().getPcdEntryList();
617 ListIterator li
= l
.listIterator();
618 while(li
.hasNext()) {
619 PcdCodedDocument
.PcdCoded
.PcdEntry msaPcd
= (PcdCodedDocument
.PcdCoded
.PcdEntry
)li
.next();
620 if (!msaPcd
.getCName().equals(cName
)) {
623 if (!msaPcd
.getTokenSpaceGuidCName().equals(tsGuid
)) {
626 PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry spdPcd
= LookupPcdDeclaration(msaPcd
, depPkgs
);
627 if (spdPcd
== null) {
631 throw new PcdDeclNotFound(mi
.getName() + " " + msaPcd
.getCName());
634 // Get Pcd help text and original item type.
636 sa
[0] = spdPcd
.getHelpText() + msaPcd
.getHelpText();
637 sa
[1] = msaPcd
.getPcdItemType()+"";
638 sa
[2] = msa
.getModuleDefinitions().getBinaryModule()+"";
652 private boolean multiSourcePcd (String cName
, String tsGuidCName
, String moduleKey
) {
653 int libCount
= getLibraryInstancesCount(moduleKey
);
654 String
[][] saaLib
= new String
[libCount
][5];
655 getLibraryInstances(moduleKey
, saaLib
);
656 ModuleIdentification mi
= WorkspaceProfile
.getModuleId(moduleKey
);
657 Vector
<ModuleIdentification
> vMi
= new Vector
<ModuleIdentification
>();
659 // create vector for module & library instance MIs.
662 for (int j
= 0; j
< saaLib
.length
; ++j
) {
663 String libKey
= saaLib
[j
][1] + " " + saaLib
[j
][2] + " " + saaLib
[j
][3] + " " + saaLib
[j
][4];
664 ModuleIdentification libMi
= WorkspaceProfile
.getModuleId(libKey
);
668 int pcdSourceCount
= 0;
669 for (int i
= 0; i
< vMi
.size(); ++i
) {
670 if (WorkspaceProfile
.pcdInMsa(cName
, tsGuidCName
, vMi
.get(i
))) {
675 if (pcdSourceCount
< 2) {
684 /**Remove PCDBuildDefinition entries from ModuleSA
685 * @param moduleKey identifier of ModuleSA.
686 * @param consumer where these entries come from.
688 public void removePcdData(String moduleKey
, ModuleIdentification consumer
) {
690 ModuleSurfaceAreaDocument
.ModuleSurfaceArea msa
= (ModuleSurfaceAreaDocument
.ModuleSurfaceArea
)WorkspaceProfile
.getModuleXmlObject(consumer
);
691 if (msa
.getPcdCoded() == null) {
695 List
<PcdCodedDocument
.PcdCoded
.PcdEntry
> l
= msa
.getPcdCoded().getPcdEntryList();
696 ListIterator li
= l
.listIterator();
698 while(li
.hasNext()) {
699 PcdCodedDocument
.PcdCoded
.PcdEntry msaPcd
= (PcdCodedDocument
.PcdCoded
.PcdEntry
)li
.next();
700 ModuleSADocument
.ModuleSA moduleSA
= getModuleSA(moduleKey
);
701 if (moduleSA
.getPcdBuildDefinition() != null) {
702 XmlCursor cursor
= moduleSA
.getPcdBuildDefinition().newCursor();
704 if (cursor
.toFirstChild()) {
706 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= (PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
) cursor
708 String cName
= msaPcd
.getCName();
709 String tsGuidCName
= msaPcd
.getTokenSpaceGuidCName();
710 if (cName
.equals(pcdData
.getCName())
711 && tsGuidCName
.equals(pcdData
.getTokenSpaceGuidCName()) && !multiSourcePcd(cName
, tsGuidCName
, moduleKey
)) {
713 maintainDynPcdMap(pcdData
.getCName() + " " + pcdData
.getTokenSpaceGuidCName(),
718 } while (cursor
.toNextSibling());
722 if (moduleSA
.getPcdBuildDefinition().getPcdDataList().size() == 0) {
731 // key for ModuleSA : "ModuleGuid ModuleVer PackageGuid PackageVer Arch"
733 public int getLibraryInstancesCount(String key
) {
734 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
735 if (msa
== null || msa
.getLibraries() == null || msa
.getLibraries().getInstanceList() == null){
738 return msa
.getLibraries().getInstanceList().size();
741 public void getLibraryInstances(String key
, String
[][] saa
){
742 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
743 if (msa
== null || msa
.getLibraries() == null || msa
.getLibraries().getInstanceList() == null){
747 ListIterator
<LibrariesDocument
.Libraries
.Instance
> li
= msa
.getLibraries().getInstanceList().listIterator();
748 for (int i
= 0; i
< saa
.length
; ++i
) {
749 LibrariesDocument
.Libraries
.Instance instance
= li
.next();
750 saa
[i
][1] = instance
.getModuleGuid();
751 saa
[i
][2] = instance
.getModuleVersion();
752 saa
[i
][3] = instance
.getPackageGuid();
753 saa
[i
][4] = instance
.getPackageVersion();
757 public void removeLibraryInstance(String key
, int i
) {
758 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
759 if (msa
== null || msa
.getLibraries() == null){
763 XmlCursor cursor
= msa
.getLibraries().newCursor();
764 if (cursor
.toFirstChild()) {
765 for (int j
= 0; j
< i
; ++j
) {
766 cursor
.toNextSibling();
769 while (cursor
.hasPrevToken()) {
770 cursor
.toPrevToken();
771 if (!cursor
.isText()) {
774 String s
= cursor
.getTextValue();
775 if (s
.matches(regExpNewLineAndSpaces
)) {
780 if (cursor
.isComment()) {
785 if (getLibraryInstancesCount(key
) == 0) {
794 public void genLibraryInstance(ModuleIdentification libMi
, String key
) {
795 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
797 msa
= getfpdFrameworkModules().addNewModuleSA();
799 LibrariesDocument
.Libraries libs
= msa
.getLibraries();
801 libs
= msa
.addNewLibraries();
804 String mn
= libMi
.getName();
805 String mg
= libMi
.getGuid();
806 String mv
= libMi
.getVersion();
807 String pn
= libMi
.getPackageId().getName();
808 String pg
= libMi
.getPackageId().getGuid();
809 String pv
= libMi
.getPackageId().getVersion();
810 LibrariesDocument
.Libraries
.Instance instance
= libs
.addNewInstance();
811 XmlCursor cursor
= instance
.newCursor();
813 String comment
= "Pkg: " + pn
+ " Mod: " + mn
814 + " Path: " + libMi
.getPath().substring(System
.getenv("WORKSPACE").length() + 1);
815 cursor
.insertComment(comment
);
824 instance
.setModuleGuid(mg
);
825 instance
.setModuleVersion(mv
);
826 instance
.setPackageGuid(pg
);
827 instance
.setPackageVersion(pv
);
831 public String
getFvBinding(String moduleKey
){
832 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(moduleKey
);
833 return getFvBinding (moduleSa
);
836 public String
getFvBinding (ModuleSADocument
.ModuleSA moduleSa
) {
837 if (moduleSa
== null || moduleSa
.getModuleSaBuildOptions() == null) {
840 return moduleSa
.getModuleSaBuildOptions().getFvBinding();
843 public void setFvBinding(ModuleSADocument
.ModuleSA moduleSa
, String fvBinding
) {
844 if (moduleSa
== null ) {
847 if (fvBinding
== null || fvBinding
.length() == 0) {
848 if(moduleSa
.getModuleSaBuildOptions() != null){
849 moduleSa
.getModuleSaBuildOptions().unsetFvBinding();
853 if(moduleSa
.getModuleSaBuildOptions() == null){
854 moduleSa
.addNewModuleSaBuildOptions().setFvBinding(fvBinding
);
857 moduleSa
.getModuleSaBuildOptions().setFvBinding(fvBinding
);
861 public void setFvBinding(String moduleKey
, String fvBinding
){
862 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(moduleKey
);
863 setFvBinding (moduleSa
, fvBinding
);
866 private int fvBindingForModuleSA (ModuleSADocument
.ModuleSA moduleSa
, String fvName
) {
867 if (moduleSa
== null || moduleSa
.getModuleSaBuildOptions() == null || moduleSa
.getModuleSaBuildOptions().getFvBinding() == null) {
871 String fvNameList
= moduleSa
.getModuleSaBuildOptions().getFvBinding();
872 String
[] fvNamesArray
= fvNameList
.split(" ");
874 for (int i
= 0; i
< fvNamesArray
.length
; ++i
) {
875 if (fvNamesArray
[i
].equals(fvName
)) {
883 public void removeFvBinding (ModuleSADocument
.ModuleSA moduleSa
, String fvName
) {
884 if (moduleSa
== null || moduleSa
.getModuleSaBuildOptions() == null || moduleSa
.getModuleSaBuildOptions().getFvBinding() == null) {
888 String fvNameList
= moduleSa
.getModuleSaBuildOptions().getFvBinding();
889 String
[] fvNamesArray
= fvNameList
.split(" ");
891 for (int i
= 0; i
< fvNamesArray
.length
; ++i
) {
892 if (fvNamesArray
[i
].equals(fvName
)) {
897 // jump over where the input fvName occurs in the original Fv list.
898 if (occursAt
!= -1) {
899 String newFvNameList
= " ";
900 for (int i
= 0; i
< fvNamesArray
.length
; ++i
) {
904 newFvNameList
+= fvNamesArray
[i
];
906 setFvBinding (moduleSa
, newFvNameList
.trim());
912 * @param fvName The FV name that to be removed from FvBinding List.
914 public void removeFvBindingAll (String fvName
) {
915 if (getfpdFrameworkModules().getModuleSAList() == null || getfpdFrameworkModules().getModuleSAList().size() == 0){
916 removeElement(getfpdFrameworkModules());
917 fpdFrameworkModules
= null;
921 Iterator
<ModuleSADocument
.ModuleSA
> li
= getfpdFrameworkModules().getModuleSAList().iterator();
922 while (li
.hasNext()) {
923 ModuleSADocument
.ModuleSA moduleSa
= li
.next();
924 removeFvBinding (moduleSa
, fvName
);
928 public void appendFvBindingAll (String fvName
) {
929 if (getfpdFrameworkModules().getModuleSAList() == null || getfpdFrameworkModules().getModuleSAList().size() == 0){
930 removeElement(getfpdFrameworkModules());
931 fpdFrameworkModules
= null;
935 Iterator
<ModuleSADocument
.ModuleSA
> li
= getfpdFrameworkModules().getModuleSAList().iterator();
936 while (li
.hasNext()) {
937 ModuleSADocument
.ModuleSA moduleSa
= li
.next();
938 appendFvBinding (moduleSa
, fvName
);
942 public void appendFvBindingFor (String oldFvName
, String newFvName
) {
943 if (getfpdFrameworkModules().getModuleSAList() == null || getfpdFrameworkModules().getModuleSAList().size() == 0){
944 removeElement(getfpdFrameworkModules());
945 fpdFrameworkModules
= null;
949 Iterator
<ModuleSADocument
.ModuleSA
> li
= getfpdFrameworkModules().getModuleSAList().iterator();
950 while (li
.hasNext()) {
951 ModuleSADocument
.ModuleSA moduleSa
= li
.next();
952 String fvBinding
= getFvBinding (moduleSa
);
953 if (fvBinding
!= null && fvBindingForModuleSA (moduleSa
, oldFvName
) >= 0) {
954 appendFvBinding (moduleSa
, newFvName
);
959 public void appendFvBinding (String moduleKey
, String fvName
) {
960 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(moduleKey
);
961 appendFvBinding (moduleSa
, fvName
);
964 public void appendFvBinding (ModuleSADocument
.ModuleSA moduleSa
, String fvName
) {
965 if (moduleSa
== null) {
969 if (moduleSa
.getModuleSaBuildOptions() == null || moduleSa
.getModuleSaBuildOptions().getFvBinding() == null) {
970 setFvBinding(moduleSa
, fvName
);
974 String fvNameList
= moduleSa
.getModuleSaBuildOptions().getFvBinding();
975 String newFvNameList
= fvNameList
+ " " + fvName
;
976 setFvBinding (moduleSa
, newFvNameList
.trim());
979 public void updateFvBindingInModuleSA (String moduleKey
, String fvName
) {
981 appendFvBinding (moduleKey
, fvName
);
984 public String
getFfsFileNameGuid(String moduleKey
){
985 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(moduleKey
);
986 if (moduleSa
== null || moduleSa
.getModuleSaBuildOptions() == null) {
989 return moduleSa
.getModuleSaBuildOptions().getFfsFileNameGuid();
992 public void setFfsFileNameGuid(String moduleKey
, String fileGuid
){
993 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
997 if(msa
.getModuleSaBuildOptions() == null){
998 msa
.addNewModuleSaBuildOptions();
1001 ModuleSaBuildOptionsDocument
.ModuleSaBuildOptions msaBuildOpts
= msa
.getModuleSaBuildOptions();
1002 if (fileGuid
!= null) {
1003 msaBuildOpts
.setFfsFileNameGuid(fileGuid
);
1006 XmlCursor cursor
= msaBuildOpts
.newCursor();
1007 if (cursor
.toChild(xmlNs
, "FfsFileNameGuid")) {
1015 public String
getFfsFormatKey(String moduleKey
){
1016 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
1017 if (msa
== null || msa
.getModuleSaBuildOptions() == null) {
1020 return msa
.getModuleSaBuildOptions().getFfsFormatKey();
1023 public void setFfsFormatKey(String moduleKey
, String ffsKey
){
1024 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
1028 if(msa
.getModuleSaBuildOptions() == null){
1029 msa
.addNewModuleSaBuildOptions().setFfsFormatKey(ffsKey
);
1032 msa
.getModuleSaBuildOptions().setFfsFormatKey(ffsKey
);
1035 public void setModuleSAForceDebug(int i
, boolean dbgEnable
) {
1036 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(i
);
1037 moduleSa
.setForceDebug(dbgEnable
);
1040 public boolean getModuleSAForceDebug (int i
) {
1041 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(i
);
1042 if (moduleSa
.getForceDebug() == true) {
1048 public void getModuleSAOptions(String moduleKey
, String
[][] saa
) {
1049 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
1050 if (msa
== null || msa
.getModuleSaBuildOptions() == null || msa
.getModuleSaBuildOptions().getOptions() == null
1051 || msa
.getModuleSaBuildOptions().getOptions().getOptionList() == null) {
1055 List
<OptionDocument
.Option
> lOpt
= msa
.getModuleSaBuildOptions().getOptions().getOptionList();
1056 ListIterator li
= lOpt
.listIterator();
1058 while(li
.hasNext()) {
1059 OptionDocument
.Option opt
= (OptionDocument
.Option
)li
.next();
1060 if (opt
.getBuildTargets() != null) {
1061 saa
[i
][0] = listToString(opt
.getBuildTargets());
1063 saa
[i
][1] = opt
.getToolChainFamily();
1064 saa
[i
][2] = opt
.getTagName();
1065 saa
[i
][3] = opt
.getToolCode();
1067 if (opt
.getSupArchList() != null){
1068 saa
[i
][4] = listToString(opt
.getSupArchList());
1074 saa
[i
][5] = opt
.getStringValue();
1080 public int getModuleSAOptionsCount(String moduleKey
){
1081 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
1082 if (msa
== null || msa
.getModuleSaBuildOptions() == null || msa
.getModuleSaBuildOptions().getOptions() == null
1083 || msa
.getModuleSaBuildOptions().getOptions().getOptionList() == null) {
1086 return msa
.getModuleSaBuildOptions().getOptions().getOptionList().size();
1089 public void genModuleSAOptionsOpt(String moduleKey
, Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
) {
1090 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
1091 if (msa
.getModuleSaBuildOptions() == null) {
1092 msa
.addNewModuleSaBuildOptions();
1094 if (msa
.getModuleSaBuildOptions().getOptions() == null){
1095 msa
.getModuleSaBuildOptions().addNewOptions();
1097 OptionDocument
.Option opt
= msa
.getModuleSaBuildOptions().getOptions().addNewOption();
1098 setBuildOptionsOpt(buildTargets
, toolChain
, tagName
, toolCmd
, archList
, contents
, opt
);
1101 public void removeModuleSAOptionsOpt(String moduleKey
, int i
) {
1102 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
1103 if (msa
.getModuleSaBuildOptions() == null || msa
.getModuleSaBuildOptions().getOptions() == null) {
1106 OptionsDocument
.Options opts
= msa
.getModuleSaBuildOptions().getOptions();
1107 XmlCursor cursor
= opts
.newCursor();
1108 if (cursor
.toFirstChild()) {
1109 for (int j
= 0; j
< i
; ++j
){
1110 cursor
.toNextSibling();
1113 if (getModuleSAOptionsCount(moduleKey
) == 0) {
1121 public void updateModuleSAOptionsOpt(String moduleKey
, int i
, Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
) {
1122 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
1123 if (msa
.getModuleSaBuildOptions() == null || msa
.getModuleSaBuildOptions().getOptions() == null) {
1126 OptionsDocument
.Options opts
= msa
.getModuleSaBuildOptions().getOptions();
1127 XmlCursor cursor
= opts
.newCursor();
1128 if (cursor
.toFirstChild()) {
1129 for (int j
= 0; j
< i
; ++j
){
1130 cursor
.toNextSibling();
1132 OptionDocument
.Option opt
= (OptionDocument
.Option
)cursor
.getObject();
1133 setBuildOptionsOpt(buildTargets
, toolChain
, tagName
, toolCmd
, archList
, contents
, opt
);
1138 /**add pcd information of module mi to a ModuleSA.
1140 * @param moduleSa if null, generate a new ModuleSA.
1142 public void addFrameworkModulesPcdBuildDefs(ModuleIdentification mi
, String arch
, ModuleSADocument
.ModuleSA moduleSa
) throws Exception
{
1143 //ToDo add Arch filter
1146 if (moduleSa
== null) {
1147 moduleSa
= genModuleSA(mi
, arch
);
1150 ModuleSurfaceAreaDocument
.ModuleSurfaceArea msa
= (ModuleSurfaceAreaDocument
.ModuleSurfaceArea
)WorkspaceProfile
.getModuleXmlObject(mi
);
1151 if (msa
.getPcdCoded() == null) {
1155 Map
<String
, XmlObject
> m
= new HashMap
<String
, XmlObject
>();
1156 m
.put("ModuleSurfaceArea", msa
);
1157 SurfaceAreaQuery
.setDoc(m
);
1158 PackageIdentification
[] depPkgs
= SurfaceAreaQuery
.getDependencePkg(null, mi
);
1160 // Implementing InitializePlatformPcdBuildDefinitions
1162 List
<PcdCodedDocument
.PcdCoded
.PcdEntry
> l
= msa
.getPcdCoded().getPcdEntryList();
1163 ListIterator li
= l
.listIterator();
1164 while(li
.hasNext()) {
1165 PcdCodedDocument
.PcdCoded
.PcdEntry msaPcd
= (PcdCodedDocument
.PcdCoded
.PcdEntry
)li
.next();
1166 PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry spdPcd
= LookupPcdDeclaration(msaPcd
, depPkgs
);
1167 if (spdPcd
== null) {
1171 throw new PcdDeclNotFound("No Declaration for PCD Entry " + msaPcd
.getCName() + " in Module " + mi
.getName());
1174 // AddItem to ModuleSA PcdBuildDefinitions
1176 String defaultVal
= msaPcd
.getDefaultValue() == null ? spdPcd
.getDefaultValue() : msaPcd
.getDefaultValue();
1178 genPcdData(msaPcd
.getCName(), spdPcd
.getToken(), msaPcd
.getTokenSpaceGuidCName(), msaPcd
.getPcdItemType().toString(), spdPcd
.getDatumType()+"", defaultVal
, moduleSa
);
1182 catch (Exception e
){
1189 private PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry
LookupPcdDeclaration (PcdCodedDocument
.PcdCoded
.PcdEntry msaPcd
, PackageIdentification
[] depPkgs
) {
1191 PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry spdPcd
= null;
1192 for (int i
= 0; i
< depPkgs
.length
; ++i
) {
1194 XmlObject
[] xo
= SurfaceAreaQuery
.getSpdPcdDeclarations(depPkgs
[i
]);
1198 for (int j
= 0; j
< xo
.length
; ++j
) {
1199 spdPcd
= (PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry
)xo
[j
];
1200 if (msaPcd
.getTokenSpaceGuidCName() == null) {
1201 if (spdPcd
.getCName().equals(msaPcd
.getCName())) {
1206 if (spdPcd
.getCName().equals(msaPcd
.getCName()) && spdPcd
.getTokenSpaceGuidCName().equals(msaPcd
.getTokenSpaceGuidCName())) {
1217 private ModuleSADocument
.ModuleSA
genModuleSA (ModuleIdentification mi
, String arch
) {
1218 PackageIdentification pi
= WorkspaceProfile
.getPackageForModule(mi
);
1219 ModuleSADocument
.ModuleSA msa
= getfpdFrameworkModules().addNewModuleSA();
1220 XmlCursor cursor
= msa
.newCursor();
1222 String comment
= "Mod: " + mi
.getName() + " Type: " + SurfaceAreaQuery
.getModuleType(mi
) + " Path: "
1223 + mi
.getPath().substring(System
.getenv("WORKSPACE").length() + 1);
1224 cursor
.insertComment(comment
);
1227 e
.printStackTrace();
1232 msa
.setModuleGuid(mi
.getGuid());
1233 msa
.setModuleVersion(mi
.getVersion());
1234 msa
.setPackageGuid(pi
.getGuid());
1235 msa
.setPackageVersion(pi
.getVersion());
1237 Vector
<String
> v
= new Vector
<String
>();
1239 msa
.setSupArchList(v
);
1245 private void genPcdData (String cName
, Object token
, String tsGuid
, String itemType
, String dataType
, String defaultVal
, ModuleSADocument
.ModuleSA moduleSa
)
1246 throws PcdItemTypeConflictException
, PcdValueMalFormed
{
1247 if (moduleSa
.getPcdBuildDefinition() == null){
1248 moduleSa
.addNewPcdBuildDefinition();
1251 // constructe pcd to modulesa mapping first.
1252 // Attention : for any error condition, remove from map this pcd.
1254 ArrayList
<String
> pcdConsumer
= LookupPlatformPcdData(cName
+ " " + tsGuid
);
1255 if (pcdConsumer
== null) {
1256 pcdConsumer
= new ArrayList
<String
>();
1259 // Check whether this PCD has already added to ModuleSA, if so, just return.
1261 String moduleInfo
= moduleSa
.getModuleGuid().toLowerCase() + " " + moduleSa
.getModuleVersion()
1262 + " " + moduleSa
.getPackageGuid().toLowerCase() + " " + moduleSa
.getPackageVersion() + " " + listToString(moduleSa
.getSupArchList());
1263 for (int i
= 0; i
< pcdConsumer
.size(); ++i
) {
1264 String pcdInfo
= pcdConsumer
.get(i
);
1265 if (moduleInfo
.equals(pcdInfo
.substring(0, pcdInfo
.lastIndexOf(" ")))){
1270 // Using existing Pcd type, if this pcd already exists in other ModuleSA
1272 if (pcdConsumer
.size() > 0) {
1274 itemType
= itemType (pcdConsumer
.get(0));
1276 String listValue
= moduleInfo
+ " " + itemType
;
1277 pcdConsumer
.add(listValue
);
1278 dynPcdMap
.put(cName
+ " " + tsGuid
, pcdConsumer
);
1280 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData fpdPcd
= moduleSa
.getPcdBuildDefinition().addNewPcdData();
1281 fpdPcd
.setCName(cName
);
1282 fpdPcd
.setToken(token
);
1283 fpdPcd
.setTokenSpaceGuidCName(tsGuid
);
1284 fpdPcd
.setDatumType(PcdDataTypes
.Enum
.forString(dataType
));
1285 fpdPcd
.setItemType(PcdItemTypes
.Enum
.forString(itemType
));
1287 if (defaultVal
!= null){
1288 fpdPcd
.setValue(defaultVal
);
1291 if (dataType
.equals("UINT8") || dataType
.equals("UINT16") || dataType
.equals("UINT32") || dataType
.equals("UINT64")) {
1292 fpdPcd
.setValue("0");
1294 if (dataType
.equals("BOOLEAN")){
1295 fpdPcd
.setValue("FALSE");
1297 if (dataType
.equals("VOID*")) {
1298 fpdPcd
.setValue("");
1302 // Using existing pcd value, if this pcd already exists in other moduleSa.
1304 if (defaultPcdValue
.get(cName
+ " " + tsGuid
) == null) {
1305 defaultPcdValue
.put(cName
+ " " + tsGuid
, fpdPcd
.getValue());
1308 fpdPcd
.setValue(defaultPcdValue
.get(cName
+ " " + tsGuid
));
1311 if (dataType
.equals("UINT8")){
1312 fpdPcd
.setMaxDatumSize(1);
1314 if (dataType
.equals("UINT16")) {
1315 fpdPcd
.setMaxDatumSize(2);
1317 if (dataType
.equals("UINT32")) {
1318 fpdPcd
.setMaxDatumSize(4);
1320 if (dataType
.equals("UINT64")){
1321 fpdPcd
.setMaxDatumSize(8);
1323 if (dataType
.equals("BOOLEAN")){
1324 fpdPcd
.setMaxDatumSize(1);
1326 if (dataType
.equals("VOID*")) {
1327 int maxSize
= setMaxSizeForPointer(fpdPcd
.getValue());
1328 fpdPcd
.setMaxDatumSize(maxSize
);
1332 if (itemType
.equals("DYNAMIC") || itemType
.equals("DYNAMIC_EX")) {
1333 ArrayList
<String
> al
= LookupDynamicPcdBuildDefinition(cName
+ " " + tsGuid
);
1335 // if only one module mapped to this pcd, then the one is myself. so no other module mapped.
1336 // so need to add one dyn pcd.
1338 if (al
.size() == 1) {
1339 addDynamicPcdBuildData(cName
, token
, tsGuid
, itemType
, dataType
, defaultVal
);
1345 public int setMaxSizeForPointer(String datum
) throws PcdValueMalFormed
{
1346 if (datum
== null) {
1349 char ch
= datum
.charAt(0);
1353 // For void* type PCD, only three datum is support:
1354 // 1) Unicode: string with start char is "L"
1355 // 2) Ansci: String is ""
1356 // 3) byte array: String start char "{"
1359 start
= datum
.indexOf('\"');
1360 end
= datum
.lastIndexOf('\"');
1361 if ((start
> end
) ||
1362 (end
> datum
.length())||
1363 ((start
== end
) && (datum
.length() > 0))) {
1364 //ToDo Error handling here
1365 throw new PcdValueMalFormed (datum
);
1368 strValue
= datum
.substring(start
+ 1, end
);
1369 return strValue
.length() * 2;
1370 } else if (ch
== '\"'){
1371 start
= datum
.indexOf('\"');
1372 end
= datum
.lastIndexOf('\"');
1373 if ((start
> end
) ||
1374 (end
> datum
.length())||
1375 ((start
== end
) && (datum
.length() > 0))) {
1376 throw new PcdValueMalFormed (datum
);
1378 strValue
= datum
.substring(start
+ 1, end
);
1379 return strValue
.length();
1380 } else if (ch
=='{') {
1381 String
[] strValueArray
;
1383 start
= datum
.indexOf('{');
1384 end
= datum
.lastIndexOf('}');
1385 strValue
= datum
.substring(start
+ 1, end
);
1386 strValue
= strValue
.trim();
1387 if (strValue
.length() == 0) {
1390 strValueArray
= strValue
.split(",");
1391 for (int index
= 0; index
< strValueArray
.length
; index
++) {
1392 Integer value
= Integer
.decode(strValueArray
[index
].trim());
1395 // "[FPD file error] The datum type of PCD %s in %s is VOID*, "+
1396 // "it must be a byte array. But the element of %s exceed the byte range",
1397 throw new PcdValueMalFormed (datum
);
1400 return strValueArray
.length
;
1404 // "[FPD file error] The datum type of PCD %s in %s is VOID*. For VOID* type, you have three format choise:\n "+
1405 // "1) UNICODE string: like L\"xxxx\";\r\n"+
1406 // "2) ANSIC string: like \"xxx\";\r\n"+
1407 // "3) Byte array: like {0x2, 0x45, 0x23}\r\n"+
1408 // "but the datum in seems does not following above format!",
1409 throw new PcdValueMalFormed (datum
);
1414 private ArrayList
<String
> LookupDynamicPcdBuildDefinition(String dynPcdKey
) {
1415 ArrayList
<String
> al
= dynPcdMap
.get(dynPcdKey
);
1420 private ArrayList
<String
> LookupPlatformPcdData(String pcdKey
) {
1422 return dynPcdMap
.get(pcdKey
);
1425 public int getDynamicPcdBuildDataCount() {
1426 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1427 removeElement(getfpdDynPcdBuildDefs());
1428 fpdDynPcdBuildDefs
= null;
1431 return getfpdDynPcdBuildDefs().getPcdBuildDataList().size();
1434 public void getDynamicPcdBuildData(String
[][] saa
) {
1435 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1436 removeElement(getfpdDynPcdBuildDefs());
1437 fpdDynPcdBuildDefs
= null;
1440 List
<DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
> l
= getfpdDynPcdBuildDefs().getPcdBuildDataList();
1441 ListIterator
<DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
> li
= l
.listIterator();
1443 while(li
.hasNext()) {
1444 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData dynPcd
= li
.next();
1445 saa
[i
][0] = dynPcd
.getCName();
1446 saa
[i
][1] = dynPcd
.getToken().toString();
1447 saa
[i
][2] = dynPcd
.getTokenSpaceGuidCName();
1448 saa
[i
][3] = dynPcd
.getMaxDatumSize()+"";
1449 saa
[i
][4] = dynPcd
.getDatumType().toString();
1455 public void addDynamicPcdBuildData(String cName
, Object token
, String tsGuid
, String itemType
, String dataType
, String defaultVal
)
1456 throws PcdValueMalFormed
{
1457 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData dynPcdData
= getfpdDynPcdBuildDefs().addNewPcdBuildData();
1458 dynPcdData
.setItemType(PcdItemTypes
.Enum
.forString(itemType
));
1459 dynPcdData
.setCName(cName
);
1460 dynPcdData
.setToken(token
);
1461 dynPcdData
.setTokenSpaceGuidCName(tsGuid
);
1462 dynPcdData
.setDatumType(PcdDataTypes
.Enum
.forString(dataType
));
1464 BigInteger bigInt
= new BigInteger("0");
1465 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo skuInfo
= dynPcdData
.addNewSkuInfo();
1466 skuInfo
.setSkuId(bigInt
);
1467 if (defaultVal
!= null){
1468 skuInfo
.setValue(defaultVal
);
1471 if (dataType
.equals("UINT8")){
1472 skuInfo
.setValue("0");
1474 if (dataType
.equals("UINT16")) {
1475 skuInfo
.setValue("0");
1477 if (dataType
.equals("UINT32")) {
1478 skuInfo
.setValue("0");
1480 if (dataType
.equals("UINT64")){
1481 skuInfo
.setValue("0");
1483 if (dataType
.equals("BOOLEAN")){
1484 skuInfo
.setValue("false");
1486 if (dataType
.equals("VOID*")) {
1487 skuInfo
.setValue("");
1490 if (dataType
.equals("UINT8")){
1491 dynPcdData
.setMaxDatumSize(1);
1493 if (dataType
.equals("UINT16")) {
1494 dynPcdData
.setMaxDatumSize(2);
1496 if (dataType
.equals("UINT32")) {
1497 dynPcdData
.setMaxDatumSize(4);
1499 if (dataType
.equals("UINT64")){
1500 dynPcdData
.setMaxDatumSize(8);
1502 if (dataType
.equals("BOOLEAN")){
1503 dynPcdData
.setMaxDatumSize(1);
1505 if (dataType
.equals("VOID*")) {
1506 int maxSize
= setMaxSizeForPointer(defaultVal
);
1507 dynPcdData
.setMaxDatumSize(maxSize
);
1511 public void removeDynamicPcdBuildData(String cName
, String tsGuid
) {
1512 XmlObject o
= fpdRoot
.getDynamicPcdBuildDefinitions();
1517 XmlCursor cursor
= o
.newCursor();
1518 if (cursor
.toFirstChild()) {
1520 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdBuildData
=
1521 (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1522 if (pcdBuildData
.getCName().equals(cName
) && pcdBuildData
.getTokenSpaceGuidCName().equals(tsGuid
)) {
1524 if (getDynamicPcdBuildDataCount() == 1) {
1532 while (cursor
.toNextSibling());
1537 // Get the Sku Info count of ith dyn pcd element.
1539 public int getDynamicPcdSkuInfoCount(int i
){
1540 if (fpdRoot
.getDynamicPcdBuildDefinitions() == null || fpdRoot
.getDynamicPcdBuildDefinitions().getPcdBuildDataList() == null
1541 || fpdRoot
.getDynamicPcdBuildDefinitions().getPcdBuildDataList().size() == 0) {
1545 int skuInfoCount
= 0;
1546 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1547 if (cursor
.toFirstChild()) {
1548 for (int j
= 0; j
< i
; ++j
) {
1549 cursor
.toNextSibling();
1551 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1552 if (pcdData
.getSkuInfoList() == null) {
1556 skuInfoCount
= pcdData
.getSkuInfoList().size();
1560 return skuInfoCount
;
1563 public void getDynamicPcdSkuInfos(int i
, String
[][] saa
){
1564 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1565 removeElement(getfpdDynPcdBuildDefs());
1566 fpdDynPcdBuildDefs
= null;
1570 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1571 if (cursor
.toFirstChild()) {
1572 for (int j
= 0; j
< i
; ++j
) {
1573 cursor
.toNextSibling();
1575 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1576 if (pcdData
.getSkuInfoList() == null) {
1581 ListIterator
<DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo
> li
= pcdData
.getSkuInfoList().listIterator();
1583 while (li
.hasNext()) {
1584 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo skuInfo
= li
.next();
1585 saa
[k
][0] = skuInfo
.getSkuId()+"";
1586 saa
[k
][1] = skuInfo
.getVariableName();
1587 saa
[k
][2] = skuInfo
.getVariableGuid();
1588 saa
[k
][3] = skuInfo
.getVariableOffset();
1589 saa
[k
][4] = skuInfo
.getHiiDefaultValue();
1590 saa
[k
][5] = skuInfo
.getVpdOffset();
1591 saa
[k
][6] = skuInfo
.getValue();
1601 public String
getDynamicPcdBuildDataValue(int i
){
1602 String value
= null;
1603 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1604 removeElement(getfpdDynPcdBuildDefs());
1605 fpdDynPcdBuildDefs
= null;
1609 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1610 if (cursor
.toFirstChild()) {
1611 for (int j
= 0; j
< i
; ++j
) {
1612 cursor
.toNextSibling();
1614 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1615 if (pcdData
.getSkuInfoList() == null) {
1619 value
= pcdData
.getSkuInfoArray(0).getValue();
1626 public String
getDynamicPcdBuildDataVpdOffset(int i
){
1627 String vpdOffset
= null;
1628 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1629 removeElement(getfpdDynPcdBuildDefs());
1630 fpdDynPcdBuildDefs
= null;
1634 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1635 if (cursor
.toFirstChild()) {
1636 for (int j
= 0; j
< i
; ++j
) {
1637 cursor
.toNextSibling();
1639 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1640 if (pcdData
.getSkuInfoList() == null) {
1644 vpdOffset
= pcdData
.getSkuInfoArray(0).getVpdOffset();
1651 public void removeDynamicPcdBuildDataSkuInfo(int i
) {
1652 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1653 removeElement(getfpdDynPcdBuildDefs());
1654 fpdDynPcdBuildDefs
= null;
1658 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1659 if (cursor
.toFirstChild()) {
1660 for (int j
= 0; j
< i
; ++j
) {
1661 cursor
.toNextSibling();
1663 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1664 if (pcdData
.getSkuInfoList() == null) {
1669 QName qSkuInfo
= new QName(xmlNs
, "SkuInfo");
1670 cursor
.toChild(qSkuInfo
);
1677 // generate sku info for ith dyn pcd build data.
1679 public void genDynamicPcdBuildDataSkuInfo(String id
, String varName
, String varGuid
, String varOffset
,
1680 String hiiDefault
, String vpdOffset
, String value
, int i
) {
1681 // if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1685 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1686 if (cursor
.toFirstChild()) {
1687 for (int j
= 0; j
< i
; ++j
) {
1688 cursor
.toNextSibling();
1690 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1691 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo skuInfo
= pcdData
.addNewSkuInfo();
1692 skuInfo
.setSkuId(new BigInteger(id
));
1693 if (varName
!= null){
1694 skuInfo
.setVariableName(varName
);
1695 skuInfo
.setVariableGuid(varGuid
);
1696 skuInfo
.setVariableOffset(varOffset
);
1697 skuInfo
.setHiiDefaultValue(hiiDefault
);
1699 else if (vpdOffset
!= null){
1700 skuInfo
.setVpdOffset(vpdOffset
);
1703 skuInfo
.setValue(value
);
1708 public void updateDynamicPcdBuildDataSkuInfo(String id
, String varName
, String varGuid
, String varOffset
,
1709 String hiiDefault
, String vpdOffset
, String value
, int i
){
1710 // if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1714 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1715 if (cursor
.toFirstChild()) {
1716 for (int j
= 0; j
< i
; ++j
) {
1717 cursor
.toNextSibling();
1719 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1720 ListIterator
<DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo
> li
= pcdData
.getSkuInfoList().listIterator();
1721 while (li
.hasNext()) {
1722 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo skuInfo
= li
.next();
1723 if (skuInfo
.getSkuId().toString().equals(id
)){
1724 if (varName
!= null){
1725 skuInfo
.setVariableName(varName
);
1726 skuInfo
.setVariableGuid(varGuid
);
1727 skuInfo
.setVariableOffset(varOffset
);
1728 skuInfo
.setHiiDefaultValue(hiiDefault
);
1730 else if (vpdOffset
!= null){
1731 skuInfo
.setVpdOffset(vpdOffset
);
1734 skuInfo
.setValue(value
);
1742 public BuildOptionsDocument
.BuildOptions
getfpdBuildOpts() {
1743 if (fpdBuildOpts
== null) {
1744 fpdBuildOpts
= fpdRoot
.addNewBuildOptions();
1746 return fpdBuildOpts
;
1749 public void genBuildOptionsUserExtensions(String fvName
, String outputFileName
, Vector
<String
[]> includeModules
) {
1750 QName elementFvName
= new QName (xmlNs
, "FvName");
1751 QName elementIncludeModules
= new QName(xmlNs
, "IncludeModules");
1752 QName elementInfFileName
= new QName(xmlNs
, "InfFileName");
1753 QName elementModule
= new QName(xmlNs
, "Module");
1755 UserExtensionsDocument
.UserExtensions userExts
= getfpdBuildOpts().addNewUserExtensions();
1756 userExts
.setUserID("IMAGES");
1757 userExts
.setIdentifier(new BigInteger("1"));
1758 XmlCursor cursor
= userExts
.newCursor();
1759 cursor
.toEndToken();
1761 cursor
.beginElement(elementFvName
);
1762 cursor
.insertChars(fvName
);
1763 cursor
.toNextToken();
1765 cursor
.beginElement(elementInfFileName
);
1766 cursor
.insertChars(fvName
+ ".inf");
1767 cursor
.toNextToken();
1769 cursor
.beginElement(elementIncludeModules
);
1770 for (int i
= 0; i
< includeModules
.size(); ++i
) {
1771 cursor
.beginElement(elementModule
);
1772 cursor
.insertAttributeWithValue("ModuleGuid", includeModules
.get(i
)[0]);
1773 if (!includeModules
.get(i
)[1].equals("null") && includeModules
.get(i
)[1].length() != 0) {
1774 cursor
.insertAttributeWithValue("ModuleVersion", includeModules
.get(i
)[1]);
1776 cursor
.insertAttributeWithValue("PackageGuid", includeModules
.get(i
)[2]);
1777 if (!includeModules
.get(i
)[3].equals("null") && includeModules
.get(i
)[3].length() != 0) {
1778 cursor
.insertAttributeWithValue("PackageVersion", includeModules
.get(i
)[3]);
1781 cursor
.insertAttributeWithValue("Arch", includeModules
.get(i
)[4]);
1782 cursor
.toEndToken();
1783 cursor
.toNextToken();
1788 public int getUserExtsIncModCount (String fvName
) {
1789 if (getfpdBuildOpts().getUserExtensionsList() == null) {
1792 ListIterator
<UserExtensionsDocument
.UserExtensions
> li
= getfpdBuildOpts().getUserExtensionsList().listIterator();
1793 QName elementIncludeModules
= new QName(xmlNs
, "IncludeModules");
1794 while (li
.hasNext()) {
1795 UserExtensionsDocument
.UserExtensions ues
= li
.next();
1796 if (!ues
.getUserID().equals("IMAGES")) {
1799 XmlCursor cursor
= ues
.newCursor();
1800 cursor
.toFirstChild();
1801 String elementName
= cursor
.getTextValue();
1802 if (elementName
.equals(fvName
)) {
1803 cursor
.toNextSibling(elementIncludeModules
);
1804 if (cursor
.toFirstChild()) {
1806 for (i
= 1; cursor
.toNextSibling(); ++i
);
1818 public void getUserExtsIncMods(String fvName
, String
[][] saa
) {
1819 if (getfpdBuildOpts().getUserExtensionsList() == null) {
1823 XmlCursor cursor
= getfpdBuildOpts().newCursor();
1824 QName elementUserExts
= new QName (xmlNs
, "UserExtensions");
1825 QName attribUserId
= new QName ("UserID");
1826 QName elementFvName
= new QName (xmlNs
, "FvName");
1827 QName elementIncludeModules
= new QName(xmlNs
, "IncludeModules");
1828 QName attribModuleGuid
= new QName("ModuleGuid");
1829 QName attribModuleVersion
= new QName("ModuleVersion");
1830 QName attribPackageGuid
= new QName("PackageGuid");
1831 QName attribPackageVersion
= new QName("PackageVersion");
1832 QName attribArch
= new QName("Arch");
1834 if (cursor
.toChild(elementUserExts
)) {
1837 if (cursor
.getAttributeText(attribUserId
).equals("IMAGES")) {
1838 cursor
.toChild(elementFvName
);
1839 String elementName
= cursor
.getTextValue();
1840 if (elementName
.equals(fvName
)) {
1841 cursor
.toNextSibling(elementIncludeModules
);
1842 if (cursor
.toFirstChild()) {
1845 saa
[i
][0] = cursor
.getAttributeText(attribModuleGuid
);
1846 saa
[i
][1] = cursor
.getAttributeText(attribModuleVersion
);
1847 saa
[i
][2] = cursor
.getAttributeText(attribPackageGuid
);
1848 saa
[i
][3] = cursor
.getAttributeText(attribPackageVersion
);
1849 saa
[i
][4] = cursor
.getAttributeText(attribArch
);
1851 }while (cursor
.toNextSibling());
1857 }while (cursor
.toNextSibling(elementUserExts
));
1863 public void updateBuildOptionsUserExtensions (String oldFvName
, String newFvName
) {
1864 if (getfpdBuildOpts().getUserExtensionsList() == null) {
1867 ListIterator
<UserExtensionsDocument
.UserExtensions
> li
= getfpdBuildOpts().getUserExtensionsList().listIterator();
1868 while (li
.hasNext()) {
1869 UserExtensionsDocument
.UserExtensions ues
= li
.next();
1870 if (!ues
.getUserID().equals("IMAGES")) {
1873 XmlCursor cursor
= ues
.newCursor();
1874 cursor
.toFirstChild();
1875 String elementName
= cursor
.getTextValue();
1876 if (elementName
.equals(oldFvName
)) {
1877 cursor
.setTextValue(newFvName
);
1884 public void removeBuildOptionsUserExtensions (String fvName
) {
1885 if (getfpdBuildOpts().getUserExtensionsList() == null) {
1889 ListIterator
<UserExtensionsDocument
.UserExtensions
> li
= getfpdBuildOpts().getUserExtensionsList().listIterator();
1890 while (li
.hasNext()) {
1891 UserExtensionsDocument
.UserExtensions ues
= li
.next();
1892 if (!ues
.getUserID().equals("IMAGES")) {
1895 XmlCursor cursor
= ues
.newCursor();
1896 cursor
.toFirstChild();
1897 String elementName
= cursor
.getTextValue();
1898 if (elementName
.equals(fvName
)) {
1909 private boolean versionEqual (String v1
, String v2
) {
1911 if ((v1
== null || v1
.length() == 0 || v1
.equalsIgnoreCase("null"))
1912 && (v2
== null || v2
.length() == 0 || v2
.equalsIgnoreCase("null"))) {
1916 if (v1
!= null && v1
.equals(v2
)) {
1923 public boolean moduleInBuildOptionsUserExtensions (String fvName
, String moduleGuid
, String moduleVersion
, String packageGuid
, String packageVersion
, String arch
) {
1924 boolean inList
= false;
1925 if (getUserExtsIncModCount(fvName
) > 0) {
1927 XmlCursor cursor
= getfpdBuildOpts().newCursor();
1928 QName elementUserExts
= new QName (xmlNs
, "UserExtensions");
1929 QName attribUserId
= new QName ("UserID");
1930 QName elementFvName
= new QName (xmlNs
, "FvName");
1931 QName elementIncludeModules
= new QName(xmlNs
, "IncludeModules");
1932 QName attribModuleGuid
= new QName("ModuleGuid");
1933 QName attribModuleVersion
= new QName("ModuleVersion");
1934 QName attribPackageGuid
= new QName("PackageGuid");
1935 QName attribPackageVersion
= new QName("PackageVersion");
1936 QName attribArch
= new QName("Arch");
1938 if (cursor
.toChild(elementUserExts
)) {
1941 if (cursor
.getAttributeText(attribUserId
).equals("IMAGES")) {
1942 cursor
.toChild(elementFvName
);
1943 String elementName
= cursor
.getTextValue();
1944 if (elementName
.equals(fvName
)) {
1945 cursor
.toNextSibling(elementIncludeModules
);
1946 if (cursor
.toFirstChild()) {
1949 String mg
= cursor
.getAttributeText(attribModuleGuid
);
1950 String mv
= cursor
.getAttributeText(attribModuleVersion
);
1951 String pg
= cursor
.getAttributeText(attribPackageGuid
);
1952 String pv
= cursor
.getAttributeText(attribPackageVersion
);
1953 String ar
= cursor
.getAttributeText(attribArch
);
1954 if (!moduleGuid
.equalsIgnoreCase(mg
)) {
1957 if (!packageGuid
.equalsIgnoreCase(pg
)) {
1960 if (!arch
.equalsIgnoreCase(ar
)) {
1963 if (!versionEqual(moduleVersion
, mv
)) {
1966 if (!versionEqual(packageVersion
, pv
)) {
1971 }while (cursor
.toNextSibling());
1977 }while (cursor
.toNextSibling(elementUserExts
));
1984 public void removeModuleInBuildOptionsUserExtensions (String fvName
, String moduleGuid
, String moduleVersion
, String packageGuid
, String packageVersion
, String arch
) {
1985 if (getUserExtsIncModCount(fvName
) > 0) {
1987 XmlCursor cursor
= getfpdBuildOpts().newCursor();
1988 QName elementUserExts
= new QName (xmlNs
, "UserExtensions");
1989 QName attribUserId
= new QName ("UserID");
1990 QName elementFvName
= new QName (xmlNs
, "FvName");
1991 QName elementIncludeModules
= new QName(xmlNs
, "IncludeModules");
1992 QName attribModuleGuid
= new QName("ModuleGuid");
1993 QName attribModuleVersion
= new QName("ModuleVersion");
1994 QName attribPackageGuid
= new QName("PackageGuid");
1995 QName attribPackageVersion
= new QName("PackageVersion");
1996 QName attribArch
= new QName("Arch");
1998 if (cursor
.toChild(elementUserExts
)) {
2001 if (cursor
.getAttributeText(attribUserId
).equals("IMAGES")) {
2002 cursor
.toChild(elementFvName
);
2003 String elementName
= cursor
.getTextValue();
2004 if (elementName
.equals(fvName
)) {
2005 cursor
.toNextSibling(elementIncludeModules
);
2006 if (cursor
.toFirstChild()) {
2009 String mg
= cursor
.getAttributeText(attribModuleGuid
);
2010 String mv
= cursor
.getAttributeText(attribModuleVersion
);
2011 String pg
= cursor
.getAttributeText(attribPackageGuid
);
2012 String pv
= cursor
.getAttributeText(attribPackageVersion
);
2013 String ar
= cursor
.getAttributeText(attribArch
);
2014 if (!moduleGuid
.equalsIgnoreCase(mg
)) {
2017 if (!packageGuid
.equalsIgnoreCase(pg
)) {
2020 if (!arch
.equalsIgnoreCase(ar
)) {
2023 if (!versionEqual(moduleVersion
, mv
)) {
2026 if (!versionEqual(packageVersion
, pv
)) {
2030 }while (cursor
.toNextSibling());
2036 }while (cursor
.toNextSibling(elementUserExts
));
2042 public void addModuleIntoBuildOptionsUserExtensions (String fvName
, String moduleGuid
, String moduleVersion
, String packageGuid
, String packageVersion
, String arch
) {
2043 if (moduleInBuildOptionsUserExtensions (fvName
, moduleGuid
, moduleVersion
, packageGuid
, packageVersion
, arch
)) {
2046 ListIterator
<UserExtensionsDocument
.UserExtensions
> li
= getfpdBuildOpts().getUserExtensionsList().listIterator();
2047 QName elementIncludeModules
= new QName(xmlNs
, "IncludeModules");
2048 QName elementModule
= new QName(xmlNs
, "Module");
2049 while (li
.hasNext()) {
2050 UserExtensionsDocument
.UserExtensions ues
= li
.next();
2051 if (!ues
.getUserID().equals("IMAGES")) {
2054 XmlCursor cursor
= ues
.newCursor();
2055 cursor
.toFirstChild();
2056 String elementName
= cursor
.getTextValue();
2057 if (elementName
.equals(fvName
)) {
2058 cursor
.toNextSibling(elementIncludeModules
);
2059 cursor
.toLastChild();
2060 cursor
.toEndToken();
2061 cursor
.toNextToken();
2062 cursor
.beginElement(elementModule
);
2063 cursor
.insertAttributeWithValue("ModuleGuid", moduleGuid
);
2064 if (!moduleVersion
.equals("null") && moduleVersion
.length() != 0) {
2065 cursor
.insertAttributeWithValue("ModuleVersion", moduleVersion
);
2067 cursor
.insertAttributeWithValue("PackageGuid", packageGuid
);
2068 if (!packageVersion
.equals("null") && packageVersion
.length() != 0) {
2069 cursor
.insertAttributeWithValue("PackageVersion", packageVersion
);
2072 cursor
.insertAttributeWithValue("Arch", arch
);
2081 public void genBuildOptionsUserDefAntTask (String id
, String fileName
, String execOrder
) {
2082 UserDefinedAntTasksDocument
.UserDefinedAntTasks udats
= getfpdBuildOpts().getUserDefinedAntTasks();
2083 if (udats
== null) {
2084 udats
= getfpdBuildOpts().addNewUserDefinedAntTasks();
2087 AntTaskDocument
.AntTask at
= udats
.addNewAntTask();
2088 setBuildOptionsUserDefAntTask(id
, fileName
, execOrder
, at
);
2091 private void setBuildOptionsUserDefAntTask(String id
, String fileName
, String execOrder
, AntTaskDocument
.AntTask at
) {
2092 at
.setId(new Integer(id
));
2093 XmlCursor cursor
= at
.newCursor();
2094 if (fileName
!= null){
2095 at
.setFilename(fileName
);
2097 else if (cursor
.toChild(xmlNs
, "Filename")) {
2100 if (execOrder
!= null) {
2101 at
.setAntCmdOptions(execOrder
);
2103 else if (cursor
.toChild(xmlNs
, "AntCmdOptions")) {
2109 public void removeBuildOptionsUserDefAntTask(int i
) {
2110 XmlObject o
= getfpdBuildOpts().getUserDefinedAntTasks();
2114 XmlCursor cursor
= o
.newCursor();
2115 if (cursor
.toFirstChild()) {
2116 for (int j
= 0; j
< i
; ++j
) {
2117 cursor
.toNextSibling();
2120 if (getBuildOptionsUserDefAntTaskCount() == 0) {
2128 public void updateBuildOptionsUserDefAntTask(int i
, String id
, String fileName
, String execOrder
){
2129 XmlObject o
= getfpdBuildOpts().getUserDefinedAntTasks();
2133 XmlCursor cursor
= o
.newCursor();
2134 if (cursor
.toFirstChild()) {
2135 for (int j
= 0; j
< i
; ++j
) {
2136 cursor
.toNextSibling();
2138 AntTaskDocument
.AntTask at
= (AntTaskDocument
.AntTask
)cursor
.getObject();
2139 setBuildOptionsUserDefAntTask(id
, fileName
, execOrder
, at
);
2144 public int getBuildOptionsUserDefAntTaskCount() {
2145 UserDefinedAntTasksDocument
.UserDefinedAntTasks udats
= getfpdBuildOpts().getUserDefinedAntTasks();
2146 if (udats
== null || udats
.getAntTaskList() == null) {
2150 return udats
.getAntTaskList().size();
2153 public void getBuildOptionsUserDefAntTasks(String
[][] saa
) {
2154 UserDefinedAntTasksDocument
.UserDefinedAntTasks udats
= getfpdBuildOpts().getUserDefinedAntTasks();
2155 if (udats
== null || udats
.getAntTaskList() == null) {
2159 List
<AntTaskDocument
.AntTask
> l
= udats
.getAntTaskList();
2160 ListIterator li
= l
.listIterator();
2162 while (li
.hasNext()) {
2163 AntTaskDocument
.AntTask at
= (AntTaskDocument
.AntTask
)li
.next();
2164 saa
[i
][0] = at
.getId() + "";
2165 saa
[i
][1] = saa
[i
][2] = "";
2166 if (at
.getFilename() != null){
2167 saa
[i
][1] = at
.getFilename();
2169 if (at
.getAntCmdOptions() != null) {
2170 saa
[i
][2] = at
.getAntCmdOptions();
2175 public void genBuildOptionsOpt(Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
) {
2176 OptionsDocument
.Options opts
= getfpdBuildOpts().getOptions();
2178 opts
= getfpdBuildOpts().addNewOptions();
2180 OptionDocument
.Option opt
= opts
.addNewOption();
2181 setBuildOptionsOpt(buildTargets
, toolChain
, tagName
, toolCmd
, archList
, contents
, opt
);
2184 private void setBuildOptionsOpt(Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
, OptionDocument
.Option opt
){
2185 opt
.setStringValue(contents
);
2186 if (buildTargets
!= null) {
2187 opt
.setBuildTargets(buildTargets
);
2190 if (opt
.isSetBuildTargets()) {
2191 opt
.unsetBuildTargets();
2195 if (toolChain
!= null && toolChain
.length() > 0) {
2196 opt
.setToolChainFamily(toolChain
);
2199 if (opt
.isSetToolChainFamily()) {
2200 opt
.unsetToolChainFamily();
2204 if (tagName
!= null && tagName
.length() > 0) {
2205 opt
.setTagName(tagName
);
2208 if (opt
.isSetTagName()) {
2213 if (toolCmd
!= null && toolCmd
.length() > 0) {
2214 opt
.setToolCode(toolCmd
);
2217 if (opt
.isSetToolCode()) {
2218 opt
.unsetToolCode();
2223 if (archList
!= null) {
2224 opt
.setSupArchList(archList
);
2227 if (opt
.isSetSupArchList()) {
2228 opt
.unsetSupArchList();
2233 public void removeBuildOptionsOpt(int i
){
2235 XmlObject o
= getfpdBuildOpts().getOptions();
2240 XmlCursor cursor
= o
.newCursor();
2241 if (cursor
.toFirstChild()) {
2242 for (int j
= 0; j
< i
; ++j
) {
2243 cursor
.toNextSibling();
2246 if (getBuildOptionsOptCount() == 0) {
2254 public void updateBuildOptionsOpt(int i
, Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
) {
2255 XmlObject o
= getfpdBuildOpts().getOptions();
2260 XmlCursor cursor
= o
.newCursor();
2261 if (cursor
.toFirstChild()) {
2262 for (int j
= 0; j
< i
; ++j
) {
2263 cursor
.toNextSibling();
2265 OptionDocument
.Option opt
= (OptionDocument
.Option
)cursor
.getObject();
2266 setBuildOptionsOpt(buildTargets
, toolChain
, tagName
, toolCmd
, archList
, contents
, opt
);
2271 public int getBuildOptionsOptCount(){
2272 if (getfpdBuildOpts().getOptions() == null || getfpdBuildOpts().getOptions().getOptionList() == null) {
2275 return getfpdBuildOpts().getOptions().getOptionList().size();
2278 public void getBuildOptionsOpts(String
[][] saa
) {
2279 if (getfpdBuildOpts().getOptions() == null || getfpdBuildOpts().getOptions().getOptionList() == null) {
2283 List
<OptionDocument
.Option
> lOpt
= getfpdBuildOpts().getOptions().getOptionList();
2284 ListIterator li
= lOpt
.listIterator();
2286 while(li
.hasNext()) {
2287 OptionDocument
.Option opt
= (OptionDocument
.Option
)li
.next();
2288 if (opt
.getBuildTargets() != null) {
2289 saa
[i
][0] = listToString(opt
.getBuildTargets());
2291 saa
[i
][1] = opt
.getToolChainFamily();
2292 if (opt
.getSupArchList() != null){
2293 saa
[i
][2] = listToString(opt
.getSupArchList());
2296 saa
[i
][3] = opt
.getToolCode();
2297 saa
[i
][4] = opt
.getTagName();
2298 saa
[i
][5] = opt
.getStringValue();
2304 public void genBuildOptionsFfs(String ffsKey
, String type
) {
2305 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getfpdBuildOpts().addNewFfs();
2306 ffs
.setFfsKey(ffsKey
);
2308 ffs
.addNewSections().setEncapsulationType(type
);
2312 public void updateBuildOptionsFfsSectionsType(int i
, String type
) {
2313 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getfpdBuildOpts().addNewFfs();
2315 ffs
.addNewSections().setEncapsulationType(type
);
2319 public void genBuildOptionsFfsAttribute(int i
, String name
, String value
) {
2320 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2321 BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute attrib
= ffs
.addNewAttribute();
2322 attrib
.setName(name
);
2323 attrib
.setValue(value
);
2326 /**update jth attribute of ith ffs.
2330 public void updateBuildOptionsFfsAttribute(int i
, int j
, String name
, String value
){
2331 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2332 XmlCursor cursor
= ffs
.newCursor();
2333 QName qAttrib
= new QName(xmlNs
, "Attribute");
2334 if (cursor
.toChild(qAttrib
)) {
2335 for (int k
= 0; k
< j
; ++k
) {
2336 cursor
.toNextSibling(qAttrib
);
2338 BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute attrib
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute
)cursor
.getObject();
2339 attrib
.setName(name
);
2340 attrib
.setValue(value
);
2345 public void removeBuildOptionsFfsAttribute(int i
, int j
){
2346 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2347 XmlCursor cursor
= ffs
.newCursor();
2348 QName qAttrib
= new QName(xmlNs
, "Attribute");
2349 if (cursor
.toChild(qAttrib
)) {
2350 for (int k
= 0; k
< j
; ++k
) {
2351 cursor
.toNextSibling(qAttrib
);
2358 public void genBuildOptionsFfsSectionsSection(int i
, String sectionType
) {
2359 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2363 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2365 if (sections
== null){
2366 sections
= ffs
.addNewSections();
2368 sections
.addNewSection().setSectionType(EfiSectionType
.Enum
.forString(sectionType
));
2371 public void removeBuildOptionsFfsSectionsSection(int i
, int j
) {
2372 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2373 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2374 if (sections
== null) {
2377 XmlCursor cursor
= sections
.newCursor();
2378 QName qSection
= new QName(xmlNs
, "Section");
2379 if (cursor
.toChild(qSection
)) {
2380 for (int k
= 0; k
< j
; ++k
) {
2381 cursor
.toNextSibling(qSection
);
2388 public void updateBuildOptionsFfsSectionsSection(int i
, int j
, String type
){
2389 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2390 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2391 if (sections
== null) {
2394 XmlCursor cursor
= sections
.newCursor();
2395 QName qSection
= new QName(xmlNs
, "Section");
2396 if (cursor
.toChild(qSection
)) {
2397 for (int k
= 0; k
< j
; ++k
) {
2398 cursor
.toNextSibling(qSection
);
2400 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Section section
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Section
)cursor
.getObject();
2401 section
.setSectionType(EfiSectionType
.Enum
.forString(type
));
2406 public void genBuildOptionsFfsSectionsSections(int i
, String encapType
) {
2407 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2411 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2413 if (sections
== null){
2414 sections
= ffs
.addNewSections();
2416 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2 sections2
= sections
.addNewSections();
2417 sections2
.setEncapsulationType(encapType
);
2418 sections2
.addNewSection().setSectionType(EfiSectionType
.Enum
.forString("EFI_SECTION_PE32"));
2421 public void removeBuildOptionsFfsSectionsSections(int i
, int j
) {
2422 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2423 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2424 if (sections
== null) {
2427 XmlCursor cursor
= sections
.newCursor();
2428 QName qSections
= new QName(xmlNs
, "Sections");
2429 if (cursor
.toChild(qSections
)) {
2430 for (int k
= 0; k
< j
; ++k
) {
2431 cursor
.toNextSibling(qSections
);
2438 public void updateBuildOptionsFfsSectionsSections(int i
, int j
, String type
) {
2439 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2440 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2441 if (sections
== null) {
2444 XmlCursor cursor
= sections
.newCursor();
2445 QName qSections
= new QName(xmlNs
, "Sections");
2446 if (cursor
.toChild(qSections
)) {
2447 for (int k
= 0; k
< j
; ++k
) {
2448 cursor
.toNextSibling(qSections
);
2450 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2 sections2
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
)cursor
.getObject();
2451 sections2
.setEncapsulationType(type
);
2456 public void genBuildOptionsFfsSectionsSectionsSection(int i
, int j
, String type
) {
2457 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2461 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2462 XmlCursor cursor
= sections
.newCursor();
2463 QName qSections
= new QName(xmlNs
, "Sections");
2464 if (cursor
.toChild(qSections
)){
2465 for (int k
= 0; k
< j
; ++k
) {
2466 cursor
.toNextSibling(qSections
);
2468 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2 sections2
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
)cursor
.getObject();
2469 sections2
.addNewSection().setSectionType(EfiSectionType
.Enum
.forString(type
));
2474 public void removeBuildOptionsFfsSectionsSectionsSection(int i
, int j
, int k
) {
2475 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2476 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2477 if (sections
== null) {
2480 XmlCursor cursor
= sections
.newCursor();
2481 QName qSections
= new QName(xmlNs
, "Sections");
2482 if (cursor
.toChild(qSections
)) {
2483 for (int l
= 0; l
< j
; ++l
) {
2484 cursor
.toNextSibling(qSections
);
2486 if (cursor
.toFirstChild()) {
2488 for (; m
< k
; ++m
) {
2489 cursor
.toNextSibling();
2501 public void updateBuildOptionsFfsSectionsSectionsSection(int i
, int j
, int k
, String type
) {
2502 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2503 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2504 if (sections
== null) {
2507 XmlCursor cursor
= sections
.newCursor();
2508 QName qSections
= new QName(xmlNs
, "Sections");
2509 if (cursor
.toChild(qSections
)) {
2510 for (int l
= 0; l
< j
; ++l
) {
2511 cursor
.toNextSibling(qSections
);
2513 if (cursor
.toFirstChild()) {
2514 for (int m
= 0; m
< k
; ++m
) {
2515 cursor
.toNextSibling();
2517 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section section
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section
)cursor
.getObject();
2518 section
.setSectionType(EfiSectionType
.Enum
.forString(type
));
2524 public void getBuildOptionsFfsSectionsSectionsSection(int i
, int j
, ArrayList
<String
> al
) {
2525 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2529 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2530 XmlCursor cursor
= sections
.newCursor();
2531 QName qSections
= new QName(xmlNs
, "Sections");
2532 if (cursor
.toChild(qSections
)){
2533 for (int k
= 0; k
< j
; ++k
) {
2534 cursor
.toNextSibling(qSections
);
2536 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2 sections2
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
)cursor
.getObject();
2537 if (sections2
.getSectionList() == null){
2541 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section
> li
= sections2
.getSectionList().listIterator();
2542 while(li
.hasNext()) {
2543 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section section
= li
.next();
2544 // if (section.isSetSectionType()) {
2545 al
.add(section
.getSectionType()+"");
2554 public int getBuildOptionsFfsCount(){
2555 if (getfpdBuildOpts().getFfsList() == null) {
2558 return getfpdBuildOpts().getFfsList().size();
2561 public void getBuildOptionsFfsKey(String
[][] saa
) {
2562 if (getfpdBuildOpts().getFfsList() == null) {
2565 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
> li
= getfpdBuildOpts().getFfsList().listIterator();
2567 while(li
.hasNext()){
2568 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= li
.next();
2569 saa
[i
][0] = ffs
.getFfsKey();
2574 public void updateBuildOptionsFfsKey(int i
, String key
) {
2575 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2579 /**Get ith FFS key and contents.
2582 public void getBuildOptionsFfs(int i
, String
[] sa
, LinkedHashMap
<String
, String
> ffsAttribMap
, ArrayList
<String
> firstLevelSections
, ArrayList
<String
> firstLevelSection
) {
2583 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2587 sa
[0] = ffs
.getFfsKey();
2588 if (ffs
.getSections() != null) {
2589 if(ffs
.getSections().getEncapsulationType() != null){
2590 sa
[1] = ffs
.getSections().getEncapsulationType();
2592 if (ffs
.getSections().getSectionList() != null){
2593 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Section
> li
= ffs
.getSections().getSectionList().listIterator();
2594 while (li
.hasNext()) {
2595 firstLevelSection
.add(li
.next().getSectionType()+"");
2598 if (ffs
.getSections().getSectionsList() != null) {
2599 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
> li
= ffs
.getSections().getSectionsList().listIterator();
2600 while(li
.hasNext()) {
2601 firstLevelSections
.add(li
.next().getEncapsulationType());
2605 if (ffs
.getAttributeList() != null) {
2606 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute
> li
= ffs
.getAttributeList().listIterator();
2607 while(li
.hasNext()) {
2608 BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute attrib
= li
.next();
2609 ffsAttribMap
.put(attrib
.getName(), attrib
.getValue());
2618 private BuildOptionsDocument
.BuildOptions
.Ffs
getFfs(int i
) {
2619 XmlObject o
= getfpdBuildOpts();
2620 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= null;
2622 XmlCursor cursor
= o
.newCursor();
2623 QName qFfs
= new QName(xmlNs
, "Ffs");
2624 if (cursor
.toChild(qFfs
)) {
2625 for (int j
= 0; j
< i
; ++j
) {
2626 cursor
.toNextSibling(qFfs
);
2628 ffs
= (BuildOptionsDocument
.BuildOptions
.Ffs
)cursor
.getObject();
2634 public void removeBuildOptionsFfs(int i
) {
2635 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2640 XmlCursor cursor
= ffs
.newCursor();
2647 public PlatformDefinitionsDocument
.PlatformDefinitions
getfpdPlatformDefs(){
2648 if (fpdPlatformDefs
== null){
2649 fpdPlatformDefs
= fpdRoot
.addNewPlatformDefinitions();
2651 return fpdPlatformDefs
;
2654 public void getPlatformDefsSupportedArchs(Vector
<Object
> archs
){
2655 if (getfpdPlatformDefs().getSupportedArchitectures() == null) {
2658 ListIterator li
= getfpdPlatformDefs().getSupportedArchitectures().listIterator();
2659 while(li
.hasNext()) {
2660 archs
.add(li
.next());
2664 public void setPlatformDefsSupportedArchs(Vector
<Object
> archs
) {
2665 if (archs
!= null) {
2666 getfpdPlatformDefs().setSupportedArchitectures(archs
);
2669 // XmlCursor cursor = getfpdPlatformDefs().newCursor();
2670 // if (cursor.toChild(xmlNs, "SupportedArchitectures")) {
2671 // cursor.removeXml();
2673 // cursor.dispose();
2677 public void getPlatformDefsBuildTargets(Vector
<Object
> targets
) {
2678 if (getfpdPlatformDefs().getBuildTargets() == null) {
2681 ListIterator li
= getfpdPlatformDefs().getBuildTargets().listIterator();
2682 while(li
.hasNext()) {
2683 targets
.add(li
.next());
2687 public void setPlatformDefsBuildTargets(Vector
<Object
> targets
) {
2688 getfpdPlatformDefs().setBuildTargets(targets
);
2691 public void genPlatformDefsSkuInfo(String id
, String name
) {
2692 SkuInfoDocument
.SkuInfo skuInfo
= null;
2693 if (getfpdPlatformDefs().getSkuInfo() == null) {
2694 skuInfo
= getfpdPlatformDefs().addNewSkuInfo();
2696 skuInfo
= getfpdPlatformDefs().getSkuInfo();
2697 if (skuInfo
.getUiSkuNameList() == null || skuInfo
.getUiSkuNameList().size() == 0) {
2698 SkuInfoDocument
.SkuInfo
.UiSkuName skuName
= skuInfo
.addNewUiSkuName();
2699 skuName
.setSkuID(new BigInteger("0"));
2700 skuName
.setStringValue("DEFAULT");
2702 if (id
.equals("0")) {
2705 SkuInfoDocument
.SkuInfo
.UiSkuName skuName
= skuInfo
.addNewUiSkuName();
2706 skuName
.setSkuID(new BigInteger(id
));
2707 skuName
.setStringValue(name
);
2710 public int getPlatformDefsSkuInfoCount(){
2711 if (getfpdPlatformDefs().getSkuInfo() == null || getfpdPlatformDefs().getSkuInfo().getUiSkuNameList() == null) {
2714 return getfpdPlatformDefs().getSkuInfo().getUiSkuNameList().size();
2717 public void getPlatformDefsSkuInfos(String
[][] saa
){
2718 if (getfpdPlatformDefs().getSkuInfo() == null || getfpdPlatformDefs().getSkuInfo().getUiSkuNameList() == null) {
2719 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null) {
2720 removeElement(getfpdDynPcdBuildDefs());
2721 fpdDynPcdBuildDefs
= null;
2726 List
<SkuInfoDocument
.SkuInfo
.UiSkuName
> l
= getfpdPlatformDefs().getSkuInfo().getUiSkuNameList();
2727 ListIterator
<SkuInfoDocument
.SkuInfo
.UiSkuName
> li
= l
.listIterator();
2729 while(li
.hasNext()) {
2730 SkuInfoDocument
.SkuInfo
.UiSkuName sku
= li
.next();
2731 saa
[i
][0] = sku
.getSkuID()+"";
2732 saa
[i
][1] = sku
.getStringValue();
2737 public void removePlatformDefsSkuInfo(int i
) {
2738 SkuInfoDocument
.SkuInfo skuInfo
= getfpdPlatformDefs().getSkuInfo();
2739 if (skuInfo
== null || i
== 0) {
2743 XmlCursor cursor
= skuInfo
.newCursor();
2744 if (cursor
.toFirstChild()) {
2745 for (int j
= 0; j
< i
; ++j
) {
2746 cursor
.toNextSibling();
2753 public void updatePlatformDefsSkuInfo(int i
, String id
, String name
) {
2754 SkuInfoDocument
.SkuInfo skuInfo
= getfpdPlatformDefs().getSkuInfo();
2755 if (skuInfo
== null || i
== 0) {
2759 XmlCursor cursor
= skuInfo
.newCursor();
2760 if (cursor
.toFirstChild()) {
2761 for (int j
= 0; j
< i
; ++j
) {
2762 cursor
.toNextSibling();
2764 SkuInfoDocument
.SkuInfo
.UiSkuName sku
= (SkuInfoDocument
.SkuInfo
.UiSkuName
)cursor
.getObject();
2765 sku
.setSkuID(new BigInteger(id
));
2766 sku
.setStringValue(name
);
2771 public String
getPlatformDefsInterDir(){
2772 if (getfpdPlatformDefs().getIntermediateDirectories() == null) {
2775 return getfpdPlatformDefs().getIntermediateDirectories().toString();
2778 public void setPlatformDefsInterDir(String interDir
){
2779 getfpdPlatformDefs().setIntermediateDirectories(IntermediateOutputType
.Enum
.forString(interDir
));
2782 public String
getPlatformDefsOutputDir() {
2783 return getfpdPlatformDefs().getOutputDirectory();
2786 public void setPlatformDefsOutputDir(String outputDir
) {
2787 if (outputDir
!= null && outputDir
.length() > 0) {
2788 getfpdPlatformDefs().setOutputDirectory(outputDir
);
2791 XmlCursor cursor
= getfpdPlatformDefs().newCursor();
2792 if (cursor
.toChild(new QName(xmlNs
, "OutputDirectory"))) {
2799 public FlashDocument
.Flash
getfpdFlash() {
2800 if (fpdFlash
== null) {
2801 fpdFlash
= fpdRoot
.addNewFlash();
2806 public void genFlashDefinitionFile(String file
) {
2807 FlashDefinitionFileDocument
.FlashDefinitionFile fdf
= getfpdFlash().getFlashDefinitionFile();
2809 fdf
= getfpdFlash().addNewFlashDefinitionFile();
2812 fdf
.setStringValue(file
);
2815 public String
getFlashDefinitionFile() {
2816 FlashDefinitionFileDocument
.FlashDefinitionFile fdf
= getfpdFlash().getFlashDefinitionFile();
2821 return fdf
.getStringValue();
2824 public void genFvImagesNameValue(String name
, String value
) {
2826 FvImagesDocument
.FvImages fi
= getfpdFlash().getFvImages();
2828 fi
= getfpdFlash().addNewFvImages();
2831 FvImagesDocument
.FvImages
.NameValue nv
= fi
.addNewNameValue();
2836 public void removeFvImagesNameValue(int i
){
2838 XmlObject o
= getfpdFlash().getFvImages();
2843 QName qNameValue
= new QName(xmlNs
, "NameValue");
2844 XmlCursor cursor
= o
.newCursor();
2845 if (cursor
.toChild(qNameValue
)) {
2846 for (int j
= 0; j
< i
; ++j
) {
2847 cursor
.toNextSibling(qNameValue
);
2854 public void updateFvImagesNameValue(int i
, String name
, String value
){
2856 XmlObject o
= getfpdFlash().getFvImages();
2861 QName qNameValue
= new QName(xmlNs
, "NameValue");
2862 XmlCursor cursor
= o
.newCursor();
2863 if (cursor
.toChild(qNameValue
)) {
2864 for (int j
= 0; j
< i
; ++j
) {
2865 cursor
.toNextSibling(qNameValue
);
2867 FvImagesDocument
.FvImages
.NameValue nv
= (FvImagesDocument
.FvImages
.NameValue
)cursor
.getObject();
2874 public int getFvImagesNameValueCount() {
2876 FvImagesDocument
.FvImages fi
= null;
2877 if ((fi
= getfpdFlash().getFvImages()) == null || fi
.getNameValueList() == null) {
2880 return fi
.getNameValueList().size();
2883 public void getFvImagesNameValues(String
[][] nv
) {
2885 FvImagesDocument
.FvImages fi
= getfpdFlash().getFvImages();
2889 List
<FvImagesDocument
.FvImages
.NameValue
> l
= fi
.getNameValueList();
2891 ListIterator li
= l
.listIterator();
2892 while (li
.hasNext()) {
2893 FvImagesDocument
.FvImages
.NameValue e
= (FvImagesDocument
.FvImages
.NameValue
) li
2895 nv
[i
][0] = e
.getName();
2896 nv
[i
][1] = e
.getValue();
2902 public void getFvImagesFvImageFvImageNames (Vector
<String
> vImageNames
) {
2903 FvImagesDocument
.FvImages fis
= getfpdFlash().getFvImages();
2904 if (fis
== null || fis
.getFvImageList() == null) {
2908 ListIterator
<FvImagesDocument
.FvImages
.FvImage
> li
= fis
.getFvImageList().listIterator();
2909 while (li
.hasNext()) {
2910 FvImagesDocument
.FvImages
.FvImage fi
= li
.next();
2911 if (fi
.getType().toString().equals("ImageName")) {
2912 vImageNames
.addAll(fi
.getFvImageNamesList());
2918 public void addFvImageFvImageNames (String
[] fvNames
) {
2919 FvImagesDocument
.FvImages fis
= getfpdFlash().getFvImages();
2920 if (fis
== null || fis
.getFvImageList() == null) {
2921 genFvImagesFvImage (fvNames
, "ImageName", null);
2925 ListIterator
<FvImagesDocument
.FvImages
.FvImage
> li
= fis
.getFvImageList().listIterator();
2926 while (li
.hasNext()) {
2927 FvImagesDocument
.FvImages
.FvImage fi
= li
.next();
2928 if (fi
.getType().toString().equals("ImageName")) {
2929 addFvImageNamesInFvImage (fi
, fvNames
);
2933 genFvImagesFvImage (fvNames
, "ImageName", null);
2936 public void addFvImageNamesInFvImage (FvImagesDocument
.FvImages
.FvImage fi
, String
[] fvNames
) {
2938 for (int i
= 0; i
< fvNames
.length
; ++i
) {
2939 fi
.addFvImageNames(fvNames
[i
]);
2943 public void addFvImageNamesInFvImage (int i
, String
[] fvNames
) {
2944 XmlObject o
= getfpdFlash().getFvImages();
2948 XmlCursor cursor
= o
.newCursor();
2949 QName qFvImage
= new QName(xmlNs
, "FvImage");
2950 if (cursor
.toChild(qFvImage
)) {
2951 for (int j
= 0; j
< i
; ++j
) {
2952 cursor
.toNextSibling(qFvImage
);
2954 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
2955 addFvImageNamesInFvImage(fi
, fvNames
);
2960 public void genFvImagesFvImage(String
[] names
, String types
, Map
<String
, String
> options
) {
2962 FvImagesDocument
.FvImages fis
= null;
2963 if ((fis
= getfpdFlash().getFvImages()) == null) {
2964 fis
= getfpdFlash().addNewFvImages();
2968 //gen FvImage with FvImageNames array
2970 FvImagesDocument
.FvImages
.FvImage fi
= fis
.addNewFvImage();
2971 for (int i
= 0; i
< names
.length
; ++i
) {
2972 fi
.addFvImageNames(names
[i
]);
2974 fi
.setType(FvImageTypes
.Enum
.forString(types
));
2975 if (options
!= null){
2976 setFvImagesFvImageFvImageOptions(options
, fi
);
2980 private void setFvImagesFvImageFvImageOptions(Map
<String
, String
> options
, FvImagesDocument
.FvImages
.FvImage fi
){
2981 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions fio
= fi
.getFvImageOptions();
2983 fio
= fi
.addNewFvImageOptions();
2986 Set
<String
> key
= options
.keySet();
2987 Iterator
<String
> i
= key
.iterator();
2988 while (i
.hasNext()) {
2990 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nv
= fio
.addNewNameValue();
2991 String k
= (String
)i
.next();
2994 nv
.setValue((String
)options
.get(k
));
3001 public void removeFvImagesFvImage(int i
) {
3003 XmlObject o
= getfpdFlash().getFvImages();
3008 QName qFvImage
= new QName(xmlNs
, "FvImage");
3009 XmlCursor cursor
= o
.newCursor();
3010 if (cursor
.toChild(qFvImage
)) {
3011 for (int j
= 0; j
< i
; ++j
) {
3012 cursor
.toNextSibling(qFvImage
);
3021 * @param newFvName The New FV Name. If null, remove the old FvImageNames entry.
3023 public void updateFvImageNameAll (String oldFvName
, String newFvName
) {
3024 if (getfpdFlash().getFvImages() == null || getfpdFlash().getFvImages().getFvImageList() == null) {
3027 ListIterator
<FvImagesDocument
.FvImages
.FvImage
> li
= getfpdFlash().getFvImages().getFvImageList().listIterator();
3028 while (li
.hasNext()) {
3029 FvImagesDocument
.FvImages
.FvImage fi
= li
.next();
3030 updateFvImageNamesInFvImage (fi
, oldFvName
, newFvName
);
3031 if (fi
.getFvImageNamesList().size() == 0) {
3037 public void updateFvImageNamesInFvImage (int i
, String oldFvName
, String newFvName
) {
3038 XmlObject o
= getfpdFlash().getFvImages();
3042 XmlCursor cursor
= o
.newCursor();
3043 QName qFvImage
= new QName(xmlNs
, "FvImage");
3044 if (cursor
.toChild(qFvImage
)) {
3045 for (int j
= 0; j
< i
; ++j
) {
3046 cursor
.toNextSibling(qFvImage
);
3048 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
3049 updateFvImageNamesInFvImage (fi
, oldFvName
, newFvName
);
3055 * @param oldFvName The FV Name to be replaced.
3056 * @param newFvName The New FV Name. If null, remove the old FvImageNames entry.
3058 public void updateFvImageNamesInFvImage (FvImagesDocument
.FvImages
.FvImage fi
, String oldFvName
, String newFvName
) {
3059 QName qFvImageNames
= new QName(xmlNs
, "FvImageNames");
3060 XmlCursor cursor
= fi
.newCursor();
3062 if (cursor
.toChild(qFvImageNames
)) {
3064 String xmlValue
= cursor
.getTextValue();
3065 if (xmlValue
.equals(oldFvName
)){
3066 if (newFvName
!= null) {
3067 cursor
.setTextValue(newFvName
);
3073 }while (cursor
.toNextSibling(qFvImageNames
));
3079 /**update the Type attribute of ith FvImage with new type.
3083 public void updateFvImagesFvImageType (int i
, String type
) {
3084 XmlObject o
= getfpdFlash().getFvImages();
3088 XmlCursor cursor
= o
.newCursor();
3089 QName qFvImage
= new QName(xmlNs
, "FvImage");
3090 if (cursor
.toChild(qFvImage
)) {
3091 for (int j
= 0; j
< i
; ++j
) {
3092 cursor
.toNextSibling(qFvImage
);
3094 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
3095 fi
.setType(FvImageTypes
.Enum
.forString(type
));
3100 public void updateFvImagesFvImage(int i
, String
[] names
, String types
, Map
<String
, String
> options
){
3102 XmlObject o
= getfpdFlash().getFvImages();
3106 XmlCursor cursor
= o
.newCursor();
3107 QName qFvImage
= new QName(xmlNs
, "FvImage");
3108 if (cursor
.toChild(qFvImage
)) {
3109 for (int j
= 0; j
< i
; ++j
) {
3110 cursor
.toNextSibling(qFvImage
);
3112 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
3113 fi
.setType(FvImageTypes
.Enum
.forString(types
));
3116 // remove old FvImageNames before adding new ones
3118 QName qFvImageNames
= new QName(xmlNs
, "FvImageNames");
3119 cursor
.toChild(qFvImageNames
);
3121 while (cursor
.toNextSibling(qFvImageNames
)) {
3125 for (int k
= 0; k
< names
.length
; ++k
) {
3126 fi
.addFvImageNames(names
[k
]);
3129 // remove old FvImageOptions before adding new options
3131 QName qFvImageOptions
= new QName(xmlNs
, "FvImageOptions");
3132 cursor
.toNextSibling(qFvImageOptions
);
3135 setFvImagesFvImageFvImageOptions(options
, fi
);
3140 public int getFvImagesFvImageCount(String type
) {
3142 if (getfpdFlash().getFvImages() == null || getfpdFlash().getFvImages().getFvImageList() == null) {
3145 List
<FvImagesDocument
.FvImages
.FvImage
> l
= getfpdFlash().getFvImages().getFvImageList();
3146 ListIterator li
= l
.listIterator();
3148 while(li
.hasNext()) {
3149 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)li
.next();
3150 if (!fi
.getType().toString().equals(type
) && !type
.equals("ALL")) {
3160 public Vector
<FvImagesDocument
.FvImages
.FvImage
> getFvImagesFvImageWithName (String fvName
, String type
) {
3161 Vector
<FvImagesDocument
.FvImages
.FvImage
> vFvImage
= new Vector
<FvImagesDocument
.FvImages
.FvImage
>();
3162 if (getfpdFlash().getFvImages() == null || getfpdFlash().getFvImages().getFvImageList() == null) {
3165 List
<FvImagesDocument
.FvImages
.FvImage
> l
= getfpdFlash().getFvImages().getFvImageList();
3166 ListIterator li
= l
.listIterator();
3167 while(li
.hasNext()) {
3168 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)li
.next();
3169 if (!fi
.getType().toString().equals(type
) && !type
.equals("ALL")) {
3172 if (fi
.getFvImageNamesList().contains(fvName
)) {
3181 * @param type "ALL" means all FvImage types: ImageName, Options, Attributes, Components.
3183 public void getFvImagesFvImages(String
[][] saa
, String type
) {
3185 if (getfpdFlash().getFvImages() == null) {
3188 List
<FvImagesDocument
.FvImages
.FvImage
> l
= getfpdFlash().getFvImages().getFvImageList();
3192 ListIterator li
= l
.listIterator();
3194 while(li
.hasNext()) {
3195 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)li
.next();
3196 if (!fi
.getType().toString().equals(type
) && !type
.equals("ALL")) {
3200 // get FvImageNames array, space separated
3202 List
<String
> lfn
= fi
.getFvImageNamesList();
3203 ListIterator lfni
= lfn
.listIterator();
3205 while (lfni
.hasNext()) {
3206 saa
[i
][0] += (String
)lfni
.next();
3209 saa
[i
][0] = saa
[i
][0].trim();
3211 saa
[i
][1] = fi
.getType()+"";
3217 public void removeFvImageNameValue (int i
, String attributeName
) {
3218 XmlObject o
= getfpdFlash().getFvImages();
3222 XmlCursor cursor
= o
.newCursor();
3223 QName qFvImage
= new QName(xmlNs
, "FvImage");
3224 if (cursor
.toChild(qFvImage
)) {
3225 for (int j
= 0; j
< i
; ++j
) {
3226 cursor
.toNextSibling(qFvImage
);
3228 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
3229 removeFvImageNameValue (fi
, attributeName
);
3233 /**Remove from fi the attribute pair with attributeName in FvImageOptions.
3235 * @param attributeName
3237 public void removeFvImageNameValue (FvImagesDocument
.FvImages
.FvImage fi
, String attributeName
) {
3238 if (fi
.getFvImageOptions() != null && fi
.getFvImageOptions().getNameValueList() != null) {
3239 ListIterator
<FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
> li
= fi
.getFvImageOptions().getNameValueList().listIterator();
3240 while (li
.hasNext()) {
3241 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nv
= li
.next();
3242 if (nv
.getName().equals(attributeName
)) {
3249 public void removeTypedNamedFvImageNameValue (String fvName
, String type
, String optName
) {
3250 Vector
<FvImagesDocument
.FvImages
.FvImage
> vFvImage
= getFvImagesFvImageWithName(fvName
, type
);
3251 for (int i
= 0; i
< vFvImage
.size(); ++i
) {
3252 FvImagesDocument
.FvImages
.FvImage fi
= vFvImage
.get(i
);
3253 removeFvImageNameValue (fi
, optName
);
3257 /**Add name-value pair to FvImage element with type.
3258 * @param fvName FV name to add name-value pair.
3259 * @param type FvImage attribute.
3263 public void setTypedNamedFvImageNameValue (String fvName
, String type
, String name
, String value
) {
3264 boolean fvImageExists
= false;
3265 if (getfpdFlash().getFvImages() == null) {
3268 List
<FvImagesDocument
.FvImages
.FvImage
> l
= getfpdFlash().getFvImages().getFvImageList();
3272 ListIterator li
= l
.listIterator();
3273 while(li
.hasNext()) {
3274 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)li
.next();
3275 if (!fi
.getType().toString().equals(type
) && !type
.equals("ALL")) {
3278 if (!fi
.getFvImageNamesList().contains(fvName
)) {
3281 fvImageExists
= true;
3282 setFvImagesFvImageNameValue (fi
, name
, value
, null);
3285 if (!fvImageExists
) {
3286 HashMap
<String
, String
> map
= new HashMap
<String
, String
>();
3287 map
.put(name
, value
);
3288 genFvImagesFvImage(new String
[]{fvName
}, type
, map
);
3292 /**Add to all FvImage elements with type, the name-value pair.
3297 public void setTypedFvImageNameValue (String type
, String name
, String value
) {
3298 if (getfpdFlash().getFvImages() == null) {
3301 List
<FvImagesDocument
.FvImages
.FvImage
> l
= getfpdFlash().getFvImages().getFvImageList();
3305 ListIterator li
= l
.listIterator();
3306 while(li
.hasNext()) {
3307 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)li
.next();
3308 if (!fi
.getType().toString().equals(type
) && !type
.equals("ALL")) {
3311 setFvImagesFvImageNameValue (fi
, name
, value
, null);
3316 public void setFvImagesFvImageNameValue (int i
, String name
, String value
) {
3317 XmlObject o
= getfpdFlash().getFvImages();
3321 XmlCursor cursor
= o
.newCursor();
3322 QName qFvImage
= new QName(xmlNs
, "FvImage");
3323 if (cursor
.toChild(qFvImage
)) {
3324 for (int j
= 0; j
< i
; ++j
) {
3325 cursor
.toNextSibling(qFvImage
);
3327 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
3328 setFvImagesFvImageNameValue (fi
, name
, value
, null);
3333 /**Add to FvImage the name-value pair, or replace old name with newName, or generate new name-value pair if not exists before.
3339 public void setFvImagesFvImageNameValue (FvImagesDocument
.FvImages
.FvImage fi
, String name
, String value
, String newName
) {
3340 if (fi
.getFvImageOptions() == null || fi
.getFvImageOptions().getNameValueList() == null) {
3341 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nv
= fi
.addNewFvImageOptions().addNewNameValue();
3344 if (newName
!= null) {
3345 nv
.setName(newName
);
3350 XmlCursor cursor
= fi
.getFvImageOptions().newCursor();
3351 if (cursor
.toFirstChild()) {
3353 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nv
= (FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
)cursor
.getObject();
3354 if (nv
.getName().equals(name
)) {
3356 if (newName
!= null) {
3357 nv
.setName(newName
);
3362 }while (cursor
.toNextSibling());
3365 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nv
= fi
.getFvImageOptions().addNewNameValue();
3368 if (newName
!= null) {
3369 nv
.setName(newName
);
3374 public void getFvImagesFvImageOptions (String fvName
, Map
<String
, String
> m
) {
3375 Vector
<FvImagesDocument
.FvImages
.FvImage
> vFvImage
= getFvImagesFvImageWithName (fvName
, "Options");
3376 for (int i
= 0; i
< vFvImage
.size(); ++i
) {
3377 FvImagesDocument
.FvImages
.FvImage fi
= vFvImage
.get(i
);
3378 if (fi
== null || fi
.getFvImageOptions() == null || fi
.getFvImageOptions().getNameValueList() == null) {
3382 ListIterator
<FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
> li
= fi
.getFvImageOptions()
3385 while (li
.hasNext()) {
3386 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nv
= li
.next();
3387 m
.put(nv
.getName(), nv
.getValue());
3392 public int getFvImagePosInFvImages (String fvNameList
, String type
) {
3393 XmlObject o
= getfpdFlash().getFvImages();
3399 String
[] fvNameArray
= fvNameList
.trim().split(" ");
3400 Vector
<String
> vFvNames
= new Vector
<String
>();
3403 XmlCursor cursor
= o
.newCursor();
3404 QName qFvImage
= new QName(xmlNs
, "FvImage");
3405 if (cursor
.toChild(qFvImage
)) {
3408 vFvNames
.removeAllElements();
3409 for (int i
= 0; i
< fvNameArray
.length
; ++i
) {
3410 vFvNames
.add(fvNameArray
[i
]);
3412 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
3413 if (!fi
.getType().toString().equals(type
)) {
3416 if (fi
.getFvImageNamesList() == null || fi
.getFvImageNamesList().size() != vFvNames
.size()) {
3419 ListIterator
<String
> li
= fi
.getFvImageNamesList().listIterator();
3420 while (li
.hasNext()) {
3421 String name
= li
.next();
3422 vFvNames
.remove(name
);
3424 if (vFvNames
.size() == 0) {
3429 }while (cursor
.toNextSibling(qFvImage
));
3435 /**Get FvImage Options for FvImage i
3436 * @param i the ith FvImage
3438 public void getFvImagesFvImageOptions(int i
, Map
<String
, String
> m
) {
3439 XmlObject o
= getfpdFlash().getFvImages();
3443 XmlCursor cursor
= o
.newCursor();
3444 QName qFvImage
= new QName(xmlNs
, "FvImage");
3445 if (cursor
.toChild(qFvImage
)) {
3446 for (int j
= 0; j
< i
; ++j
) {
3447 cursor
.toNextSibling(qFvImage
);
3449 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
3450 if (fi
.getFvImageOptions() == null || fi
.getFvImageOptions().getNameValueList() == null){
3454 ListIterator
<FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
> li
= fi
.getFvImageOptions().getNameValueList().listIterator();
3455 while(li
.hasNext()){
3456 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nv
= li
.next();
3457 m
.put(nv
.getName(), nv
.getValue());
3464 Get platform header element
3465 @return PlatformHeaderDocument.PlatformHeader
3467 public PlatformHeaderDocument
.PlatformHeader
getFpdHdr() {
3468 if (fpdHdr
== null) {
3469 fpdHdr
= fpdRoot
.addNewPlatformHeader();
3475 public String
getFpdHdrPlatformName() {
3476 return getFpdHdr().getPlatformName();
3479 public String
getFpdHdrGuidValue() {
3480 return getFpdHdr().getGuidValue();
3483 public String
getFpdHdrVer() {
3484 return getFpdHdr().getVersion();
3487 public String
getFpdHdrAbs() {
3488 return getFpdHdr().getAbstract();
3491 public String
getFpdHdrDescription() {
3492 return getFpdHdr().getDescription();
3495 public String
getFpdHdrCopyright() {
3496 return getFpdHdr().getCopyright();
3499 public String
getFpdHdrLicense() {
3500 LicenseDocument
.License l
= getFpdHdr().getLicense();
3504 return l
.getStringValue();
3507 public String
getFpdHdrUrl() {
3508 LicenseDocument
.License l
= getFpdHdr().getLicense();
3515 public String
getFpdHdrSpec() {
3517 return "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052";
3518 // return getFpdHdr().getSpecification();
3521 public void setFpdHdrPlatformName(String name
){
3522 getFpdHdr().setPlatformName(name
);
3525 public void setFpdHdrGuidValue(String guid
){
3526 getFpdHdr().setGuidValue(guid
);
3529 public void setFpdHdrVer(String v
){
3530 getFpdHdr().setVersion(v
);
3533 public void setFpdHdrAbs(String abs
) {
3534 getFpdHdr().setAbstract(abs
);
3537 public void setFpdHdrDescription(String desc
){
3538 getFpdHdr().setDescription(desc
);
3541 public void setFpdHdrCopyright(String cr
) {
3542 getFpdHdr().setCopyright(cr
);
3545 public void setFpdHdrLicense(String license
){
3546 LicenseDocument
.License l
= getFpdHdr().getLicense();
3548 getFpdHdr().addNewLicense().setStringValue(license
);
3551 l
.setStringValue(license
);
3555 public void setFpdHdrUrl(String url
){
3556 LicenseDocument
.License l
= getFpdHdr().getLicense();
3562 public void setFpdHdrSpec(String s
){
3563 s
= "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052";
3564 getFpdHdr().setSpecification(s
);
3567 Save the processed xml contents to file
3569 @param fpdFile The file to save xml contents
3570 @throws IOException Exceptions during file operation
3572 public void saveAs(File fpdFile
) throws IOException
{
3574 XmlOptions options
= new XmlOptions();
3576 options
.setCharacterEncoding("UTF-8");
3577 options
.setSavePrettyPrint();
3578 options
.setSavePrettyPrintIndent(2);
3580 fpdd
.save(fpdFile
, options
);
3581 } catch (IOException e
) {
3582 e
.printStackTrace();
3587 private String
listToString(List l
) {
3592 ListIterator li
= l
.listIterator();
3593 while(li
.hasNext()) {
3600 private void removeElement(XmlObject o
) {
3601 XmlCursor cursor
= o
.newCursor();
3607 class PcdItemTypeConflictException
extends Exception
{
3612 private static final long serialVersionUID
= 1L;
3613 private String details
= null;
3615 PcdItemTypeConflictException(String pcdName
, String info
){
3616 ModuleIdentification mi
= WorkspaceProfile
.getModuleId(info
);
3617 details
= pcdName
+ " ItemType Conflicts with " + mi
.getName() + " in Pkg " + mi
.getPackageId().getName();
3620 public String
getMessage() {
3625 class PcdDeclNotFound
extends Exception
{
3630 private static final long serialVersionUID
= 1L;
3631 private String details
= null;
3633 PcdDeclNotFound(String info
) {
3634 details
= "PcdDeclNotFound: " + info
;
3637 public String
getMessage() {
3642 class PcdValueMalFormed
extends Exception
{
3647 private static final long serialVersionUID
= 1L;
3648 private String details
= null;
3650 PcdValueMalFormed(String info
) {
3651 details
= "PcdValueMalFormed: " + info
;
3654 public String
getMessage() {