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 if (cursor
.getObject() == null) {
364 String s
= cursor
.getTextValue();
365 if (s
.matches(regExpNewLineAndSpaces
)) {
370 if (cursor
.isComment()) {
376 if (getFrameworkModulesCount() == 0) {
384 public boolean adjustPcd (int seqModuleSa
) throws Exception
{
385 boolean dataModified
= false;
386 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(seqModuleSa
);
387 int pcdCount
= getPcdDataCount(seqModuleSa
);
388 String
[][] saaModuleSaPcd
= new String
[pcdCount
][7];
389 getPcdData(seqModuleSa
, saaModuleSaPcd
);
390 String mg
= moduleSa
.getModuleGuid();
391 String mv
= moduleSa
.getModuleVersion();
392 String pg
= moduleSa
.getPackageGuid();
393 String pv
= moduleSa
.getPackageVersion();
394 String arch
= listToString(moduleSa
.getSupArchList());
396 // delete pcd in ModuleSA but not in MSA files any longer.
398 String moduleKey
= mg
+ " " + mv
+ " " + pg
+ " " + pv
+ " " + arch
;
399 int libCount
= getLibraryInstancesCount(moduleKey
);
400 String
[][] saaLib
= new String
[libCount
][5];
401 getLibraryInstances(moduleKey
, saaLib
);
402 ModuleIdentification mi
= WorkspaceProfile
.getModuleId(moduleKey
);
403 Vector
<ModuleIdentification
> vMi
= new Vector
<ModuleIdentification
>();
405 // create vector for module & library instance MIs.
408 for (int j
= 0; j
< saaLib
.length
; ++j
) {
409 String libKey
= saaLib
[j
][1] + " " + saaLib
[j
][2] + " " + saaLib
[j
][3] + " " + saaLib
[j
][4];
410 ModuleIdentification libMi
= WorkspaceProfile
.getModuleId(libKey
);
414 nextPcd
:for (int i
= 0; i
< saaModuleSaPcd
.length
; ++i
) {
416 for (int j
= 0; j
< vMi
.size(); ++j
) {
417 ModuleIdentification nextMi
= vMi
.get(j
);
418 if (WorkspaceProfile
.pcdInMsa(saaModuleSaPcd
[i
][0], saaModuleSaPcd
[i
][1], nextMi
)) {
422 removePcdData(seqModuleSa
, saaModuleSaPcd
[i
][0], saaModuleSaPcd
[i
][1]);
426 // add new Pcd from MSA file to ModuleSA.
428 for (int i
= 0; i
< vMi
.size(); ++i
) {
429 ModuleSurfaceAreaDocument
.ModuleSurfaceArea msa
= (ModuleSurfaceAreaDocument
.ModuleSurfaceArea
) WorkspaceProfile
430 .getModuleXmlObject(vMi
432 if (msa
.getPcdCoded() == null || msa
.getPcdCoded().getPcdEntryList() == null) {
435 ListIterator li
= msa
.getPcdCoded().getPcdEntryList().listIterator();
436 msaPcdIter
:while (li
.hasNext()) {
437 PcdCodedDocument
.PcdCoded
.PcdEntry msaPcd
= (PcdCodedDocument
.PcdCoded
.PcdEntry
) li
.next();
438 ArrayList
<String
> al
= getDynPcdMapValue(msaPcd
.getCName() + " " + msaPcd
.getTokenSpaceGuidCName());
440 for (int j
= 0; j
< al
.size(); ++j
) {
441 if (al
.get(j
).contains(moduleKey
)) {
447 PackageIdentification
[] depPkgs
= SurfaceAreaQuery
.getDependencePkg(null, vMi
.get(i
));
448 PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry spdPcd
= LookupPcdDeclaration(msaPcd
, depPkgs
);
449 if (spdPcd
== null) {
453 throw new PcdDeclNotFound("No Declaration for PCD Entry " + msaPcd
.getCName() + " in Module "
457 // AddItem to ModuleSA PcdBuildDefinitions
459 String defaultVal
= msaPcd
.getDefaultValue() == null ? spdPcd
.getDefaultValue()
460 : msaPcd
.getDefaultValue();
462 genPcdData(msaPcd
.getCName(), spdPcd
.getToken(), msaPcd
.getTokenSpaceGuidCName(),
463 msaPcd
.getPcdItemType().toString(), spdPcd
.getDatumType() + "", defaultVal
, moduleSa
);
472 private void maintainDynPcdMap(String pcdKey
, String moduleInfo
) {
474 ArrayList
<String
> al
= dynPcdMap
.get(pcdKey
);
478 String
[] s
= moduleInfo
.split(" ");
479 for(int i
= 0; i
< al
.size(); ++i
){
480 String consumer
= al
.get(i
);
481 if (consumer
.contains(s
[0]) && consumer
.contains(s
[2])){
482 String
[] consumerPart
= consumer
.split(" ");
483 if (!consumerPart
[4].equals(s
[4])) {
491 if (al
.size() == 0) {
492 defaultPcdValue
.remove(pcdKey
);
493 dynPcdMap
.remove(pcdKey
);
494 String
[] s1
= pcdKey
.split(" ");
495 removeDynamicPcdBuildData(s1
[0], s1
[1]);
500 // key for ModuleSA : "ModuleGuid ModuleVer PackageGuid PackageVer Arch"
502 public int getPcdDataCount (int i
){
503 ModuleSADocument
.ModuleSA msa
= getModuleSA(i
);
505 if (msa
== null || msa
.getPcdBuildDefinition() == null || msa
.getPcdBuildDefinition().getPcdDataList() == null){
508 return msa
.getPcdBuildDefinition().getPcdDataList().size();
512 public void getPcdData (int i
, String
[][] saa
) {
513 ModuleSADocument
.ModuleSA msa
= getModuleSA(i
);
515 if (msa
== null || msa
.getPcdBuildDefinition() == null || msa
.getPcdBuildDefinition().getPcdDataList() == null){
518 ListIterator
<PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
>li
= msa
.getPcdBuildDefinition().getPcdDataList().listIterator();
519 for (int k
= 0; k
< saa
.length
; ++k
) {
520 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= li
.next();
521 saa
[k
][0] = pcdData
.getCName();
522 saa
[k
][1] = pcdData
.getTokenSpaceGuidCName();
523 saa
[k
][2] = pcdData
.getItemType()+"";
524 saa
[k
][3] = pcdData
.getToken().toString();
525 saa
[k
][4] = pcdData
.getMaxDatumSize()+"";
526 saa
[k
][5] = pcdData
.getDatumType()+"";
527 saa
[k
][6] = pcdData
.getValue();
532 public void removePcdData (int seqModuleSa
, String cName
, String tsGuid
) {
533 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(seqModuleSa
);
534 if (moduleSa
== null || moduleSa
.getPcdBuildDefinition() == null){
538 String mg
= moduleSa
.getModuleGuid();
539 String mv
= moduleSa
.getModuleVersion();
540 String pg
= moduleSa
.getPackageGuid();
541 String pv
= moduleSa
.getPackageVersion();
542 String arch
= listToString(moduleSa
.getSupArchList());
543 String moduleKey
= mg
+ " " + mv
+ " " + pg
+ " " + pv
+ " " + arch
;
545 XmlCursor cursor
= moduleSa
.getPcdBuildDefinition().newCursor();
546 if (cursor
.toFirstChild()){
549 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= (PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
)cursor
.getObject();
550 if (pcdData
.getCName().equals(cName
) && pcdData
.getTokenSpaceGuidCName().equals(tsGuid
)) {
551 maintainDynPcdMap(cName
+ " " + tsGuid
, moduleKey
);
552 if (getPcdDataCount(seqModuleSa
) == 1) {
559 while(cursor
.toNextSibling());
565 public void updatePcdData (String key
, String cName
, String tsGuid
, String itemType
, String maxSize
, String value
){
566 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(key
);
567 if (moduleSa
== null || moduleSa
.getPcdBuildDefinition() == null){
571 XmlCursor cursor
= moduleSa
.getPcdBuildDefinition().newCursor();
572 if (cursor
.toFirstChild()){
574 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= (PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
)cursor
.getObject();
575 if (pcdData
.getCName().equals(cName
) && pcdData
.getTokenSpaceGuidCName().equals(tsGuid
)) {
577 // change item type while not updating dynPcdData????
579 pcdData
.setItemType(PcdItemTypes
.Enum
.forString(itemType
));
580 if(pcdData
.getDatumType().equals("VOID*")) {
581 pcdData
.setMaxDatumSize(new Integer(maxSize
));
583 pcdData
.setValue(value
);
584 defaultPcdValue
.put(cName
+ " " + tsGuid
, value
);
588 while(cursor
.toNextSibling());
593 /**Get original Pcd info from MSA & SPD files.
594 * @param mi ModuleIdentification from which MSA & SPD come
595 * @param cName PCD cName
596 * @param sa Results: HelpText, Original item type.
599 public boolean getPcdBuildDataInfo(ModuleIdentification mi
, String cName
, String tsGuid
, String
[] sa
) throws Exception
{
602 ModuleSurfaceAreaDocument
.ModuleSurfaceArea msa
= (ModuleSurfaceAreaDocument
.ModuleSurfaceArea
)WorkspaceProfile
.getModuleXmlObject(mi
);
603 if (msa
.getPcdCoded() == null) {
607 Map
<String
, XmlObject
> m
= new HashMap
<String
, XmlObject
>();
608 m
.put("ModuleSurfaceArea", msa
);
609 SurfaceAreaQuery
.setDoc(m
);
610 PackageIdentification
[] depPkgs
= SurfaceAreaQuery
.getDependencePkg(null, mi
);
612 // First look through MSA pcd entries.
614 List
<PcdCodedDocument
.PcdCoded
.PcdEntry
> l
= msa
.getPcdCoded().getPcdEntryList();
615 ListIterator li
= l
.listIterator();
616 while(li
.hasNext()) {
617 PcdCodedDocument
.PcdCoded
.PcdEntry msaPcd
= (PcdCodedDocument
.PcdCoded
.PcdEntry
)li
.next();
618 if (!msaPcd
.getCName().equals(cName
)) {
621 if (!msaPcd
.getTokenSpaceGuidCName().equals(tsGuid
)) {
624 PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry spdPcd
= LookupPcdDeclaration(msaPcd
, depPkgs
);
625 if (spdPcd
== null) {
629 throw new PcdDeclNotFound(mi
.getName() + " " + msaPcd
.getCName());
632 // Get Pcd help text and original item type.
634 sa
[0] = spdPcd
.getHelpText() + msaPcd
.getHelpText();
635 sa
[1] = msaPcd
.getPcdItemType()+"";
636 sa
[2] = msa
.getModuleDefinitions().getBinaryModule()+"";
650 private boolean multiSourcePcd (String cName
, String tsGuidCName
, String moduleKey
) {
651 int libCount
= getLibraryInstancesCount(moduleKey
);
652 String
[][] saaLib
= new String
[libCount
][5];
653 getLibraryInstances(moduleKey
, saaLib
);
654 ModuleIdentification mi
= WorkspaceProfile
.getModuleId(moduleKey
);
655 Vector
<ModuleIdentification
> vMi
= new Vector
<ModuleIdentification
>();
657 // create vector for module & library instance MIs.
660 for (int j
= 0; j
< saaLib
.length
; ++j
) {
661 String libKey
= saaLib
[j
][1] + " " + saaLib
[j
][2] + " " + saaLib
[j
][3] + " " + saaLib
[j
][4];
662 ModuleIdentification libMi
= WorkspaceProfile
.getModuleId(libKey
);
666 int pcdSourceCount
= 0;
667 for (int i
= 0; i
< vMi
.size(); ++i
) {
668 if (WorkspaceProfile
.pcdInMsa(cName
, tsGuidCName
, vMi
.get(i
))) {
673 if (pcdSourceCount
< 2) {
682 /**Remove PCDBuildDefinition entries from ModuleSA
683 * @param moduleKey identifier of ModuleSA.
684 * @param consumer where these entries come from.
686 public void removePcdData(String moduleKey
, ModuleIdentification consumer
) {
688 ModuleSurfaceAreaDocument
.ModuleSurfaceArea msa
= (ModuleSurfaceAreaDocument
.ModuleSurfaceArea
)WorkspaceProfile
.getModuleXmlObject(consumer
);
689 if (msa
.getPcdCoded() == null) {
693 List
<PcdCodedDocument
.PcdCoded
.PcdEntry
> l
= msa
.getPcdCoded().getPcdEntryList();
694 ListIterator li
= l
.listIterator();
696 while(li
.hasNext()) {
697 PcdCodedDocument
.PcdCoded
.PcdEntry msaPcd
= (PcdCodedDocument
.PcdCoded
.PcdEntry
)li
.next();
698 ModuleSADocument
.ModuleSA moduleSA
= getModuleSA(moduleKey
);
699 if (moduleSA
.getPcdBuildDefinition() != null) {
700 XmlCursor cursor
= moduleSA
.getPcdBuildDefinition().newCursor();
702 if (cursor
.toFirstChild()) {
704 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= (PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
) cursor
706 String cName
= msaPcd
.getCName();
707 String tsGuidCName
= msaPcd
.getTokenSpaceGuidCName();
708 if (cName
.equals(pcdData
.getCName())
709 && tsGuidCName
.equals(pcdData
.getTokenSpaceGuidCName()) && !multiSourcePcd(cName
, tsGuidCName
, moduleKey
)) {
711 maintainDynPcdMap(pcdData
.getCName() + " " + pcdData
.getTokenSpaceGuidCName(),
716 } while (cursor
.toNextSibling());
720 if (moduleSA
.getPcdBuildDefinition().getPcdDataList().size() == 0) {
729 // key for ModuleSA : "ModuleGuid ModuleVer PackageGuid PackageVer Arch"
731 public int getLibraryInstancesCount(String key
) {
732 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
733 if (msa
== null || msa
.getLibraries() == null || msa
.getLibraries().getInstanceList() == null){
736 return msa
.getLibraries().getInstanceList().size();
739 public void getLibraryInstances(String key
, String
[][] saa
){
740 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
741 if (msa
== null || msa
.getLibraries() == null || msa
.getLibraries().getInstanceList() == null){
745 ListIterator
<LibrariesDocument
.Libraries
.Instance
> li
= msa
.getLibraries().getInstanceList().listIterator();
746 for (int i
= 0; i
< saa
.length
; ++i
) {
747 LibrariesDocument
.Libraries
.Instance instance
= li
.next();
748 saa
[i
][1] = instance
.getModuleGuid();
749 saa
[i
][2] = instance
.getModuleVersion();
750 saa
[i
][3] = instance
.getPackageGuid();
751 saa
[i
][4] = instance
.getPackageVersion();
755 public void removeLibraryInstance(String key
, int i
) {
756 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
757 if (msa
== null || msa
.getLibraries() == null){
761 XmlCursor cursor
= msa
.getLibraries().newCursor();
762 if (cursor
.toFirstChild()) {
763 for (int j
= 0; j
< i
; ++j
) {
764 cursor
.toNextSibling();
767 while (cursor
.hasPrevToken()) {
768 cursor
.toPrevToken();
769 if (!cursor
.isText()) {
772 String s
= cursor
.getTextValue();
773 if (s
.matches(regExpNewLineAndSpaces
)) {
778 if (cursor
.isComment()) {
783 if (getLibraryInstancesCount(key
) == 0) {
792 public void genLibraryInstance(ModuleIdentification libMi
, String key
) {
793 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
795 msa
= getfpdFrameworkModules().addNewModuleSA();
797 LibrariesDocument
.Libraries libs
= msa
.getLibraries();
799 libs
= msa
.addNewLibraries();
802 String mn
= libMi
.getName();
803 String mg
= libMi
.getGuid();
804 String mv
= libMi
.getVersion();
805 String pn
= libMi
.getPackageId().getName();
806 String pg
= libMi
.getPackageId().getGuid();
807 String pv
= libMi
.getPackageId().getVersion();
808 LibrariesDocument
.Libraries
.Instance instance
= libs
.addNewInstance();
809 XmlCursor cursor
= instance
.newCursor();
811 String comment
= "Pkg: " + pn
+ " Mod: " + mn
812 + " Path: " + libMi
.getPath().substring(System
.getenv("WORKSPACE").length() + 1);
813 cursor
.insertComment(comment
);
822 instance
.setModuleGuid(mg
);
823 instance
.setModuleVersion(mv
);
824 instance
.setPackageGuid(pg
);
825 instance
.setPackageVersion(pv
);
829 public String
getFvBinding(String moduleKey
){
830 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(moduleKey
);
831 return getFvBinding (moduleSa
);
834 public String
getFvBinding (ModuleSADocument
.ModuleSA moduleSa
) {
835 if (moduleSa
== null || moduleSa
.getModuleSaBuildOptions() == null) {
838 return moduleSa
.getModuleSaBuildOptions().getFvBinding();
841 public void setFvBinding(ModuleSADocument
.ModuleSA moduleSa
, String fvBinding
) {
842 if (moduleSa
== null ) {
845 if (fvBinding
== null || fvBinding
.length() == 0) {
846 if(moduleSa
.getModuleSaBuildOptions() != null){
847 moduleSa
.getModuleSaBuildOptions().unsetFvBinding();
851 if(moduleSa
.getModuleSaBuildOptions() == null){
852 moduleSa
.addNewModuleSaBuildOptions().setFvBinding(fvBinding
);
855 moduleSa
.getModuleSaBuildOptions().setFvBinding(fvBinding
);
859 public void setFvBinding(String moduleKey
, String fvBinding
){
860 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(moduleKey
);
861 setFvBinding (moduleSa
, fvBinding
);
864 private int fvBindingForModuleSA (ModuleSADocument
.ModuleSA moduleSa
, String fvName
) {
865 if (moduleSa
== null || moduleSa
.getModuleSaBuildOptions() == null || moduleSa
.getModuleSaBuildOptions().getFvBinding() == null) {
869 String fvNameList
= moduleSa
.getModuleSaBuildOptions().getFvBinding();
870 String
[] fvNamesArray
= fvNameList
.split(" ");
872 for (int i
= 0; i
< fvNamesArray
.length
; ++i
) {
873 if (fvNamesArray
[i
].equals(fvName
)) {
881 public void removeFvBinding (ModuleSADocument
.ModuleSA moduleSa
, String fvName
) {
882 if (moduleSa
== null || moduleSa
.getModuleSaBuildOptions() == null || moduleSa
.getModuleSaBuildOptions().getFvBinding() == null) {
886 String fvNameList
= moduleSa
.getModuleSaBuildOptions().getFvBinding();
887 String
[] fvNamesArray
= fvNameList
.split(" ");
889 for (int i
= 0; i
< fvNamesArray
.length
; ++i
) {
890 if (fvNamesArray
[i
].equals(fvName
)) {
895 // jump over where the input fvName occurs in the original Fv list.
896 if (occursAt
!= -1) {
897 String newFvNameList
= " ";
898 for (int i
= 0; i
< fvNamesArray
.length
; ++i
) {
902 newFvNameList
+= fvNamesArray
[i
];
904 setFvBinding (moduleSa
, newFvNameList
.trim());
910 * @param fvName The FV name that to be removed from FvBinding List.
912 public void removeFvBindingAll (String fvName
) {
913 if (getfpdFrameworkModules().getModuleSAList() == null || getfpdFrameworkModules().getModuleSAList().size() == 0){
914 removeElement(getfpdFrameworkModules());
915 fpdFrameworkModules
= null;
919 Iterator
<ModuleSADocument
.ModuleSA
> li
= getfpdFrameworkModules().getModuleSAList().iterator();
920 while (li
.hasNext()) {
921 ModuleSADocument
.ModuleSA moduleSa
= li
.next();
922 removeFvBinding (moduleSa
, fvName
);
926 public void appendFvBindingAll (String fvName
) {
927 if (getfpdFrameworkModules().getModuleSAList() == null || getfpdFrameworkModules().getModuleSAList().size() == 0){
928 removeElement(getfpdFrameworkModules());
929 fpdFrameworkModules
= null;
933 Iterator
<ModuleSADocument
.ModuleSA
> li
= getfpdFrameworkModules().getModuleSAList().iterator();
934 while (li
.hasNext()) {
935 ModuleSADocument
.ModuleSA moduleSa
= li
.next();
936 appendFvBinding (moduleSa
, fvName
);
940 public void appendFvBindingFor (String oldFvName
, String newFvName
) {
941 if (getfpdFrameworkModules().getModuleSAList() == null || getfpdFrameworkModules().getModuleSAList().size() == 0){
942 removeElement(getfpdFrameworkModules());
943 fpdFrameworkModules
= null;
947 Iterator
<ModuleSADocument
.ModuleSA
> li
= getfpdFrameworkModules().getModuleSAList().iterator();
948 while (li
.hasNext()) {
949 ModuleSADocument
.ModuleSA moduleSa
= li
.next();
950 String fvBinding
= getFvBinding (moduleSa
);
951 if (fvBinding
!= null && fvBindingForModuleSA (moduleSa
, oldFvName
) >= 0) {
952 appendFvBinding (moduleSa
, newFvName
);
957 public void appendFvBinding (String moduleKey
, String fvName
) {
958 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(moduleKey
);
959 appendFvBinding (moduleSa
, fvName
);
962 public void appendFvBinding (ModuleSADocument
.ModuleSA moduleSa
, String fvName
) {
963 if (moduleSa
== null) {
967 if (moduleSa
.getModuleSaBuildOptions() == null || moduleSa
.getModuleSaBuildOptions().getFvBinding() == null) {
968 setFvBinding(moduleSa
, fvName
);
972 String fvNameList
= moduleSa
.getModuleSaBuildOptions().getFvBinding();
973 String newFvNameList
= fvNameList
+ " " + fvName
;
974 setFvBinding (moduleSa
, newFvNameList
.trim());
977 public void updateFvBindingInModuleSA (String moduleKey
, String fvName
) {
979 appendFvBinding (moduleKey
, fvName
);
982 public String
getFfsFileNameGuid(String moduleKey
){
983 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(moduleKey
);
984 if (moduleSa
== null || moduleSa
.getModuleSaBuildOptions() == null) {
987 return moduleSa
.getModuleSaBuildOptions().getFfsFileNameGuid();
990 public void setFfsFileNameGuid(String moduleKey
, String fileGuid
){
991 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
995 if(msa
.getModuleSaBuildOptions() == null){
996 msa
.addNewModuleSaBuildOptions();
999 ModuleSaBuildOptionsDocument
.ModuleSaBuildOptions msaBuildOpts
= msa
.getModuleSaBuildOptions();
1000 if (fileGuid
!= null) {
1001 msaBuildOpts
.setFfsFileNameGuid(fileGuid
);
1004 XmlCursor cursor
= msaBuildOpts
.newCursor();
1005 if (cursor
.toChild(xmlNs
, "FfsFileNameGuid")) {
1013 public String
getFfsFormatKey(String moduleKey
){
1014 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
1015 if (msa
== null || msa
.getModuleSaBuildOptions() == null) {
1018 return msa
.getModuleSaBuildOptions().getFfsFormatKey();
1021 public void setFfsFormatKey(String moduleKey
, String ffsKey
){
1022 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
1026 if(msa
.getModuleSaBuildOptions() == null){
1027 msa
.addNewModuleSaBuildOptions().setFfsFormatKey(ffsKey
);
1030 msa
.getModuleSaBuildOptions().setFfsFormatKey(ffsKey
);
1033 public void setModuleSAForceDebug(int i
, boolean dbgEnable
) {
1034 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(i
);
1035 moduleSa
.setForceDebug(dbgEnable
);
1038 public boolean getModuleSAForceDebug (int i
) {
1039 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(i
);
1040 if (moduleSa
.getForceDebug() == true) {
1046 public void getModuleSAOptions(String moduleKey
, String
[][] saa
) {
1047 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
1048 if (msa
== null || msa
.getModuleSaBuildOptions() == null || msa
.getModuleSaBuildOptions().getOptions() == null
1049 || msa
.getModuleSaBuildOptions().getOptions().getOptionList() == null) {
1053 List
<OptionDocument
.Option
> lOpt
= msa
.getModuleSaBuildOptions().getOptions().getOptionList();
1054 ListIterator li
= lOpt
.listIterator();
1056 while(li
.hasNext()) {
1057 OptionDocument
.Option opt
= (OptionDocument
.Option
)li
.next();
1058 if (opt
.getBuildTargets() != null) {
1059 saa
[i
][0] = listToString(opt
.getBuildTargets());
1061 saa
[i
][1] = opt
.getToolChainFamily();
1062 saa
[i
][2] = opt
.getTagName();
1063 saa
[i
][3] = opt
.getToolCode();
1065 if (opt
.getSupArchList() != null){
1066 saa
[i
][4] = listToString(opt
.getSupArchList());
1072 saa
[i
][5] = opt
.getStringValue();
1078 public int getModuleSAOptionsCount(String moduleKey
){
1079 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
1080 if (msa
== null || msa
.getModuleSaBuildOptions() == null || msa
.getModuleSaBuildOptions().getOptions() == null
1081 || msa
.getModuleSaBuildOptions().getOptions().getOptionList() == null) {
1084 return msa
.getModuleSaBuildOptions().getOptions().getOptionList().size();
1087 public void genModuleSAOptionsOpt(String moduleKey
, Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
) {
1088 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
1089 if (msa
.getModuleSaBuildOptions() == null) {
1090 msa
.addNewModuleSaBuildOptions();
1092 if (msa
.getModuleSaBuildOptions().getOptions() == null){
1093 msa
.getModuleSaBuildOptions().addNewOptions();
1095 OptionDocument
.Option opt
= msa
.getModuleSaBuildOptions().getOptions().addNewOption();
1096 setBuildOptionsOpt(buildTargets
, toolChain
, tagName
, toolCmd
, archList
, contents
, opt
);
1099 public void removeModuleSAOptionsOpt(String moduleKey
, int i
) {
1100 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
1101 if (msa
.getModuleSaBuildOptions() == null || msa
.getModuleSaBuildOptions().getOptions() == null) {
1104 OptionsDocument
.Options opts
= msa
.getModuleSaBuildOptions().getOptions();
1105 XmlCursor cursor
= opts
.newCursor();
1106 if (cursor
.toFirstChild()) {
1107 for (int j
= 0; j
< i
; ++j
){
1108 cursor
.toNextSibling();
1111 if (getModuleSAOptionsCount(moduleKey
) == 0) {
1119 public void updateModuleSAOptionsOpt(String moduleKey
, int i
, Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
) {
1120 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
1121 if (msa
.getModuleSaBuildOptions() == null || msa
.getModuleSaBuildOptions().getOptions() == null) {
1124 OptionsDocument
.Options opts
= msa
.getModuleSaBuildOptions().getOptions();
1125 XmlCursor cursor
= opts
.newCursor();
1126 if (cursor
.toFirstChild()) {
1127 for (int j
= 0; j
< i
; ++j
){
1128 cursor
.toNextSibling();
1130 OptionDocument
.Option opt
= (OptionDocument
.Option
)cursor
.getObject();
1131 setBuildOptionsOpt(buildTargets
, toolChain
, tagName
, toolCmd
, archList
, contents
, opt
);
1136 /**add pcd information of module mi to a ModuleSA.
1138 * @param moduleSa if null, generate a new ModuleSA.
1140 public void addFrameworkModulesPcdBuildDefs(ModuleIdentification mi
, String arch
, ModuleSADocument
.ModuleSA moduleSa
) throws Exception
{
1141 //ToDo add Arch filter
1144 if (moduleSa
== null) {
1145 moduleSa
= genModuleSA(mi
, arch
);
1148 ModuleSurfaceAreaDocument
.ModuleSurfaceArea msa
= (ModuleSurfaceAreaDocument
.ModuleSurfaceArea
)WorkspaceProfile
.getModuleXmlObject(mi
);
1149 if (msa
.getPcdCoded() == null) {
1153 Map
<String
, XmlObject
> m
= new HashMap
<String
, XmlObject
>();
1154 m
.put("ModuleSurfaceArea", msa
);
1155 SurfaceAreaQuery
.setDoc(m
);
1156 PackageIdentification
[] depPkgs
= SurfaceAreaQuery
.getDependencePkg(null, mi
);
1158 // Implementing InitializePlatformPcdBuildDefinitions
1160 List
<PcdCodedDocument
.PcdCoded
.PcdEntry
> l
= msa
.getPcdCoded().getPcdEntryList();
1161 ListIterator li
= l
.listIterator();
1162 while(li
.hasNext()) {
1163 PcdCodedDocument
.PcdCoded
.PcdEntry msaPcd
= (PcdCodedDocument
.PcdCoded
.PcdEntry
)li
.next();
1164 PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry spdPcd
= LookupPcdDeclaration(msaPcd
, depPkgs
);
1165 if (spdPcd
== null) {
1169 throw new PcdDeclNotFound("No Declaration for PCD Entry " + msaPcd
.getCName() + " in Module " + mi
.getName());
1172 // AddItem to ModuleSA PcdBuildDefinitions
1174 String defaultVal
= msaPcd
.getDefaultValue() == null ? spdPcd
.getDefaultValue() : msaPcd
.getDefaultValue();
1176 genPcdData(msaPcd
.getCName(), spdPcd
.getToken(), msaPcd
.getTokenSpaceGuidCName(), msaPcd
.getPcdItemType().toString(), spdPcd
.getDatumType()+"", defaultVal
, moduleSa
);
1180 catch (Exception e
){
1187 private PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry
LookupPcdDeclaration (PcdCodedDocument
.PcdCoded
.PcdEntry msaPcd
, PackageIdentification
[] depPkgs
) {
1189 PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry spdPcd
= null;
1190 for (int i
= 0; i
< depPkgs
.length
; ++i
) {
1192 XmlObject
[] xo
= SurfaceAreaQuery
.getSpdPcdDeclarations(depPkgs
[i
]);
1196 for (int j
= 0; j
< xo
.length
; ++j
) {
1197 spdPcd
= (PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry
)xo
[j
];
1198 if (msaPcd
.getTokenSpaceGuidCName() == null) {
1199 if (spdPcd
.getCName().equals(msaPcd
.getCName())) {
1204 if (spdPcd
.getCName().equals(msaPcd
.getCName()) && spdPcd
.getTokenSpaceGuidCName().equals(msaPcd
.getTokenSpaceGuidCName())) {
1215 private ModuleSADocument
.ModuleSA
genModuleSA (ModuleIdentification mi
, String arch
) {
1216 PackageIdentification pi
= WorkspaceProfile
.getPackageForModule(mi
);
1217 ModuleSADocument
.ModuleSA msa
= getfpdFrameworkModules().addNewModuleSA();
1218 XmlCursor cursor
= msa
.newCursor();
1220 String comment
= "Mod: " + mi
.getName() + " Type: " + SurfaceAreaQuery
.getModuleType(mi
) + " Path: "
1221 + mi
.getPath().substring(System
.getenv("WORKSPACE").length() + 1);
1222 cursor
.insertComment(comment
);
1225 e
.printStackTrace();
1230 msa
.setModuleGuid(mi
.getGuid());
1231 msa
.setModuleVersion(mi
.getVersion());
1232 msa
.setPackageGuid(pi
.getGuid());
1233 msa
.setPackageVersion(pi
.getVersion());
1235 Vector
<String
> v
= new Vector
<String
>();
1237 msa
.setSupArchList(v
);
1243 private void genPcdData (String cName
, Object token
, String tsGuid
, String itemType
, String dataType
, String defaultVal
, ModuleSADocument
.ModuleSA moduleSa
)
1244 throws PcdItemTypeConflictException
, PcdValueMalFormed
{
1245 if (moduleSa
.getPcdBuildDefinition() == null){
1246 moduleSa
.addNewPcdBuildDefinition();
1249 // constructe pcd to modulesa mapping first.
1250 // Attention : for any error condition, remove from map this pcd.
1252 ArrayList
<String
> pcdConsumer
= LookupPlatformPcdData(cName
+ " " + tsGuid
);
1253 if (pcdConsumer
== null) {
1254 pcdConsumer
= new ArrayList
<String
>();
1257 // Check whether this PCD has already added to ModuleSA, if so, just return.
1259 String moduleInfo
= moduleSa
.getModuleGuid().toLowerCase() + " " + moduleSa
.getModuleVersion()
1260 + " " + moduleSa
.getPackageGuid().toLowerCase() + " " + moduleSa
.getPackageVersion() + " " + listToString(moduleSa
.getSupArchList());
1261 for (int i
= 0; i
< pcdConsumer
.size(); ++i
) {
1262 String pcdInfo
= pcdConsumer
.get(i
);
1263 if (moduleInfo
.equals(pcdInfo
.substring(0, pcdInfo
.lastIndexOf(" ")))){
1268 // Using existing Pcd type, if this pcd already exists in other ModuleSA
1270 if (pcdConsumer
.size() > 0) {
1272 itemType
= itemType (pcdConsumer
.get(0));
1274 String listValue
= moduleInfo
+ " " + itemType
;
1275 pcdConsumer
.add(listValue
);
1276 dynPcdMap
.put(cName
+ " " + tsGuid
, pcdConsumer
);
1278 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData fpdPcd
= moduleSa
.getPcdBuildDefinition().addNewPcdData();
1279 fpdPcd
.setCName(cName
);
1280 fpdPcd
.setToken(token
);
1281 fpdPcd
.setTokenSpaceGuidCName(tsGuid
);
1282 fpdPcd
.setDatumType(PcdDataTypes
.Enum
.forString(dataType
));
1283 fpdPcd
.setItemType(PcdItemTypes
.Enum
.forString(itemType
));
1285 if (defaultVal
!= null){
1286 fpdPcd
.setValue(defaultVal
);
1289 if (dataType
.equals("UINT8") || dataType
.equals("UINT16") || dataType
.equals("UINT32") || dataType
.equals("UINT64")) {
1290 fpdPcd
.setValue("0");
1292 if (dataType
.equals("BOOLEAN")){
1293 fpdPcd
.setValue("FALSE");
1295 if (dataType
.equals("VOID*")) {
1296 fpdPcd
.setValue("");
1300 // Using existing pcd value, if this pcd already exists in other moduleSa.
1302 if (defaultPcdValue
.get(cName
+ " " + tsGuid
) == null) {
1303 defaultPcdValue
.put(cName
+ " " + tsGuid
, fpdPcd
.getValue());
1306 fpdPcd
.setValue(defaultPcdValue
.get(cName
+ " " + tsGuid
));
1309 if (dataType
.equals("UINT8")){
1310 fpdPcd
.setMaxDatumSize(1);
1312 if (dataType
.equals("UINT16")) {
1313 fpdPcd
.setMaxDatumSize(2);
1315 if (dataType
.equals("UINT32")) {
1316 fpdPcd
.setMaxDatumSize(4);
1318 if (dataType
.equals("UINT64")){
1319 fpdPcd
.setMaxDatumSize(8);
1321 if (dataType
.equals("BOOLEAN")){
1322 fpdPcd
.setMaxDatumSize(1);
1324 if (dataType
.equals("VOID*")) {
1325 int maxSize
= setMaxSizeForPointer(fpdPcd
.getValue());
1326 fpdPcd
.setMaxDatumSize(maxSize
);
1330 if (itemType
.equals("DYNAMIC") || itemType
.equals("DYNAMIC_EX")) {
1331 ArrayList
<String
> al
= LookupDynamicPcdBuildDefinition(cName
+ " " + tsGuid
);
1333 // if only one module mapped to this pcd, then the one is myself. so no other module mapped.
1334 // so need to add one dyn pcd.
1336 if (al
.size() == 1) {
1337 addDynamicPcdBuildData(cName
, token
, tsGuid
, itemType
, dataType
, defaultVal
);
1343 public int setMaxSizeForPointer(String datum
) throws PcdValueMalFormed
{
1344 if (datum
== null) {
1347 char ch
= datum
.charAt(0);
1351 // For void* type PCD, only three datum is support:
1352 // 1) Unicode: string with start char is "L"
1353 // 2) Ansci: String is ""
1354 // 3) byte array: String start char "{"
1357 start
= datum
.indexOf('\"');
1358 end
= datum
.lastIndexOf('\"');
1359 if ((start
> end
) ||
1360 (end
> datum
.length())||
1361 ((start
== end
) && (datum
.length() > 0))) {
1362 //ToDo Error handling here
1363 throw new PcdValueMalFormed (datum
);
1366 strValue
= datum
.substring(start
+ 1, end
);
1367 return strValue
.length() * 2;
1368 } else if (ch
== '\"'){
1369 start
= datum
.indexOf('\"');
1370 end
= datum
.lastIndexOf('\"');
1371 if ((start
> end
) ||
1372 (end
> datum
.length())||
1373 ((start
== end
) && (datum
.length() > 0))) {
1374 throw new PcdValueMalFormed (datum
);
1376 strValue
= datum
.substring(start
+ 1, end
);
1377 return strValue
.length();
1378 } else if (ch
=='{') {
1379 String
[] strValueArray
;
1381 start
= datum
.indexOf('{');
1382 end
= datum
.lastIndexOf('}');
1383 strValue
= datum
.substring(start
+ 1, end
);
1384 strValue
= strValue
.trim();
1385 if (strValue
.length() == 0) {
1388 strValueArray
= strValue
.split(",");
1389 for (int index
= 0; index
< strValueArray
.length
; index
++) {
1390 Integer value
= Integer
.decode(strValueArray
[index
].trim());
1393 // "[FPD file error] The datum type of PCD %s in %s is VOID*, "+
1394 // "it must be a byte array. But the element of %s exceed the byte range",
1395 throw new PcdValueMalFormed (datum
);
1398 return strValueArray
.length
;
1402 // "[FPD file error] The datum type of PCD %s in %s is VOID*. For VOID* type, you have three format choise:\n "+
1403 // "1) UNICODE string: like L\"xxxx\";\r\n"+
1404 // "2) ANSIC string: like \"xxx\";\r\n"+
1405 // "3) Byte array: like {0x2, 0x45, 0x23}\r\n"+
1406 // "but the datum in seems does not following above format!",
1407 throw new PcdValueMalFormed (datum
);
1412 private ArrayList
<String
> LookupDynamicPcdBuildDefinition(String dynPcdKey
) {
1413 ArrayList
<String
> al
= dynPcdMap
.get(dynPcdKey
);
1418 private ArrayList
<String
> LookupPlatformPcdData(String pcdKey
) {
1420 return dynPcdMap
.get(pcdKey
);
1423 public int getDynamicPcdBuildDataCount() {
1424 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1425 removeElement(getfpdDynPcdBuildDefs());
1426 fpdDynPcdBuildDefs
= null;
1429 return getfpdDynPcdBuildDefs().getPcdBuildDataList().size();
1432 public void getDynamicPcdBuildData(String
[][] saa
) {
1433 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1434 removeElement(getfpdDynPcdBuildDefs());
1435 fpdDynPcdBuildDefs
= null;
1438 List
<DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
> l
= getfpdDynPcdBuildDefs().getPcdBuildDataList();
1439 ListIterator
<DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
> li
= l
.listIterator();
1441 while(li
.hasNext()) {
1442 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData dynPcd
= li
.next();
1443 saa
[i
][0] = dynPcd
.getCName();
1444 saa
[i
][1] = dynPcd
.getToken().toString();
1445 saa
[i
][2] = dynPcd
.getTokenSpaceGuidCName();
1446 saa
[i
][3] = dynPcd
.getMaxDatumSize()+"";
1447 saa
[i
][4] = dynPcd
.getDatumType().toString();
1453 public void addDynamicPcdBuildData(String cName
, Object token
, String tsGuid
, String itemType
, String dataType
, String defaultVal
)
1454 throws PcdValueMalFormed
{
1455 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData dynPcdData
= getfpdDynPcdBuildDefs().addNewPcdBuildData();
1456 dynPcdData
.setItemType(PcdItemTypes
.Enum
.forString(itemType
));
1457 dynPcdData
.setCName(cName
);
1458 dynPcdData
.setToken(token
);
1459 dynPcdData
.setTokenSpaceGuidCName(tsGuid
);
1460 dynPcdData
.setDatumType(PcdDataTypes
.Enum
.forString(dataType
));
1462 BigInteger bigInt
= new BigInteger("0");
1463 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo skuInfo
= dynPcdData
.addNewSkuInfo();
1464 skuInfo
.setSkuId(bigInt
);
1465 if (defaultVal
!= null){
1466 skuInfo
.setValue(defaultVal
);
1469 if (dataType
.equals("UINT8")){
1470 skuInfo
.setValue("0");
1472 if (dataType
.equals("UINT16")) {
1473 skuInfo
.setValue("0");
1475 if (dataType
.equals("UINT32")) {
1476 skuInfo
.setValue("0");
1478 if (dataType
.equals("UINT64")){
1479 skuInfo
.setValue("0");
1481 if (dataType
.equals("BOOLEAN")){
1482 skuInfo
.setValue("false");
1484 if (dataType
.equals("VOID*")) {
1485 skuInfo
.setValue("");
1488 if (dataType
.equals("UINT8")){
1489 dynPcdData
.setMaxDatumSize(1);
1491 if (dataType
.equals("UINT16")) {
1492 dynPcdData
.setMaxDatumSize(2);
1494 if (dataType
.equals("UINT32")) {
1495 dynPcdData
.setMaxDatumSize(4);
1497 if (dataType
.equals("UINT64")){
1498 dynPcdData
.setMaxDatumSize(8);
1500 if (dataType
.equals("BOOLEAN")){
1501 dynPcdData
.setMaxDatumSize(1);
1503 if (dataType
.equals("VOID*")) {
1504 int maxSize
= setMaxSizeForPointer(defaultVal
);
1505 dynPcdData
.setMaxDatumSize(maxSize
);
1509 public void removeDynamicPcdBuildData(String cName
, String tsGuid
) {
1510 XmlObject o
= fpdRoot
.getDynamicPcdBuildDefinitions();
1515 XmlCursor cursor
= o
.newCursor();
1516 if (cursor
.toFirstChild()) {
1518 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdBuildData
=
1519 (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1520 if (pcdBuildData
.getCName().equals(cName
) && pcdBuildData
.getTokenSpaceGuidCName().equals(tsGuid
)) {
1522 if (getDynamicPcdBuildDataCount() == 1) {
1530 while (cursor
.toNextSibling());
1535 // Get the Sku Info count of ith dyn pcd element.
1537 public int getDynamicPcdSkuInfoCount(int i
){
1538 if (fpdRoot
.getDynamicPcdBuildDefinitions() == null || fpdRoot
.getDynamicPcdBuildDefinitions().getPcdBuildDataList() == null
1539 || fpdRoot
.getDynamicPcdBuildDefinitions().getPcdBuildDataList().size() == 0) {
1543 int skuInfoCount
= 0;
1544 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1545 if (cursor
.toFirstChild()) {
1546 for (int j
= 0; j
< i
; ++j
) {
1547 cursor
.toNextSibling();
1549 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1550 if (pcdData
.getSkuInfoList() == null) {
1554 skuInfoCount
= pcdData
.getSkuInfoList().size();
1558 return skuInfoCount
;
1561 public void getDynamicPcdSkuInfos(int i
, String
[][] saa
){
1562 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1563 removeElement(getfpdDynPcdBuildDefs());
1564 fpdDynPcdBuildDefs
= null;
1568 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1569 if (cursor
.toFirstChild()) {
1570 for (int j
= 0; j
< i
; ++j
) {
1571 cursor
.toNextSibling();
1573 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1574 if (pcdData
.getSkuInfoList() == null) {
1579 ListIterator
<DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo
> li
= pcdData
.getSkuInfoList().listIterator();
1581 while (li
.hasNext()) {
1582 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo skuInfo
= li
.next();
1583 saa
[k
][0] = skuInfo
.getSkuId()+"";
1584 saa
[k
][1] = skuInfo
.getVariableName();
1585 saa
[k
][2] = skuInfo
.getVariableGuid();
1586 saa
[k
][3] = skuInfo
.getVariableOffset();
1587 saa
[k
][4] = skuInfo
.getHiiDefaultValue();
1588 saa
[k
][5] = skuInfo
.getVpdOffset();
1589 saa
[k
][6] = skuInfo
.getValue();
1599 public String
getDynamicPcdBuildDataValue(int i
){
1600 String value
= null;
1601 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1602 removeElement(getfpdDynPcdBuildDefs());
1603 fpdDynPcdBuildDefs
= null;
1607 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1608 if (cursor
.toFirstChild()) {
1609 for (int j
= 0; j
< i
; ++j
) {
1610 cursor
.toNextSibling();
1612 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1613 if (pcdData
.getSkuInfoList() == null) {
1617 value
= pcdData
.getSkuInfoArray(0).getValue();
1624 public String
getDynamicPcdBuildDataVpdOffset(int i
){
1625 String vpdOffset
= null;
1626 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1627 removeElement(getfpdDynPcdBuildDefs());
1628 fpdDynPcdBuildDefs
= null;
1632 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1633 if (cursor
.toFirstChild()) {
1634 for (int j
= 0; j
< i
; ++j
) {
1635 cursor
.toNextSibling();
1637 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1638 if (pcdData
.getSkuInfoList() == null) {
1642 vpdOffset
= pcdData
.getSkuInfoArray(0).getVpdOffset();
1649 public void removeDynamicPcdBuildDataSkuInfo(int i
) {
1650 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1651 removeElement(getfpdDynPcdBuildDefs());
1652 fpdDynPcdBuildDefs
= null;
1656 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1657 if (cursor
.toFirstChild()) {
1658 for (int j
= 0; j
< i
; ++j
) {
1659 cursor
.toNextSibling();
1661 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1662 if (pcdData
.getSkuInfoList() == null) {
1667 QName qSkuInfo
= new QName(xmlNs
, "SkuInfo");
1668 cursor
.toChild(qSkuInfo
);
1675 // generate sku info for ith dyn pcd build data.
1677 public void genDynamicPcdBuildDataSkuInfo(String id
, String varName
, String varGuid
, String varOffset
,
1678 String hiiDefault
, String vpdOffset
, String value
, int i
) {
1679 // if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1683 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1684 if (cursor
.toFirstChild()) {
1685 for (int j
= 0; j
< i
; ++j
) {
1686 cursor
.toNextSibling();
1688 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1689 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo skuInfo
= pcdData
.addNewSkuInfo();
1690 skuInfo
.setSkuId(new BigInteger(id
));
1691 if (varName
!= null){
1692 skuInfo
.setVariableName(varName
);
1693 skuInfo
.setVariableGuid(varGuid
);
1694 skuInfo
.setVariableOffset(varOffset
);
1695 skuInfo
.setHiiDefaultValue(hiiDefault
);
1697 else if (vpdOffset
!= null){
1698 skuInfo
.setVpdOffset(vpdOffset
);
1701 skuInfo
.setValue(value
);
1706 public void updateDynamicPcdBuildDataSkuInfo(String id
, String varName
, String varGuid
, String varOffset
,
1707 String hiiDefault
, String vpdOffset
, String value
, int i
){
1708 // if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1712 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1713 if (cursor
.toFirstChild()) {
1714 for (int j
= 0; j
< i
; ++j
) {
1715 cursor
.toNextSibling();
1717 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1718 ListIterator
<DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo
> li
= pcdData
.getSkuInfoList().listIterator();
1719 while (li
.hasNext()) {
1720 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo skuInfo
= li
.next();
1721 if (skuInfo
.getSkuId().toString().equals(id
)){
1722 if (varName
!= null){
1723 skuInfo
.setVariableName(varName
);
1724 skuInfo
.setVariableGuid(varGuid
);
1725 skuInfo
.setVariableOffset(varOffset
);
1726 skuInfo
.setHiiDefaultValue(hiiDefault
);
1728 else if (vpdOffset
!= null){
1729 skuInfo
.setVpdOffset(vpdOffset
);
1732 skuInfo
.setValue(value
);
1740 public BuildOptionsDocument
.BuildOptions
getfpdBuildOpts() {
1741 if (fpdBuildOpts
== null) {
1742 fpdBuildOpts
= fpdRoot
.addNewBuildOptions();
1744 return fpdBuildOpts
;
1747 public void genBuildOptionsUserExtensions(String fvName
, String outputFileName
, Vector
<String
[]> includeModules
) {
1748 QName elementFvName
= new QName (xmlNs
, "FvName");
1749 QName elementIncludeModules
= new QName(xmlNs
, "IncludeModules");
1750 QName elementInfFileName
= new QName(xmlNs
, "InfFileName");
1751 QName elementModule
= new QName(xmlNs
, "Module");
1753 UserExtensionsDocument
.UserExtensions userExts
= getfpdBuildOpts().addNewUserExtensions();
1754 userExts
.setUserID("IMAGES");
1755 userExts
.setIdentifier(new BigInteger("1"));
1756 XmlCursor cursor
= userExts
.newCursor();
1757 cursor
.toEndToken();
1759 cursor
.beginElement(elementFvName
);
1760 cursor
.insertChars(fvName
);
1761 cursor
.toNextToken();
1763 cursor
.beginElement(elementInfFileName
);
1764 cursor
.insertChars(fvName
+ ".inf");
1765 cursor
.toNextToken();
1767 cursor
.beginElement(elementIncludeModules
);
1768 for (int i
= 0; i
< includeModules
.size(); ++i
) {
1769 cursor
.beginElement(elementModule
);
1770 cursor
.insertAttributeWithValue("ModuleGuid", includeModules
.get(i
)[0]);
1771 if (!includeModules
.get(i
)[1].equals("null") && includeModules
.get(i
)[1].length() != 0) {
1772 cursor
.insertAttributeWithValue("ModuleVersion", includeModules
.get(i
)[1]);
1774 cursor
.insertAttributeWithValue("PackageGuid", includeModules
.get(i
)[2]);
1775 if (!includeModules
.get(i
)[3].equals("null") && includeModules
.get(i
)[3].length() != 0) {
1776 cursor
.insertAttributeWithValue("PackageVersion", includeModules
.get(i
)[3]);
1779 cursor
.insertAttributeWithValue("Arch", includeModules
.get(i
)[4]);
1780 cursor
.toEndToken();
1781 cursor
.toNextToken();
1786 public int getUserExtsIncModCount (String fvName
) {
1787 if (getfpdBuildOpts().getUserExtensionsList() == null) {
1790 ListIterator
<UserExtensionsDocument
.UserExtensions
> li
= getfpdBuildOpts().getUserExtensionsList().listIterator();
1791 QName elementIncludeModules
= new QName(xmlNs
, "IncludeModules");
1792 while (li
.hasNext()) {
1793 UserExtensionsDocument
.UserExtensions ues
= li
.next();
1794 if (!ues
.getUserID().equals("IMAGES")) {
1797 XmlCursor cursor
= ues
.newCursor();
1798 cursor
.toFirstChild();
1799 String elementName
= cursor
.getTextValue();
1800 if (elementName
.equals(fvName
)) {
1801 cursor
.toNextSibling(elementIncludeModules
);
1802 if (cursor
.toFirstChild()) {
1804 for (i
= 1; cursor
.toNextSibling(); ++i
);
1816 public void getUserExtsIncMods(String fvName
, String
[][] saa
) {
1817 if (getfpdBuildOpts().getUserExtensionsList() == null) {
1821 XmlCursor cursor
= getfpdBuildOpts().newCursor();
1822 QName elementUserExts
= new QName (xmlNs
, "UserExtensions");
1823 QName attribUserId
= new QName ("UserID");
1824 QName elementFvName
= new QName (xmlNs
, "FvName");
1825 QName elementIncludeModules
= new QName(xmlNs
, "IncludeModules");
1826 QName attribModuleGuid
= new QName("ModuleGuid");
1827 QName attribModuleVersion
= new QName("ModuleVersion");
1828 QName attribPackageGuid
= new QName("PackageGuid");
1829 QName attribPackageVersion
= new QName("PackageVersion");
1830 QName attribArch
= new QName("Arch");
1832 if (cursor
.toChild(elementUserExts
)) {
1835 if (cursor
.getAttributeText(attribUserId
).equals("IMAGES")) {
1836 cursor
.toChild(elementFvName
);
1837 String elementName
= cursor
.getTextValue();
1838 if (elementName
.equals(fvName
)) {
1839 cursor
.toNextSibling(elementIncludeModules
);
1840 if (cursor
.toFirstChild()) {
1843 saa
[i
][0] = cursor
.getAttributeText(attribModuleGuid
);
1844 saa
[i
][1] = cursor
.getAttributeText(attribModuleVersion
);
1845 saa
[i
][2] = cursor
.getAttributeText(attribPackageGuid
);
1846 saa
[i
][3] = cursor
.getAttributeText(attribPackageVersion
);
1847 saa
[i
][4] = cursor
.getAttributeText(attribArch
);
1849 }while (cursor
.toNextSibling());
1855 }while (cursor
.toNextSibling(elementUserExts
));
1861 public void updateBuildOptionsUserExtensions (String oldFvName
, String newFvName
) {
1862 if (getfpdBuildOpts().getUserExtensionsList() == null) {
1865 ListIterator
<UserExtensionsDocument
.UserExtensions
> li
= getfpdBuildOpts().getUserExtensionsList().listIterator();
1866 while (li
.hasNext()) {
1867 UserExtensionsDocument
.UserExtensions ues
= li
.next();
1868 if (!ues
.getUserID().equals("IMAGES")) {
1871 XmlCursor cursor
= ues
.newCursor();
1872 cursor
.toFirstChild();
1873 String elementName
= cursor
.getTextValue();
1874 if (elementName
.equals(oldFvName
)) {
1875 cursor
.setTextValue(newFvName
);
1882 public void removeBuildOptionsUserExtensions (String fvName
) {
1883 if (getfpdBuildOpts().getUserExtensionsList() == null) {
1887 ListIterator
<UserExtensionsDocument
.UserExtensions
> li
= getfpdBuildOpts().getUserExtensionsList().listIterator();
1888 while (li
.hasNext()) {
1889 UserExtensionsDocument
.UserExtensions ues
= li
.next();
1890 if (!ues
.getUserID().equals("IMAGES")) {
1893 XmlCursor cursor
= ues
.newCursor();
1894 cursor
.toFirstChild();
1895 String elementName
= cursor
.getTextValue();
1896 if (elementName
.equals(fvName
)) {
1907 private boolean versionEqual (String v1
, String v2
) {
1909 if ((v1
== null || v1
.length() == 0 || v1
.equalsIgnoreCase("null"))
1910 && (v2
== null || v2
.length() == 0 || v2
.equalsIgnoreCase("null"))) {
1914 if (v1
!= null && v1
.equals(v2
)) {
1921 public boolean moduleInBuildOptionsUserExtensions (String fvName
, String moduleGuid
, String moduleVersion
, String packageGuid
, String packageVersion
, String arch
) {
1922 boolean inList
= false;
1923 if (getUserExtsIncModCount(fvName
) > 0) {
1925 XmlCursor cursor
= getfpdBuildOpts().newCursor();
1926 QName elementUserExts
= new QName (xmlNs
, "UserExtensions");
1927 QName attribUserId
= new QName ("UserID");
1928 QName elementFvName
= new QName (xmlNs
, "FvName");
1929 QName elementIncludeModules
= new QName(xmlNs
, "IncludeModules");
1930 QName attribModuleGuid
= new QName("ModuleGuid");
1931 QName attribModuleVersion
= new QName("ModuleVersion");
1932 QName attribPackageGuid
= new QName("PackageGuid");
1933 QName attribPackageVersion
= new QName("PackageVersion");
1934 QName attribArch
= new QName("Arch");
1936 if (cursor
.toChild(elementUserExts
)) {
1939 if (cursor
.getAttributeText(attribUserId
).equals("IMAGES")) {
1940 cursor
.toChild(elementFvName
);
1941 String elementName
= cursor
.getTextValue();
1942 if (elementName
.equals(fvName
)) {
1943 cursor
.toNextSibling(elementIncludeModules
);
1944 if (cursor
.toFirstChild()) {
1947 String mg
= cursor
.getAttributeText(attribModuleGuid
);
1948 String mv
= cursor
.getAttributeText(attribModuleVersion
);
1949 String pg
= cursor
.getAttributeText(attribPackageGuid
);
1950 String pv
= cursor
.getAttributeText(attribPackageVersion
);
1951 String ar
= cursor
.getAttributeText(attribArch
);
1952 if (!moduleGuid
.equalsIgnoreCase(mg
)) {
1955 if (!packageGuid
.equalsIgnoreCase(pg
)) {
1958 if (!arch
.equalsIgnoreCase(ar
)) {
1961 if (!versionEqual(moduleVersion
, mv
)) {
1964 if (!versionEqual(packageVersion
, pv
)) {
1969 }while (cursor
.toNextSibling());
1975 }while (cursor
.toNextSibling(elementUserExts
));
1982 public void removeModuleInBuildOptionsUserExtensions (String fvName
, String moduleGuid
, String moduleVersion
, String packageGuid
, String packageVersion
, String arch
) {
1983 if (getUserExtsIncModCount(fvName
) > 0) {
1985 XmlCursor cursor
= getfpdBuildOpts().newCursor();
1986 QName elementUserExts
= new QName (xmlNs
, "UserExtensions");
1987 QName attribUserId
= new QName ("UserID");
1988 QName elementFvName
= new QName (xmlNs
, "FvName");
1989 QName elementIncludeModules
= new QName(xmlNs
, "IncludeModules");
1990 QName attribModuleGuid
= new QName("ModuleGuid");
1991 QName attribModuleVersion
= new QName("ModuleVersion");
1992 QName attribPackageGuid
= new QName("PackageGuid");
1993 QName attribPackageVersion
= new QName("PackageVersion");
1994 QName attribArch
= new QName("Arch");
1996 if (cursor
.toChild(elementUserExts
)) {
1999 if (cursor
.getAttributeText(attribUserId
).equals("IMAGES")) {
2000 cursor
.toChild(elementFvName
);
2001 String elementName
= cursor
.getTextValue();
2002 if (elementName
.equals(fvName
)) {
2003 cursor
.toNextSibling(elementIncludeModules
);
2004 if (cursor
.toFirstChild()) {
2007 String mg
= cursor
.getAttributeText(attribModuleGuid
);
2008 String mv
= cursor
.getAttributeText(attribModuleVersion
);
2009 String pg
= cursor
.getAttributeText(attribPackageGuid
);
2010 String pv
= cursor
.getAttributeText(attribPackageVersion
);
2011 String ar
= cursor
.getAttributeText(attribArch
);
2012 if (!moduleGuid
.equalsIgnoreCase(mg
)) {
2015 if (!packageGuid
.equalsIgnoreCase(pg
)) {
2018 if (!arch
.equalsIgnoreCase(ar
)) {
2021 if (!versionEqual(moduleVersion
, mv
)) {
2024 if (!versionEqual(packageVersion
, pv
)) {
2028 }while (cursor
.toNextSibling());
2034 }while (cursor
.toNextSibling(elementUserExts
));
2040 public void genBuildOptionsUserDefAntTask (String id
, String fileName
, String execOrder
) {
2041 UserDefinedAntTasksDocument
.UserDefinedAntTasks udats
= getfpdBuildOpts().getUserDefinedAntTasks();
2042 if (udats
== null) {
2043 udats
= getfpdBuildOpts().addNewUserDefinedAntTasks();
2046 AntTaskDocument
.AntTask at
= udats
.addNewAntTask();
2047 setBuildOptionsUserDefAntTask(id
, fileName
, execOrder
, at
);
2050 private void setBuildOptionsUserDefAntTask(String id
, String fileName
, String execOrder
, AntTaskDocument
.AntTask at
) {
2051 at
.setId(new Integer(id
));
2052 XmlCursor cursor
= at
.newCursor();
2053 if (fileName
!= null){
2054 at
.setFilename(fileName
);
2056 else if (cursor
.toChild(xmlNs
, "Filename")) {
2059 if (execOrder
!= null) {
2060 at
.setAntCmdOptions(execOrder
);
2062 else if (cursor
.toChild(xmlNs
, "AntCmdOptions")) {
2068 public void removeBuildOptionsUserDefAntTask(int i
) {
2069 XmlObject o
= getfpdBuildOpts().getUserDefinedAntTasks();
2073 XmlCursor cursor
= o
.newCursor();
2074 if (cursor
.toFirstChild()) {
2075 for (int j
= 0; j
< i
; ++j
) {
2076 cursor
.toNextSibling();
2079 if (getBuildOptionsUserDefAntTaskCount() == 0) {
2087 public void updateBuildOptionsUserDefAntTask(int i
, String id
, String fileName
, String execOrder
){
2088 XmlObject o
= getfpdBuildOpts().getUserDefinedAntTasks();
2092 XmlCursor cursor
= o
.newCursor();
2093 if (cursor
.toFirstChild()) {
2094 for (int j
= 0; j
< i
; ++j
) {
2095 cursor
.toNextSibling();
2097 AntTaskDocument
.AntTask at
= (AntTaskDocument
.AntTask
)cursor
.getObject();
2098 setBuildOptionsUserDefAntTask(id
, fileName
, execOrder
, at
);
2103 public int getBuildOptionsUserDefAntTaskCount() {
2104 UserDefinedAntTasksDocument
.UserDefinedAntTasks udats
= getfpdBuildOpts().getUserDefinedAntTasks();
2105 if (udats
== null || udats
.getAntTaskList() == null) {
2109 return udats
.getAntTaskList().size();
2112 public void getBuildOptionsUserDefAntTasks(String
[][] saa
) {
2113 UserDefinedAntTasksDocument
.UserDefinedAntTasks udats
= getfpdBuildOpts().getUserDefinedAntTasks();
2114 if (udats
== null || udats
.getAntTaskList() == null) {
2118 List
<AntTaskDocument
.AntTask
> l
= udats
.getAntTaskList();
2119 ListIterator li
= l
.listIterator();
2121 while (li
.hasNext()) {
2122 AntTaskDocument
.AntTask at
= (AntTaskDocument
.AntTask
)li
.next();
2123 saa
[i
][0] = at
.getId() + "";
2124 saa
[i
][1] = saa
[i
][2] = "";
2125 if (at
.getFilename() != null){
2126 saa
[i
][1] = at
.getFilename();
2128 if (at
.getAntCmdOptions() != null) {
2129 saa
[i
][2] = at
.getAntCmdOptions();
2134 public void genBuildOptionsOpt(Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
) {
2135 OptionsDocument
.Options opts
= getfpdBuildOpts().getOptions();
2137 opts
= getfpdBuildOpts().addNewOptions();
2139 OptionDocument
.Option opt
= opts
.addNewOption();
2140 setBuildOptionsOpt(buildTargets
, toolChain
, tagName
, toolCmd
, archList
, contents
, opt
);
2143 private void setBuildOptionsOpt(Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
, OptionDocument
.Option opt
){
2144 opt
.setStringValue(contents
);
2145 if (buildTargets
!= null) {
2146 opt
.setBuildTargets(buildTargets
);
2149 if (opt
.isSetBuildTargets()) {
2150 opt
.unsetBuildTargets();
2154 if (toolChain
!= null && toolChain
.length() > 0) {
2155 opt
.setToolChainFamily(toolChain
);
2158 if (opt
.isSetToolChainFamily()) {
2159 opt
.unsetToolChainFamily();
2163 if (tagName
!= null && tagName
.length() > 0) {
2164 opt
.setTagName(tagName
);
2167 if (opt
.isSetTagName()) {
2172 if (toolCmd
!= null && toolCmd
.length() > 0) {
2173 opt
.setToolCode(toolCmd
);
2176 if (opt
.isSetToolCode()) {
2177 opt
.unsetToolCode();
2182 if (archList
!= null) {
2183 opt
.setSupArchList(archList
);
2186 if (opt
.isSetSupArchList()) {
2187 opt
.unsetSupArchList();
2192 public void removeBuildOptionsOpt(int i
){
2194 XmlObject o
= getfpdBuildOpts().getOptions();
2199 XmlCursor cursor
= o
.newCursor();
2200 if (cursor
.toFirstChild()) {
2201 for (int j
= 0; j
< i
; ++j
) {
2202 cursor
.toNextSibling();
2205 if (getBuildOptionsOptCount() == 0) {
2213 public void updateBuildOptionsOpt(int i
, Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
) {
2214 XmlObject o
= getfpdBuildOpts().getOptions();
2219 XmlCursor cursor
= o
.newCursor();
2220 if (cursor
.toFirstChild()) {
2221 for (int j
= 0; j
< i
; ++j
) {
2222 cursor
.toNextSibling();
2224 OptionDocument
.Option opt
= (OptionDocument
.Option
)cursor
.getObject();
2225 setBuildOptionsOpt(buildTargets
, toolChain
, tagName
, toolCmd
, archList
, contents
, opt
);
2230 public int getBuildOptionsOptCount(){
2231 if (getfpdBuildOpts().getOptions() == null || getfpdBuildOpts().getOptions().getOptionList() == null) {
2234 return getfpdBuildOpts().getOptions().getOptionList().size();
2237 public void getBuildOptionsOpts(String
[][] saa
) {
2238 if (getfpdBuildOpts().getOptions() == null || getfpdBuildOpts().getOptions().getOptionList() == null) {
2242 List
<OptionDocument
.Option
> lOpt
= getfpdBuildOpts().getOptions().getOptionList();
2243 ListIterator li
= lOpt
.listIterator();
2245 while(li
.hasNext()) {
2246 OptionDocument
.Option opt
= (OptionDocument
.Option
)li
.next();
2247 if (opt
.getBuildTargets() != null) {
2248 saa
[i
][0] = listToString(opt
.getBuildTargets());
2250 saa
[i
][1] = opt
.getToolChainFamily();
2251 if (opt
.getSupArchList() != null){
2252 saa
[i
][2] = listToString(opt
.getSupArchList());
2255 saa
[i
][3] = opt
.getToolCode();
2256 saa
[i
][4] = opt
.getTagName();
2257 saa
[i
][5] = opt
.getStringValue();
2263 public void genBuildOptionsFfs(String ffsKey
, String type
) {
2264 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getfpdBuildOpts().addNewFfs();
2265 ffs
.setFfsKey(ffsKey
);
2267 ffs
.addNewSections().setEncapsulationType(type
);
2271 public void updateBuildOptionsFfsSectionsType(int i
, String type
) {
2272 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getfpdBuildOpts().addNewFfs();
2274 ffs
.addNewSections().setEncapsulationType(type
);
2278 public void genBuildOptionsFfsAttribute(int i
, String name
, String value
) {
2279 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2280 BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute attrib
= ffs
.addNewAttribute();
2281 attrib
.setName(name
);
2282 attrib
.setValue(value
);
2285 /**update jth attribute of ith ffs.
2289 public void updateBuildOptionsFfsAttribute(int i
, int j
, String name
, String value
){
2290 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2291 XmlCursor cursor
= ffs
.newCursor();
2292 QName qAttrib
= new QName(xmlNs
, "Attribute");
2293 if (cursor
.toChild(qAttrib
)) {
2294 for (int k
= 0; k
< j
; ++k
) {
2295 cursor
.toNextSibling(qAttrib
);
2297 BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute attrib
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute
)cursor
.getObject();
2298 attrib
.setName(name
);
2299 attrib
.setValue(value
);
2304 public void removeBuildOptionsFfsAttribute(int i
, int j
){
2305 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2306 XmlCursor cursor
= ffs
.newCursor();
2307 QName qAttrib
= new QName(xmlNs
, "Attribute");
2308 if (cursor
.toChild(qAttrib
)) {
2309 for (int k
= 0; k
< j
; ++k
) {
2310 cursor
.toNextSibling(qAttrib
);
2317 public void genBuildOptionsFfsSectionsSection(int i
, String sectionType
) {
2318 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2322 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2324 if (sections
== null){
2325 sections
= ffs
.addNewSections();
2327 sections
.addNewSection().setSectionType(EfiSectionType
.Enum
.forString(sectionType
));
2330 public void removeBuildOptionsFfsSectionsSection(int i
, int j
) {
2331 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2332 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2333 if (sections
== null) {
2336 XmlCursor cursor
= sections
.newCursor();
2337 QName qSection
= new QName(xmlNs
, "Section");
2338 if (cursor
.toChild(qSection
)) {
2339 for (int k
= 0; k
< j
; ++k
) {
2340 cursor
.toNextSibling(qSection
);
2347 public void updateBuildOptionsFfsSectionsSection(int i
, int j
, String type
){
2348 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2349 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2350 if (sections
== null) {
2353 XmlCursor cursor
= sections
.newCursor();
2354 QName qSection
= new QName(xmlNs
, "Section");
2355 if (cursor
.toChild(qSection
)) {
2356 for (int k
= 0; k
< j
; ++k
) {
2357 cursor
.toNextSibling(qSection
);
2359 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Section section
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Section
)cursor
.getObject();
2360 section
.setSectionType(EfiSectionType
.Enum
.forString(type
));
2365 public void genBuildOptionsFfsSectionsSections(int i
, String encapType
) {
2366 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2370 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2372 if (sections
== null){
2373 sections
= ffs
.addNewSections();
2375 sections
.addNewSections().setEncapsulationType(encapType
);
2378 public void removeBuildOptionsFfsSectionsSections(int i
, int j
) {
2379 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2380 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2381 if (sections
== null) {
2384 XmlCursor cursor
= sections
.newCursor();
2385 QName qSections
= new QName(xmlNs
, "Sections");
2386 if (cursor
.toChild(qSections
)) {
2387 for (int k
= 0; k
< j
; ++k
) {
2388 cursor
.toNextSibling(qSections
);
2395 public void updateBuildOptionsFfsSectionsSections(int i
, int j
, String type
) {
2396 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2397 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2398 if (sections
== null) {
2401 XmlCursor cursor
= sections
.newCursor();
2402 QName qSections
= new QName(xmlNs
, "Sections");
2403 if (cursor
.toChild(qSections
)) {
2404 for (int k
= 0; k
< j
; ++k
) {
2405 cursor
.toNextSibling(qSections
);
2407 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2 sections2
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
)cursor
.getObject();
2408 sections2
.setEncapsulationType(type
);
2413 public void genBuildOptionsFfsSectionsSectionsSection(int i
, int j
, String type
) {
2414 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2418 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2419 XmlCursor cursor
= sections
.newCursor();
2420 QName qSections
= new QName(xmlNs
, "Sections");
2421 if (cursor
.toChild(qSections
)){
2422 for (int k
= 0; k
< j
; ++k
) {
2423 cursor
.toNextSibling(qSections
);
2425 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2 sections2
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
)cursor
.getObject();
2426 sections2
.addNewSection().setSectionType(EfiSectionType
.Enum
.forString(type
));
2431 public void removeBuildOptionsFfsSectionsSectionsSection(int i
, int j
, int k
) {
2432 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2433 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2434 if (sections
== null) {
2437 XmlCursor cursor
= sections
.newCursor();
2438 QName qSections
= new QName(xmlNs
, "Sections");
2439 if (cursor
.toChild(qSections
)) {
2440 for (int l
= 0; l
< j
; ++l
) {
2441 cursor
.toNextSibling(qSections
);
2443 if (cursor
.toFirstChild()) {
2445 for (; m
< k
; ++m
) {
2446 cursor
.toNextSibling();
2458 public void updateBuildOptionsFfsSectionsSectionsSection(int i
, int j
, int k
, String type
) {
2459 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2460 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2461 if (sections
== null) {
2464 XmlCursor cursor
= sections
.newCursor();
2465 QName qSections
= new QName(xmlNs
, "Sections");
2466 if (cursor
.toChild(qSections
)) {
2467 for (int l
= 0; l
< j
; ++l
) {
2468 cursor
.toNextSibling(qSections
);
2470 if (cursor
.toFirstChild()) {
2471 for (int m
= 0; m
< k
; ++m
) {
2472 cursor
.toNextSibling();
2474 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section section
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section
)cursor
.getObject();
2475 section
.setSectionType(EfiSectionType
.Enum
.forString(type
));
2481 public void getBuildOptionsFfsSectionsSectionsSection(int i
, int j
, ArrayList
<String
> al
) {
2482 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2486 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2487 XmlCursor cursor
= sections
.newCursor();
2488 QName qSections
= new QName(xmlNs
, "Sections");
2489 if (cursor
.toChild(qSections
)){
2490 for (int k
= 0; k
< j
; ++k
) {
2491 cursor
.toNextSibling(qSections
);
2493 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2 sections2
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
)cursor
.getObject();
2494 if (sections2
.getSectionList() == null){
2498 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section
> li
= sections2
.getSectionList().listIterator();
2499 while(li
.hasNext()) {
2500 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section section
= li
.next();
2501 if (section
.isSetSectionType()) {
2502 al
.add(section
.getSectionType().toString());
2511 public int getBuildOptionsFfsCount(){
2512 if (getfpdBuildOpts().getFfsList() == null) {
2515 return getfpdBuildOpts().getFfsList().size();
2518 public void getBuildOptionsFfsKey(String
[][] saa
) {
2519 if (getfpdBuildOpts().getFfsList() == null) {
2522 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
> li
= getfpdBuildOpts().getFfsList().listIterator();
2524 while(li
.hasNext()){
2525 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= li
.next();
2526 saa
[i
][0] = ffs
.getFfsKey();
2531 public void updateBuildOptionsFfsKey(int i
, String key
) {
2532 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2536 /**Get ith FFS key and contents.
2539 public void getBuildOptionsFfs(int i
, String
[] sa
, LinkedHashMap
<String
, String
> ffsAttribMap
, ArrayList
<String
> firstLevelSections
, ArrayList
<String
> firstLevelSection
) {
2540 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2544 sa
[0] = ffs
.getFfsKey();
2545 if (ffs
.getSections() != null) {
2546 if(ffs
.getSections().getEncapsulationType() != null){
2547 sa
[1] = ffs
.getSections().getEncapsulationType();
2549 if (ffs
.getSections().getSectionList() != null){
2550 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Section
> li
= ffs
.getSections().getSectionList().listIterator();
2551 while (li
.hasNext()) {
2552 firstLevelSection
.add(li
.next().getSectionType().toString());
2555 if (ffs
.getSections().getSectionsList() != null) {
2556 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
> li
= ffs
.getSections().getSectionsList().listIterator();
2557 while(li
.hasNext()) {
2558 firstLevelSections
.add(li
.next().getEncapsulationType());
2562 if (ffs
.getAttributeList() != null) {
2563 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute
> li
= ffs
.getAttributeList().listIterator();
2564 while(li
.hasNext()) {
2565 BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute attrib
= li
.next();
2566 ffsAttribMap
.put(attrib
.getName(), attrib
.getValue());
2575 private BuildOptionsDocument
.BuildOptions
.Ffs
getFfs(int i
) {
2576 XmlObject o
= getfpdBuildOpts();
2577 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= null;
2579 XmlCursor cursor
= o
.newCursor();
2580 QName qFfs
= new QName(xmlNs
, "Ffs");
2581 if (cursor
.toChild(qFfs
)) {
2582 for (int j
= 0; j
< i
; ++j
) {
2583 cursor
.toNextSibling(qFfs
);
2585 ffs
= (BuildOptionsDocument
.BuildOptions
.Ffs
)cursor
.getObject();
2591 public void removeBuildOptionsFfs(int i
) {
2592 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2597 XmlCursor cursor
= ffs
.newCursor();
2604 public PlatformDefinitionsDocument
.PlatformDefinitions
getfpdPlatformDefs(){
2605 if (fpdPlatformDefs
== null){
2606 fpdPlatformDefs
= fpdRoot
.addNewPlatformDefinitions();
2608 return fpdPlatformDefs
;
2611 public void getPlatformDefsSupportedArchs(Vector
<Object
> archs
){
2612 if (getfpdPlatformDefs().getSupportedArchitectures() == null) {
2615 ListIterator li
= getfpdPlatformDefs().getSupportedArchitectures().listIterator();
2616 while(li
.hasNext()) {
2617 archs
.add(li
.next());
2621 public void setPlatformDefsSupportedArchs(Vector
<Object
> archs
) {
2622 if (archs
!= null) {
2623 getfpdPlatformDefs().setSupportedArchitectures(archs
);
2626 // XmlCursor cursor = getfpdPlatformDefs().newCursor();
2627 // if (cursor.toChild(xmlNs, "SupportedArchitectures")) {
2628 // cursor.removeXml();
2630 // cursor.dispose();
2634 public void getPlatformDefsBuildTargets(Vector
<Object
> targets
) {
2635 if (getfpdPlatformDefs().getBuildTargets() == null) {
2638 ListIterator li
= getfpdPlatformDefs().getBuildTargets().listIterator();
2639 while(li
.hasNext()) {
2640 targets
.add(li
.next());
2644 public void setPlatformDefsBuildTargets(Vector
<Object
> targets
) {
2645 getfpdPlatformDefs().setBuildTargets(targets
);
2648 public void genPlatformDefsSkuInfo(String id
, String name
) {
2649 SkuInfoDocument
.SkuInfo skuInfo
= null;
2650 if (getfpdPlatformDefs().getSkuInfo() == null) {
2651 skuInfo
= getfpdPlatformDefs().addNewSkuInfo();
2653 skuInfo
= getfpdPlatformDefs().getSkuInfo();
2654 if (skuInfo
.getUiSkuNameList() == null || skuInfo
.getUiSkuNameList().size() == 0) {
2655 SkuInfoDocument
.SkuInfo
.UiSkuName skuName
= skuInfo
.addNewUiSkuName();
2656 skuName
.setSkuID(new BigInteger("0"));
2657 skuName
.setStringValue("DEFAULT");
2659 if (id
.equals("0")) {
2662 SkuInfoDocument
.SkuInfo
.UiSkuName skuName
= skuInfo
.addNewUiSkuName();
2663 skuName
.setSkuID(new BigInteger(id
));
2664 skuName
.setStringValue(name
);
2667 public int getPlatformDefsSkuInfoCount(){
2668 if (getfpdPlatformDefs().getSkuInfo() == null || getfpdPlatformDefs().getSkuInfo().getUiSkuNameList() == null) {
2671 return getfpdPlatformDefs().getSkuInfo().getUiSkuNameList().size();
2674 public void getPlatformDefsSkuInfos(String
[][] saa
){
2675 if (getfpdPlatformDefs().getSkuInfo() == null || getfpdPlatformDefs().getSkuInfo().getUiSkuNameList() == null) {
2676 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null) {
2677 removeElement(getfpdDynPcdBuildDefs());
2678 fpdDynPcdBuildDefs
= null;
2683 List
<SkuInfoDocument
.SkuInfo
.UiSkuName
> l
= getfpdPlatformDefs().getSkuInfo().getUiSkuNameList();
2684 ListIterator
<SkuInfoDocument
.SkuInfo
.UiSkuName
> li
= l
.listIterator();
2686 while(li
.hasNext()) {
2687 SkuInfoDocument
.SkuInfo
.UiSkuName sku
= li
.next();
2688 saa
[i
][0] = sku
.getSkuID()+"";
2689 saa
[i
][1] = sku
.getStringValue();
2694 public void removePlatformDefsSkuInfo(int i
) {
2695 SkuInfoDocument
.SkuInfo skuInfo
= getfpdPlatformDefs().getSkuInfo();
2696 if (skuInfo
== null || i
== 0) {
2700 XmlCursor cursor
= skuInfo
.newCursor();
2701 if (cursor
.toFirstChild()) {
2702 for (int j
= 0; j
< i
; ++j
) {
2703 cursor
.toNextSibling();
2710 public void updatePlatformDefsSkuInfo(int i
, String id
, String name
) {
2711 SkuInfoDocument
.SkuInfo skuInfo
= getfpdPlatformDefs().getSkuInfo();
2712 if (skuInfo
== null || i
== 0) {
2716 XmlCursor cursor
= skuInfo
.newCursor();
2717 if (cursor
.toFirstChild()) {
2718 for (int j
= 0; j
< i
; ++j
) {
2719 cursor
.toNextSibling();
2721 SkuInfoDocument
.SkuInfo
.UiSkuName sku
= (SkuInfoDocument
.SkuInfo
.UiSkuName
)cursor
.getObject();
2722 sku
.setSkuID(new BigInteger(id
));
2723 sku
.setStringValue(name
);
2728 public String
getPlatformDefsInterDir(){
2729 if (getfpdPlatformDefs().getIntermediateDirectories() == null) {
2732 return getfpdPlatformDefs().getIntermediateDirectories().toString();
2735 public void setPlatformDefsInterDir(String interDir
){
2736 getfpdPlatformDefs().setIntermediateDirectories(IntermediateOutputType
.Enum
.forString(interDir
));
2739 public String
getPlatformDefsOutputDir() {
2740 return getfpdPlatformDefs().getOutputDirectory();
2743 public void setPlatformDefsOutputDir(String outputDir
) {
2744 if (outputDir
!= null && outputDir
.length() > 0) {
2745 getfpdPlatformDefs().setOutputDirectory(outputDir
);
2748 XmlCursor cursor
= getfpdPlatformDefs().newCursor();
2749 if (cursor
.toChild(new QName(xmlNs
, "OutputDirectory"))) {
2756 public FlashDocument
.Flash
getfpdFlash() {
2757 if (fpdFlash
== null) {
2758 fpdFlash
= fpdRoot
.addNewFlash();
2763 public void genFlashDefinitionFile(String file
) {
2764 FlashDefinitionFileDocument
.FlashDefinitionFile fdf
= getfpdFlash().getFlashDefinitionFile();
2766 fdf
= getfpdFlash().addNewFlashDefinitionFile();
2769 fdf
.setStringValue(file
);
2772 public String
getFlashDefinitionFile() {
2773 FlashDefinitionFileDocument
.FlashDefinitionFile fdf
= getfpdFlash().getFlashDefinitionFile();
2778 return fdf
.getStringValue();
2781 public void genFvImagesNameValue(String name
, String value
) {
2783 FvImagesDocument
.FvImages fi
= getfpdFlash().getFvImages();
2785 fi
= getfpdFlash().addNewFvImages();
2788 FvImagesDocument
.FvImages
.NameValue nv
= fi
.addNewNameValue();
2793 public void removeFvImagesNameValue(int i
){
2795 XmlObject o
= getfpdFlash().getFvImages();
2800 QName qNameValue
= new QName(xmlNs
, "NameValue");
2801 XmlCursor cursor
= o
.newCursor();
2802 if (cursor
.toChild(qNameValue
)) {
2803 for (int j
= 0; j
< i
; ++j
) {
2804 cursor
.toNextSibling(qNameValue
);
2811 public void updateFvImagesNameValue(int i
, String name
, String value
){
2813 XmlObject o
= getfpdFlash().getFvImages();
2818 QName qNameValue
= new QName(xmlNs
, "NameValue");
2819 XmlCursor cursor
= o
.newCursor();
2820 if (cursor
.toChild(qNameValue
)) {
2821 for (int j
= 0; j
< i
; ++j
) {
2822 cursor
.toNextSibling(qNameValue
);
2824 FvImagesDocument
.FvImages
.NameValue nv
= (FvImagesDocument
.FvImages
.NameValue
)cursor
.getObject();
2831 public int getFvImagesNameValueCount() {
2833 FvImagesDocument
.FvImages fi
= null;
2834 if ((fi
= getfpdFlash().getFvImages()) == null || fi
.getNameValueList() == null) {
2837 return fi
.getNameValueList().size();
2840 public void getFvImagesNameValues(String
[][] nv
) {
2842 FvImagesDocument
.FvImages fi
= getfpdFlash().getFvImages();
2846 List
<FvImagesDocument
.FvImages
.NameValue
> l
= fi
.getNameValueList();
2848 ListIterator li
= l
.listIterator();
2849 while (li
.hasNext()) {
2850 FvImagesDocument
.FvImages
.NameValue e
= (FvImagesDocument
.FvImages
.NameValue
) li
2852 nv
[i
][0] = e
.getName();
2853 nv
[i
][1] = e
.getValue();
2859 public void getFvImagesFvImageFvImageNames (Vector
<String
> vImageNames
) {
2860 FvImagesDocument
.FvImages fis
= getfpdFlash().getFvImages();
2861 if (fis
== null || fis
.getFvImageList() == null) {
2865 ListIterator
<FvImagesDocument
.FvImages
.FvImage
> li
= fis
.getFvImageList().listIterator();
2866 while (li
.hasNext()) {
2867 FvImagesDocument
.FvImages
.FvImage fi
= li
.next();
2868 if (fi
.getType().toString().equals("ImageName")) {
2869 vImageNames
.addAll(fi
.getFvImageNamesList());
2875 public void addFvImageFvImageNames (String
[] fvNames
) {
2876 FvImagesDocument
.FvImages fis
= getfpdFlash().getFvImages();
2877 if (fis
== null || fis
.getFvImageList() == null) {
2878 genFvImagesFvImage (fvNames
, "ImageName", null);
2882 ListIterator
<FvImagesDocument
.FvImages
.FvImage
> li
= fis
.getFvImageList().listIterator();
2883 while (li
.hasNext()) {
2884 FvImagesDocument
.FvImages
.FvImage fi
= li
.next();
2885 if (fi
.getType().toString().equals("ImageName")) {
2886 addFvImageNamesInFvImage (fi
, fvNames
);
2890 genFvImagesFvImage (fvNames
, "ImageName", null);
2893 public void addFvImageNamesInFvImage (FvImagesDocument
.FvImages
.FvImage fi
, String
[] fvNames
) {
2895 for (int i
= 0; i
< fvNames
.length
; ++i
) {
2896 fi
.addFvImageNames(fvNames
[i
]);
2900 public void addFvImageNamesInFvImage (int i
, String
[] fvNames
) {
2901 XmlObject o
= getfpdFlash().getFvImages();
2905 XmlCursor cursor
= o
.newCursor();
2906 QName qFvImage
= new QName(xmlNs
, "FvImage");
2907 if (cursor
.toChild(qFvImage
)) {
2908 for (int j
= 0; j
< i
; ++j
) {
2909 cursor
.toNextSibling(qFvImage
);
2911 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
2912 addFvImageNamesInFvImage(fi
, fvNames
);
2917 public void genFvImagesFvImage(String
[] names
, String types
, Map
<String
, String
> options
) {
2919 FvImagesDocument
.FvImages fis
= null;
2920 if ((fis
= getfpdFlash().getFvImages()) == null) {
2921 fis
= getfpdFlash().addNewFvImages();
2925 //gen FvImage with FvImageNames array
2927 FvImagesDocument
.FvImages
.FvImage fi
= fis
.addNewFvImage();
2928 for (int i
= 0; i
< names
.length
; ++i
) {
2929 fi
.addFvImageNames(names
[i
]);
2931 fi
.setType(FvImageTypes
.Enum
.forString(types
));
2932 if (options
!= null){
2933 setFvImagesFvImageFvImageOptions(options
, fi
);
2937 private void setFvImagesFvImageFvImageOptions(Map
<String
, String
> options
, FvImagesDocument
.FvImages
.FvImage fi
){
2938 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions fio
= fi
.getFvImageOptions();
2940 fio
= fi
.addNewFvImageOptions();
2943 Set
<String
> key
= options
.keySet();
2944 Iterator
<String
> i
= key
.iterator();
2945 while (i
.hasNext()) {
2947 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nv
= fio
.addNewNameValue();
2948 String k
= (String
)i
.next();
2951 nv
.setValue((String
)options
.get(k
));
2958 public void removeFvImagesFvImage(int i
) {
2960 XmlObject o
= getfpdFlash().getFvImages();
2965 QName qFvImage
= new QName(xmlNs
, "FvImage");
2966 XmlCursor cursor
= o
.newCursor();
2967 if (cursor
.toChild(qFvImage
)) {
2968 for (int j
= 0; j
< i
; ++j
) {
2969 cursor
.toNextSibling(qFvImage
);
2978 * @param newFvName The New FV Name. If null, remove the old FvImageNames entry.
2980 public void updateFvImageNameAll (String oldFvName
, String newFvName
) {
2981 if (getfpdFlash().getFvImages() == null || getfpdFlash().getFvImages().getFvImageList() == null) {
2984 ListIterator
<FvImagesDocument
.FvImages
.FvImage
> li
= getfpdFlash().getFvImages().getFvImageList().listIterator();
2985 while (li
.hasNext()) {
2986 FvImagesDocument
.FvImages
.FvImage fi
= li
.next();
2987 updateFvImageNamesInFvImage (fi
, oldFvName
, newFvName
);
2988 if (fi
.getFvImageNamesList().size() == 0) {
2994 public void updateFvImageNamesInFvImage (int i
, String oldFvName
, String newFvName
) {
2995 XmlObject o
= getfpdFlash().getFvImages();
2999 XmlCursor cursor
= o
.newCursor();
3000 QName qFvImage
= new QName(xmlNs
, "FvImage");
3001 if (cursor
.toChild(qFvImage
)) {
3002 for (int j
= 0; j
< i
; ++j
) {
3003 cursor
.toNextSibling(qFvImage
);
3005 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
3006 updateFvImageNamesInFvImage (fi
, oldFvName
, newFvName
);
3012 * @param oldFvName The FV Name to be replaced.
3013 * @param newFvName The New FV Name. If null, remove the old FvImageNames entry.
3015 public void updateFvImageNamesInFvImage (FvImagesDocument
.FvImages
.FvImage fi
, String oldFvName
, String newFvName
) {
3016 QName qFvImageNames
= new QName(xmlNs
, "FvImageNames");
3017 XmlCursor cursor
= fi
.newCursor();
3019 if (cursor
.toChild(qFvImageNames
)) {
3021 String xmlValue
= cursor
.getTextValue();
3022 if (xmlValue
.equals(oldFvName
)){
3023 if (newFvName
!= null) {
3024 cursor
.setTextValue(newFvName
);
3030 }while (cursor
.toNextSibling(qFvImageNames
));
3036 /**update the Type attribute of ith FvImage with new type.
3040 public void updateFvImagesFvImageType (int i
, String type
) {
3041 XmlObject o
= getfpdFlash().getFvImages();
3045 XmlCursor cursor
= o
.newCursor();
3046 QName qFvImage
= new QName(xmlNs
, "FvImage");
3047 if (cursor
.toChild(qFvImage
)) {
3048 for (int j
= 0; j
< i
; ++j
) {
3049 cursor
.toNextSibling(qFvImage
);
3051 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
3052 fi
.setType(FvImageTypes
.Enum
.forString(type
));
3057 public void updateFvImagesFvImage(int i
, String
[] names
, String types
, Map
<String
, String
> options
){
3059 XmlObject o
= getfpdFlash().getFvImages();
3063 XmlCursor cursor
= o
.newCursor();
3064 QName qFvImage
= new QName(xmlNs
, "FvImage");
3065 if (cursor
.toChild(qFvImage
)) {
3066 for (int j
= 0; j
< i
; ++j
) {
3067 cursor
.toNextSibling(qFvImage
);
3069 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
3070 fi
.setType(FvImageTypes
.Enum
.forString(types
));
3073 // remove old FvImageNames before adding new ones
3075 QName qFvImageNames
= new QName(xmlNs
, "FvImageNames");
3076 cursor
.toChild(qFvImageNames
);
3078 while (cursor
.toNextSibling(qFvImageNames
)) {
3082 for (int k
= 0; k
< names
.length
; ++k
) {
3083 fi
.addFvImageNames(names
[k
]);
3086 // remove old FvImageOptions before adding new options
3088 QName qFvImageOptions
= new QName(xmlNs
, "FvImageOptions");
3089 cursor
.toNextSibling(qFvImageOptions
);
3092 setFvImagesFvImageFvImageOptions(options
, fi
);
3097 public int getFvImagesFvImageCount(String type
) {
3099 if (getfpdFlash().getFvImages() == null || getfpdFlash().getFvImages().getFvImageList() == null) {
3102 List
<FvImagesDocument
.FvImages
.FvImage
> l
= getfpdFlash().getFvImages().getFvImageList();
3103 ListIterator li
= l
.listIterator();
3105 while(li
.hasNext()) {
3106 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)li
.next();
3107 if (!fi
.getType().toString().equals(type
) && !type
.equals("ALL")) {
3117 public Vector
<FvImagesDocument
.FvImages
.FvImage
> getFvImagesFvImageWithName (String fvName
, String type
) {
3118 Vector
<FvImagesDocument
.FvImages
.FvImage
> vFvImage
= new Vector
<FvImagesDocument
.FvImages
.FvImage
>();
3119 if (getfpdFlash().getFvImages() == null || getfpdFlash().getFvImages().getFvImageList() == null) {
3122 List
<FvImagesDocument
.FvImages
.FvImage
> l
= getfpdFlash().getFvImages().getFvImageList();
3123 ListIterator li
= l
.listIterator();
3124 while(li
.hasNext()) {
3125 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)li
.next();
3126 if (!fi
.getType().toString().equals(type
) && !type
.equals("ALL")) {
3129 if (fi
.getFvImageNamesList().contains(fvName
)) {
3138 * @param type "ALL" means all FvImage types: ImageName, Options, Attributes, Components.
3140 public void getFvImagesFvImages(String
[][] saa
, String type
) {
3142 if (getfpdFlash().getFvImages() == null) {
3145 List
<FvImagesDocument
.FvImages
.FvImage
> l
= getfpdFlash().getFvImages().getFvImageList();
3149 ListIterator li
= l
.listIterator();
3151 while(li
.hasNext()) {
3152 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)li
.next();
3153 if (!fi
.getType().toString().equals(type
) && !type
.equals("ALL")) {
3157 // get FvImageNames array, space separated
3159 List
<String
> lfn
= fi
.getFvImageNamesList();
3160 ListIterator lfni
= lfn
.listIterator();
3162 while (lfni
.hasNext()) {
3163 saa
[i
][0] += (String
)lfni
.next();
3166 saa
[i
][0] = saa
[i
][0].trim();
3168 saa
[i
][1] = fi
.getType()+"";
3174 public void removeFvImageNameValue (int i
, String attributeName
) {
3175 XmlObject o
= getfpdFlash().getFvImages();
3179 XmlCursor cursor
= o
.newCursor();
3180 QName qFvImage
= new QName(xmlNs
, "FvImage");
3181 if (cursor
.toChild(qFvImage
)) {
3182 for (int j
= 0; j
< i
; ++j
) {
3183 cursor
.toNextSibling(qFvImage
);
3185 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
3186 removeFvImageNameValue (fi
, attributeName
);
3190 /**Remove from fi the attribute pair with attributeName in FvImageOptions.
3192 * @param attributeName
3194 public void removeFvImageNameValue (FvImagesDocument
.FvImages
.FvImage fi
, String attributeName
) {
3195 if (fi
.getFvImageOptions() != null && fi
.getFvImageOptions().getNameValueList() != null) {
3196 ListIterator
<FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
> li
= fi
.getFvImageOptions().getNameValueList().listIterator();
3197 while (li
.hasNext()) {
3198 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nv
= li
.next();
3199 if (nv
.getName().equals(attributeName
)) {
3206 public void removeTypedNamedFvImageNameValue (String fvName
, String type
, String optName
) {
3207 Vector
<FvImagesDocument
.FvImages
.FvImage
> vFvImage
= getFvImagesFvImageWithName(fvName
, type
);
3208 for (int i
= 0; i
< vFvImage
.size(); ++i
) {
3209 FvImagesDocument
.FvImages
.FvImage fi
= vFvImage
.get(i
);
3210 removeFvImageNameValue (fi
, optName
);
3214 /**Add name-value pair to FvImage element with type.
3215 * @param fvName FV name to add name-value pair.
3216 * @param type FvImage attribute.
3220 public void setTypedNamedFvImageNameValue (String fvName
, String type
, String name
, String value
) {
3221 boolean fvImageExists
= false;
3222 if (getfpdFlash().getFvImages() == null) {
3225 List
<FvImagesDocument
.FvImages
.FvImage
> l
= getfpdFlash().getFvImages().getFvImageList();
3229 ListIterator li
= l
.listIterator();
3230 while(li
.hasNext()) {
3231 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)li
.next();
3232 if (!fi
.getType().toString().equals(type
) && !type
.equals("ALL")) {
3235 if (!fi
.getFvImageNamesList().contains(fvName
)) {
3238 fvImageExists
= true;
3239 setFvImagesFvImageNameValue (fi
, name
, value
, null);
3242 if (!fvImageExists
) {
3243 HashMap
<String
, String
> map
= new HashMap
<String
, String
>();
3244 map
.put(name
, value
);
3245 genFvImagesFvImage(new String
[]{fvName
}, type
, map
);
3249 /**Add to all FvImage elements with type, the name-value pair.
3254 public void setTypedFvImageNameValue (String type
, String name
, String value
) {
3255 if (getfpdFlash().getFvImages() == null) {
3258 List
<FvImagesDocument
.FvImages
.FvImage
> l
= getfpdFlash().getFvImages().getFvImageList();
3262 ListIterator li
= l
.listIterator();
3263 while(li
.hasNext()) {
3264 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)li
.next();
3265 if (!fi
.getType().toString().equals(type
) && !type
.equals("ALL")) {
3268 setFvImagesFvImageNameValue (fi
, name
, value
, null);
3273 public void setFvImagesFvImageNameValue (int i
, String name
, String value
) {
3274 XmlObject o
= getfpdFlash().getFvImages();
3278 XmlCursor cursor
= o
.newCursor();
3279 QName qFvImage
= new QName(xmlNs
, "FvImage");
3280 if (cursor
.toChild(qFvImage
)) {
3281 for (int j
= 0; j
< i
; ++j
) {
3282 cursor
.toNextSibling(qFvImage
);
3284 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
3285 setFvImagesFvImageNameValue (fi
, name
, value
, null);
3290 /**Add to FvImage the name-value pair, or replace old name with newName, or generate new name-value pair if not exists before.
3296 public void setFvImagesFvImageNameValue (FvImagesDocument
.FvImages
.FvImage fi
, String name
, String value
, String newName
) {
3297 if (fi
.getFvImageOptions() == null || fi
.getFvImageOptions().getNameValueList() == null) {
3298 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nv
= fi
.addNewFvImageOptions().addNewNameValue();
3301 if (newName
!= null) {
3302 nv
.setName(newName
);
3307 XmlCursor cursor
= fi
.getFvImageOptions().newCursor();
3308 if (cursor
.toFirstChild()) {
3310 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nv
= (FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
)cursor
.getObject();
3311 if (nv
.getName().equals(name
)) {
3313 if (newName
!= null) {
3314 nv
.setName(newName
);
3319 }while (cursor
.toNextSibling());
3322 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nv
= fi
.getFvImageOptions().addNewNameValue();
3325 if (newName
!= null) {
3326 nv
.setName(newName
);
3331 public void getFvImagesFvImageOptions (String fvName
, Map
<String
, String
> m
) {
3332 Vector
<FvImagesDocument
.FvImages
.FvImage
> vFvImage
= getFvImagesFvImageWithName (fvName
, "Options");
3333 for (int i
= 0; i
< vFvImage
.size(); ++i
) {
3334 FvImagesDocument
.FvImages
.FvImage fi
= vFvImage
.get(i
);
3335 if (fi
== null || fi
.getFvImageOptions() == null || fi
.getFvImageOptions().getNameValueList() == null) {
3339 ListIterator
<FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
> li
= fi
.getFvImageOptions()
3342 while (li
.hasNext()) {
3343 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nv
= li
.next();
3344 m
.put(nv
.getName(), nv
.getValue());
3349 public int getFvImagePosInFvImages (String fvNameList
, String type
) {
3350 XmlObject o
= getfpdFlash().getFvImages();
3356 String
[] fvNameArray
= fvNameList
.trim().split(" ");
3357 Vector
<String
> vFvNames
= new Vector
<String
>();
3360 XmlCursor cursor
= o
.newCursor();
3361 QName qFvImage
= new QName(xmlNs
, "FvImage");
3362 if (cursor
.toChild(qFvImage
)) {
3365 vFvNames
.removeAllElements();
3366 for (int i
= 0; i
< fvNameArray
.length
; ++i
) {
3367 vFvNames
.add(fvNameArray
[i
]);
3369 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
3370 if (!fi
.getType().toString().equals(type
)) {
3373 if (fi
.getFvImageNamesList() == null || fi
.getFvImageNamesList().size() != vFvNames
.size()) {
3376 ListIterator
<String
> li
= fi
.getFvImageNamesList().listIterator();
3377 while (li
.hasNext()) {
3378 String name
= li
.next();
3379 vFvNames
.remove(name
);
3381 if (vFvNames
.size() == 0) {
3386 }while (cursor
.toNextSibling(qFvImage
));
3392 /**Get FvImage Options for FvImage i
3393 * @param i the ith FvImage
3395 public void getFvImagesFvImageOptions(int i
, Map
<String
, String
> m
) {
3396 XmlObject o
= getfpdFlash().getFvImages();
3400 XmlCursor cursor
= o
.newCursor();
3401 QName qFvImage
= new QName(xmlNs
, "FvImage");
3402 if (cursor
.toChild(qFvImage
)) {
3403 for (int j
= 0; j
< i
; ++j
) {
3404 cursor
.toNextSibling(qFvImage
);
3406 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
3407 if (fi
.getFvImageOptions() == null || fi
.getFvImageOptions().getNameValueList() == null){
3411 ListIterator
<FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
> li
= fi
.getFvImageOptions().getNameValueList().listIterator();
3412 while(li
.hasNext()){
3413 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nv
= li
.next();
3414 m
.put(nv
.getName(), nv
.getValue());
3421 Get platform header element
3422 @return PlatformHeaderDocument.PlatformHeader
3424 public PlatformHeaderDocument
.PlatformHeader
getFpdHdr() {
3425 if (fpdHdr
== null) {
3426 fpdHdr
= fpdRoot
.addNewPlatformHeader();
3432 public String
getFpdHdrPlatformName() {
3433 return getFpdHdr().getPlatformName();
3436 public String
getFpdHdrGuidValue() {
3437 return getFpdHdr().getGuidValue();
3440 public String
getFpdHdrVer() {
3441 return getFpdHdr().getVersion();
3444 public String
getFpdHdrAbs() {
3445 return getFpdHdr().getAbstract();
3448 public String
getFpdHdrDescription() {
3449 return getFpdHdr().getDescription();
3452 public String
getFpdHdrCopyright() {
3453 return getFpdHdr().getCopyright();
3456 public String
getFpdHdrLicense() {
3457 LicenseDocument
.License l
= getFpdHdr().getLicense();
3461 return l
.getStringValue();
3464 public String
getFpdHdrUrl() {
3465 LicenseDocument
.License l
= getFpdHdr().getLicense();
3472 public String
getFpdHdrSpec() {
3474 return "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052";
3475 // return getFpdHdr().getSpecification();
3478 public void setFpdHdrPlatformName(String name
){
3479 getFpdHdr().setPlatformName(name
);
3482 public void setFpdHdrGuidValue(String guid
){
3483 getFpdHdr().setGuidValue(guid
);
3486 public void setFpdHdrVer(String v
){
3487 getFpdHdr().setVersion(v
);
3490 public void setFpdHdrAbs(String abs
) {
3491 getFpdHdr().setAbstract(abs
);
3494 public void setFpdHdrDescription(String desc
){
3495 getFpdHdr().setDescription(desc
);
3498 public void setFpdHdrCopyright(String cr
) {
3499 getFpdHdr().setCopyright(cr
);
3502 public void setFpdHdrLicense(String license
){
3503 LicenseDocument
.License l
= getFpdHdr().getLicense();
3505 getFpdHdr().addNewLicense().setStringValue(license
);
3508 l
.setStringValue(license
);
3512 public void setFpdHdrUrl(String url
){
3513 LicenseDocument
.License l
= getFpdHdr().getLicense();
3519 public void setFpdHdrSpec(String s
){
3520 s
= "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052";
3521 getFpdHdr().setSpecification(s
);
3524 Save the processed xml contents to file
3526 @param fpdFile The file to save xml contents
3527 @throws IOException Exceptions during file operation
3529 public void saveAs(File fpdFile
) throws IOException
{
3531 XmlOptions options
= new XmlOptions();
3533 options
.setCharacterEncoding("UTF-8");
3534 options
.setSavePrettyPrint();
3535 options
.setSavePrettyPrintIndent(2);
3537 fpdd
.save(fpdFile
, options
);
3538 } catch (IOException e
) {
3539 e
.printStackTrace();
3544 private String
listToString(List l
) {
3549 ListIterator li
= l
.listIterator();
3550 while(li
.hasNext()) {
3557 private void removeElement(XmlObject o
) {
3558 XmlCursor cursor
= o
.newCursor();
3564 class PcdItemTypeConflictException
extends Exception
{
3569 private static final long serialVersionUID
= 1L;
3570 private String details
= null;
3572 PcdItemTypeConflictException(String pcdName
, String info
){
3573 ModuleIdentification mi
= WorkspaceProfile
.getModuleId(info
);
3574 details
= pcdName
+ " ItemType Conflicts with " + mi
.getName() + " in Pkg " + mi
.getPackageId().getName();
3577 public String
getMessage() {
3582 class PcdDeclNotFound
extends Exception
{
3587 private static final long serialVersionUID
= 1L;
3588 private String details
= null;
3590 PcdDeclNotFound(String info
) {
3591 details
= "PcdDeclNotFound: " + info
;
3594 public String
getMessage() {
3599 class PcdValueMalFormed
extends Exception
{
3604 private static final long serialVersionUID
= 1L;
3605 private String details
= null;
3607 PcdValueMalFormed(String info
) {
3608 details
= "PcdValueMalFormed: " + info
;
3611 public String
getMessage() {