2 Java class FpdFileContents is used to parse fpd xml file.
4 Copyright (c) 2006, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13 package org
.tianocore
.frameworkwizard
.platform
.ui
;
16 import java
.io
.IOException
;
17 import java
.math
.BigInteger
;
18 import java
.util
.ArrayList
;
19 import java
.util
.HashMap
;
20 import java
.util
.Iterator
;
21 import java
.util
.LinkedHashMap
;
22 import java
.util
.List
;
23 import java
.util
.ListIterator
;
26 import java
.util
.Vector
;
28 import javax
.xml
.namespace
.QName
;
30 import org
.apache
.xmlbeans
.XmlCursor
;
31 import org
.apache
.xmlbeans
.XmlObject
;
32 import org
.apache
.xmlbeans
.XmlOptions
;
33 import org
.tianocore
.AntTaskDocument
;
34 import org
.tianocore
.BuildOptionsDocument
;
35 import org
.tianocore
.DynamicPcdBuildDefinitionsDocument
;
36 import org
.tianocore
.EfiSectionType
;
37 import org
.tianocore
.FlashDefinitionFileDocument
;
38 import org
.tianocore
.FlashDocument
;
39 import org
.tianocore
.FrameworkModulesDocument
;
40 import org
.tianocore
.IntermediateOutputType
;
41 import org
.tianocore
.LibrariesDocument
;
42 import org
.tianocore
.ModuleSADocument
;
43 import org
.tianocore
.ModuleSaBuildOptionsDocument
;
44 import org
.tianocore
.ModuleSurfaceAreaDocument
;
45 import org
.tianocore
.OptionDocument
;
46 import org
.tianocore
.OptionsDocument
;
47 import org
.tianocore
.PcdBuildDefinitionDocument
;
48 import org
.tianocore
.PcdCodedDocument
;
49 import org
.tianocore
.PcdDataTypes
;
50 import org
.tianocore
.PcdDeclarationsDocument
;
51 import org
.tianocore
.PcdItemTypes
;
52 import org
.tianocore
.PlatformDefinitionsDocument
;
53 import org
.tianocore
.PlatformSurfaceAreaDocument
;
54 import org
.tianocore
.FvImageTypes
;
55 import org
.tianocore
.FvImagesDocument
;
56 import org
.tianocore
.LicenseDocument
;
57 import org
.tianocore
.PlatformHeaderDocument
;
58 import org
.tianocore
.SkuInfoDocument
;
59 import org
.tianocore
.UserDefinedAntTasksDocument
;
60 import org
.tianocore
.UserExtensionsDocument
;
61 import org
.tianocore
.frameworkwizard
.platform
.ui
.global
.WorkspaceProfile
;
62 import org
.tianocore
.frameworkwizard
.platform
.ui
.global
.SurfaceAreaQuery
;
63 import org
.tianocore
.frameworkwizard
.module
.Identifications
.ModuleIdentification
;
64 import org
.tianocore
.frameworkwizard
.packaging
.PackageIdentification
;
67 This class processes fpd file contents such as add remove xml elements.
68 @since PackageEditor 1.0
70 public class FpdFileContents
{
72 static final String xmlNs
= "http://www.TianoCore.org/2006/Edk2.0";
73 static final String regExpNewLineAndSpaces
= "((\n)|(\r\n)|(\r)|(\u0085)|(\u2028)|(\u2029))(\\s)*";
75 private PlatformSurfaceAreaDocument fpdd
= null;
77 private PlatformSurfaceAreaDocument
.PlatformSurfaceArea fpdRoot
= null;
79 private PlatformHeaderDocument
.PlatformHeader fpdHdr
= null;
81 private PlatformDefinitionsDocument
.PlatformDefinitions fpdPlatformDefs
= null;
83 private FlashDocument
.Flash fpdFlash
= null;
85 private BuildOptionsDocument
.BuildOptions fpdBuildOpts
= null;
87 private FrameworkModulesDocument
.FrameworkModules fpdFrameworkModules
= null;
89 private DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions fpdDynPcdBuildDefs
= null;
91 private HashMap
<String
, ArrayList
<String
>> dynPcdMap
= null;
93 private HashMap
<String
, String
> defaultPcdValue
= new HashMap
<String
, String
>();
95 private String
itemType (String pcdInfo
) {
97 return pcdInfo
.substring(pcdInfo
.lastIndexOf(" ") + 1);
101 * look through all pcd data in all ModuleSA, create pcd -> ModuleSA mappings.
103 public void initDynPcdMap() {
104 if (dynPcdMap
== null) {
105 dynPcdMap
= new HashMap
<String
, ArrayList
<String
>>();
106 List
<ModuleSADocument
.ModuleSA
> l
= getfpdFrameworkModules().getModuleSAList();
108 removeElement(getfpdFrameworkModules());
109 fpdFrameworkModules
= null;
112 ListIterator
<ModuleSADocument
.ModuleSA
> li
= l
.listIterator();
113 while (li
.hasNext()) {
114 ModuleSADocument
.ModuleSA moduleSa
= li
.next();
115 if (moduleSa
.getPcdBuildDefinition() == null || moduleSa
.getPcdBuildDefinition().getPcdDataList() == null) {
118 String ModuleInfo
= moduleSa
.getModuleGuid() + " " + moduleSa
.getModuleVersion() +
119 " " + moduleSa
.getPackageGuid() + " " + moduleSa
.getPackageVersion() + " " + listToString(moduleSa
.getSupArchList());
120 List
<PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
> lp
= moduleSa
.getPcdBuildDefinition().getPcdDataList();
121 ListIterator
<PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
> lpi
= lp
.listIterator();
122 while (lpi
.hasNext()) {
123 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= lpi
.next();
124 String pcdKey
= pcdData
.getCName() + " " + pcdData
.getTokenSpaceGuidCName();
125 if (dynPcdMap
.get(pcdKey
) == null) {
126 ArrayList
<String
> al
= new ArrayList
<String
>();
127 al
.add(ModuleInfo
+ " " + pcdData
.getItemType().toString());
128 dynPcdMap
.put(pcdKey
, al
);
131 dynPcdMap
.get(pcdKey
).add(ModuleInfo
+ " " + pcdData
.getItemType().toString());
138 public ArrayList
<String
> getDynPcdMapValue(String key
) {
139 return dynPcdMap
.get(key
);
142 Constructor to create a new spd file
144 public FpdFileContents() {
146 fpdd
= PlatformSurfaceAreaDocument
.Factory
.newInstance();
147 fpdRoot
= fpdd
.addNewPlatformSurfaceArea();
152 Constructor for existing document object
155 public FpdFileContents(PlatformSurfaceAreaDocument
.PlatformSurfaceArea fpd
) {
157 fpdHdr
= fpdRoot
.getPlatformHeader();
158 fpdPlatformDefs
= fpdRoot
.getPlatformDefinitions();
159 fpdBuildOpts
= fpdRoot
.getBuildOptions();
160 fpdFrameworkModules
= fpdRoot
.getFrameworkModules();
161 fpdDynPcdBuildDefs
= fpdRoot
.getDynamicPcdBuildDefinitions();
162 fpdFlash
= fpdRoot
.getFlash();
166 Constructor based on an existing spd file
168 @param f Existing spd file
170 public FpdFileContents(File f
) {
172 fpdd
= PlatformSurfaceAreaDocument
.Factory
.parse(f
);
173 fpdRoot
= fpdd
.getPlatformSurfaceArea();
174 } catch (Exception e
) {
175 System
.out
.println(e
.toString());
179 public DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
getfpdDynPcdBuildDefs() {
180 if (fpdDynPcdBuildDefs
== null){
181 fpdDynPcdBuildDefs
= fpdRoot
.addNewDynamicPcdBuildDefinitions();
183 return fpdDynPcdBuildDefs
;
186 public FrameworkModulesDocument
.FrameworkModules
getfpdFrameworkModules() {
187 if (fpdFrameworkModules
== null){
188 fpdFrameworkModules
= fpdRoot
.addNewFrameworkModules();
190 return fpdFrameworkModules
;
193 public void 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 String s
= cursor
.getTextValue();
362 if (s
.matches(regExpNewLineAndSpaces
)) {
367 if (cursor
.isComment()) {
373 if (getFrameworkModulesCount() == 0) {
381 public boolean adjustPcd (int seqModuleSa
) throws Exception
{
382 boolean dataModified
= false;
383 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(seqModuleSa
);
384 int pcdCount
= getPcdDataCount(seqModuleSa
);
385 String
[][] saaModuleSaPcd
= new String
[pcdCount
][7];
386 getPcdData(seqModuleSa
, saaModuleSaPcd
);
387 String mg
= moduleSa
.getModuleGuid();
388 String mv
= moduleSa
.getModuleVersion();
389 String pg
= moduleSa
.getPackageGuid();
390 String pv
= moduleSa
.getPackageVersion();
391 String arch
= listToString(moduleSa
.getSupArchList());
393 // delete pcd in ModuleSA but not in MSA files any longer.
395 String moduleKey
= mg
+ " " + mv
+ " " + pg
+ " " + pv
+ " " + arch
;
396 int libCount
= getLibraryInstancesCount(moduleKey
);
397 String
[][] saaLib
= new String
[libCount
][5];
398 getLibraryInstances(moduleKey
, saaLib
);
399 ModuleIdentification mi
= WorkspaceProfile
.getModuleId(moduleKey
);
400 Vector
<ModuleIdentification
> vMi
= new Vector
<ModuleIdentification
>();
402 // create vector for module & library instance MIs.
405 for (int j
= 0; j
< saaLib
.length
; ++j
) {
406 String libKey
= saaLib
[j
][1] + " " + saaLib
[j
][2] + " " + saaLib
[j
][3] + " " + saaLib
[j
][4];
407 ModuleIdentification libMi
= WorkspaceProfile
.getModuleId(libKey
);
411 nextPcd
:for (int i
= 0; i
< saaModuleSaPcd
.length
; ++i
) {
413 for (int j
= 0; j
< vMi
.size(); ++j
) {
414 ModuleIdentification nextMi
= vMi
.get(j
);
415 if (WorkspaceProfile
.pcdInMsa(saaModuleSaPcd
[i
][0], saaModuleSaPcd
[i
][1], nextMi
)) {
419 removePcdData(seqModuleSa
, saaModuleSaPcd
[i
][0], saaModuleSaPcd
[i
][1]);
423 // add new Pcd from MSA file to ModuleSA.
425 for (int i
= 0; i
< vMi
.size(); ++i
) {
426 ModuleSurfaceAreaDocument
.ModuleSurfaceArea msa
= (ModuleSurfaceAreaDocument
.ModuleSurfaceArea
) WorkspaceProfile
427 .getModuleXmlObject(vMi
429 if (msa
.getPcdCoded() == null || msa
.getPcdCoded().getPcdEntryList() == null) {
432 ListIterator li
= msa
.getPcdCoded().getPcdEntryList().listIterator();
433 msaPcdIter
:while (li
.hasNext()) {
434 PcdCodedDocument
.PcdCoded
.PcdEntry msaPcd
= (PcdCodedDocument
.PcdCoded
.PcdEntry
) li
.next();
435 ArrayList
<String
> al
= getDynPcdMapValue(msaPcd
.getCName() + " " + msaPcd
.getTokenSpaceGuidCName());
437 for (int j
= 0; j
< al
.size(); ++j
) {
438 if (al
.get(j
).contains(moduleKey
)) {
444 PackageIdentification
[] depPkgs
= SurfaceAreaQuery
.getDependencePkg(null, vMi
.get(i
));
445 PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry spdPcd
= LookupPcdDeclaration(msaPcd
, depPkgs
);
446 if (spdPcd
== null) {
450 throw new PcdDeclNotFound("No Declaration for PCD Entry " + msaPcd
.getCName() + " in Module "
454 // AddItem to ModuleSA PcdBuildDefinitions
456 String defaultVal
= msaPcd
.getDefaultValue() == null ? spdPcd
.getDefaultValue()
457 : msaPcd
.getDefaultValue();
459 genPcdData(msaPcd
.getCName(), spdPcd
.getToken(), msaPcd
.getTokenSpaceGuidCName(),
460 msaPcd
.getPcdItemType().toString(), spdPcd
.getDatumType() + "", defaultVal
, moduleSa
);
469 private void maintainDynPcdMap(String pcdKey
, String moduleInfo
) {
471 ArrayList
<String
> al
= dynPcdMap
.get(pcdKey
);
475 String
[] s
= moduleInfo
.split(" ");
476 for(int i
= 0; i
< al
.size(); ++i
){
477 String consumer
= al
.get(i
);
478 if (consumer
.contains(s
[0]) && consumer
.contains(s
[2])){
479 String
[] consumerPart
= consumer
.split(" ");
480 if (!consumerPart
[4].equals(s
[4])) {
488 if (al
.size() == 0) {
489 defaultPcdValue
.remove(pcdKey
);
490 dynPcdMap
.remove(pcdKey
);
491 String
[] s1
= pcdKey
.split(" ");
492 removeDynamicPcdBuildData(s1
[0], s1
[1]);
497 // key for ModuleSA : "ModuleGuid ModuleVer PackageGuid PackageVer Arch"
499 public int getPcdDataCount (int i
){
500 ModuleSADocument
.ModuleSA msa
= getModuleSA(i
);
502 if (msa
== null || msa
.getPcdBuildDefinition() == null || msa
.getPcdBuildDefinition().getPcdDataList() == null){
505 return msa
.getPcdBuildDefinition().getPcdDataList().size();
509 public void getPcdData (int i
, String
[][] saa
) {
510 ModuleSADocument
.ModuleSA msa
= getModuleSA(i
);
512 if (msa
== null || msa
.getPcdBuildDefinition() == null || msa
.getPcdBuildDefinition().getPcdDataList() == null){
515 ListIterator
<PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
>li
= msa
.getPcdBuildDefinition().getPcdDataList().listIterator();
516 for (int k
= 0; k
< saa
.length
; ++k
) {
517 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= li
.next();
518 saa
[k
][0] = pcdData
.getCName();
519 saa
[k
][1] = pcdData
.getTokenSpaceGuidCName();
520 saa
[k
][2] = pcdData
.getItemType()+"";
521 saa
[k
][3] = pcdData
.getToken().toString();
522 saa
[k
][4] = pcdData
.getMaxDatumSize()+"";
523 saa
[k
][5] = pcdData
.getDatumType()+"";
524 saa
[k
][6] = pcdData
.getValue();
529 public void removePcdData (int seqModuleSa
, String cName
, String tsGuid
) {
530 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(seqModuleSa
);
531 if (moduleSa
== null || moduleSa
.getPcdBuildDefinition() == null){
535 String mg
= moduleSa
.getModuleGuid();
536 String mv
= moduleSa
.getModuleVersion();
537 String pg
= moduleSa
.getPackageGuid();
538 String pv
= moduleSa
.getPackageVersion();
539 String arch
= listToString(moduleSa
.getSupArchList());
540 String moduleKey
= mg
+ " " + mv
+ " " + pg
+ " " + pv
+ " " + arch
;
542 XmlCursor cursor
= moduleSa
.getPcdBuildDefinition().newCursor();
543 if (cursor
.toFirstChild()){
546 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= (PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
)cursor
.getObject();
547 if (pcdData
.getCName().equals(cName
) && pcdData
.getTokenSpaceGuidCName().equals(tsGuid
)) {
548 maintainDynPcdMap(cName
+ " " + tsGuid
, moduleKey
);
549 if (getPcdDataCount(seqModuleSa
) == 1) {
556 while(cursor
.toNextSibling());
562 public void updatePcdData (String key
, String cName
, String tsGuid
, String itemType
, String maxSize
, String value
){
563 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(key
);
564 if (moduleSa
== null || moduleSa
.getPcdBuildDefinition() == null){
568 XmlCursor cursor
= moduleSa
.getPcdBuildDefinition().newCursor();
569 if (cursor
.toFirstChild()){
571 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= (PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
)cursor
.getObject();
572 if (pcdData
.getCName().equals(cName
) && pcdData
.getTokenSpaceGuidCName().equals(tsGuid
)) {
574 // change item type while not updating dynPcdData????
576 pcdData
.setItemType(PcdItemTypes
.Enum
.forString(itemType
));
577 if(pcdData
.getDatumType().equals("VOID*")) {
578 pcdData
.setMaxDatumSize(new Integer(maxSize
));
580 pcdData
.setValue(value
);
581 defaultPcdValue
.put(cName
+ " " + tsGuid
, value
);
585 while(cursor
.toNextSibling());
590 /**Get original Pcd info from MSA & SPD files.
591 * @param mi ModuleIdentification from which MSA & SPD come
592 * @param cName PCD cName
593 * @param sa Results: HelpText, Original item type.
596 public boolean getPcdBuildDataInfo(ModuleIdentification mi
, String cName
, String tsGuid
, String
[] sa
) throws Exception
{
599 ModuleSurfaceAreaDocument
.ModuleSurfaceArea msa
= (ModuleSurfaceAreaDocument
.ModuleSurfaceArea
)WorkspaceProfile
.getModuleXmlObject(mi
);
600 if (msa
.getPcdCoded() == null) {
604 Map
<String
, XmlObject
> m
= new HashMap
<String
, XmlObject
>();
605 m
.put("ModuleSurfaceArea", msa
);
606 SurfaceAreaQuery
.setDoc(m
);
607 PackageIdentification
[] depPkgs
= SurfaceAreaQuery
.getDependencePkg(null, mi
);
609 // First look through MSA pcd entries.
611 List
<PcdCodedDocument
.PcdCoded
.PcdEntry
> l
= msa
.getPcdCoded().getPcdEntryList();
612 ListIterator li
= l
.listIterator();
613 while(li
.hasNext()) {
614 PcdCodedDocument
.PcdCoded
.PcdEntry msaPcd
= (PcdCodedDocument
.PcdCoded
.PcdEntry
)li
.next();
615 if (!msaPcd
.getCName().equals(cName
)) {
618 if (!msaPcd
.getTokenSpaceGuidCName().equals(tsGuid
)) {
621 PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry spdPcd
= LookupPcdDeclaration(msaPcd
, depPkgs
);
622 if (spdPcd
== null) {
626 throw new PcdDeclNotFound(mi
.getName() + " " + msaPcd
.getCName());
629 // Get Pcd help text and original item type.
631 sa
[0] = spdPcd
.getHelpText() + msaPcd
.getHelpText();
632 sa
[1] = msaPcd
.getPcdItemType()+"";
633 sa
[2] = msa
.getModuleDefinitions().getBinaryModule()+"";
647 private boolean multiSourcePcd (String cName
, String tsGuidCName
, String moduleKey
) {
648 int libCount
= getLibraryInstancesCount(moduleKey
);
649 String
[][] saaLib
= new String
[libCount
][5];
650 getLibraryInstances(moduleKey
, saaLib
);
651 ModuleIdentification mi
= WorkspaceProfile
.getModuleId(moduleKey
);
652 Vector
<ModuleIdentification
> vMi
= new Vector
<ModuleIdentification
>();
654 // create vector for module & library instance MIs.
657 for (int j
= 0; j
< saaLib
.length
; ++j
) {
658 String libKey
= saaLib
[j
][1] + " " + saaLib
[j
][2] + " " + saaLib
[j
][3] + " " + saaLib
[j
][4];
659 ModuleIdentification libMi
= WorkspaceProfile
.getModuleId(libKey
);
663 int pcdSourceCount
= 0;
664 for (int i
= 0; i
< vMi
.size(); ++i
) {
665 if (WorkspaceProfile
.pcdInMsa(cName
, tsGuidCName
, vMi
.get(i
))) {
670 if (pcdSourceCount
< 2) {
679 /**Remove PCDBuildDefinition entries from ModuleSA
680 * @param moduleKey identifier of ModuleSA.
681 * @param consumer where these entries come from.
683 public void removePcdData(String moduleKey
, ModuleIdentification consumer
) {
685 ModuleSurfaceAreaDocument
.ModuleSurfaceArea msa
= (ModuleSurfaceAreaDocument
.ModuleSurfaceArea
)WorkspaceProfile
.getModuleXmlObject(consumer
);
686 if (msa
.getPcdCoded() == null) {
690 List
<PcdCodedDocument
.PcdCoded
.PcdEntry
> l
= msa
.getPcdCoded().getPcdEntryList();
691 ListIterator li
= l
.listIterator();
693 while(li
.hasNext()) {
694 PcdCodedDocument
.PcdCoded
.PcdEntry msaPcd
= (PcdCodedDocument
.PcdCoded
.PcdEntry
)li
.next();
695 ModuleSADocument
.ModuleSA moduleSA
= getModuleSA(moduleKey
);
696 if (moduleSA
.getPcdBuildDefinition() != null) {
697 XmlCursor cursor
= moduleSA
.getPcdBuildDefinition().newCursor();
699 if (cursor
.toFirstChild()) {
701 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= (PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
) cursor
703 String cName
= msaPcd
.getCName();
704 String tsGuidCName
= msaPcd
.getTokenSpaceGuidCName();
705 if (cName
.equals(pcdData
.getCName())
706 && tsGuidCName
.equals(pcdData
.getTokenSpaceGuidCName()) && !multiSourcePcd(cName
, tsGuidCName
, moduleKey
)) {
708 maintainDynPcdMap(pcdData
.getCName() + " " + pcdData
.getTokenSpaceGuidCName(),
713 } while (cursor
.toNextSibling());
717 if (moduleSA
.getPcdBuildDefinition().getPcdDataList().size() == 0) {
726 // key for ModuleSA : "ModuleGuid ModuleVer PackageGuid PackageVer Arch"
728 public int getLibraryInstancesCount(String key
) {
729 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
730 if (msa
== null || msa
.getLibraries() == null || msa
.getLibraries().getInstanceList() == null){
733 return msa
.getLibraries().getInstanceList().size();
736 public void getLibraryInstances(String key
, String
[][] saa
){
737 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
738 if (msa
== null || msa
.getLibraries() == null || msa
.getLibraries().getInstanceList() == null){
742 ListIterator
<LibrariesDocument
.Libraries
.Instance
> li
= msa
.getLibraries().getInstanceList().listIterator();
743 for (int i
= 0; i
< saa
.length
; ++i
) {
744 LibrariesDocument
.Libraries
.Instance instance
= li
.next();
745 saa
[i
][1] = instance
.getModuleGuid();
746 saa
[i
][2] = instance
.getModuleVersion();
747 saa
[i
][3] = instance
.getPackageGuid();
748 saa
[i
][4] = instance
.getPackageVersion();
752 public void removeLibraryInstance(String key
, int i
) {
753 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
754 if (msa
== null || msa
.getLibraries() == null){
758 XmlCursor cursor
= msa
.getLibraries().newCursor();
759 if (cursor
.toFirstChild()) {
760 for (int j
= 0; j
< i
; ++j
) {
761 cursor
.toNextSibling();
764 while (cursor
.hasPrevToken()) {
765 cursor
.toPrevToken();
766 if (!cursor
.isText()) {
769 String s
= cursor
.getTextValue();
770 if (s
.matches(regExpNewLineAndSpaces
)) {
775 if (cursor
.isComment()) {
780 if (getLibraryInstancesCount(key
) == 0) {
789 public void genLibraryInstance(ModuleIdentification libMi
, String key
) {
790 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
792 msa
= getfpdFrameworkModules().addNewModuleSA();
794 LibrariesDocument
.Libraries libs
= msa
.getLibraries();
796 libs
= msa
.addNewLibraries();
799 String mn
= libMi
.getName();
800 String mg
= libMi
.getGuid();
801 String mv
= libMi
.getVersion();
802 String pn
= libMi
.getPackageId().getName();
803 String pg
= libMi
.getPackageId().getGuid();
804 String pv
= libMi
.getPackageId().getVersion();
805 LibrariesDocument
.Libraries
.Instance instance
= libs
.addNewInstance();
806 XmlCursor cursor
= instance
.newCursor();
808 String comment
= "Pkg: " + pn
+ " Mod: " + mn
809 + " Path: " + libMi
.getPath().substring(System
.getenv("WORKSPACE").length() + 1);
810 cursor
.insertComment(comment
);
819 instance
.setModuleGuid(mg
);
820 instance
.setModuleVersion(mv
);
821 instance
.setPackageGuid(pg
);
822 instance
.setPackageVersion(pv
);
826 public String
getFvBinding(String moduleKey
){
827 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(moduleKey
);
828 return getFvBinding (moduleSa
);
831 public String
getFvBinding (ModuleSADocument
.ModuleSA moduleSa
) {
832 if (moduleSa
== null || moduleSa
.getModuleSaBuildOptions() == null) {
835 return moduleSa
.getModuleSaBuildOptions().getFvBinding();
838 public void setFvBinding(ModuleSADocument
.ModuleSA moduleSa
, String fvBinding
) {
839 if (moduleSa
== null ) {
842 if (fvBinding
== null || fvBinding
.length() == 0) {
843 if(moduleSa
.getModuleSaBuildOptions() != null){
844 moduleSa
.getModuleSaBuildOptions().unsetFvBinding();
848 if(moduleSa
.getModuleSaBuildOptions() == null){
849 moduleSa
.addNewModuleSaBuildOptions().setFvBinding(fvBinding
);
852 moduleSa
.getModuleSaBuildOptions().setFvBinding(fvBinding
);
856 public void setFvBinding(String moduleKey
, String fvBinding
){
857 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(moduleKey
);
858 setFvBinding (moduleSa
, fvBinding
);
861 private int fvBindingForModuleSA (ModuleSADocument
.ModuleSA moduleSa
, String fvName
) {
862 if (moduleSa
== null || moduleSa
.getModuleSaBuildOptions() == null || moduleSa
.getModuleSaBuildOptions().getFvBinding() == null) {
866 String fvNameList
= moduleSa
.getModuleSaBuildOptions().getFvBinding();
867 String
[] fvNamesArray
= fvNameList
.split(" ");
869 for (int i
= 0; i
< fvNamesArray
.length
; ++i
) {
870 if (fvNamesArray
[i
].equals(fvName
)) {
878 public void removeFvBinding (ModuleSADocument
.ModuleSA moduleSa
, String fvName
) {
879 if (moduleSa
== null || moduleSa
.getModuleSaBuildOptions() == null || moduleSa
.getModuleSaBuildOptions().getFvBinding() == null) {
883 String fvNameList
= moduleSa
.getModuleSaBuildOptions().getFvBinding();
884 String
[] fvNamesArray
= fvNameList
.split(" ");
886 for (int i
= 0; i
< fvNamesArray
.length
; ++i
) {
887 if (fvNamesArray
[i
].equals(fvName
)) {
892 // jump over where the input fvName occurs in the original Fv list.
893 if (occursAt
!= -1) {
894 String newFvNameList
= " ";
895 for (int i
= 0; i
< fvNamesArray
.length
; ++i
) {
899 newFvNameList
+= fvNamesArray
[i
];
901 setFvBinding (moduleSa
, newFvNameList
.trim());
907 * @param fvName The FV name that to be removed from FvBinding List.
909 public void removeFvBindingAll (String fvName
) {
910 if (getfpdFrameworkModules().getModuleSAList() == null || getfpdFrameworkModules().getModuleSAList().size() == 0){
911 removeElement(getfpdFrameworkModules());
912 fpdFrameworkModules
= null;
916 Iterator
<ModuleSADocument
.ModuleSA
> li
= getfpdFrameworkModules().getModuleSAList().iterator();
917 while (li
.hasNext()) {
918 ModuleSADocument
.ModuleSA moduleSa
= li
.next();
919 removeFvBinding (moduleSa
, fvName
);
923 public void appendFvBindingAll (String fvName
) {
924 if (getfpdFrameworkModules().getModuleSAList() == null || getfpdFrameworkModules().getModuleSAList().size() == 0){
925 removeElement(getfpdFrameworkModules());
926 fpdFrameworkModules
= null;
930 Iterator
<ModuleSADocument
.ModuleSA
> li
= getfpdFrameworkModules().getModuleSAList().iterator();
931 while (li
.hasNext()) {
932 ModuleSADocument
.ModuleSA moduleSa
= li
.next();
933 appendFvBinding (moduleSa
, fvName
);
937 public void appendFvBindingFor (String oldFvName
, String newFvName
) {
938 if (getfpdFrameworkModules().getModuleSAList() == null || getfpdFrameworkModules().getModuleSAList().size() == 0){
939 removeElement(getfpdFrameworkModules());
940 fpdFrameworkModules
= null;
944 Iterator
<ModuleSADocument
.ModuleSA
> li
= getfpdFrameworkModules().getModuleSAList().iterator();
945 while (li
.hasNext()) {
946 ModuleSADocument
.ModuleSA moduleSa
= li
.next();
947 String fvBinding
= getFvBinding (moduleSa
);
948 if (fvBinding
!= null && fvBindingForModuleSA (moduleSa
, oldFvName
) >= 0) {
949 appendFvBinding (moduleSa
, newFvName
);
954 public void appendFvBinding (String moduleKey
, String fvName
) {
955 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(moduleKey
);
956 appendFvBinding (moduleSa
, fvName
);
959 public void appendFvBinding (ModuleSADocument
.ModuleSA moduleSa
, String fvName
) {
960 if (moduleSa
== null) {
964 if (moduleSa
.getModuleSaBuildOptions() == null || moduleSa
.getModuleSaBuildOptions().getFvBinding() == null) {
965 setFvBinding(moduleSa
, fvName
);
969 String fvNameList
= moduleSa
.getModuleSaBuildOptions().getFvBinding();
970 String newFvNameList
= fvNameList
+ " " + fvName
;
971 setFvBinding (moduleSa
, newFvNameList
.trim());
974 public void updateFvBindingInModuleSA (String moduleKey
, String fvName
) {
976 appendFvBinding (moduleKey
, fvName
);
979 public String
getFfsFileNameGuid(String moduleKey
){
980 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(moduleKey
);
981 if (moduleSa
== null || moduleSa
.getModuleSaBuildOptions() == null) {
984 return moduleSa
.getModuleSaBuildOptions().getFfsFileNameGuid();
987 public void setFfsFileNameGuid(String moduleKey
, String fileGuid
){
988 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
992 if(msa
.getModuleSaBuildOptions() == null){
993 msa
.addNewModuleSaBuildOptions();
996 ModuleSaBuildOptionsDocument
.ModuleSaBuildOptions msaBuildOpts
= msa
.getModuleSaBuildOptions();
997 if (fileGuid
!= null) {
998 msaBuildOpts
.setFfsFileNameGuid(fileGuid
);
1001 XmlCursor cursor
= msaBuildOpts
.newCursor();
1002 if (cursor
.toChild(xmlNs
, "FfsFileNameGuid")) {
1010 public String
getFfsFormatKey(String moduleKey
){
1011 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
1012 if (msa
== null || msa
.getModuleSaBuildOptions() == null) {
1015 return msa
.getModuleSaBuildOptions().getFfsFormatKey();
1018 public void setFfsFormatKey(String moduleKey
, String ffsKey
){
1019 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
1023 if(msa
.getModuleSaBuildOptions() == null){
1024 msa
.addNewModuleSaBuildOptions().setFfsFormatKey(ffsKey
);
1027 msa
.getModuleSaBuildOptions().setFfsFormatKey(ffsKey
);
1030 public void setModuleSAForceDebug(int i
, boolean dbgEnable
) {
1031 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(i
);
1032 moduleSa
.setForceDebug(dbgEnable
);
1035 public boolean getModuleSAForceDebug (int i
) {
1036 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(i
);
1037 if (moduleSa
.getForceDebug() == true) {
1043 public void getModuleSAOptions(String moduleKey
, String
[][] saa
) {
1044 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
1045 if (msa
== null || msa
.getModuleSaBuildOptions() == null || msa
.getModuleSaBuildOptions().getOptions() == null
1046 || msa
.getModuleSaBuildOptions().getOptions().getOptionList() == null) {
1050 List
<OptionDocument
.Option
> lOpt
= msa
.getModuleSaBuildOptions().getOptions().getOptionList();
1051 ListIterator li
= lOpt
.listIterator();
1053 while(li
.hasNext()) {
1054 OptionDocument
.Option opt
= (OptionDocument
.Option
)li
.next();
1055 if (opt
.getBuildTargets() != null) {
1056 saa
[i
][0] = listToString(opt
.getBuildTargets());
1058 saa
[i
][1] = opt
.getToolChainFamily();
1059 saa
[i
][2] = opt
.getTagName();
1060 saa
[i
][3] = opt
.getToolCode();
1062 if (opt
.getSupArchList() != null){
1063 saa
[i
][4] = listToString(opt
.getSupArchList());
1069 saa
[i
][5] = opt
.getStringValue();
1075 public int getModuleSAOptionsCount(String moduleKey
){
1076 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
1077 if (msa
== null || msa
.getModuleSaBuildOptions() == null || msa
.getModuleSaBuildOptions().getOptions() == null
1078 || msa
.getModuleSaBuildOptions().getOptions().getOptionList() == null) {
1081 return msa
.getModuleSaBuildOptions().getOptions().getOptionList().size();
1084 public void genModuleSAOptionsOpt(String moduleKey
, Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
) {
1085 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
1086 if (msa
.getModuleSaBuildOptions() == null) {
1087 msa
.addNewModuleSaBuildOptions();
1089 if (msa
.getModuleSaBuildOptions().getOptions() == null){
1090 msa
.getModuleSaBuildOptions().addNewOptions();
1092 OptionDocument
.Option opt
= msa
.getModuleSaBuildOptions().getOptions().addNewOption();
1093 setBuildOptionsOpt(buildTargets
, toolChain
, tagName
, toolCmd
, archList
, contents
, opt
);
1096 public void removeModuleSAOptionsOpt(String moduleKey
, int i
) {
1097 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
1098 if (msa
.getModuleSaBuildOptions() == null || msa
.getModuleSaBuildOptions().getOptions() == null) {
1101 OptionsDocument
.Options opts
= msa
.getModuleSaBuildOptions().getOptions();
1102 XmlCursor cursor
= opts
.newCursor();
1103 if (cursor
.toFirstChild()) {
1104 for (int j
= 0; j
< i
; ++j
){
1105 cursor
.toNextSibling();
1112 public void updateModuleSAOptionsOpt(String moduleKey
, int i
, Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
) {
1113 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
1114 if (msa
.getModuleSaBuildOptions() == null || msa
.getModuleSaBuildOptions().getOptions() == null) {
1117 OptionsDocument
.Options opts
= msa
.getModuleSaBuildOptions().getOptions();
1118 XmlCursor cursor
= opts
.newCursor();
1119 if (cursor
.toFirstChild()) {
1120 for (int j
= 0; j
< i
; ++j
){
1121 cursor
.toNextSibling();
1123 OptionDocument
.Option opt
= (OptionDocument
.Option
)cursor
.getObject();
1124 setBuildOptionsOpt(buildTargets
, toolChain
, tagName
, toolCmd
, archList
, contents
, opt
);
1129 /**add pcd information of module mi to a ModuleSA.
1131 * @param moduleSa if null, generate a new ModuleSA.
1133 public void addFrameworkModulesPcdBuildDefs(ModuleIdentification mi
, String arch
, ModuleSADocument
.ModuleSA moduleSa
) throws Exception
{
1134 //ToDo add Arch filter
1137 if (moduleSa
== null) {
1138 moduleSa
= genModuleSA(mi
, arch
);
1141 ModuleSurfaceAreaDocument
.ModuleSurfaceArea msa
= (ModuleSurfaceAreaDocument
.ModuleSurfaceArea
)WorkspaceProfile
.getModuleXmlObject(mi
);
1142 if (msa
.getPcdCoded() == null) {
1146 Map
<String
, XmlObject
> m
= new HashMap
<String
, XmlObject
>();
1147 m
.put("ModuleSurfaceArea", msa
);
1148 SurfaceAreaQuery
.setDoc(m
);
1149 PackageIdentification
[] depPkgs
= SurfaceAreaQuery
.getDependencePkg(null, mi
);
1151 // Implementing InitializePlatformPcdBuildDefinitions
1153 List
<PcdCodedDocument
.PcdCoded
.PcdEntry
> l
= msa
.getPcdCoded().getPcdEntryList();
1154 ListIterator li
= l
.listIterator();
1155 while(li
.hasNext()) {
1156 PcdCodedDocument
.PcdCoded
.PcdEntry msaPcd
= (PcdCodedDocument
.PcdCoded
.PcdEntry
)li
.next();
1157 PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry spdPcd
= LookupPcdDeclaration(msaPcd
, depPkgs
);
1158 if (spdPcd
== null) {
1162 throw new PcdDeclNotFound("No Declaration for PCD Entry " + msaPcd
.getCName() + " in Module " + mi
.getName());
1165 // AddItem to ModuleSA PcdBuildDefinitions
1167 String defaultVal
= msaPcd
.getDefaultValue() == null ? spdPcd
.getDefaultValue() : msaPcd
.getDefaultValue();
1169 genPcdData(msaPcd
.getCName(), spdPcd
.getToken(), msaPcd
.getTokenSpaceGuidCName(), msaPcd
.getPcdItemType().toString(), spdPcd
.getDatumType()+"", defaultVal
, moduleSa
);
1173 catch (Exception e
){
1180 private PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry
LookupPcdDeclaration (PcdCodedDocument
.PcdCoded
.PcdEntry msaPcd
, PackageIdentification
[] depPkgs
) {
1182 PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry spdPcd
= null;
1183 for (int i
= 0; i
< depPkgs
.length
; ++i
) {
1185 XmlObject
[] xo
= SurfaceAreaQuery
.getSpdPcdDeclarations(depPkgs
[i
]);
1189 for (int j
= 0; j
< xo
.length
; ++j
) {
1190 spdPcd
= (PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry
)xo
[j
];
1191 if (msaPcd
.getTokenSpaceGuidCName() == null) {
1192 if (spdPcd
.getCName().equals(msaPcd
.getCName())) {
1197 if (spdPcd
.getCName().equals(msaPcd
.getCName()) && spdPcd
.getTokenSpaceGuidCName().equals(msaPcd
.getTokenSpaceGuidCName())) {
1208 private ModuleSADocument
.ModuleSA
genModuleSA (ModuleIdentification mi
, String arch
) {
1209 PackageIdentification pi
= WorkspaceProfile
.getPackageForModule(mi
);
1210 ModuleSADocument
.ModuleSA msa
= getfpdFrameworkModules().addNewModuleSA();
1211 XmlCursor cursor
= msa
.newCursor();
1213 String comment
= "Mod: " + mi
.getName() + " Type: " + SurfaceAreaQuery
.getModuleType(mi
) + " Path: "
1214 + mi
.getPath().substring(System
.getenv("WORKSPACE").length() + 1);
1215 cursor
.insertComment(comment
);
1218 e
.printStackTrace();
1223 msa
.setModuleGuid(mi
.getGuid());
1224 msa
.setModuleVersion(mi
.getVersion());
1225 msa
.setPackageGuid(pi
.getGuid());
1226 msa
.setPackageVersion(pi
.getVersion());
1228 Vector
<String
> v
= new Vector
<String
>();
1230 msa
.setSupArchList(v
);
1236 private void genPcdData (String cName
, Object token
, String tsGuid
, String itemType
, String dataType
, String defaultVal
, ModuleSADocument
.ModuleSA moduleSa
)
1237 throws PcdItemTypeConflictException
, PcdValueMalFormed
{
1238 if (moduleSa
.getPcdBuildDefinition() == null){
1239 moduleSa
.addNewPcdBuildDefinition();
1242 // constructe pcd to modulesa mapping first.
1243 // Attention : for any error condition, remove from map this pcd.
1245 ArrayList
<String
> pcdConsumer
= LookupPlatformPcdData(cName
+ " " + tsGuid
);
1246 if (pcdConsumer
== null) {
1247 pcdConsumer
= new ArrayList
<String
>();
1250 // Check whether this PCD has already added to ModuleSA, if so, just return.
1252 String moduleInfo
= moduleSa
.getModuleGuid().toLowerCase() + " " + moduleSa
.getModuleVersion()
1253 + " " + moduleSa
.getPackageGuid().toLowerCase() + " " + moduleSa
.getPackageVersion() + " " + listToString(moduleSa
.getSupArchList());
1254 for (int i
= 0; i
< pcdConsumer
.size(); ++i
) {
1255 String pcdInfo
= pcdConsumer
.get(i
);
1256 if (moduleInfo
.equals(pcdInfo
.substring(0, pcdInfo
.lastIndexOf(" ")))){
1261 // Using existing Pcd type, if this pcd already exists in other ModuleSA
1263 if (pcdConsumer
.size() > 0) {
1265 itemType
= itemType (pcdConsumer
.get(0));
1267 String listValue
= moduleInfo
+ " " + itemType
;
1268 pcdConsumer
.add(listValue
);
1269 dynPcdMap
.put(cName
+ " " + tsGuid
, pcdConsumer
);
1271 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData fpdPcd
= moduleSa
.getPcdBuildDefinition().addNewPcdData();
1272 fpdPcd
.setCName(cName
);
1273 fpdPcd
.setToken(token
);
1274 fpdPcd
.setTokenSpaceGuidCName(tsGuid
);
1275 fpdPcd
.setDatumType(PcdDataTypes
.Enum
.forString(dataType
));
1276 fpdPcd
.setItemType(PcdItemTypes
.Enum
.forString(itemType
));
1278 if (defaultVal
!= null){
1279 fpdPcd
.setValue(defaultVal
);
1282 if (dataType
.equals("UINT8") || dataType
.equals("UINT16") || dataType
.equals("UINT32") || dataType
.equals("UINT64")) {
1283 fpdPcd
.setValue("0");
1285 if (dataType
.equals("BOOLEAN")){
1286 fpdPcd
.setValue("FALSE");
1288 if (dataType
.equals("VOID*")) {
1289 fpdPcd
.setValue("");
1293 // Using existing pcd value, if this pcd already exists in other moduleSa.
1295 if (defaultPcdValue
.get(cName
+ " " + tsGuid
) == null) {
1296 defaultPcdValue
.put(cName
+ " " + tsGuid
, fpdPcd
.getValue());
1299 fpdPcd
.setValue(defaultPcdValue
.get(cName
+ " " + tsGuid
));
1302 if (dataType
.equals("UINT8")){
1303 fpdPcd
.setMaxDatumSize(1);
1305 if (dataType
.equals("UINT16")) {
1306 fpdPcd
.setMaxDatumSize(2);
1308 if (dataType
.equals("UINT32")) {
1309 fpdPcd
.setMaxDatumSize(4);
1311 if (dataType
.equals("UINT64")){
1312 fpdPcd
.setMaxDatumSize(8);
1314 if (dataType
.equals("BOOLEAN")){
1315 fpdPcd
.setMaxDatumSize(1);
1317 if (dataType
.equals("VOID*")) {
1318 int maxSize
= setMaxSizeForPointer(fpdPcd
.getValue());
1319 fpdPcd
.setMaxDatumSize(maxSize
);
1323 if (itemType
.equals("DYNAMIC") || itemType
.equals("DYNAMIC_EX")) {
1324 ArrayList
<String
> al
= LookupDynamicPcdBuildDefinition(cName
+ " " + tsGuid
);
1326 // if only one module mapped to this pcd, then the one is myself. so no other module mapped.
1327 // so need to add one dyn pcd.
1329 if (al
.size() == 1) {
1330 addDynamicPcdBuildData(cName
, token
, tsGuid
, itemType
, dataType
, defaultVal
);
1336 public int setMaxSizeForPointer(String datum
) throws PcdValueMalFormed
{
1337 if (datum
== null) {
1340 char ch
= datum
.charAt(0);
1344 // For void* type PCD, only three datum is support:
1345 // 1) Unicode: string with start char is "L"
1346 // 2) Ansci: String is ""
1347 // 3) byte array: String start char "{"
1350 start
= datum
.indexOf('\"');
1351 end
= datum
.lastIndexOf('\"');
1352 if ((start
> end
) ||
1353 (end
> datum
.length())||
1354 ((start
== end
) && (datum
.length() > 0))) {
1355 //ToDo Error handling here
1356 throw new PcdValueMalFormed (datum
);
1359 strValue
= datum
.substring(start
+ 1, end
);
1360 return strValue
.length() * 2;
1361 } else if (ch
== '\"'){
1362 start
= datum
.indexOf('\"');
1363 end
= datum
.lastIndexOf('\"');
1364 if ((start
> end
) ||
1365 (end
> datum
.length())||
1366 ((start
== end
) && (datum
.length() > 0))) {
1367 throw new PcdValueMalFormed (datum
);
1369 strValue
= datum
.substring(start
+ 1, end
);
1370 return strValue
.length();
1371 } else if (ch
=='{') {
1372 String
[] strValueArray
;
1374 start
= datum
.indexOf('{');
1375 end
= datum
.lastIndexOf('}');
1376 strValue
= datum
.substring(start
+ 1, end
);
1377 strValue
= strValue
.trim();
1378 if (strValue
.length() == 0) {
1381 strValueArray
= strValue
.split(",");
1382 for (int index
= 0; index
< strValueArray
.length
; index
++) {
1383 Integer value
= Integer
.decode(strValueArray
[index
].trim());
1386 // "[FPD file error] The datum type of PCD %s in %s is VOID*, "+
1387 // "it must be a byte array. But the element of %s exceed the byte range",
1388 throw new PcdValueMalFormed (datum
);
1391 return strValueArray
.length
;
1395 // "[FPD file error] The datum type of PCD %s in %s is VOID*. For VOID* type, you have three format choise:\n "+
1396 // "1) UNICODE string: like L\"xxxx\";\r\n"+
1397 // "2) ANSIC string: like \"xxx\";\r\n"+
1398 // "3) Byte array: like {0x2, 0x45, 0x23}\r\n"+
1399 // "but the datum in seems does not following above format!",
1400 throw new PcdValueMalFormed (datum
);
1405 private ArrayList
<String
> LookupDynamicPcdBuildDefinition(String dynPcdKey
) {
1406 ArrayList
<String
> al
= dynPcdMap
.get(dynPcdKey
);
1411 private ArrayList
<String
> LookupPlatformPcdData(String pcdKey
) {
1413 return dynPcdMap
.get(pcdKey
);
1416 public int getDynamicPcdBuildDataCount() {
1417 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1418 removeElement(getfpdDynPcdBuildDefs());
1419 fpdDynPcdBuildDefs
= null;
1422 return getfpdDynPcdBuildDefs().getPcdBuildDataList().size();
1425 public void getDynamicPcdBuildData(String
[][] saa
) {
1426 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1427 removeElement(getfpdDynPcdBuildDefs());
1428 fpdDynPcdBuildDefs
= null;
1431 List
<DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
> l
= getfpdDynPcdBuildDefs().getPcdBuildDataList();
1432 ListIterator
<DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
> li
= l
.listIterator();
1434 while(li
.hasNext()) {
1435 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData dynPcd
= li
.next();
1436 saa
[i
][0] = dynPcd
.getCName();
1437 saa
[i
][1] = dynPcd
.getToken().toString();
1438 saa
[i
][2] = dynPcd
.getTokenSpaceGuidCName();
1439 saa
[i
][3] = dynPcd
.getMaxDatumSize()+"";
1440 saa
[i
][4] = dynPcd
.getDatumType().toString();
1446 public void addDynamicPcdBuildData(String cName
, Object token
, String tsGuid
, String itemType
, String dataType
, String defaultVal
)
1447 throws PcdValueMalFormed
{
1448 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData dynPcdData
= getfpdDynPcdBuildDefs().addNewPcdBuildData();
1449 dynPcdData
.setItemType(PcdItemTypes
.Enum
.forString(itemType
));
1450 dynPcdData
.setCName(cName
);
1451 dynPcdData
.setToken(token
);
1452 dynPcdData
.setTokenSpaceGuidCName(tsGuid
);
1453 dynPcdData
.setDatumType(PcdDataTypes
.Enum
.forString(dataType
));
1455 BigInteger bigInt
= new BigInteger("0");
1456 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo skuInfo
= dynPcdData
.addNewSkuInfo();
1457 skuInfo
.setSkuId(bigInt
);
1458 if (defaultVal
!= null){
1459 skuInfo
.setValue(defaultVal
);
1462 if (dataType
.equals("UINT8")){
1463 skuInfo
.setValue("0");
1465 if (dataType
.equals("UINT16")) {
1466 skuInfo
.setValue("0");
1468 if (dataType
.equals("UINT32")) {
1469 skuInfo
.setValue("0");
1471 if (dataType
.equals("UINT64")){
1472 skuInfo
.setValue("0");
1474 if (dataType
.equals("BOOLEAN")){
1475 skuInfo
.setValue("false");
1477 if (dataType
.equals("VOID*")) {
1478 skuInfo
.setValue("");
1481 if (dataType
.equals("UINT8")){
1482 dynPcdData
.setMaxDatumSize(1);
1484 if (dataType
.equals("UINT16")) {
1485 dynPcdData
.setMaxDatumSize(2);
1487 if (dataType
.equals("UINT32")) {
1488 dynPcdData
.setMaxDatumSize(4);
1490 if (dataType
.equals("UINT64")){
1491 dynPcdData
.setMaxDatumSize(8);
1493 if (dataType
.equals("BOOLEAN")){
1494 dynPcdData
.setMaxDatumSize(1);
1496 if (dataType
.equals("VOID*")) {
1497 int maxSize
= setMaxSizeForPointer(defaultVal
);
1498 dynPcdData
.setMaxDatumSize(maxSize
);
1502 public void removeDynamicPcdBuildData(String cName
, String tsGuid
) {
1503 XmlObject o
= fpdRoot
.getDynamicPcdBuildDefinitions();
1508 XmlCursor cursor
= o
.newCursor();
1509 if (cursor
.toFirstChild()) {
1511 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdBuildData
=
1512 (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1513 if (pcdBuildData
.getCName().equals(cName
) && pcdBuildData
.getTokenSpaceGuidCName().equals(tsGuid
)) {
1515 if (getDynamicPcdBuildDataCount() == 1) {
1523 while (cursor
.toNextSibling());
1528 // Get the Sku Info count of ith dyn pcd element.
1530 public int getDynamicPcdSkuInfoCount(int i
){
1531 if (fpdRoot
.getDynamicPcdBuildDefinitions() == null || fpdRoot
.getDynamicPcdBuildDefinitions().getPcdBuildDataList() == null
1532 || fpdRoot
.getDynamicPcdBuildDefinitions().getPcdBuildDataList().size() == 0) {
1536 int skuInfoCount
= 0;
1537 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1538 if (cursor
.toFirstChild()) {
1539 for (int j
= 0; j
< i
; ++j
) {
1540 cursor
.toNextSibling();
1542 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1543 if (pcdData
.getSkuInfoList() == null) {
1547 skuInfoCount
= pcdData
.getSkuInfoList().size();
1551 return skuInfoCount
;
1554 public void getDynamicPcdSkuInfos(int i
, String
[][] saa
){
1555 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1556 removeElement(getfpdDynPcdBuildDefs());
1557 fpdDynPcdBuildDefs
= null;
1561 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1562 if (cursor
.toFirstChild()) {
1563 for (int j
= 0; j
< i
; ++j
) {
1564 cursor
.toNextSibling();
1566 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1567 if (pcdData
.getSkuInfoList() == null) {
1572 ListIterator
<DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo
> li
= pcdData
.getSkuInfoList().listIterator();
1574 while (li
.hasNext()) {
1575 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo skuInfo
= li
.next();
1576 saa
[k
][0] = skuInfo
.getSkuId()+"";
1577 saa
[k
][1] = skuInfo
.getVariableName();
1578 saa
[k
][2] = skuInfo
.getVariableGuid();
1579 saa
[k
][3] = skuInfo
.getVariableOffset();
1580 saa
[k
][4] = skuInfo
.getHiiDefaultValue();
1581 saa
[k
][5] = skuInfo
.getVpdOffset();
1582 saa
[k
][6] = skuInfo
.getValue();
1592 public String
getDynamicPcdBuildDataValue(int i
){
1593 String value
= null;
1594 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1595 removeElement(getfpdDynPcdBuildDefs());
1596 fpdDynPcdBuildDefs
= null;
1600 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1601 if (cursor
.toFirstChild()) {
1602 for (int j
= 0; j
< i
; ++j
) {
1603 cursor
.toNextSibling();
1605 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1606 if (pcdData
.getSkuInfoList() == null) {
1610 value
= pcdData
.getSkuInfoArray(0).getValue();
1617 public String
getDynamicPcdBuildDataVpdOffset(int i
){
1618 String vpdOffset
= null;
1619 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1620 removeElement(getfpdDynPcdBuildDefs());
1621 fpdDynPcdBuildDefs
= null;
1625 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1626 if (cursor
.toFirstChild()) {
1627 for (int j
= 0; j
< i
; ++j
) {
1628 cursor
.toNextSibling();
1630 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1631 if (pcdData
.getSkuInfoList() == null) {
1635 vpdOffset
= pcdData
.getSkuInfoArray(0).getVpdOffset();
1642 public void removeDynamicPcdBuildDataSkuInfo(int i
) {
1643 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1644 removeElement(getfpdDynPcdBuildDefs());
1645 fpdDynPcdBuildDefs
= null;
1649 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1650 if (cursor
.toFirstChild()) {
1651 for (int j
= 0; j
< i
; ++j
) {
1652 cursor
.toNextSibling();
1654 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1655 if (pcdData
.getSkuInfoList() == null) {
1660 QName qSkuInfo
= new QName(xmlNs
, "SkuInfo");
1661 cursor
.toChild(qSkuInfo
);
1668 // generate sku info for ith dyn pcd build data.
1670 public void genDynamicPcdBuildDataSkuInfo(String id
, String varName
, String varGuid
, String varOffset
,
1671 String hiiDefault
, String vpdOffset
, String value
, int i
) {
1672 // if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1676 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1677 if (cursor
.toFirstChild()) {
1678 for (int j
= 0; j
< i
; ++j
) {
1679 cursor
.toNextSibling();
1681 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1682 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo skuInfo
= pcdData
.addNewSkuInfo();
1683 skuInfo
.setSkuId(new BigInteger(id
));
1684 if (varName
!= null){
1685 skuInfo
.setVariableName(varName
);
1686 skuInfo
.setVariableGuid(varGuid
);
1687 skuInfo
.setVariableOffset(varOffset
);
1688 skuInfo
.setHiiDefaultValue(hiiDefault
);
1690 else if (vpdOffset
!= null){
1691 skuInfo
.setVpdOffset(vpdOffset
);
1694 skuInfo
.setValue(value
);
1699 public void updateDynamicPcdBuildDataSkuInfo(String id
, String varName
, String varGuid
, String varOffset
,
1700 String hiiDefault
, String vpdOffset
, String value
, int i
){
1701 // if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1705 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1706 if (cursor
.toFirstChild()) {
1707 for (int j
= 0; j
< i
; ++j
) {
1708 cursor
.toNextSibling();
1710 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1711 ListIterator
<DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo
> li
= pcdData
.getSkuInfoList().listIterator();
1712 while (li
.hasNext()) {
1713 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo skuInfo
= li
.next();
1714 if (skuInfo
.getSkuId().toString().equals(id
)){
1715 if (varName
!= null){
1716 skuInfo
.setVariableName(varName
);
1717 skuInfo
.setVariableGuid(varGuid
);
1718 skuInfo
.setVariableOffset(varOffset
);
1719 skuInfo
.setHiiDefaultValue(hiiDefault
);
1721 else if (vpdOffset
!= null){
1722 skuInfo
.setVpdOffset(vpdOffset
);
1725 skuInfo
.setValue(value
);
1733 public BuildOptionsDocument
.BuildOptions
getfpdBuildOpts() {
1734 if (fpdBuildOpts
== null) {
1735 fpdBuildOpts
= fpdRoot
.addNewBuildOptions();
1737 return fpdBuildOpts
;
1740 public void genBuildOptionsUserExtensions(String fvName
, String outputFileName
, Vector
<String
[]> includeModules
) {
1741 QName elementFvName
= new QName (xmlNs
, "FvName");
1742 QName elementIncludeModules
= new QName(xmlNs
, "IncludeModules");
1743 QName elementInfFileName
= new QName(xmlNs
, "InfFileName");
1744 QName elementModule
= new QName(xmlNs
, "Module");
1746 UserExtensionsDocument
.UserExtensions userExts
= getfpdBuildOpts().addNewUserExtensions();
1747 userExts
.setUserID("IMAGES");
1748 userExts
.setIdentifier(new BigInteger("1"));
1749 XmlCursor cursor
= userExts
.newCursor();
1750 cursor
.toEndToken();
1752 cursor
.beginElement(elementFvName
);
1753 cursor
.insertChars(fvName
);
1754 cursor
.toNextToken();
1756 cursor
.beginElement(elementInfFileName
);
1757 cursor
.insertChars(fvName
+ ".inf");
1758 cursor
.toNextToken();
1760 cursor
.beginElement(elementIncludeModules
);
1761 for (int i
= 0; i
< includeModules
.size(); ++i
) {
1762 cursor
.beginElement(elementModule
);
1763 cursor
.insertAttributeWithValue("ModuleGuid", includeModules
.get(i
)[0]);
1764 if (!includeModules
.get(i
)[1].equals("null") && includeModules
.get(i
)[1].length() != 0) {
1765 cursor
.insertAttributeWithValue("ModuleVersion", includeModules
.get(i
)[1]);
1767 cursor
.insertAttributeWithValue("PackageGuid", includeModules
.get(i
)[2]);
1768 if (!includeModules
.get(i
)[3].equals("null") && includeModules
.get(i
)[3].length() != 0) {
1769 cursor
.insertAttributeWithValue("PackageVersion", includeModules
.get(i
)[3]);
1772 cursor
.insertAttributeWithValue("Arch", includeModules
.get(i
)[4]);
1773 cursor
.toEndToken();
1774 cursor
.toNextToken();
1779 public int getUserExtsIncModCount (String fvName
) {
1780 if (getfpdBuildOpts().getUserExtensionsList() == null) {
1783 ListIterator
<UserExtensionsDocument
.UserExtensions
> li
= getfpdBuildOpts().getUserExtensionsList().listIterator();
1784 QName elementIncludeModules
= new QName(xmlNs
, "IncludeModules");
1785 while (li
.hasNext()) {
1786 UserExtensionsDocument
.UserExtensions ues
= li
.next();
1787 if (!ues
.getUserID().equals("IMAGES")) {
1790 XmlCursor cursor
= ues
.newCursor();
1791 cursor
.toFirstChild();
1792 String elementName
= cursor
.getTextValue();
1793 if (elementName
.equals(fvName
)) {
1794 cursor
.toNextSibling(elementIncludeModules
);
1795 if (cursor
.toFirstChild()) {
1797 for (i
= 1; cursor
.toNextSibling(); ++i
);
1809 public void getUserExtsIncMods(String fvName
, String
[][] saa
) {
1810 if (getfpdBuildOpts().getUserExtensionsList() == null) {
1814 XmlCursor cursor
= getfpdBuildOpts().newCursor();
1815 QName elementUserExts
= new QName (xmlNs
, "UserExtensions");
1816 QName attribUserId
= new QName ("UserID");
1817 QName elementFvName
= new QName (xmlNs
, "FvName");
1818 QName elementIncludeModules
= new QName(xmlNs
, "IncludeModules");
1819 QName attribModuleGuid
= new QName("ModuleGuid");
1820 QName attribModuleVersion
= new QName("ModuleVersion");
1821 QName attribPackageGuid
= new QName("PackageGuid");
1822 QName attribPackageVersion
= new QName("PackageVersion");
1823 QName attribArch
= new QName("Arch");
1825 if (cursor
.toChild(elementUserExts
)) {
1828 if (cursor
.getAttributeText(attribUserId
).equals("IMAGES")) {
1829 cursor
.toChild(elementFvName
);
1830 String elementName
= cursor
.getTextValue();
1831 if (elementName
.equals(fvName
)) {
1832 cursor
.toNextSibling(elementIncludeModules
);
1833 if (cursor
.toFirstChild()) {
1836 saa
[i
][0] = cursor
.getAttributeText(attribModuleGuid
);
1837 saa
[i
][1] = cursor
.getAttributeText(attribModuleVersion
);
1838 saa
[i
][2] = cursor
.getAttributeText(attribPackageGuid
);
1839 saa
[i
][3] = cursor
.getAttributeText(attribPackageVersion
);
1840 saa
[i
][4] = cursor
.getAttributeText(attribArch
);
1842 }while (cursor
.toNextSibling());
1848 }while (cursor
.toNextSibling(elementUserExts
));
1854 public void updateBuildOptionsUserExtensions (String oldFvName
, String newFvName
) {
1855 if (getfpdBuildOpts().getUserExtensionsList() == null) {
1858 ListIterator
<UserExtensionsDocument
.UserExtensions
> li
= getfpdBuildOpts().getUserExtensionsList().listIterator();
1859 while (li
.hasNext()) {
1860 UserExtensionsDocument
.UserExtensions ues
= li
.next();
1861 if (!ues
.getUserID().equals("IMAGES")) {
1864 XmlCursor cursor
= ues
.newCursor();
1865 cursor
.toFirstChild();
1866 String elementName
= cursor
.getTextValue();
1867 if (elementName
.equals(oldFvName
)) {
1868 cursor
.setTextValue(newFvName
);
1875 public void removeBuildOptionsUserExtensions (String fvName
) {
1876 if (getfpdBuildOpts().getUserExtensionsList() == null) {
1880 ListIterator
<UserExtensionsDocument
.UserExtensions
> li
= getfpdBuildOpts().getUserExtensionsList().listIterator();
1881 while (li
.hasNext()) {
1882 UserExtensionsDocument
.UserExtensions ues
= li
.next();
1883 if (!ues
.getUserID().equals("IMAGES")) {
1886 XmlCursor cursor
= ues
.newCursor();
1887 cursor
.toFirstChild();
1888 String elementName
= cursor
.getTextValue();
1889 if (elementName
.equals(fvName
)) {
1900 private boolean versionEqual (String v1
, String v2
) {
1902 if ((v1
== null || v1
.length() == 0 || v1
.equalsIgnoreCase("null"))
1903 && (v2
== null || v2
.length() == 0 || v2
.equalsIgnoreCase("null"))) {
1907 if (v1
!= null && v1
.equals(v2
)) {
1914 public boolean moduleInBuildOptionsUserExtensions (String fvName
, String moduleGuid
, String moduleVersion
, String packageGuid
, String packageVersion
, String arch
) {
1915 boolean inList
= false;
1916 if (getUserExtsIncModCount(fvName
) > 0) {
1918 XmlCursor cursor
= getfpdBuildOpts().newCursor();
1919 QName elementUserExts
= new QName (xmlNs
, "UserExtensions");
1920 QName attribUserId
= new QName ("UserID");
1921 QName elementFvName
= new QName (xmlNs
, "FvName");
1922 QName elementIncludeModules
= new QName(xmlNs
, "IncludeModules");
1923 QName attribModuleGuid
= new QName("ModuleGuid");
1924 QName attribModuleVersion
= new QName("ModuleVersion");
1925 QName attribPackageGuid
= new QName("PackageGuid");
1926 QName attribPackageVersion
= new QName("PackageVersion");
1927 QName attribArch
= new QName("Arch");
1929 if (cursor
.toChild(elementUserExts
)) {
1932 if (cursor
.getAttributeText(attribUserId
).equals("IMAGES")) {
1933 cursor
.toChild(elementFvName
);
1934 String elementName
= cursor
.getTextValue();
1935 if (elementName
.equals(fvName
)) {
1936 cursor
.toNextSibling(elementIncludeModules
);
1937 if (cursor
.toFirstChild()) {
1940 String mg
= cursor
.getAttributeText(attribModuleGuid
);
1941 String mv
= cursor
.getAttributeText(attribModuleVersion
);
1942 String pg
= cursor
.getAttributeText(attribPackageGuid
);
1943 String pv
= cursor
.getAttributeText(attribPackageVersion
);
1944 String ar
= cursor
.getAttributeText(attribArch
);
1945 if (!moduleGuid
.equalsIgnoreCase(mg
)) {
1948 if (!packageGuid
.equalsIgnoreCase(pg
)) {
1951 if (!arch
.equalsIgnoreCase(ar
)) {
1954 if (!versionEqual(moduleVersion
, mv
)) {
1957 if (!versionEqual(packageVersion
, pv
)) {
1962 }while (cursor
.toNextSibling());
1968 }while (cursor
.toNextSibling(elementUserExts
));
1975 public void removeModuleInBuildOptionsUserExtensions (String fvName
, String moduleGuid
, String moduleVersion
, String packageGuid
, String packageVersion
, String arch
) {
1976 if (getUserExtsIncModCount(fvName
) > 0) {
1978 XmlCursor cursor
= getfpdBuildOpts().newCursor();
1979 QName elementUserExts
= new QName (xmlNs
, "UserExtensions");
1980 QName attribUserId
= new QName ("UserID");
1981 QName elementFvName
= new QName (xmlNs
, "FvName");
1982 QName elementIncludeModules
= new QName(xmlNs
, "IncludeModules");
1983 QName attribModuleGuid
= new QName("ModuleGuid");
1984 QName attribModuleVersion
= new QName("ModuleVersion");
1985 QName attribPackageGuid
= new QName("PackageGuid");
1986 QName attribPackageVersion
= new QName("PackageVersion");
1987 QName attribArch
= new QName("Arch");
1989 if (cursor
.toChild(elementUserExts
)) {
1992 if (cursor
.getAttributeText(attribUserId
).equals("IMAGES")) {
1993 cursor
.toChild(elementFvName
);
1994 String elementName
= cursor
.getTextValue();
1995 if (elementName
.equals(fvName
)) {
1996 cursor
.toNextSibling(elementIncludeModules
);
1997 if (cursor
.toFirstChild()) {
2000 String mg
= cursor
.getAttributeText(attribModuleGuid
);
2001 String mv
= cursor
.getAttributeText(attribModuleVersion
);
2002 String pg
= cursor
.getAttributeText(attribPackageGuid
);
2003 String pv
= cursor
.getAttributeText(attribPackageVersion
);
2004 String ar
= cursor
.getAttributeText(attribArch
);
2005 if (!moduleGuid
.equalsIgnoreCase(mg
)) {
2008 if (!packageGuid
.equalsIgnoreCase(pg
)) {
2011 if (!arch
.equalsIgnoreCase(ar
)) {
2014 if (!versionEqual(moduleVersion
, mv
)) {
2017 if (!versionEqual(packageVersion
, pv
)) {
2021 }while (cursor
.toNextSibling());
2027 }while (cursor
.toNextSibling(elementUserExts
));
2033 public void genBuildOptionsUserDefAntTask (String id
, String fileName
, String execOrder
) {
2034 UserDefinedAntTasksDocument
.UserDefinedAntTasks udats
= getfpdBuildOpts().getUserDefinedAntTasks();
2035 if (udats
== null) {
2036 udats
= getfpdBuildOpts().addNewUserDefinedAntTasks();
2039 AntTaskDocument
.AntTask at
= udats
.addNewAntTask();
2040 setBuildOptionsUserDefAntTask(id
, fileName
, execOrder
, at
);
2043 private void setBuildOptionsUserDefAntTask(String id
, String fileName
, String execOrder
, AntTaskDocument
.AntTask at
) {
2044 at
.setId(new Integer(id
));
2045 XmlCursor cursor
= at
.newCursor();
2046 if (fileName
!= null){
2047 at
.setFilename(fileName
);
2049 else if (cursor
.toChild(xmlNs
, "Filename")) {
2052 if (execOrder
!= null) {
2053 at
.setAntCmdOptions(execOrder
);
2055 else if (cursor
.toChild(xmlNs
, "AntCmdOptions")) {
2061 public void removeBuildOptionsUserDefAntTask(int i
) {
2062 XmlObject o
= getfpdBuildOpts().getUserDefinedAntTasks();
2066 XmlCursor cursor
= o
.newCursor();
2067 if (cursor
.toFirstChild()) {
2068 for (int j
= 0; j
< i
; ++j
) {
2069 cursor
.toNextSibling();
2072 if (getBuildOptionsUserDefAntTaskCount() == 0) {
2080 public void updateBuildOptionsUserDefAntTask(int i
, String id
, String fileName
, String execOrder
){
2081 XmlObject o
= getfpdBuildOpts().getUserDefinedAntTasks();
2085 XmlCursor cursor
= o
.newCursor();
2086 if (cursor
.toFirstChild()) {
2087 for (int j
= 0; j
< i
; ++j
) {
2088 cursor
.toNextSibling();
2090 AntTaskDocument
.AntTask at
= (AntTaskDocument
.AntTask
)cursor
.getObject();
2091 setBuildOptionsUserDefAntTask(id
, fileName
, execOrder
, at
);
2096 public int getBuildOptionsUserDefAntTaskCount() {
2097 UserDefinedAntTasksDocument
.UserDefinedAntTasks udats
= getfpdBuildOpts().getUserDefinedAntTasks();
2098 if (udats
== null || udats
.getAntTaskList() == null) {
2102 return udats
.getAntTaskList().size();
2105 public void getBuildOptionsUserDefAntTasks(String
[][] saa
) {
2106 UserDefinedAntTasksDocument
.UserDefinedAntTasks udats
= getfpdBuildOpts().getUserDefinedAntTasks();
2107 if (udats
== null || udats
.getAntTaskList() == null) {
2111 List
<AntTaskDocument
.AntTask
> l
= udats
.getAntTaskList();
2112 ListIterator li
= l
.listIterator();
2114 while (li
.hasNext()) {
2115 AntTaskDocument
.AntTask at
= (AntTaskDocument
.AntTask
)li
.next();
2116 saa
[i
][0] = at
.getId() + "";
2117 saa
[i
][1] = saa
[i
][2] = "";
2118 if (at
.getFilename() != null){
2119 saa
[i
][1] = at
.getFilename();
2121 if (at
.getAntCmdOptions() != null) {
2122 saa
[i
][2] = at
.getAntCmdOptions();
2127 public void genBuildOptionsOpt(Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
) {
2128 OptionsDocument
.Options opts
= getfpdBuildOpts().getOptions();
2130 opts
= getfpdBuildOpts().addNewOptions();
2132 OptionDocument
.Option opt
= opts
.addNewOption();
2133 setBuildOptionsOpt(buildTargets
, toolChain
, tagName
, toolCmd
, archList
, contents
, opt
);
2136 private void setBuildOptionsOpt(Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
, OptionDocument
.Option opt
){
2137 opt
.setStringValue(contents
);
2138 if (buildTargets
!= null) {
2139 opt
.setBuildTargets(buildTargets
);
2142 if (opt
.isSetBuildTargets()) {
2143 opt
.unsetBuildTargets();
2147 if (toolChain
!= null && toolChain
.length() > 0) {
2148 opt
.setToolChainFamily(toolChain
);
2151 if (opt
.isSetToolChainFamily()) {
2152 opt
.unsetToolChainFamily();
2156 if (tagName
!= null && tagName
.length() > 0) {
2157 opt
.setTagName(tagName
);
2160 if (opt
.isSetTagName()) {
2165 if (toolCmd
!= null && toolCmd
.length() > 0) {
2166 opt
.setToolCode(toolCmd
);
2169 if (opt
.isSetToolCode()) {
2170 opt
.unsetToolCode();
2175 if (archList
!= null) {
2176 opt
.setSupArchList(archList
);
2179 if (opt
.isSetSupArchList()) {
2180 opt
.unsetSupArchList();
2185 public void removeBuildOptionsOpt(int i
){
2187 XmlObject o
= getfpdBuildOpts().getOptions();
2192 XmlCursor cursor
= o
.newCursor();
2193 if (cursor
.toFirstChild()) {
2194 for (int j
= 0; j
< i
; ++j
) {
2195 cursor
.toNextSibling();
2198 if (getBuildOptionsOptCount() == 0) {
2206 public void updateBuildOptionsOpt(int i
, Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
) {
2207 XmlObject o
= getfpdBuildOpts().getOptions();
2212 XmlCursor cursor
= o
.newCursor();
2213 if (cursor
.toFirstChild()) {
2214 for (int j
= 0; j
< i
; ++j
) {
2215 cursor
.toNextSibling();
2217 OptionDocument
.Option opt
= (OptionDocument
.Option
)cursor
.getObject();
2218 setBuildOptionsOpt(buildTargets
, toolChain
, tagName
, toolCmd
, archList
, contents
, opt
);
2223 public int getBuildOptionsOptCount(){
2224 if (getfpdBuildOpts().getOptions() == null || getfpdBuildOpts().getOptions().getOptionList() == null) {
2227 return getfpdBuildOpts().getOptions().getOptionList().size();
2230 public void getBuildOptionsOpts(String
[][] saa
) {
2231 if (getfpdBuildOpts().getOptions() == null || getfpdBuildOpts().getOptions().getOptionList() == null) {
2235 List
<OptionDocument
.Option
> lOpt
= getfpdBuildOpts().getOptions().getOptionList();
2236 ListIterator li
= lOpt
.listIterator();
2238 while(li
.hasNext()) {
2239 OptionDocument
.Option opt
= (OptionDocument
.Option
)li
.next();
2240 if (opt
.getBuildTargets() != null) {
2241 saa
[i
][0] = listToString(opt
.getBuildTargets());
2243 saa
[i
][1] = opt
.getToolChainFamily();
2244 if (opt
.getSupArchList() != null){
2245 saa
[i
][2] = listToString(opt
.getSupArchList());
2248 saa
[i
][3] = opt
.getToolCode();
2249 saa
[i
][4] = opt
.getTagName();
2250 saa
[i
][5] = opt
.getStringValue();
2256 public void genBuildOptionsFfs(String ffsKey
, String type
) {
2257 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getfpdBuildOpts().addNewFfs();
2258 ffs
.setFfsKey(ffsKey
);
2260 ffs
.addNewSections().setEncapsulationType(type
);
2264 public void updateBuildOptionsFfsSectionsType(int i
, String type
) {
2265 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getfpdBuildOpts().addNewFfs();
2267 ffs
.addNewSections().setEncapsulationType(type
);
2271 public void genBuildOptionsFfsAttribute(int i
, String name
, String value
) {
2272 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2273 BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute attrib
= ffs
.addNewAttribute();
2274 attrib
.setName(name
);
2275 attrib
.setValue(value
);
2278 /**update jth attribute of ith ffs.
2282 public void updateBuildOptionsFfsAttribute(int i
, int j
, String name
, String value
){
2283 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2284 XmlCursor cursor
= ffs
.newCursor();
2285 QName qAttrib
= new QName(xmlNs
, "Attribute");
2286 if (cursor
.toChild(qAttrib
)) {
2287 for (int k
= 0; k
< j
; ++k
) {
2288 cursor
.toNextSibling(qAttrib
);
2290 BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute attrib
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute
)cursor
.getObject();
2291 attrib
.setName(name
);
2292 attrib
.setValue(value
);
2297 public void removeBuildOptionsFfsAttribute(int i
, int j
){
2298 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2299 XmlCursor cursor
= ffs
.newCursor();
2300 QName qAttrib
= new QName(xmlNs
, "Attribute");
2301 if (cursor
.toChild(qAttrib
)) {
2302 for (int k
= 0; k
< j
; ++k
) {
2303 cursor
.toNextSibling(qAttrib
);
2310 public void genBuildOptionsFfsSectionsSection(int i
, String sectionType
) {
2311 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2315 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2317 if (sections
== null){
2318 sections
= ffs
.addNewSections();
2320 sections
.addNewSection().setSectionType(EfiSectionType
.Enum
.forString(sectionType
));
2323 public void removeBuildOptionsFfsSectionsSection(int i
, int j
) {
2324 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2325 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2326 if (sections
== null) {
2329 XmlCursor cursor
= sections
.newCursor();
2330 QName qSection
= new QName(xmlNs
, "Section");
2331 if (cursor
.toChild(qSection
)) {
2332 for (int k
= 0; k
< j
; ++k
) {
2333 cursor
.toNextSibling(qSection
);
2340 public void updateBuildOptionsFfsSectionsSection(int i
, int j
, String type
){
2341 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2342 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2343 if (sections
== null) {
2346 XmlCursor cursor
= sections
.newCursor();
2347 QName qSection
= new QName(xmlNs
, "Section");
2348 if (cursor
.toChild(qSection
)) {
2349 for (int k
= 0; k
< j
; ++k
) {
2350 cursor
.toNextSibling(qSection
);
2352 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Section section
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Section
)cursor
.getObject();
2353 section
.setSectionType(EfiSectionType
.Enum
.forString(type
));
2358 public void genBuildOptionsFfsSectionsSections(int i
, String encapType
) {
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
.addNewSections().setEncapsulationType(encapType
);
2371 public void removeBuildOptionsFfsSectionsSections(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 qSections
= new QName(xmlNs
, "Sections");
2379 if (cursor
.toChild(qSections
)) {
2380 for (int k
= 0; k
< j
; ++k
) {
2381 cursor
.toNextSibling(qSections
);
2388 public void updateBuildOptionsFfsSectionsSections(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 qSections
= new QName(xmlNs
, "Sections");
2396 if (cursor
.toChild(qSections
)) {
2397 for (int k
= 0; k
< j
; ++k
) {
2398 cursor
.toNextSibling(qSections
);
2400 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2 sections2
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
)cursor
.getObject();
2401 sections2
.setEncapsulationType(type
);
2406 public void genBuildOptionsFfsSectionsSectionsSection(int i
, int j
, String type
) {
2407 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2411 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2412 XmlCursor cursor
= sections
.newCursor();
2413 QName qSections
= new QName(xmlNs
, "Sections");
2414 if (cursor
.toChild(qSections
)){
2415 for (int k
= 0; k
< j
; ++k
) {
2416 cursor
.toNextSibling(qSections
);
2418 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2 sections2
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
)cursor
.getObject();
2419 sections2
.addNewSection().setSectionType(EfiSectionType
.Enum
.forString(type
));
2424 public void removeBuildOptionsFfsSectionsSectionsSection(int i
, int j
, int k
) {
2425 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2426 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2427 if (sections
== null) {
2430 XmlCursor cursor
= sections
.newCursor();
2431 QName qSections
= new QName(xmlNs
, "Sections");
2432 if (cursor
.toChild(qSections
)) {
2433 for (int l
= 0; l
< j
; ++l
) {
2434 cursor
.toNextSibling(qSections
);
2436 if (cursor
.toFirstChild()) {
2438 for (; m
< k
; ++m
) {
2439 cursor
.toNextSibling();
2451 public void updateBuildOptionsFfsSectionsSectionsSection(int i
, int j
, int k
, String type
) {
2452 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2453 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2454 if (sections
== null) {
2457 XmlCursor cursor
= sections
.newCursor();
2458 QName qSections
= new QName(xmlNs
, "Sections");
2459 if (cursor
.toChild(qSections
)) {
2460 for (int l
= 0; l
< j
; ++l
) {
2461 cursor
.toNextSibling(qSections
);
2463 if (cursor
.toFirstChild()) {
2464 for (int m
= 0; m
< k
; ++m
) {
2465 cursor
.toNextSibling();
2467 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section section
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section
)cursor
.getObject();
2468 section
.setSectionType(EfiSectionType
.Enum
.forString(type
));
2474 public void getBuildOptionsFfsSectionsSectionsSection(int i
, int j
, ArrayList
<String
> al
) {
2475 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2479 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2480 XmlCursor cursor
= sections
.newCursor();
2481 QName qSections
= new QName(xmlNs
, "Sections");
2482 if (cursor
.toChild(qSections
)){
2483 for (int k
= 0; k
< j
; ++k
) {
2484 cursor
.toNextSibling(qSections
);
2486 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2 sections2
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
)cursor
.getObject();
2487 if (sections2
.getSectionList() == null){
2491 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section
> li
= sections2
.getSectionList().listIterator();
2492 while(li
.hasNext()) {
2493 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section section
= li
.next();
2494 if (section
.isSetSectionType()) {
2495 al
.add(section
.getSectionType().toString());
2504 public int getBuildOptionsFfsCount(){
2505 if (getfpdBuildOpts().getFfsList() == null) {
2508 return getfpdBuildOpts().getFfsList().size();
2511 public void getBuildOptionsFfsKey(String
[][] saa
) {
2512 if (getfpdBuildOpts().getFfsList() == null) {
2515 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
> li
= getfpdBuildOpts().getFfsList().listIterator();
2517 while(li
.hasNext()){
2518 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= li
.next();
2519 saa
[i
][0] = ffs
.getFfsKey();
2524 public void updateBuildOptionsFfsKey(int i
, String key
) {
2525 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2529 /**Get ith FFS key and contents.
2532 public void getBuildOptionsFfs(int i
, String
[] sa
, LinkedHashMap
<String
, String
> ffsAttribMap
, ArrayList
<String
> firstLevelSections
, ArrayList
<String
> firstLevelSection
) {
2533 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2537 sa
[0] = ffs
.getFfsKey();
2538 if (ffs
.getSections() != null) {
2539 if(ffs
.getSections().getEncapsulationType() != null){
2540 sa
[1] = ffs
.getSections().getEncapsulationType();
2542 if (ffs
.getSections().getSectionList() != null){
2543 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Section
> li
= ffs
.getSections().getSectionList().listIterator();
2544 while (li
.hasNext()) {
2545 firstLevelSection
.add(li
.next().getSectionType().toString());
2548 if (ffs
.getSections().getSectionsList() != null) {
2549 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
> li
= ffs
.getSections().getSectionsList().listIterator();
2550 while(li
.hasNext()) {
2551 firstLevelSections
.add(li
.next().getEncapsulationType());
2555 if (ffs
.getAttributeList() != null) {
2556 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute
> li
= ffs
.getAttributeList().listIterator();
2557 while(li
.hasNext()) {
2558 BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute attrib
= li
.next();
2559 ffsAttribMap
.put(attrib
.getName(), attrib
.getValue());
2568 private BuildOptionsDocument
.BuildOptions
.Ffs
getFfs(int i
) {
2569 XmlObject o
= getfpdBuildOpts();
2570 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= null;
2572 XmlCursor cursor
= o
.newCursor();
2573 QName qFfs
= new QName(xmlNs
, "Ffs");
2574 if (cursor
.toChild(qFfs
)) {
2575 for (int j
= 0; j
< i
; ++j
) {
2576 cursor
.toNextSibling(qFfs
);
2578 ffs
= (BuildOptionsDocument
.BuildOptions
.Ffs
)cursor
.getObject();
2584 public void removeBuildOptionsFfs(int i
) {
2585 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2590 XmlCursor cursor
= ffs
.newCursor();
2597 public PlatformDefinitionsDocument
.PlatformDefinitions
getfpdPlatformDefs(){
2598 if (fpdPlatformDefs
== null){
2599 fpdPlatformDefs
= fpdRoot
.addNewPlatformDefinitions();
2601 return fpdPlatformDefs
;
2604 public void getPlatformDefsSupportedArchs(Vector
<Object
> archs
){
2605 if (getfpdPlatformDefs().getSupportedArchitectures() == null) {
2608 ListIterator li
= getfpdPlatformDefs().getSupportedArchitectures().listIterator();
2609 while(li
.hasNext()) {
2610 archs
.add(li
.next());
2614 public void setPlatformDefsSupportedArchs(Vector
<Object
> archs
) {
2615 if (archs
!= null) {
2616 getfpdPlatformDefs().setSupportedArchitectures(archs
);
2619 // XmlCursor cursor = getfpdPlatformDefs().newCursor();
2620 // if (cursor.toChild(xmlNs, "SupportedArchitectures")) {
2621 // cursor.removeXml();
2623 // cursor.dispose();
2627 public void getPlatformDefsBuildTargets(Vector
<Object
> targets
) {
2628 if (getfpdPlatformDefs().getBuildTargets() == null) {
2631 ListIterator li
= getfpdPlatformDefs().getBuildTargets().listIterator();
2632 while(li
.hasNext()) {
2633 targets
.add(li
.next());
2637 public void setPlatformDefsBuildTargets(Vector
<Object
> targets
) {
2638 getfpdPlatformDefs().setBuildTargets(targets
);
2641 public void genPlatformDefsSkuInfo(String id
, String name
) {
2642 SkuInfoDocument
.SkuInfo skuInfo
= null;
2643 if (getfpdPlatformDefs().getSkuInfo() == null) {
2644 skuInfo
= getfpdPlatformDefs().addNewSkuInfo();
2646 skuInfo
= getfpdPlatformDefs().getSkuInfo();
2647 if (skuInfo
.getUiSkuNameList() == null || skuInfo
.getUiSkuNameList().size() == 0) {
2648 SkuInfoDocument
.SkuInfo
.UiSkuName skuName
= skuInfo
.addNewUiSkuName();
2649 skuName
.setSkuID(new BigInteger("0"));
2650 skuName
.setStringValue("DEFAULT");
2652 if (id
.equals("0")) {
2655 SkuInfoDocument
.SkuInfo
.UiSkuName skuName
= skuInfo
.addNewUiSkuName();
2656 skuName
.setSkuID(new BigInteger(id
));
2657 skuName
.setStringValue(name
);
2660 public int getPlatformDefsSkuInfoCount(){
2661 if (getfpdPlatformDefs().getSkuInfo() == null || getfpdPlatformDefs().getSkuInfo().getUiSkuNameList() == null) {
2664 return getfpdPlatformDefs().getSkuInfo().getUiSkuNameList().size();
2667 public void getPlatformDefsSkuInfos(String
[][] saa
){
2668 if (getfpdPlatformDefs().getSkuInfo() == null || getfpdPlatformDefs().getSkuInfo().getUiSkuNameList() == null) {
2669 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null) {
2670 removeElement(getfpdDynPcdBuildDefs());
2671 fpdDynPcdBuildDefs
= null;
2676 List
<SkuInfoDocument
.SkuInfo
.UiSkuName
> l
= getfpdPlatformDefs().getSkuInfo().getUiSkuNameList();
2677 ListIterator
<SkuInfoDocument
.SkuInfo
.UiSkuName
> li
= l
.listIterator();
2679 while(li
.hasNext()) {
2680 SkuInfoDocument
.SkuInfo
.UiSkuName sku
= li
.next();
2681 saa
[i
][0] = sku
.getSkuID()+"";
2682 saa
[i
][1] = sku
.getStringValue();
2687 public void removePlatformDefsSkuInfo(int i
) {
2688 SkuInfoDocument
.SkuInfo skuInfo
= getfpdPlatformDefs().getSkuInfo();
2689 if (skuInfo
== null || i
== 0) {
2693 XmlCursor cursor
= skuInfo
.newCursor();
2694 if (cursor
.toFirstChild()) {
2695 for (int j
= 0; j
< i
; ++j
) {
2696 cursor
.toNextSibling();
2703 public void updatePlatformDefsSkuInfo(int i
, String id
, String name
) {
2704 SkuInfoDocument
.SkuInfo skuInfo
= getfpdPlatformDefs().getSkuInfo();
2705 if (skuInfo
== null || i
== 0) {
2709 XmlCursor cursor
= skuInfo
.newCursor();
2710 if (cursor
.toFirstChild()) {
2711 for (int j
= 0; j
< i
; ++j
) {
2712 cursor
.toNextSibling();
2714 SkuInfoDocument
.SkuInfo
.UiSkuName sku
= (SkuInfoDocument
.SkuInfo
.UiSkuName
)cursor
.getObject();
2715 sku
.setSkuID(new BigInteger(id
));
2716 sku
.setStringValue(name
);
2721 public String
getPlatformDefsInterDir(){
2722 if (getfpdPlatformDefs().getIntermediateDirectories() == null) {
2725 return getfpdPlatformDefs().getIntermediateDirectories().toString();
2728 public void setPlatformDefsInterDir(String interDir
){
2729 getfpdPlatformDefs().setIntermediateDirectories(IntermediateOutputType
.Enum
.forString(interDir
));
2732 public String
getPlatformDefsOutputDir() {
2733 return getfpdPlatformDefs().getOutputDirectory();
2736 public void setPlatformDefsOutputDir(String outputDir
) {
2737 if (outputDir
!= null && outputDir
.length() > 0) {
2738 getfpdPlatformDefs().setOutputDirectory(outputDir
);
2741 XmlCursor cursor
= getfpdPlatformDefs().newCursor();
2742 if (cursor
.toChild(new QName(xmlNs
, "OutputDirectory"))) {
2749 public FlashDocument
.Flash
getfpdFlash() {
2750 if (fpdFlash
== null) {
2751 fpdFlash
= fpdRoot
.addNewFlash();
2756 public void genFlashDefinitionFile(String file
) {
2757 FlashDefinitionFileDocument
.FlashDefinitionFile fdf
= getfpdFlash().getFlashDefinitionFile();
2759 fdf
= getfpdFlash().addNewFlashDefinitionFile();
2762 fdf
.setStringValue(file
);
2765 public String
getFlashDefinitionFile() {
2766 FlashDefinitionFileDocument
.FlashDefinitionFile fdf
= getfpdFlash().getFlashDefinitionFile();
2771 return fdf
.getStringValue();
2774 public void genFvImagesNameValue(String name
, String value
) {
2776 FvImagesDocument
.FvImages fi
= getfpdFlash().getFvImages();
2778 fi
= getfpdFlash().addNewFvImages();
2781 FvImagesDocument
.FvImages
.NameValue nv
= fi
.addNewNameValue();
2786 public void removeFvImagesNameValue(int i
){
2788 XmlObject o
= getfpdFlash().getFvImages();
2793 QName qNameValue
= new QName(xmlNs
, "NameValue");
2794 XmlCursor cursor
= o
.newCursor();
2795 if (cursor
.toChild(qNameValue
)) {
2796 for (int j
= 0; j
< i
; ++j
) {
2797 cursor
.toNextSibling(qNameValue
);
2804 public void updateFvImagesNameValue(int i
, String name
, String value
){
2806 XmlObject o
= getfpdFlash().getFvImages();
2811 QName qNameValue
= new QName(xmlNs
, "NameValue");
2812 XmlCursor cursor
= o
.newCursor();
2813 if (cursor
.toChild(qNameValue
)) {
2814 for (int j
= 0; j
< i
; ++j
) {
2815 cursor
.toNextSibling(qNameValue
);
2817 FvImagesDocument
.FvImages
.NameValue nv
= (FvImagesDocument
.FvImages
.NameValue
)cursor
.getObject();
2824 public int getFvImagesNameValueCount() {
2826 FvImagesDocument
.FvImages fi
= null;
2827 if ((fi
= getfpdFlash().getFvImages()) == null || fi
.getNameValueList() == null) {
2830 return fi
.getNameValueList().size();
2833 public void getFvImagesNameValues(String
[][] nv
) {
2835 FvImagesDocument
.FvImages fi
= getfpdFlash().getFvImages();
2839 List
<FvImagesDocument
.FvImages
.NameValue
> l
= fi
.getNameValueList();
2841 ListIterator li
= l
.listIterator();
2842 while (li
.hasNext()) {
2843 FvImagesDocument
.FvImages
.NameValue e
= (FvImagesDocument
.FvImages
.NameValue
) li
2845 nv
[i
][0] = e
.getName();
2846 nv
[i
][1] = e
.getValue();
2852 public void getFvImagesFvImageFvImageNames (Vector
<String
> vImageNames
) {
2853 FvImagesDocument
.FvImages fis
= getfpdFlash().getFvImages();
2854 if (fis
== null || fis
.getFvImageList() == null) {
2858 ListIterator
<FvImagesDocument
.FvImages
.FvImage
> li
= fis
.getFvImageList().listIterator();
2859 while (li
.hasNext()) {
2860 FvImagesDocument
.FvImages
.FvImage fi
= li
.next();
2861 if (fi
.getType().toString().equals("ImageName")) {
2862 vImageNames
.addAll(fi
.getFvImageNamesList());
2868 public void addFvImageFvImageNames (String
[] fvNames
) {
2869 FvImagesDocument
.FvImages fis
= getfpdFlash().getFvImages();
2870 if (fis
== null || fis
.getFvImageList() == null) {
2871 genFvImagesFvImage (fvNames
, "ImageName", null);
2875 ListIterator
<FvImagesDocument
.FvImages
.FvImage
> li
= fis
.getFvImageList().listIterator();
2876 while (li
.hasNext()) {
2877 FvImagesDocument
.FvImages
.FvImage fi
= li
.next();
2878 if (fi
.getType().toString().equals("ImageName")) {
2879 addFvImageNamesInFvImage (fi
, fvNames
);
2883 genFvImagesFvImage (fvNames
, "ImageName", null);
2886 public void addFvImageNamesInFvImage (FvImagesDocument
.FvImages
.FvImage fi
, String
[] fvNames
) {
2888 for (int i
= 0; i
< fvNames
.length
; ++i
) {
2889 fi
.addFvImageNames(fvNames
[i
]);
2893 public void addFvImageNamesInFvImage (int i
, String
[] fvNames
) {
2894 XmlObject o
= getfpdFlash().getFvImages();
2898 XmlCursor cursor
= o
.newCursor();
2899 QName qFvImage
= new QName(xmlNs
, "FvImage");
2900 if (cursor
.toChild(qFvImage
)) {
2901 for (int j
= 0; j
< i
; ++j
) {
2902 cursor
.toNextSibling(qFvImage
);
2904 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
2905 addFvImageNamesInFvImage(fi
, fvNames
);
2910 public void genFvImagesFvImage(String
[] names
, String types
, Map
<String
, String
> options
) {
2912 FvImagesDocument
.FvImages fis
= null;
2913 if ((fis
= getfpdFlash().getFvImages()) == null) {
2914 fis
= getfpdFlash().addNewFvImages();
2918 //gen FvImage with FvImageNames array
2920 FvImagesDocument
.FvImages
.FvImage fi
= fis
.addNewFvImage();
2921 for (int i
= 0; i
< names
.length
; ++i
) {
2922 fi
.addFvImageNames(names
[i
]);
2924 fi
.setType(FvImageTypes
.Enum
.forString(types
));
2925 if (options
!= null){
2926 setFvImagesFvImageFvImageOptions(options
, fi
);
2930 private void setFvImagesFvImageFvImageOptions(Map
<String
, String
> options
, FvImagesDocument
.FvImages
.FvImage fi
){
2931 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions fio
= fi
.getFvImageOptions();
2933 fio
= fi
.addNewFvImageOptions();
2936 Set
<String
> key
= options
.keySet();
2937 Iterator
<String
> i
= key
.iterator();
2938 while (i
.hasNext()) {
2940 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nv
= fio
.addNewNameValue();
2941 String k
= (String
)i
.next();
2944 nv
.setValue((String
)options
.get(k
));
2951 public void removeFvImagesFvImage(int i
) {
2953 XmlObject o
= getfpdFlash().getFvImages();
2958 QName qFvImage
= new QName(xmlNs
, "FvImage");
2959 XmlCursor cursor
= o
.newCursor();
2960 if (cursor
.toChild(qFvImage
)) {
2961 for (int j
= 0; j
< i
; ++j
) {
2962 cursor
.toNextSibling(qFvImage
);
2971 * @param newFvName The New FV Name. If null, remove the old FvImageNames entry.
2973 public void updateFvImageNameAll (String oldFvName
, String newFvName
) {
2974 if (getfpdFlash().getFvImages() == null || getfpdFlash().getFvImages().getFvImageList() == null) {
2977 ListIterator
<FvImagesDocument
.FvImages
.FvImage
> li
= getfpdFlash().getFvImages().getFvImageList().listIterator();
2978 while (li
.hasNext()) {
2979 FvImagesDocument
.FvImages
.FvImage fi
= li
.next();
2980 updateFvImageNamesInFvImage (fi
, oldFvName
, newFvName
);
2981 if (fi
.getFvImageNamesList().size() == 0) {
2987 public void updateFvImageNamesInFvImage (int i
, String oldFvName
, String newFvName
) {
2988 XmlObject o
= getfpdFlash().getFvImages();
2992 XmlCursor cursor
= o
.newCursor();
2993 QName qFvImage
= new QName(xmlNs
, "FvImage");
2994 if (cursor
.toChild(qFvImage
)) {
2995 for (int j
= 0; j
< i
; ++j
) {
2996 cursor
.toNextSibling(qFvImage
);
2998 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
2999 updateFvImageNamesInFvImage (fi
, oldFvName
, newFvName
);
3005 * @param oldFvName The FV Name to be replaced.
3006 * @param newFvName The New FV Name. If null, remove the old FvImageNames entry.
3008 public void updateFvImageNamesInFvImage (FvImagesDocument
.FvImages
.FvImage fi
, String oldFvName
, String newFvName
) {
3009 QName qFvImageNames
= new QName(xmlNs
, "FvImageNames");
3010 XmlCursor cursor
= fi
.newCursor();
3012 if (cursor
.toChild(qFvImageNames
)) {
3014 String xmlValue
= cursor
.getTextValue();
3015 if (xmlValue
.equals(oldFvName
)){
3016 if (newFvName
!= null) {
3017 cursor
.setTextValue(newFvName
);
3023 }while (cursor
.toNextSibling(qFvImageNames
));
3029 /**update the Type attribute of ith FvImage with new type.
3033 public void updateFvImagesFvImageType (int i
, String type
) {
3034 XmlObject o
= getfpdFlash().getFvImages();
3038 XmlCursor cursor
= o
.newCursor();
3039 QName qFvImage
= new QName(xmlNs
, "FvImage");
3040 if (cursor
.toChild(qFvImage
)) {
3041 for (int j
= 0; j
< i
; ++j
) {
3042 cursor
.toNextSibling(qFvImage
);
3044 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
3045 fi
.setType(FvImageTypes
.Enum
.forString(type
));
3050 public void updateFvImagesFvImage(int i
, String
[] names
, String types
, Map
<String
, String
> options
){
3052 XmlObject o
= getfpdFlash().getFvImages();
3056 XmlCursor cursor
= o
.newCursor();
3057 QName qFvImage
= new QName(xmlNs
, "FvImage");
3058 if (cursor
.toChild(qFvImage
)) {
3059 for (int j
= 0; j
< i
; ++j
) {
3060 cursor
.toNextSibling(qFvImage
);
3062 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
3063 fi
.setType(FvImageTypes
.Enum
.forString(types
));
3066 // remove old FvImageNames before adding new ones
3068 QName qFvImageNames
= new QName(xmlNs
, "FvImageNames");
3069 cursor
.toChild(qFvImageNames
);
3071 while (cursor
.toNextSibling(qFvImageNames
)) {
3075 for (int k
= 0; k
< names
.length
; ++k
) {
3076 fi
.addFvImageNames(names
[k
]);
3079 // remove old FvImageOptions before adding new options
3081 QName qFvImageOptions
= new QName(xmlNs
, "FvImageOptions");
3082 cursor
.toNextSibling(qFvImageOptions
);
3085 setFvImagesFvImageFvImageOptions(options
, fi
);
3090 public int getFvImagesFvImageCount(String type
) {
3092 if (getfpdFlash().getFvImages() == null || getfpdFlash().getFvImages().getFvImageList() == null) {
3095 List
<FvImagesDocument
.FvImages
.FvImage
> l
= getfpdFlash().getFvImages().getFvImageList();
3096 ListIterator li
= l
.listIterator();
3098 while(li
.hasNext()) {
3099 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)li
.next();
3100 if (!fi
.getType().toString().equals(type
) && !type
.equals("ALL")) {
3110 public Vector
<FvImagesDocument
.FvImages
.FvImage
> getFvImagesFvImageWithName (String fvName
, String type
) {
3111 Vector
<FvImagesDocument
.FvImages
.FvImage
> vFvImage
= new Vector
<FvImagesDocument
.FvImages
.FvImage
>();
3112 if (getfpdFlash().getFvImages() == null || getfpdFlash().getFvImages().getFvImageList() == null) {
3115 List
<FvImagesDocument
.FvImages
.FvImage
> l
= getfpdFlash().getFvImages().getFvImageList();
3116 ListIterator li
= l
.listIterator();
3117 while(li
.hasNext()) {
3118 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)li
.next();
3119 if (!fi
.getType().toString().equals(type
) && !type
.equals("ALL")) {
3122 if (fi
.getFvImageNamesList().contains(fvName
)) {
3131 * @param type "ALL" means all FvImage types: ImageName, Options, Attributes, Components.
3133 public void getFvImagesFvImages(String
[][] saa
, String type
) {
3135 if (getfpdFlash().getFvImages() == null) {
3138 List
<FvImagesDocument
.FvImages
.FvImage
> l
= getfpdFlash().getFvImages().getFvImageList();
3142 ListIterator li
= l
.listIterator();
3144 while(li
.hasNext()) {
3145 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)li
.next();
3146 if (!fi
.getType().toString().equals(type
) && !type
.equals("ALL")) {
3150 // get FvImageNames array, space separated
3152 List
<String
> lfn
= fi
.getFvImageNamesList();
3153 ListIterator lfni
= lfn
.listIterator();
3155 while (lfni
.hasNext()) {
3156 saa
[i
][0] += (String
)lfni
.next();
3159 saa
[i
][0] = saa
[i
][0].trim();
3161 saa
[i
][1] = fi
.getType()+"";
3167 public void removeFvImageNameValue (int i
, String attributeName
) {
3168 XmlObject o
= getfpdFlash().getFvImages();
3172 XmlCursor cursor
= o
.newCursor();
3173 QName qFvImage
= new QName(xmlNs
, "FvImage");
3174 if (cursor
.toChild(qFvImage
)) {
3175 for (int j
= 0; j
< i
; ++j
) {
3176 cursor
.toNextSibling(qFvImage
);
3178 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
3179 removeFvImageNameValue (fi
, attributeName
);
3183 /**Remove from fi the attribute pair with attributeName in FvImageOptions.
3185 * @param attributeName
3187 public void removeFvImageNameValue (FvImagesDocument
.FvImages
.FvImage fi
, String attributeName
) {
3188 if (fi
.getFvImageOptions() != null && fi
.getFvImageOptions().getNameValueList() != null) {
3189 ListIterator
<FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
> li
= fi
.getFvImageOptions().getNameValueList().listIterator();
3190 while (li
.hasNext()) {
3191 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nv
= li
.next();
3192 if (nv
.getName().equals(attributeName
)) {
3199 public void removeTypedNamedFvImageNameValue (String fvName
, String type
, String optName
) {
3200 Vector
<FvImagesDocument
.FvImages
.FvImage
> vFvImage
= getFvImagesFvImageWithName(fvName
, type
);
3201 for (int i
= 0; i
< vFvImage
.size(); ++i
) {
3202 FvImagesDocument
.FvImages
.FvImage fi
= vFvImage
.get(i
);
3203 removeFvImageNameValue (fi
, optName
);
3207 /**Add name-value pair to FvImage element with type.
3208 * @param fvName FV name to add name-value pair.
3209 * @param type FvImage attribute.
3213 public void setTypedNamedFvImageNameValue (String fvName
, String type
, String name
, String value
) {
3214 boolean fvImageExists
= false;
3215 if (getfpdFlash().getFvImages() == null) {
3218 List
<FvImagesDocument
.FvImages
.FvImage
> l
= getfpdFlash().getFvImages().getFvImageList();
3222 ListIterator li
= l
.listIterator();
3223 while(li
.hasNext()) {
3224 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)li
.next();
3225 if (!fi
.getType().toString().equals(type
) && !type
.equals("ALL")) {
3228 if (!fi
.getFvImageNamesList().contains(fvName
)) {
3231 fvImageExists
= true;
3232 setFvImagesFvImageNameValue (fi
, name
, value
, null);
3235 if (!fvImageExists
) {
3236 HashMap
<String
, String
> map
= new HashMap
<String
, String
>();
3237 map
.put(name
, value
);
3238 genFvImagesFvImage(new String
[]{fvName
}, type
, map
);
3242 /**Add to all FvImage elements with type, the name-value pair.
3247 public void setTypedFvImageNameValue (String type
, String name
, String value
) {
3248 if (getfpdFlash().getFvImages() == null) {
3251 List
<FvImagesDocument
.FvImages
.FvImage
> l
= getfpdFlash().getFvImages().getFvImageList();
3255 ListIterator li
= l
.listIterator();
3256 while(li
.hasNext()) {
3257 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)li
.next();
3258 if (!fi
.getType().toString().equals(type
) && !type
.equals("ALL")) {
3261 setFvImagesFvImageNameValue (fi
, name
, value
, null);
3266 public void setFvImagesFvImageNameValue (int i
, String name
, String value
) {
3267 XmlObject o
= getfpdFlash().getFvImages();
3271 XmlCursor cursor
= o
.newCursor();
3272 QName qFvImage
= new QName(xmlNs
, "FvImage");
3273 if (cursor
.toChild(qFvImage
)) {
3274 for (int j
= 0; j
< i
; ++j
) {
3275 cursor
.toNextSibling(qFvImage
);
3277 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
3278 setFvImagesFvImageNameValue (fi
, name
, value
, null);
3283 /**Add to FvImage the name-value pair, or replace old name with newName, or generate new name-value pair if not exists before.
3289 public void setFvImagesFvImageNameValue (FvImagesDocument
.FvImages
.FvImage fi
, String name
, String value
, String newName
) {
3290 if (fi
.getFvImageOptions() == null || fi
.getFvImageOptions().getNameValueList() == null) {
3291 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nv
= fi
.addNewFvImageOptions().addNewNameValue();
3294 if (newName
!= null) {
3295 nv
.setName(newName
);
3300 XmlCursor cursor
= fi
.getFvImageOptions().newCursor();
3301 if (cursor
.toFirstChild()) {
3303 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nv
= (FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
)cursor
.getObject();
3304 if (nv
.getName().equals(name
)) {
3306 if (newName
!= null) {
3307 nv
.setName(newName
);
3312 }while (cursor
.toNextSibling());
3315 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nv
= fi
.getFvImageOptions().addNewNameValue();
3318 if (newName
!= null) {
3319 nv
.setName(newName
);
3324 public void getFvImagesFvImageOptions (String fvName
, Map
<String
, String
> m
) {
3325 Vector
<FvImagesDocument
.FvImages
.FvImage
> vFvImage
= getFvImagesFvImageWithName (fvName
, "Options");
3326 for (int i
= 0; i
< vFvImage
.size(); ++i
) {
3327 FvImagesDocument
.FvImages
.FvImage fi
= vFvImage
.get(i
);
3328 if (fi
== null || fi
.getFvImageOptions() == null || fi
.getFvImageOptions().getNameValueList() == null) {
3332 ListIterator
<FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
> li
= fi
.getFvImageOptions()
3335 while (li
.hasNext()) {
3336 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nv
= li
.next();
3337 m
.put(nv
.getName(), nv
.getValue());
3342 public int getFvImagePosInFvImages (String fvNameList
, String type
) {
3343 XmlObject o
= getfpdFlash().getFvImages();
3349 String
[] fvNameArray
= fvNameList
.trim().split(" ");
3350 Vector
<String
> vFvNames
= new Vector
<String
>();
3353 XmlCursor cursor
= o
.newCursor();
3354 QName qFvImage
= new QName(xmlNs
, "FvImage");
3355 if (cursor
.toChild(qFvImage
)) {
3358 vFvNames
.removeAllElements();
3359 for (int i
= 0; i
< fvNameArray
.length
; ++i
) {
3360 vFvNames
.add(fvNameArray
[i
]);
3362 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
3363 if (!fi
.getType().toString().equals(type
)) {
3366 if (fi
.getFvImageNamesList() == null || fi
.getFvImageNamesList().size() != vFvNames
.size()) {
3369 ListIterator
<String
> li
= fi
.getFvImageNamesList().listIterator();
3370 while (li
.hasNext()) {
3371 String name
= li
.next();
3372 vFvNames
.remove(name
);
3374 if (vFvNames
.size() == 0) {
3379 }while (cursor
.toNextSibling(qFvImage
));
3385 /**Get FvImage Options for FvImage i
3386 * @param i the ith FvImage
3388 public void getFvImagesFvImageOptions(int i
, Map
<String
, String
> m
) {
3389 XmlObject o
= getfpdFlash().getFvImages();
3393 XmlCursor cursor
= o
.newCursor();
3394 QName qFvImage
= new QName(xmlNs
, "FvImage");
3395 if (cursor
.toChild(qFvImage
)) {
3396 for (int j
= 0; j
< i
; ++j
) {
3397 cursor
.toNextSibling(qFvImage
);
3399 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
3400 if (fi
.getFvImageOptions() == null || fi
.getFvImageOptions().getNameValueList() == null){
3404 ListIterator
<FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
> li
= fi
.getFvImageOptions().getNameValueList().listIterator();
3405 while(li
.hasNext()){
3406 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nv
= li
.next();
3407 m
.put(nv
.getName(), nv
.getValue());
3414 Get platform header element
3415 @return PlatformHeaderDocument.PlatformHeader
3417 public PlatformHeaderDocument
.PlatformHeader
getFpdHdr() {
3418 if (fpdHdr
== null) {
3419 fpdHdr
= fpdRoot
.addNewPlatformHeader();
3425 public String
getFpdHdrPlatformName() {
3426 return getFpdHdr().getPlatformName();
3429 public String
getFpdHdrGuidValue() {
3430 return getFpdHdr().getGuidValue();
3433 public String
getFpdHdrVer() {
3434 return getFpdHdr().getVersion();
3437 public String
getFpdHdrAbs() {
3438 return getFpdHdr().getAbstract();
3441 public String
getFpdHdrDescription() {
3442 return getFpdHdr().getDescription();
3445 public String
getFpdHdrCopyright() {
3446 return getFpdHdr().getCopyright();
3449 public String
getFpdHdrLicense() {
3450 LicenseDocument
.License l
= getFpdHdr().getLicense();
3454 return l
.getStringValue();
3457 public String
getFpdHdrUrl() {
3458 LicenseDocument
.License l
= getFpdHdr().getLicense();
3465 public String
getFpdHdrSpec() {
3467 return "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052";
3468 // return getFpdHdr().getSpecification();
3471 public void setFpdHdrPlatformName(String name
){
3472 getFpdHdr().setPlatformName(name
);
3475 public void setFpdHdrGuidValue(String guid
){
3476 getFpdHdr().setGuidValue(guid
);
3479 public void setFpdHdrVer(String v
){
3480 getFpdHdr().setVersion(v
);
3483 public void setFpdHdrAbs(String abs
) {
3484 getFpdHdr().setAbstract(abs
);
3487 public void setFpdHdrDescription(String desc
){
3488 getFpdHdr().setDescription(desc
);
3491 public void setFpdHdrCopyright(String cr
) {
3492 getFpdHdr().setCopyright(cr
);
3495 public void setFpdHdrLicense(String license
){
3496 LicenseDocument
.License l
= getFpdHdr().getLicense();
3498 getFpdHdr().addNewLicense().setStringValue(license
);
3501 l
.setStringValue(license
);
3505 public void setFpdHdrUrl(String url
){
3506 LicenseDocument
.License l
= getFpdHdr().getLicense();
3512 public void setFpdHdrSpec(String s
){
3513 s
= "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052";
3514 getFpdHdr().setSpecification(s
);
3517 Save the processed xml contents to file
3519 @param fpdFile The file to save xml contents
3520 @throws IOException Exceptions during file operation
3522 public void saveAs(File fpdFile
) throws IOException
{
3524 XmlOptions options
= new XmlOptions();
3526 options
.setCharacterEncoding("UTF-8");
3527 options
.setSavePrettyPrint();
3528 options
.setSavePrettyPrintIndent(2);
3530 fpdd
.save(fpdFile
, options
);
3531 } catch (IOException e
) {
3532 e
.printStackTrace();
3537 private String
listToString(List l
) {
3542 ListIterator li
= l
.listIterator();
3543 while(li
.hasNext()) {
3550 private void removeElement(XmlObject o
) {
3551 XmlCursor cursor
= o
.newCursor();
3557 class PcdItemTypeConflictException
extends Exception
{
3562 private static final long serialVersionUID
= 1L;
3563 private String details
= null;
3565 PcdItemTypeConflictException(String pcdName
, String info
){
3566 ModuleIdentification mi
= WorkspaceProfile
.getModuleId(info
);
3567 details
= pcdName
+ " ItemType Conflicts with " + mi
.getName() + " in Pkg " + mi
.getPackageId().getName();
3570 public String
getMessage() {
3575 class PcdDeclNotFound
extends Exception
{
3580 private static final long serialVersionUID
= 1L;
3581 private String details
= null;
3583 PcdDeclNotFound(String info
) {
3584 details
= "PcdDeclNotFound: " + info
;
3587 public String
getMessage() {
3592 class PcdValueMalFormed
extends Exception
{
3597 private static final long serialVersionUID
= 1L;
3598 private String details
= null;
3600 PcdValueMalFormed(String info
) {
3601 details
= "PcdValueMalFormed: " + info
;
3604 public String
getMessage() {