2 Java class FpdFileContents is used to parse fpd xml file.
4 Copyright (c) 2006, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13 package org
.tianocore
.frameworkwizard
.platform
.ui
;
16 import java
.io
.IOException
;
17 import java
.math
.BigInteger
;
18 import java
.util
.ArrayList
;
19 import java
.util
.HashMap
;
20 import java
.util
.Iterator
;
21 import java
.util
.LinkedHashMap
;
22 import java
.util
.List
;
23 import java
.util
.ListIterator
;
26 import java
.util
.Vector
;
28 import javax
.xml
.namespace
.QName
;
30 import org
.apache
.xmlbeans
.XmlCursor
;
31 import org
.apache
.xmlbeans
.XmlObject
;
32 import org
.apache
.xmlbeans
.XmlOptions
;
33 import org
.tianocore
.AntTaskDocument
;
34 import org
.tianocore
.BuildOptionsDocument
;
35 import org
.tianocore
.DynamicPcdBuildDefinitionsDocument
;
36 import org
.tianocore
.EfiSectionType
;
37 import org
.tianocore
.FlashDefinitionFileDocument
;
38 import org
.tianocore
.FlashDocument
;
39 import org
.tianocore
.FrameworkModulesDocument
;
40 import org
.tianocore
.IntermediateOutputType
;
41 import org
.tianocore
.LibrariesDocument
;
42 import org
.tianocore
.ModuleSADocument
;
43 import org
.tianocore
.ModuleSaBuildOptionsDocument
;
44 import org
.tianocore
.ModuleSurfaceAreaDocument
;
45 import org
.tianocore
.OptionDocument
;
46 import org
.tianocore
.OptionsDocument
;
47 import org
.tianocore
.PcdBuildDefinitionDocument
;
48 import org
.tianocore
.PcdCodedDocument
;
49 import org
.tianocore
.PcdDataTypes
;
50 import org
.tianocore
.PcdDeclarationsDocument
;
51 import org
.tianocore
.PcdItemTypes
;
52 import org
.tianocore
.PlatformDefinitionsDocument
;
53 import org
.tianocore
.PlatformSurfaceAreaDocument
;
54 import org
.tianocore
.FvImageTypes
;
55 import org
.tianocore
.FvImagesDocument
;
56 import org
.tianocore
.LicenseDocument
;
57 import org
.tianocore
.PlatformHeaderDocument
;
58 import org
.tianocore
.SkuInfoDocument
;
59 import org
.tianocore
.UserDefinedAntTasksDocument
;
60 import org
.tianocore
.UserExtensionsDocument
;
61 import org
.tianocore
.frameworkwizard
.platform
.ui
.global
.WorkspaceProfile
;
62 import org
.tianocore
.frameworkwizard
.platform
.ui
.global
.SurfaceAreaQuery
;
63 import org
.tianocore
.frameworkwizard
.module
.Identifications
.ModuleIdentification
;
64 import org
.tianocore
.frameworkwizard
.packaging
.PackageIdentification
;
67 This class processes fpd file contents such as add remove xml elements.
68 @since PackageEditor 1.0
70 public class FpdFileContents
{
72 static final String xmlNs
= "http://www.TianoCore.org/2006/Edk2.0";
74 private PlatformSurfaceAreaDocument fpdd
= null;
76 private PlatformSurfaceAreaDocument
.PlatformSurfaceArea fpdRoot
= null;
78 private PlatformHeaderDocument
.PlatformHeader fpdHdr
= null;
80 private PlatformDefinitionsDocument
.PlatformDefinitions fpdPlatformDefs
= null;
82 private FlashDocument
.Flash fpdFlash
= null;
84 private BuildOptionsDocument
.BuildOptions fpdBuildOpts
= null;
86 private FrameworkModulesDocument
.FrameworkModules fpdFrameworkModules
= null;
88 private DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions fpdDynPcdBuildDefs
= null;
90 private HashMap
<String
, ArrayList
<String
>> dynPcdMap
= null;
92 private HashMap
<String
, String
> defaultPcdValue
= new HashMap
<String
, String
>();
95 * look through all pcd data in all ModuleSA, create pcd -> ModuleSA mappings.
97 public void initDynPcdMap() {
98 if (dynPcdMap
== null) {
99 dynPcdMap
= new HashMap
<String
, ArrayList
<String
>>();
100 List
<ModuleSADocument
.ModuleSA
> l
= getfpdFrameworkModules().getModuleSAList();
102 removeElement(getfpdFrameworkModules());
103 fpdFrameworkModules
= null;
106 ListIterator
<ModuleSADocument
.ModuleSA
> li
= l
.listIterator();
107 while (li
.hasNext()) {
108 ModuleSADocument
.ModuleSA moduleSa
= li
.next();
109 if (moduleSa
.getPcdBuildDefinition() == null || moduleSa
.getPcdBuildDefinition().getPcdDataList() == null) {
112 String ModuleInfo
= moduleSa
.getModuleGuid() + " " + moduleSa
.getModuleVersion() +
113 " " + moduleSa
.getPackageGuid() + " " + moduleSa
.getPackageVersion() + " " + listToString(moduleSa
.getSupArchList());
114 List
<PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
> lp
= moduleSa
.getPcdBuildDefinition().getPcdDataList();
115 ListIterator
<PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
> lpi
= lp
.listIterator();
116 while (lpi
.hasNext()) {
117 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= lpi
.next();
118 String pcdKey
= pcdData
.getCName() + " " + pcdData
.getTokenSpaceGuidCName();
119 if (dynPcdMap
.get(pcdKey
) == null) {
120 ArrayList
<String
> al
= new ArrayList
<String
>();
121 al
.add(ModuleInfo
+ " " + pcdData
.getItemType().toString());
122 dynPcdMap
.put(pcdKey
, al
);
125 dynPcdMap
.get(pcdKey
).add(ModuleInfo
+ " " + pcdData
.getItemType().toString());
132 public ArrayList
<String
> getDynPcdMapValue(String key
) {
133 return dynPcdMap
.get(key
);
136 Constructor to create a new spd file
138 public FpdFileContents() {
140 fpdd
= PlatformSurfaceAreaDocument
.Factory
.newInstance();
141 fpdRoot
= fpdd
.addNewPlatformSurfaceArea();
146 Constructor for existing document object
149 public FpdFileContents(PlatformSurfaceAreaDocument
.PlatformSurfaceArea fpd
) {
151 fpdHdr
= fpdRoot
.getPlatformHeader();
152 fpdPlatformDefs
= fpdRoot
.getPlatformDefinitions();
153 fpdBuildOpts
= fpdRoot
.getBuildOptions();
154 fpdFrameworkModules
= fpdRoot
.getFrameworkModules();
155 fpdDynPcdBuildDefs
= fpdRoot
.getDynamicPcdBuildDefinitions();
156 fpdFlash
= fpdRoot
.getFlash();
160 Constructor based on an existing spd file
162 @param f Existing spd file
164 public FpdFileContents(File f
) {
166 fpdd
= PlatformSurfaceAreaDocument
.Factory
.parse(f
);
167 fpdRoot
= fpdd
.getPlatformSurfaceArea();
168 } catch (Exception e
) {
169 System
.out
.println(e
.toString());
173 public DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
getfpdDynPcdBuildDefs() {
174 if (fpdDynPcdBuildDefs
== null){
175 fpdDynPcdBuildDefs
= fpdRoot
.addNewDynamicPcdBuildDefinitions();
177 return fpdDynPcdBuildDefs
;
180 public FrameworkModulesDocument
.FrameworkModules
getfpdFrameworkModules() {
181 if (fpdFrameworkModules
== null){
182 fpdFrameworkModules
= fpdRoot
.addNewFrameworkModules();
184 return fpdFrameworkModules
;
187 public void getFrameworkModuleGuid (String fvName
, Vector
<String
> vGuid
) {
188 if (getFrameworkModulesCount() == 0){
192 ListIterator li
= getfpdFrameworkModules().getModuleSAList().listIterator();
193 while(li
.hasNext()) {
194 ModuleSADocument
.ModuleSA moduleSa
= (ModuleSADocument
.ModuleSA
)li
.next();
195 if (moduleSa
.getModuleSaBuildOptions() == null) {
198 String fvBinding
= moduleSa
.getModuleSaBuildOptions().getFvBinding();
199 if (fvBinding
== null) {
203 String
[] fvNames
= fvBinding
.split(" ");
204 for (int i
= 0; i
< fvNames
.length
; ++i
) {
205 if (fvNames
[i
].equals(fvName
) || fvNames
[i
].replaceAll("_", "").equals(fvName
)) {
206 vGuid
.add(moduleSa
.getModuleGuid());
213 public int getFrameworkModulesCount() {
214 if (getfpdFrameworkModules().getModuleSAList() == null || getfpdFrameworkModules().getModuleSAList().size() == 0){
215 removeElement(getfpdFrameworkModules());
216 fpdFrameworkModules
= null;
219 return getfpdFrameworkModules().getModuleSAList().size();
222 public void getFrameworkModulesInfo(String
[][] saa
) {
223 if (getFrameworkModulesCount() == 0){
227 ListIterator li
= getfpdFrameworkModules().getModuleSAList().listIterator();
229 while(li
.hasNext()) {
230 ModuleSADocument
.ModuleSA moduleSa
= (ModuleSADocument
.ModuleSA
)li
.next();
231 saa
[i
][0] = moduleSa
.getModuleGuid();
232 saa
[i
][1] = moduleSa
.getModuleVersion();
234 saa
[i
][2] = moduleSa
.getPackageGuid();
235 saa
[i
][3] = moduleSa
.getPackageVersion();
236 saa
[i
][4] = listToString(moduleSa
.getSupArchList());
241 public void getFrameworkModuleInfo(int i
, String
[] sa
) {
242 ModuleSADocument
.ModuleSA msa
= getModuleSA(i
);
246 sa
[0] = msa
.getModuleGuid();
247 sa
[1] = msa
.getModuleVersion();
248 sa
[2] = msa
.getPackageGuid();
249 sa
[3] = msa
.getPackageVersion();
250 sa
[4] = listToString(msa
.getSupArchList());
253 public ModuleSADocument
.ModuleSA
getModuleSA(String key
) {
254 String
[] s
= key
.split(" ");
255 if (getfpdFrameworkModules().getModuleSAList() == null || getfpdFrameworkModules().getModuleSAList().size() == 0) {
256 removeElement(getfpdFrameworkModules());
257 fpdFrameworkModules
= null;
260 ListIterator li
= getfpdFrameworkModules().getModuleSAList().listIterator();
261 while(li
.hasNext()) {
262 ModuleSADocument
.ModuleSA moduleSa
= (ModuleSADocument
.ModuleSA
)li
.next();
263 if (moduleSa
.getModuleGuid().equalsIgnoreCase(s
[0]) && moduleSa
.getPackageGuid().equalsIgnoreCase(s
[2])) {
264 if (moduleSa
.getModuleVersion() != null) {
265 if (!moduleSa
.getModuleVersion().equals(s
[1])) {
269 if (moduleSa
.getPackageVersion() != null) {
270 if (!moduleSa
.getPackageVersion().equals(s
[3])) {
274 //ToDo add arch check for s[4]
275 if (moduleSa
.getSupArchList() != null) {
276 if (!listToString(moduleSa
.getSupArchList()).equals(s
[4])) {
286 private ModuleSADocument
.ModuleSA
getModuleSA(int i
) {
287 ModuleSADocument
.ModuleSA moduleSa
= null;
288 if (fpdRoot
.getFrameworkModules() == null) {
291 XmlCursor cursor
= fpdRoot
.getFrameworkModules().newCursor();
292 if (cursor
.toFirstChild()) {
293 for (int j
= 0; j
< i
; ++j
) {
294 cursor
.toNextSibling();
296 moduleSa
= (ModuleSADocument
.ModuleSA
)cursor
.getObject();
302 public void removeModuleSA(int i
) {
303 XmlObject o
= fpdRoot
.getFrameworkModules();
308 XmlCursor cursor
= o
.newCursor();
309 if (cursor
.toFirstChild()) {
310 for (int j
= 0; j
< i
; ++j
) {
311 cursor
.toNextSibling();
314 // remove pcd from dynPcdMap, if DynamicPcdBuildData exists, remove them too.
316 ModuleSADocument
.ModuleSA moduleSa
= (ModuleSADocument
.ModuleSA
)cursor
.getObject();
317 String moduleInfo
= moduleSa
.getModuleGuid() + " " + moduleSa
.getModuleVersion() + " " +
318 moduleSa
.getPackageGuid()+ " " + moduleSa
.getPackageVersion() + " " + listToString(moduleSa
.getSupArchList());
319 PcdBuildDefinitionDocument
.PcdBuildDefinition pcdBuildDef
= moduleSa
.getPcdBuildDefinition();
320 if (pcdBuildDef
!= null && pcdBuildDef
.getPcdDataList() != null) {
321 ListIterator
<PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
> li
= pcdBuildDef
.getPcdDataList().listIterator();
322 while(li
.hasNext()) {
323 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= li
.next();
324 maintainDynPcdMap(pcdData
.getCName() + " " + pcdData
.getTokenSpaceGuidCName(), moduleInfo
);
329 cursor
.toPrevToken();
330 if (cursor
.isComment()) {
335 if (getFrameworkModulesCount() == 0) {
343 public boolean adjustPcd (int seqModuleSa
) throws Exception
{
344 boolean dataModified
= false;
345 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(seqModuleSa
);
346 int pcdCount
= getPcdDataCount(seqModuleSa
);
347 String
[][] saaModuleSaPcd
= new String
[pcdCount
][7];
348 getPcdData(seqModuleSa
, saaModuleSaPcd
);
349 String mg
= moduleSa
.getModuleGuid();
350 String mv
= moduleSa
.getModuleVersion();
351 String pg
= moduleSa
.getPackageGuid();
352 String pv
= moduleSa
.getPackageVersion();
353 String arch
= listToString(moduleSa
.getSupArchList());
355 // delete pcd in ModuleSA but not in MSA files any longer.
357 String moduleKey
= mg
+ " " + mv
+ " " + pg
+ " " + pv
+ " " + arch
;
358 int libCount
= getLibraryInstancesCount(moduleKey
);
359 String
[][] saaLib
= new String
[libCount
][5];
360 getLibraryInstances(moduleKey
, saaLib
);
361 ModuleIdentification mi
= WorkspaceProfile
.getModuleId(moduleKey
);
362 Vector
<ModuleIdentification
> vMi
= new Vector
<ModuleIdentification
>();
365 nextPcd
:for (int i
= 0; i
< saaModuleSaPcd
.length
; ++i
) {
366 if (WorkspaceProfile
.pcdInMsa(saaModuleSaPcd
[i
][0], saaModuleSaPcd
[i
][1], mi
)){
369 for (int j
= 0; j
< saaLib
.length
; ++j
) {
370 String libKey
= saaLib
[j
][1] + " " + saaLib
[j
][2] + " " + saaLib
[j
][3] + " " + saaLib
[j
][4];
371 ModuleIdentification libMi
= WorkspaceProfile
.getModuleId(libKey
);
373 if (WorkspaceProfile
.pcdInMsa(saaModuleSaPcd
[i
][0], saaModuleSaPcd
[i
][1], libMi
)) {
377 removePcdData(seqModuleSa
, saaModuleSaPcd
[i
][0], saaModuleSaPcd
[i
][1]);
381 catch (Exception e
) {
385 // add new Pcd from MSA file to ModuleSA.
389 for (int i
= 0; i
< vMi
.size(); ++i
) {
390 ModuleSurfaceAreaDocument
.ModuleSurfaceArea msa
= (ModuleSurfaceAreaDocument
.ModuleSurfaceArea
) WorkspaceProfile
391 .getModuleXmlObject(vMi
393 if (msa
.getPcdCoded() == null || msa
.getPcdCoded().getPcdEntryList() == null) {
396 ListIterator li
= msa
.getPcdCoded().getPcdEntryList().listIterator();
397 msaPcdIter
:while (li
.hasNext()) {
398 PcdCodedDocument
.PcdCoded
.PcdEntry msaPcd
= (PcdCodedDocument
.PcdCoded
.PcdEntry
) li
.next();
399 ArrayList
<String
> al
= getDynPcdMapValue(msaPcd
.getCName() + " " + msaPcd
.getTokenSpaceGuidCName());
401 for (int j
= 0; j
< al
.size(); ++j
) {
402 if (al
.get(j
).contains(moduleKey
)) {
408 Map
<String
, XmlObject
> m
= new HashMap
<String
, XmlObject
>();
409 m
.put("ModuleSurfaceArea", msa
);
410 SurfaceAreaQuery
.setDoc(m
);
411 PackageIdentification
[] depPkgs
= SurfaceAreaQuery
.getDependencePkg(null, vMi
.get(i
));
412 PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry spdPcd
= LookupPcdDeclaration(msaPcd
, depPkgs
);
413 if (spdPcd
== null) {
417 throw new PcdDeclNotFound("No Declaration for PCD Entry " + msaPcd
.getCName() + " in Module "
421 // AddItem to ModuleSA PcdBuildDefinitions
423 String defaultVal
= msaPcd
.getDefaultValue() == null ? spdPcd
.getDefaultValue()
424 : msaPcd
.getDefaultValue();
426 genPcdData(msaPcd
.getCName(), spdPcd
.getToken(), msaPcd
.getTokenSpaceGuidCName(),
427 msaPcd
.getPcdItemType().toString(), spdPcd
.getDatumType() + "", defaultVal
, moduleSa
);
440 private void maintainDynPcdMap(String pcdKey
, String moduleInfo
) {
442 ArrayList
<String
> al
= dynPcdMap
.get(pcdKey
);
446 String
[] s
= moduleInfo
.split(" ");
447 for(int i
= 0; i
< al
.size(); ++i
){
448 String consumer
= al
.get(i
);
449 if (consumer
.contains(s
[0]) && consumer
.contains(s
[2])){
450 String
[] consumerPart
= consumer
.split(" ");
451 if (!consumerPart
[4].equals(s
[4])) {
459 if (al
.size() == 0) {
460 defaultPcdValue
.remove(pcdKey
);
461 dynPcdMap
.remove(pcdKey
);
462 String
[] s1
= pcdKey
.split(" ");
463 removeDynamicPcdBuildData(s1
[0], s1
[1]);
468 // key for ModuleSA : "ModuleGuid ModuleVer PackageGuid PackageVer Arch"
470 public int getPcdDataCount (int i
){
471 ModuleSADocument
.ModuleSA msa
= getModuleSA(i
);
473 if (msa
== null || msa
.getPcdBuildDefinition() == null || msa
.getPcdBuildDefinition().getPcdDataList() == null){
476 return msa
.getPcdBuildDefinition().getPcdDataList().size();
480 public void getPcdData (int i
, String
[][] saa
) {
481 ModuleSADocument
.ModuleSA msa
= getModuleSA(i
);
483 if (msa
== null || msa
.getPcdBuildDefinition() == null || msa
.getPcdBuildDefinition().getPcdDataList() == null){
486 ListIterator
<PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
>li
= msa
.getPcdBuildDefinition().getPcdDataList().listIterator();
487 for (int k
= 0; k
< saa
.length
; ++k
) {
488 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= li
.next();
489 saa
[k
][0] = pcdData
.getCName();
490 saa
[k
][1] = pcdData
.getTokenSpaceGuidCName();
491 saa
[k
][2] = pcdData
.getItemType()+"";
492 saa
[k
][3] = pcdData
.getToken().toString();
493 saa
[k
][4] = pcdData
.getMaxDatumSize()+"";
494 saa
[k
][5] = pcdData
.getDatumType()+"";
495 saa
[k
][6] = pcdData
.getValue();
500 public void removePcdData (int seqModuleSa
, String cName
, String tsGuid
) {
501 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(seqModuleSa
);
502 if (moduleSa
== null || moduleSa
.getPcdBuildDefinition() == null){
506 String mg
= moduleSa
.getModuleGuid();
507 String mv
= moduleSa
.getModuleVersion();
508 String pg
= moduleSa
.getPackageGuid();
509 String pv
= moduleSa
.getPackageVersion();
510 String arch
= listToString(moduleSa
.getSupArchList());
511 String moduleKey
= mg
+ " " + mv
+ " " + pg
+ " " + pv
+ " " + arch
;
513 XmlCursor cursor
= moduleSa
.getPcdBuildDefinition().newCursor();
514 if (cursor
.toFirstChild()){
517 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= (PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
)cursor
.getObject();
518 if (pcdData
.getCName().equals(cName
) && pcdData
.getTokenSpaceGuidCName().equals(tsGuid
)) {
519 maintainDynPcdMap(cName
+ " " + tsGuid
, moduleKey
);
520 if (getPcdDataCount(seqModuleSa
) == 1) {
527 while(cursor
.toNextSibling());
533 public void updatePcdData (String key
, String cName
, String tsGuid
, String itemType
, String maxSize
, String value
){
534 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(key
);
535 if (moduleSa
== null || moduleSa
.getPcdBuildDefinition() == null){
539 XmlCursor cursor
= moduleSa
.getPcdBuildDefinition().newCursor();
540 if (cursor
.toFirstChild()){
542 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= (PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
)cursor
.getObject();
543 if (pcdData
.getCName().equals(cName
) && pcdData
.getTokenSpaceGuidCName().equals(tsGuid
)) {
544 pcdData
.setItemType(PcdItemTypes
.Enum
.forString(itemType
));
545 if(pcdData
.getDatumType().equals("VOID*")) {
546 pcdData
.setMaxDatumSize(new Integer(maxSize
));
548 pcdData
.setValue(value
);
549 defaultPcdValue
.put(cName
+ " " + tsGuid
, value
);
553 while(cursor
.toNextSibling());
558 /**Get original Pcd info from MSA & SPD files.
559 * @param mi ModuleIdentification from which MSA & SPD come
560 * @param cName PCD cName
561 * @param sa Results: HelpText, Original item type.
564 public boolean getPcdBuildDataInfo(ModuleIdentification mi
, String cName
, String tsGuid
, String
[] sa
) throws Exception
{
567 ModuleSurfaceAreaDocument
.ModuleSurfaceArea msa
= (ModuleSurfaceAreaDocument
.ModuleSurfaceArea
)WorkspaceProfile
.getModuleXmlObject(mi
);
568 if (msa
.getPcdCoded() == null) {
572 Map
<String
, XmlObject
> m
= new HashMap
<String
, XmlObject
>();
573 m
.put("ModuleSurfaceArea", msa
);
574 SurfaceAreaQuery
.setDoc(m
);
575 PackageIdentification
[] depPkgs
= SurfaceAreaQuery
.getDependencePkg(null, mi
);
577 // First look through MSA pcd entries.
579 List
<PcdCodedDocument
.PcdCoded
.PcdEntry
> l
= msa
.getPcdCoded().getPcdEntryList();
580 ListIterator li
= l
.listIterator();
581 while(li
.hasNext()) {
582 PcdCodedDocument
.PcdCoded
.PcdEntry msaPcd
= (PcdCodedDocument
.PcdCoded
.PcdEntry
)li
.next();
583 if (!msaPcd
.getCName().equals(cName
)) {
586 if (!msaPcd
.getTokenSpaceGuidCName().equals(tsGuid
)) {
589 PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry spdPcd
= LookupPcdDeclaration(msaPcd
, depPkgs
);
590 if (spdPcd
== null) {
594 throw new PcdDeclNotFound(mi
.getName() + " " + msaPcd
.getCName());
597 // Get Pcd help text and original item type.
599 sa
[0] = spdPcd
.getHelpText() + msaPcd
.getHelpText();
600 sa
[1] = msaPcd
.getPcdItemType()+"";
614 /**Remove PCDBuildDefinition entries from ModuleSA
615 * @param moduleKey identifier of ModuleSA.
616 * @param consumer where these entries come from.
618 public void removePcdData(String moduleKey
, ModuleIdentification consumer
) {
620 ModuleSurfaceAreaDocument
.ModuleSurfaceArea msa
= (ModuleSurfaceAreaDocument
.ModuleSurfaceArea
)WorkspaceProfile
.getModuleXmlObject(consumer
);
621 if (msa
.getPcdCoded() == null) {
625 List
<PcdCodedDocument
.PcdCoded
.PcdEntry
> l
= msa
.getPcdCoded().getPcdEntryList();
626 ListIterator li
= l
.listIterator();
628 while(li
.hasNext()) {
629 PcdCodedDocument
.PcdCoded
.PcdEntry msaPcd
= (PcdCodedDocument
.PcdCoded
.PcdEntry
)li
.next();
630 ModuleSADocument
.ModuleSA moduleSA
= getModuleSA(moduleKey
);
631 if (moduleSA
.getPcdBuildDefinition() != null) {
632 XmlCursor cursor
= moduleSA
.getPcdBuildDefinition().newCursor();
633 if (cursor
.toFirstChild()) {
634 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= (PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
) cursor
636 if (msaPcd
.getCName().equals(pcdData
.getCName())
637 && msaPcd
.getTokenSpaceGuidCName().equals(pcdData
.getTokenSpaceGuidCName())) {
639 maintainDynPcdMap(pcdData
.getCName() + " " + pcdData
.getTokenSpaceGuidCName(), moduleKey
);
643 while (cursor
.toNextSibling()) {
644 pcdData
= (PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
) cursor
.getObject();
645 if (msaPcd
.getCName().equals(pcdData
.getCName())
646 && msaPcd
.getTokenSpaceGuidCName().equals(pcdData
.getTokenSpaceGuidCName())) {
647 maintainDynPcdMap(pcdData
.getCName() + " " + pcdData
.getTokenSpaceGuidCName(),
665 // key for ModuleSA : "ModuleGuid ModuleVer PackageGuid PackageVer Arch"
667 public int getLibraryInstancesCount(String key
) {
668 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
669 if (msa
== null || msa
.getLibraries() == null || msa
.getLibraries().getInstanceList() == null){
672 return msa
.getLibraries().getInstanceList().size();
675 public void getLibraryInstances(String key
, String
[][] saa
){
676 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
677 if (msa
== null || msa
.getLibraries() == null || msa
.getLibraries().getInstanceList() == null){
681 ListIterator
<LibrariesDocument
.Libraries
.Instance
> li
= msa
.getLibraries().getInstanceList().listIterator();
682 for (int i
= 0; i
< saa
.length
; ++i
) {
683 LibrariesDocument
.Libraries
.Instance instance
= li
.next();
684 saa
[i
][1] = instance
.getModuleGuid();
685 saa
[i
][2] = instance
.getModuleVersion();
686 saa
[i
][3] = instance
.getPackageGuid();
687 saa
[i
][4] = instance
.getPackageVersion();
691 public void removeLibraryInstance(String key
, int i
) {
692 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
693 if (msa
== null || msa
.getLibraries() == null){
697 XmlCursor cursor
= msa
.getLibraries().newCursor();
698 if (cursor
.toFirstChild()) {
699 for (int j
= 0; j
< i
; ++j
) {
700 cursor
.toNextSibling();
703 cursor
.toPrevToken();
704 if (cursor
.isComment()) {
709 if (getLibraryInstancesCount(key
) == 0) {
718 public void genLibraryInstance(ModuleIdentification libMi
, String key
) {
719 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
721 msa
= getfpdFrameworkModules().addNewModuleSA();
723 LibrariesDocument
.Libraries libs
= msa
.getLibraries();
725 libs
= msa
.addNewLibraries();
728 String mn
= libMi
.getName();
729 String mg
= libMi
.getGuid();
730 String mv
= libMi
.getVersion();
731 String pn
= libMi
.getPackageId().getName();
732 String pg
= libMi
.getPackageId().getGuid();
733 String pv
= libMi
.getPackageId().getVersion();
734 LibrariesDocument
.Libraries
.Instance instance
= libs
.addNewInstance();
735 XmlCursor cursor
= instance
.newCursor();
737 String comment
= "Pkg: " + pn
+ " Mod: " + mn
738 + " Path: " + libMi
.getPath().substring(System
.getenv("WORKSPACE").length() + 1);
739 cursor
.insertComment(comment
);
748 instance
.setModuleGuid(mg
);
749 instance
.setModuleVersion(mv
);
750 instance
.setPackageGuid(pg
);
751 instance
.setPackageVersion(pv
);
755 public String
getFvBinding(String moduleKey
){
756 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
757 if (msa
== null || msa
.getModuleSaBuildOptions() == null) {
760 return msa
.getModuleSaBuildOptions().getFvBinding();
763 public void setFvBinding(ModuleSADocument
.ModuleSA moduleSa
, String fvBinding
) {
764 if (moduleSa
== null ) {
767 if (fvBinding
== null || fvBinding
.length() == 0) {
768 if(moduleSa
.getModuleSaBuildOptions() != null){
769 moduleSa
.getModuleSaBuildOptions().unsetFvBinding();
773 if(moduleSa
.getModuleSaBuildOptions() == null){
774 moduleSa
.addNewModuleSaBuildOptions().setFvBinding(fvBinding
);
777 moduleSa
.getModuleSaBuildOptions().setFvBinding(fvBinding
);
781 public void setFvBinding(String moduleKey
, String fvBinding
){
782 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(moduleKey
);
783 setFvBinding (moduleSa
, fvBinding
);
786 public void removeFvBinding (ModuleSADocument
.ModuleSA moduleSa
, String fvName
) {
787 if (moduleSa
== null || moduleSa
.getModuleSaBuildOptions() == null || moduleSa
.getModuleSaBuildOptions().getFvBinding() == null) {
791 String fvNameList
= moduleSa
.getModuleSaBuildOptions().getFvBinding();
792 String
[] fvNamesArray
= fvNameList
.split(" ");
794 for (int i
= 0; i
< fvNamesArray
.length
; ++i
) {
795 if (fvNamesArray
[i
].equals(fvName
)) {
800 // jump over where the input fvName occurs in the original Fv list.
801 if (occursAt
!= -1) {
802 String newFvNameList
= " ";
803 for (int i
= 0; i
< fvNamesArray
.length
; ++i
) {
807 newFvNameList
+= fvNamesArray
[i
];
809 setFvBinding (moduleSa
, newFvNameList
.trim());
815 * @param fvName The FV name that to be removed from FvBinding List.
817 public void removeFvBindingAll (String fvName
) {
818 if (getfpdFrameworkModules().getModuleSAList() == null || getfpdFrameworkModules().getModuleSAList().size() == 0){
819 removeElement(getfpdFrameworkModules());
820 fpdFrameworkModules
= null;
824 Iterator
<ModuleSADocument
.ModuleSA
> li
= getfpdFrameworkModules().getModuleSAList().iterator();
825 while (li
.hasNext()) {
826 ModuleSADocument
.ModuleSA moduleSa
= li
.next();
827 removeFvBinding (moduleSa
, fvName
);
831 public void appendFvBinding (String moduleKey
, String fvName
) {
832 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(moduleKey
);
833 appendFvBinding (moduleSa
, fvName
);
836 public void appendFvBinding (ModuleSADocument
.ModuleSA moduleSa
, String fvName
) {
837 if (moduleSa
== null) {
841 if (moduleSa
.getModuleSaBuildOptions() == null || moduleSa
.getModuleSaBuildOptions().getFvBinding() == null) {
842 setFvBinding(moduleSa
, fvName
);
846 String fvNameList
= moduleSa
.getModuleSaBuildOptions().getFvBinding();
847 String newFvNameList
= fvNameList
+ " " + fvName
;
848 setFvBinding (moduleSa
, newFvNameList
.trim());
851 public void updateFvBindingInModuleSA (ModuleIdentification mi
, String fvName
) {
852 Vector
<Object
> vSupArchs
= new Vector
<Object
>();
853 getPlatformDefsSupportedArchs(vSupArchs
);
854 String moduleInfo
= mi
.getGuid() + " " + mi
.getVersion() + " " + mi
.getPackageId().getGuid() + " " + mi
.getPackageId().getVersion();
855 for (int i
= 0; i
< vSupArchs
.size(); ++i
) {
856 String moduleKey
= moduleInfo
+ " " + vSupArchs
.get(i
);
857 appendFvBinding (moduleKey
, fvName
);
861 public String
getFfsFileNameGuid(String moduleKey
){
862 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(moduleKey
);
863 if (moduleSa
== null || moduleSa
.getModuleSaBuildOptions() == null) {
866 return moduleSa
.getModuleSaBuildOptions().getFfsFileNameGuid();
869 public void setFfsFileNameGuid(String moduleKey
, String fileGuid
){
870 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
874 if(msa
.getModuleSaBuildOptions() == null){
875 msa
.addNewModuleSaBuildOptions();
878 ModuleSaBuildOptionsDocument
.ModuleSaBuildOptions msaBuildOpts
= msa
.getModuleSaBuildOptions();
879 if (fileGuid
!= null) {
880 msaBuildOpts
.setFfsFileNameGuid(fileGuid
);
883 XmlCursor cursor
= msaBuildOpts
.newCursor();
884 if (cursor
.toChild(xmlNs
, "FfsFileNameGuid")) {
892 public String
getFfsFormatKey(String moduleKey
){
893 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
894 if (msa
== null || msa
.getModuleSaBuildOptions() == null) {
897 return msa
.getModuleSaBuildOptions().getFfsFormatKey();
900 public void setFfsFormatKey(String moduleKey
, String ffsKey
){
901 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
905 if(msa
.getModuleSaBuildOptions() == null){
906 msa
.addNewModuleSaBuildOptions().setFfsFormatKey(ffsKey
);
909 msa
.getModuleSaBuildOptions().setFfsFormatKey(ffsKey
);
912 public void setModuleSAForceDebug(int i
, boolean dbgEnable
) {
913 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(i
);
914 moduleSa
.setForceDebug(dbgEnable
);
917 public boolean getModuleSAForceDebug (int i
) {
918 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(i
);
919 if (moduleSa
.getForceDebug() == true) {
925 public void getModuleSAOptions(String moduleKey
, String
[][] saa
) {
926 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
927 if (msa
== null || msa
.getModuleSaBuildOptions() == null || msa
.getModuleSaBuildOptions().getOptions() == null
928 || msa
.getModuleSaBuildOptions().getOptions().getOptionList() == null) {
932 List
<OptionDocument
.Option
> lOpt
= msa
.getModuleSaBuildOptions().getOptions().getOptionList();
933 ListIterator li
= lOpt
.listIterator();
935 while(li
.hasNext()) {
936 OptionDocument
.Option opt
= (OptionDocument
.Option
)li
.next();
937 if (opt
.getBuildTargets() != null) {
938 saa
[i
][0] = listToString(opt
.getBuildTargets());
940 saa
[i
][1] = opt
.getToolChainFamily();
941 saa
[i
][2] = opt
.getTagName();
942 saa
[i
][3] = opt
.getToolCode();
944 if (opt
.getSupArchList() != null){
945 saa
[i
][4] = listToString(opt
.getSupArchList());
949 saa
[i
][5] = opt
.getStringValue();
955 public int getModuleSAOptionsCount(String moduleKey
){
956 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
957 if (msa
== null || msa
.getModuleSaBuildOptions() == null || msa
.getModuleSaBuildOptions().getOptions() == null
958 || msa
.getModuleSaBuildOptions().getOptions().getOptionList() == null) {
961 return msa
.getModuleSaBuildOptions().getOptions().getOptionList().size();
964 public void genModuleSAOptionsOpt(String moduleKey
, Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
) {
965 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
966 if (msa
.getModuleSaBuildOptions() == null) {
967 msa
.addNewModuleSaBuildOptions();
969 if (msa
.getModuleSaBuildOptions().getOptions() == null){
970 msa
.getModuleSaBuildOptions().addNewOptions();
972 OptionDocument
.Option opt
= msa
.getModuleSaBuildOptions().getOptions().addNewOption();
973 setBuildOptionsOpt(buildTargets
, toolChain
, tagName
, toolCmd
, archList
, contents
, opt
);
976 public void removeModuleSAOptionsOpt(String moduleKey
, int i
) {
977 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
978 if (msa
.getModuleSaBuildOptions() == null || msa
.getModuleSaBuildOptions().getOptions() == null) {
981 OptionsDocument
.Options opts
= msa
.getModuleSaBuildOptions().getOptions();
982 XmlCursor cursor
= opts
.newCursor();
983 if (cursor
.toFirstChild()) {
984 for (int j
= 0; j
< i
; ++j
){
985 cursor
.toNextSibling();
992 public void updateModuleSAOptionsOpt(String moduleKey
, int i
, Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
) {
993 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
994 if (msa
.getModuleSaBuildOptions() == null || msa
.getModuleSaBuildOptions().getOptions() == null) {
997 OptionsDocument
.Options opts
= msa
.getModuleSaBuildOptions().getOptions();
998 XmlCursor cursor
= opts
.newCursor();
999 if (cursor
.toFirstChild()) {
1000 for (int j
= 0; j
< i
; ++j
){
1001 cursor
.toNextSibling();
1003 OptionDocument
.Option opt
= (OptionDocument
.Option
)cursor
.getObject();
1004 setBuildOptionsOpt(buildTargets
, toolChain
, tagName
, toolCmd
, archList
, contents
, opt
);
1009 /**add pcd information of module mi to a ModuleSA.
1011 * @param moduleSa if null, generate a new ModuleSA.
1013 public void addFrameworkModulesPcdBuildDefs(ModuleIdentification mi
, String arch
, ModuleSADocument
.ModuleSA moduleSa
) throws Exception
{
1014 //ToDo add Arch filter
1017 if (moduleSa
== null) {
1018 moduleSa
= genModuleSA(mi
, arch
);
1021 ModuleSurfaceAreaDocument
.ModuleSurfaceArea msa
= (ModuleSurfaceAreaDocument
.ModuleSurfaceArea
)WorkspaceProfile
.getModuleXmlObject(mi
);
1022 if (msa
.getPcdCoded() == null) {
1026 Map
<String
, XmlObject
> m
= new HashMap
<String
, XmlObject
>();
1027 m
.put("ModuleSurfaceArea", msa
);
1028 SurfaceAreaQuery
.setDoc(m
);
1029 PackageIdentification
[] depPkgs
= SurfaceAreaQuery
.getDependencePkg(null, mi
);
1031 // Implementing InitializePlatformPcdBuildDefinitions
1033 List
<PcdCodedDocument
.PcdCoded
.PcdEntry
> l
= msa
.getPcdCoded().getPcdEntryList();
1034 ListIterator li
= l
.listIterator();
1035 while(li
.hasNext()) {
1036 PcdCodedDocument
.PcdCoded
.PcdEntry msaPcd
= (PcdCodedDocument
.PcdCoded
.PcdEntry
)li
.next();
1037 PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry spdPcd
= LookupPcdDeclaration(msaPcd
, depPkgs
);
1038 if (spdPcd
== null) {
1042 throw new PcdDeclNotFound("No Declaration for PCD Entry " + msaPcd
.getCName() + " in Module " + mi
.getName());
1045 // AddItem to ModuleSA PcdBuildDefinitions
1047 String defaultVal
= msaPcd
.getDefaultValue() == null ? spdPcd
.getDefaultValue() : msaPcd
.getDefaultValue();
1049 genPcdData(msaPcd
.getCName(), spdPcd
.getToken(), msaPcd
.getTokenSpaceGuidCName(), msaPcd
.getPcdItemType().toString(), spdPcd
.getDatumType()+"", defaultVal
, moduleSa
);
1053 catch (Exception e
){
1060 private PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry
LookupPcdDeclaration (PcdCodedDocument
.PcdCoded
.PcdEntry msaPcd
, PackageIdentification
[] depPkgs
) {
1062 PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry spdPcd
= null;
1063 for (int i
= 0; i
< depPkgs
.length
; ++i
) {
1065 XmlObject
[] xo
= SurfaceAreaQuery
.getSpdPcdDeclarations(depPkgs
[i
]);
1069 for (int j
= 0; j
< xo
.length
; ++j
) {
1070 spdPcd
= (PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry
)xo
[j
];
1071 if (msaPcd
.getTokenSpaceGuidCName() == null) {
1072 if (spdPcd
.getCName().equals(msaPcd
.getCName())) {
1077 if (spdPcd
.getCName().equals(msaPcd
.getCName()) && spdPcd
.getTokenSpaceGuidCName().equals(msaPcd
.getTokenSpaceGuidCName())) {
1088 private ModuleSADocument
.ModuleSA
genModuleSA (ModuleIdentification mi
, String arch
) {
1089 PackageIdentification pi
= WorkspaceProfile
.getPackageForModule(mi
);
1090 ModuleSADocument
.ModuleSA msa
= getfpdFrameworkModules().addNewModuleSA();
1091 XmlCursor cursor
= msa
.newCursor();
1093 String comment
= "Mod: " + mi
.getName() + " Type: " + SurfaceAreaQuery
.getModuleType(mi
) + " Path: "
1094 + mi
.getPath().substring(System
.getenv("WORKSPACE").length() + 1);
1095 cursor
.insertComment(comment
);
1098 e
.printStackTrace();
1103 msa
.setModuleGuid(mi
.getGuid());
1104 msa
.setModuleVersion(mi
.getVersion());
1105 msa
.setPackageGuid(pi
.getGuid());
1106 msa
.setPackageVersion(pi
.getVersion());
1108 Vector
<String
> v
= new Vector
<String
>();
1110 msa
.setSupArchList(v
);
1116 private void genPcdData (String cName
, Object token
, String tsGuid
, String itemType
, String dataType
, String defaultVal
, ModuleSADocument
.ModuleSA moduleSa
)
1117 throws PcdItemTypeConflictException
, PcdValueMalFormed
{
1118 if (moduleSa
.getPcdBuildDefinition() == null){
1119 moduleSa
.addNewPcdBuildDefinition();
1122 // constructe pcd to modulesa mapping first.
1123 // Attention : for any error condition, remove from map this pcd.
1125 ArrayList
<String
> pcdConsumer
= LookupPlatformPcdData(cName
+ " " + tsGuid
);
1126 if (pcdConsumer
== null) {
1127 pcdConsumer
= new ArrayList
<String
>();
1130 // Using existing Pcd type, if this pcd already exists in other ModuleSA
1132 if (pcdConsumer
.size() > 0) {
1133 String
[] valPart
= pcdConsumer
.get(0).split(" ");
1134 itemType
= valPart
[5];
1136 String listValue
= moduleSa
.getModuleGuid() + " " + moduleSa
.getModuleVersion()
1137 + " " + moduleSa
.getPackageGuid() + " " + moduleSa
.getPackageVersion() + " " + listToString(moduleSa
.getSupArchList())
1139 pcdConsumer
.add(listValue
);
1140 dynPcdMap
.put(cName
+ " " + tsGuid
, pcdConsumer
);
1142 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData fpdPcd
= moduleSa
.getPcdBuildDefinition().addNewPcdData();
1143 fpdPcd
.setCName(cName
);
1144 fpdPcd
.setToken(token
);
1145 fpdPcd
.setTokenSpaceGuidCName(tsGuid
);
1146 fpdPcd
.setDatumType(PcdDataTypes
.Enum
.forString(dataType
));
1147 fpdPcd
.setItemType(PcdItemTypes
.Enum
.forString(itemType
));
1149 if (defaultVal
!= null){
1150 fpdPcd
.setValue(defaultVal
);
1153 if (dataType
.equals("UINT8") || dataType
.equals("UINT16") || dataType
.equals("UINT32") || dataType
.equals("UINT64")) {
1154 fpdPcd
.setValue("0");
1156 if (dataType
.equals("BOOLEAN")){
1157 fpdPcd
.setValue("false");
1159 if (dataType
.equals("VOID*")) {
1160 fpdPcd
.setValue("");
1164 // Using existing pcd value, if this pcd already exists in other moduleSa.
1166 if (defaultPcdValue
.get(cName
+ " " + tsGuid
) == null) {
1167 defaultPcdValue
.put(cName
+ " " + tsGuid
, fpdPcd
.getValue());
1170 fpdPcd
.setValue(defaultPcdValue
.get(cName
+ " " + tsGuid
));
1173 if (dataType
.equals("UINT8")){
1174 fpdPcd
.setMaxDatumSize(1);
1176 if (dataType
.equals("UINT16")) {
1177 fpdPcd
.setMaxDatumSize(2);
1179 if (dataType
.equals("UINT32")) {
1180 fpdPcd
.setMaxDatumSize(4);
1182 if (dataType
.equals("UINT64")){
1183 fpdPcd
.setMaxDatumSize(8);
1185 if (dataType
.equals("BOOLEAN")){
1186 fpdPcd
.setMaxDatumSize(1);
1188 if (dataType
.equals("VOID*")) {
1189 int maxSize
= setMaxSizeForPointer(fpdPcd
.getValue());
1190 fpdPcd
.setMaxDatumSize(maxSize
);
1194 if (itemType
.equals("DYNAMIC") || itemType
.equals("DYNAMIC_EX")) {
1195 ArrayList
<String
> al
= LookupDynamicPcdBuildDefinition(cName
+ " " + tsGuid
);
1197 // if only one module mapped to this pcd, then the one is myself. so no other module mapped.
1198 // so need to add one dyn pcd.
1200 if (al
.size() == 1) {
1201 addDynamicPcdBuildData(cName
, token
, tsGuid
, itemType
, dataType
, defaultVal
);
1207 public int setMaxSizeForPointer(String datum
) throws PcdValueMalFormed
{
1208 if (datum
== null) {
1211 char ch
= datum
.charAt(0);
1215 // For void* type PCD, only three datum is support:
1216 // 1) Unicode: string with start char is "L"
1217 // 2) Ansci: String is ""
1218 // 3) byte array: String start char "{"
1221 start
= datum
.indexOf('\"');
1222 end
= datum
.lastIndexOf('\"');
1223 if ((start
> end
) ||
1224 (end
> datum
.length())||
1225 ((start
== end
) && (datum
.length() > 0))) {
1226 //ToDo Error handling here
1227 throw new PcdValueMalFormed (datum
);
1230 strValue
= datum
.substring(start
+ 1, end
);
1231 return strValue
.length() * 2;
1232 } else if (ch
== '\"'){
1233 start
= datum
.indexOf('\"');
1234 end
= datum
.lastIndexOf('\"');
1235 if ((start
> end
) ||
1236 (end
> datum
.length())||
1237 ((start
== end
) && (datum
.length() > 0))) {
1238 throw new PcdValueMalFormed (datum
);
1240 strValue
= datum
.substring(start
+ 1, end
);
1241 return strValue
.length();
1242 } else if (ch
=='{') {
1243 String
[] strValueArray
;
1245 start
= datum
.indexOf('{');
1246 end
= datum
.lastIndexOf('}');
1247 strValue
= datum
.substring(start
+ 1, end
);
1248 strValue
= strValue
.trim();
1249 if (strValue
.length() == 0) {
1252 strValueArray
= strValue
.split(",");
1253 for (int index
= 0; index
< strValueArray
.length
; index
++) {
1254 Integer value
= Integer
.decode(strValueArray
[index
].trim());
1257 // "[FPD file error] The datum type of PCD %s in %s is VOID*, "+
1258 // "it must be a byte array. But the element of %s exceed the byte range",
1259 throw new PcdValueMalFormed (datum
);
1262 return strValueArray
.length
;
1266 // "[FPD file error] The datum type of PCD %s in %s is VOID*. For VOID* type, you have three format choise:\n "+
1267 // "1) UNICODE string: like L\"xxxx\";\r\n"+
1268 // "2) ANSIC string: like \"xxx\";\r\n"+
1269 // "3) Byte array: like {0x2, 0x45, 0x23}\r\n"+
1270 // "but the datum in seems does not following above format!",
1271 throw new PcdValueMalFormed (datum
);
1276 private ArrayList
<String
> LookupDynamicPcdBuildDefinition(String dynPcdKey
) {
1277 ArrayList
<String
> al
= dynPcdMap
.get(dynPcdKey
);
1282 private ArrayList
<String
> LookupPlatformPcdData(String pcdKey
) {
1284 return dynPcdMap
.get(pcdKey
);
1287 public int getDynamicPcdBuildDataCount() {
1288 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1289 removeElement(getfpdDynPcdBuildDefs());
1290 fpdDynPcdBuildDefs
= null;
1293 return getfpdDynPcdBuildDefs().getPcdBuildDataList().size();
1296 public void getDynamicPcdBuildData(String
[][] saa
) {
1297 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1298 removeElement(getfpdDynPcdBuildDefs());
1299 fpdDynPcdBuildDefs
= null;
1302 List
<DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
> l
= getfpdDynPcdBuildDefs().getPcdBuildDataList();
1303 ListIterator
<DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
> li
= l
.listIterator();
1305 while(li
.hasNext()) {
1306 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData dynPcd
= li
.next();
1307 saa
[i
][0] = dynPcd
.getCName();
1308 saa
[i
][1] = dynPcd
.getToken().toString();
1309 saa
[i
][2] = dynPcd
.getTokenSpaceGuidCName();
1310 saa
[i
][3] = dynPcd
.getMaxDatumSize()+"";
1311 saa
[i
][4] = dynPcd
.getDatumType().toString();
1317 public void addDynamicPcdBuildData(String cName
, Object token
, String tsGuid
, String itemType
, String dataType
, String defaultVal
)
1318 throws PcdValueMalFormed
{
1319 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData dynPcdData
= getfpdDynPcdBuildDefs().addNewPcdBuildData();
1320 dynPcdData
.setItemType(PcdItemTypes
.Enum
.forString(itemType
));
1321 dynPcdData
.setCName(cName
);
1322 dynPcdData
.setToken(token
);
1323 dynPcdData
.setTokenSpaceGuidCName(tsGuid
);
1324 dynPcdData
.setDatumType(PcdDataTypes
.Enum
.forString(dataType
));
1326 BigInteger bigInt
= new BigInteger("0");
1327 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo skuInfo
= dynPcdData
.addNewSkuInfo();
1328 skuInfo
.setSkuId(bigInt
);
1329 if (defaultVal
!= null){
1330 skuInfo
.setValue(defaultVal
);
1333 if (dataType
.equals("UINT8")){
1334 skuInfo
.setValue("0");
1336 if (dataType
.equals("UINT16")) {
1337 skuInfo
.setValue("0");
1339 if (dataType
.equals("UINT32")) {
1340 skuInfo
.setValue("0");
1342 if (dataType
.equals("UINT64")){
1343 skuInfo
.setValue("0");
1345 if (dataType
.equals("BOOLEAN")){
1346 skuInfo
.setValue("false");
1348 if (dataType
.equals("VOID*")) {
1349 skuInfo
.setValue("");
1352 if (dataType
.equals("UINT8")){
1353 dynPcdData
.setMaxDatumSize(1);
1355 if (dataType
.equals("UINT16")) {
1356 dynPcdData
.setMaxDatumSize(2);
1358 if (dataType
.equals("UINT32")) {
1359 dynPcdData
.setMaxDatumSize(4);
1361 if (dataType
.equals("UINT64")){
1362 dynPcdData
.setMaxDatumSize(8);
1364 if (dataType
.equals("BOOLEAN")){
1365 dynPcdData
.setMaxDatumSize(1);
1367 if (dataType
.equals("VOID*")) {
1368 int maxSize
= setMaxSizeForPointer(defaultVal
);
1369 dynPcdData
.setMaxDatumSize(maxSize
);
1373 public void removeDynamicPcdBuildData(String cName
, String tsGuid
) {
1374 XmlObject o
= fpdRoot
.getDynamicPcdBuildDefinitions();
1379 XmlCursor cursor
= o
.newCursor();
1380 if (cursor
.toFirstChild()) {
1382 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdBuildData
=
1383 (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1384 if (pcdBuildData
.getCName().equals(cName
) && pcdBuildData
.getTokenSpaceGuidCName().equals(tsGuid
)) {
1386 if (getDynamicPcdBuildDataCount() == 1) {
1394 while (cursor
.toNextSibling());
1399 // Get the Sku Info count of ith dyn pcd element.
1401 public int getDynamicPcdSkuInfoCount(int i
){
1402 if (fpdRoot
.getDynamicPcdBuildDefinitions() == null || fpdRoot
.getDynamicPcdBuildDefinitions().getPcdBuildDataList() == null
1403 || fpdRoot
.getDynamicPcdBuildDefinitions().getPcdBuildDataList().size() == 0) {
1407 int skuInfoCount
= 0;
1408 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1409 if (cursor
.toFirstChild()) {
1410 for (int j
= 0; j
< i
; ++j
) {
1411 cursor
.toNextSibling();
1413 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1414 if (pcdData
.getSkuInfoList() == null) {
1418 skuInfoCount
= pcdData
.getSkuInfoList().size();
1422 return skuInfoCount
;
1425 public void getDynamicPcdSkuInfos(int i
, String
[][] saa
){
1426 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1427 removeElement(getfpdDynPcdBuildDefs());
1428 fpdDynPcdBuildDefs
= null;
1432 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1433 if (cursor
.toFirstChild()) {
1434 for (int j
= 0; j
< i
; ++j
) {
1435 cursor
.toNextSibling();
1437 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1438 if (pcdData
.getSkuInfoList() == null) {
1443 ListIterator
<DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo
> li
= pcdData
.getSkuInfoList().listIterator();
1445 while (li
.hasNext()) {
1446 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo skuInfo
= li
.next();
1447 saa
[k
][0] = skuInfo
.getSkuId()+"";
1448 saa
[k
][1] = skuInfo
.getVariableName();
1449 saa
[k
][2] = skuInfo
.getVariableGuid();
1450 saa
[k
][3] = skuInfo
.getVariableOffset();
1451 saa
[k
][4] = skuInfo
.getHiiDefaultValue();
1452 saa
[k
][5] = skuInfo
.getVpdOffset();
1453 saa
[k
][6] = skuInfo
.getValue();
1463 public String
getDynamicPcdBuildDataValue(int i
){
1464 String value
= null;
1465 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1466 removeElement(getfpdDynPcdBuildDefs());
1467 fpdDynPcdBuildDefs
= null;
1471 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1472 if (cursor
.toFirstChild()) {
1473 for (int j
= 0; j
< i
; ++j
) {
1474 cursor
.toNextSibling();
1476 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1477 if (pcdData
.getSkuInfoList() == null) {
1481 value
= pcdData
.getSkuInfoArray(0).getValue();
1488 public String
getDynamicPcdBuildDataVpdOffset(int i
){
1489 String vpdOffset
= null;
1490 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1491 removeElement(getfpdDynPcdBuildDefs());
1492 fpdDynPcdBuildDefs
= null;
1496 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1497 if (cursor
.toFirstChild()) {
1498 for (int j
= 0; j
< i
; ++j
) {
1499 cursor
.toNextSibling();
1501 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1502 if (pcdData
.getSkuInfoList() == null) {
1506 vpdOffset
= pcdData
.getSkuInfoArray(0).getVpdOffset();
1513 public void removeDynamicPcdBuildDataSkuInfo(int i
) {
1514 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1515 removeElement(getfpdDynPcdBuildDefs());
1516 fpdDynPcdBuildDefs
= null;
1520 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1521 if (cursor
.toFirstChild()) {
1522 for (int j
= 0; j
< i
; ++j
) {
1523 cursor
.toNextSibling();
1525 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1526 if (pcdData
.getSkuInfoList() == null) {
1531 QName qSkuInfo
= new QName(xmlNs
, "SkuInfo");
1532 cursor
.toChild(qSkuInfo
);
1539 // generate sku info for ith dyn pcd build data.
1541 public void genDynamicPcdBuildDataSkuInfo(String id
, String varName
, String varGuid
, String varOffset
,
1542 String hiiDefault
, String vpdOffset
, String value
, int i
) {
1543 // if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1547 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1548 if (cursor
.toFirstChild()) {
1549 for (int j
= 0; j
< i
; ++j
) {
1550 cursor
.toNextSibling();
1552 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1553 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo skuInfo
= pcdData
.addNewSkuInfo();
1554 skuInfo
.setSkuId(new BigInteger(id
));
1555 if (varName
!= null){
1556 skuInfo
.setVariableName(varName
);
1557 skuInfo
.setVariableGuid(varGuid
);
1558 skuInfo
.setVariableOffset(varOffset
);
1559 skuInfo
.setHiiDefaultValue(hiiDefault
);
1561 else if (vpdOffset
!= null){
1562 skuInfo
.setVpdOffset(vpdOffset
);
1565 skuInfo
.setValue(value
);
1570 public void updateDynamicPcdBuildDataSkuInfo(String id
, String varName
, String varGuid
, String varOffset
,
1571 String hiiDefault
, String vpdOffset
, String value
, int i
){
1572 // if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1576 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1577 if (cursor
.toFirstChild()) {
1578 for (int j
= 0; j
< i
; ++j
) {
1579 cursor
.toNextSibling();
1581 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1582 ListIterator
<DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo
> li
= pcdData
.getSkuInfoList().listIterator();
1583 while (li
.hasNext()) {
1584 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo skuInfo
= li
.next();
1585 if (skuInfo
.getSkuId().toString().equals(id
)){
1586 if (varName
!= null){
1587 skuInfo
.setVariableName(varName
);
1588 skuInfo
.setVariableGuid(varGuid
);
1589 skuInfo
.setVariableOffset(varOffset
);
1590 skuInfo
.setHiiDefaultValue(hiiDefault
);
1592 else if (vpdOffset
!= null){
1593 skuInfo
.setVpdOffset(vpdOffset
);
1596 skuInfo
.setValue(value
);
1604 public BuildOptionsDocument
.BuildOptions
getfpdBuildOpts() {
1605 if (fpdBuildOpts
== null) {
1606 fpdBuildOpts
= fpdRoot
.addNewBuildOptions();
1608 return fpdBuildOpts
;
1611 public void genBuildOptionsUserExtensions(String fvName
, String outputFileName
, Vector
<String
[]> includeModules
) {
1612 UserExtensionsDocument
.UserExtensions userExts
= getfpdBuildOpts().addNewUserExtensions();
1613 userExts
.setUserID("IMAGES");
1614 userExts
.setIdentifier(new BigInteger("1"));
1615 XmlCursor cursor
= userExts
.newCursor();
1616 cursor
.toEndToken();
1618 cursor
.beginElement("FvName");
1619 cursor
.insertChars(fvName
);
1620 cursor
.toNextToken();
1622 cursor
.beginElement("InfFileName");
1623 cursor
.insertChars(fvName
+ ".inf");
1624 cursor
.toNextToken();
1626 cursor
.beginElement("IncludeModules");
1627 for (int i
= 0; i
< includeModules
.size(); ++i
) {
1628 cursor
.beginElement("Module");
1629 cursor
.insertAttributeWithValue("ModuleGuid", includeModules
.get(i
)[0]);
1630 cursor
.insertAttributeWithValue("BaseName", includeModules
.get(i
)[1]);
1631 cursor
.toEndToken();
1632 cursor
.toNextToken();
1637 public int getUserExtsIncModCount (String fvName
) {
1638 if (getfpdBuildOpts().getUserExtensionsList() == null) {
1641 ListIterator
<UserExtensionsDocument
.UserExtensions
> li
= getfpdBuildOpts().getUserExtensionsList().listIterator();
1642 while (li
.hasNext()) {
1643 UserExtensionsDocument
.UserExtensions ues
= li
.next();
1644 if (!ues
.getUserID().equals("IMAGES")) {
1647 XmlCursor cursor
= ues
.newCursor();
1648 cursor
.toFirstChild();
1649 String elementName
= cursor
.getTextValue();
1650 if (elementName
.equals(fvName
)) {
1651 cursor
.toNextSibling(new QName("", "IncludeModules"));
1652 if (cursor
.toFirstChild()) {
1654 for (i
= 1; cursor
.toNextSibling(); ++i
);
1666 public void getUserExtsIncMods(String fvName
, String
[][] saa
) {
1667 if (getfpdBuildOpts().getUserExtensionsList() == null) {
1670 ListIterator
<UserExtensionsDocument
.UserExtensions
> li
= getfpdBuildOpts().getUserExtensionsList().listIterator();
1671 while (li
.hasNext()) {
1672 UserExtensionsDocument
.UserExtensions ues
= li
.next();
1673 if (!ues
.getUserID().equals("IMAGES")) {
1676 XmlCursor cursor
= ues
.newCursor();
1677 cursor
.toFirstChild();
1678 String elementName
= cursor
.getTextValue();
1679 if (elementName
.equals(fvName
)) {
1680 cursor
.toNextSibling(new QName("", "IncludeModules"));
1681 if (cursor
.toFirstChild()) {
1684 saa
[i
][0] = cursor
.getAttributeText(new QName("ModuleGuid"));
1685 saa
[i
][1] = cursor
.getAttributeText(new QName("BaseName"));
1687 }while (cursor
.toNextSibling());
1697 public void removeBuildOptionsUserExtensions (String fvName
) {
1698 if (getfpdBuildOpts().getUserExtensionsList() == null) {
1702 ListIterator
<UserExtensionsDocument
.UserExtensions
> li
= getfpdBuildOpts().getUserExtensionsList().listIterator();
1703 while (li
.hasNext()) {
1704 UserExtensionsDocument
.UserExtensions ues
= li
.next();
1705 if (!ues
.getUserID().equals("IMAGES")) {
1708 XmlCursor cursor
= ues
.newCursor();
1709 cursor
.toFirstChild();
1710 String elementName
= cursor
.getTextValue();
1711 if (elementName
.equals(fvName
)) {
1723 public void genBuildOptionsUserDefAntTask (String id
, String fileName
, String execOrder
) {
1724 UserDefinedAntTasksDocument
.UserDefinedAntTasks udats
= getfpdBuildOpts().getUserDefinedAntTasks();
1725 if (udats
== null) {
1726 udats
= getfpdBuildOpts().addNewUserDefinedAntTasks();
1729 AntTaskDocument
.AntTask at
= udats
.addNewAntTask();
1730 setBuildOptionsUserDefAntTask(id
, fileName
, execOrder
, at
);
1733 private void setBuildOptionsUserDefAntTask(String id
, String fileName
, String execOrder
, AntTaskDocument
.AntTask at
) {
1734 at
.setId(new Integer(id
));
1735 XmlCursor cursor
= at
.newCursor();
1736 if (fileName
!= null){
1737 at
.setFilename(fileName
);
1739 else if (cursor
.toChild(xmlNs
, "Filename")) {
1742 if (execOrder
!= null) {
1743 at
.setAntCmdOptions(execOrder
);
1745 else if (cursor
.toChild(xmlNs
, "AntCmdOptions")) {
1751 public void removeBuildOptionsUserDefAntTask(int i
) {
1752 XmlObject o
= getfpdBuildOpts().getUserDefinedAntTasks();
1756 XmlCursor cursor
= o
.newCursor();
1757 if (cursor
.toFirstChild()) {
1758 for (int j
= 0; j
< i
; ++j
) {
1759 cursor
.toNextSibling();
1762 if (getBuildOptionsUserDefAntTaskCount() == 0) {
1770 public void updateBuildOptionsUserDefAntTask(int i
, String id
, String fileName
, String execOrder
){
1771 XmlObject o
= getfpdBuildOpts().getUserDefinedAntTasks();
1775 XmlCursor cursor
= o
.newCursor();
1776 if (cursor
.toFirstChild()) {
1777 for (int j
= 0; j
< i
; ++j
) {
1778 cursor
.toNextSibling();
1780 AntTaskDocument
.AntTask at
= (AntTaskDocument
.AntTask
)cursor
.getObject();
1781 setBuildOptionsUserDefAntTask(id
, fileName
, execOrder
, at
);
1786 public int getBuildOptionsUserDefAntTaskCount() {
1787 UserDefinedAntTasksDocument
.UserDefinedAntTasks udats
= getfpdBuildOpts().getUserDefinedAntTasks();
1788 if (udats
== null || udats
.getAntTaskList() == null) {
1792 return udats
.getAntTaskList().size();
1795 public void getBuildOptionsUserDefAntTasks(String
[][] saa
) {
1796 UserDefinedAntTasksDocument
.UserDefinedAntTasks udats
= getfpdBuildOpts().getUserDefinedAntTasks();
1797 if (udats
== null || udats
.getAntTaskList() == null) {
1801 List
<AntTaskDocument
.AntTask
> l
= udats
.getAntTaskList();
1802 ListIterator li
= l
.listIterator();
1804 while (li
.hasNext()) {
1805 AntTaskDocument
.AntTask at
= (AntTaskDocument
.AntTask
)li
.next();
1806 saa
[i
][0] = at
.getId() + "";
1807 saa
[i
][1] = saa
[i
][2] = "";
1808 if (at
.getFilename() != null){
1809 saa
[i
][1] = at
.getFilename();
1811 if (at
.getAntCmdOptions() != null) {
1812 saa
[i
][2] = at
.getAntCmdOptions();
1817 public void genBuildOptionsOpt(Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
) {
1818 OptionsDocument
.Options opts
= getfpdBuildOpts().getOptions();
1820 opts
= getfpdBuildOpts().addNewOptions();
1822 OptionDocument
.Option opt
= opts
.addNewOption();
1823 setBuildOptionsOpt(buildTargets
, toolChain
, tagName
, toolCmd
, archList
, contents
, opt
);
1826 private void setBuildOptionsOpt(Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
, OptionDocument
.Option opt
){
1827 opt
.setStringValue(contents
);
1829 opt
.setBuildTargets(buildTargets
);
1830 opt
.setToolChainFamily(toolChain
);
1831 opt
.setTagName(tagName
);
1832 opt
.setToolCode(toolCmd
);
1834 if (archList
!= null) {
1835 opt
.setSupArchList(archList
);
1838 if (opt
.isSetSupArchList()) {
1839 opt
.unsetSupArchList();
1844 public void removeBuildOptionsOpt(int i
){
1846 XmlObject o
= getfpdBuildOpts().getOptions();
1851 XmlCursor cursor
= o
.newCursor();
1852 if (cursor
.toFirstChild()) {
1853 for (int j
= 0; j
< i
; ++j
) {
1854 cursor
.toNextSibling();
1857 if (getBuildOptionsOptCount() == 0) {
1865 public void updateBuildOptionsOpt(int i
, Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
) {
1866 XmlObject o
= getfpdBuildOpts().getOptions();
1871 XmlCursor cursor
= o
.newCursor();
1872 if (cursor
.toFirstChild()) {
1873 for (int j
= 0; j
< i
; ++j
) {
1874 cursor
.toNextSibling();
1876 OptionDocument
.Option opt
= (OptionDocument
.Option
)cursor
.getObject();
1877 setBuildOptionsOpt(buildTargets
, toolChain
, tagName
, toolCmd
, archList
, contents
, opt
);
1882 public int getBuildOptionsOptCount(){
1883 if (getfpdBuildOpts().getOptions() == null || getfpdBuildOpts().getOptions().getOptionList() == null) {
1886 return getfpdBuildOpts().getOptions().getOptionList().size();
1889 public void getBuildOptionsOpts(String
[][] saa
) {
1890 if (getfpdBuildOpts().getOptions() == null || getfpdBuildOpts().getOptions().getOptionList() == null) {
1894 List
<OptionDocument
.Option
> lOpt
= getfpdBuildOpts().getOptions().getOptionList();
1895 ListIterator li
= lOpt
.listIterator();
1897 while(li
.hasNext()) {
1898 OptionDocument
.Option opt
= (OptionDocument
.Option
)li
.next();
1899 if (opt
.getBuildTargets() != null) {
1900 saa
[i
][0] = listToString(opt
.getBuildTargets());
1902 saa
[i
][1] = opt
.getToolChainFamily();
1903 if (opt
.getSupArchList() != null){
1904 saa
[i
][2] = listToString(opt
.getSupArchList());
1907 saa
[i
][3] = opt
.getToolCode();
1908 saa
[i
][4] = opt
.getTagName();
1909 saa
[i
][5] = opt
.getStringValue();
1915 public void genBuildOptionsFfs(String ffsKey
, String type
) {
1916 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getfpdBuildOpts().addNewFfs();
1917 ffs
.setFfsKey(ffsKey
);
1919 ffs
.addNewSections().setEncapsulationType(type
);
1923 public void updateBuildOptionsFfsSectionsType(int i
, String type
) {
1924 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getfpdBuildOpts().addNewFfs();
1926 ffs
.addNewSections().setEncapsulationType(type
);
1930 public void genBuildOptionsFfsAttribute(int i
, String name
, String value
) {
1931 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1932 BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute attrib
= ffs
.addNewAttribute();
1933 attrib
.setName(name
);
1934 attrib
.setValue(value
);
1937 /**update jth attribute of ith ffs.
1941 public void updateBuildOptionsFfsAttribute(int i
, int j
, String name
, String value
){
1942 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1943 XmlCursor cursor
= ffs
.newCursor();
1944 QName qAttrib
= new QName(xmlNs
, "Attribute");
1945 if (cursor
.toChild(qAttrib
)) {
1946 for (int k
= 0; k
< j
; ++k
) {
1947 cursor
.toNextSibling(qAttrib
);
1949 BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute attrib
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute
)cursor
.getObject();
1950 attrib
.setName(name
);
1951 attrib
.setValue(value
);
1956 public void removeBuildOptionsFfsAttribute(int i
, int j
){
1957 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1958 XmlCursor cursor
= ffs
.newCursor();
1959 QName qAttrib
= new QName(xmlNs
, "Attribute");
1960 if (cursor
.toChild(qAttrib
)) {
1961 for (int k
= 0; k
< j
; ++k
) {
1962 cursor
.toNextSibling(qAttrib
);
1969 public void genBuildOptionsFfsSectionsSection(int i
, String sectionType
) {
1970 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1974 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1976 if (sections
== null){
1977 sections
= ffs
.addNewSections();
1979 sections
.addNewSection().setSectionType(EfiSectionType
.Enum
.forString(sectionType
));
1982 public void removeBuildOptionsFfsSectionsSection(int i
, int j
) {
1983 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1984 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1985 if (sections
== null) {
1988 XmlCursor cursor
= sections
.newCursor();
1989 QName qSection
= new QName(xmlNs
, "Section");
1990 if (cursor
.toChild(qSection
)) {
1991 for (int k
= 0; k
< j
; ++k
) {
1992 cursor
.toNextSibling(qSection
);
1999 public void updateBuildOptionsFfsSectionsSection(int i
, int j
, String type
){
2000 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2001 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2002 if (sections
== null) {
2005 XmlCursor cursor
= sections
.newCursor();
2006 QName qSection
= new QName(xmlNs
, "Section");
2007 if (cursor
.toChild(qSection
)) {
2008 for (int k
= 0; k
< j
; ++k
) {
2009 cursor
.toNextSibling(qSection
);
2011 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Section section
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Section
)cursor
.getObject();
2012 section
.setSectionType(EfiSectionType
.Enum
.forString(type
));
2017 public void genBuildOptionsFfsSectionsSections(int i
, String encapType
) {
2018 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2022 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2024 if (sections
== null){
2025 sections
= ffs
.addNewSections();
2027 sections
.addNewSections().setEncapsulationType(encapType
);
2030 public void removeBuildOptionsFfsSectionsSections(int i
, int j
) {
2031 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2032 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2033 if (sections
== null) {
2036 XmlCursor cursor
= sections
.newCursor();
2037 QName qSections
= new QName(xmlNs
, "Sections");
2038 if (cursor
.toChild(qSections
)) {
2039 for (int k
= 0; k
< j
; ++k
) {
2040 cursor
.toNextSibling(qSections
);
2047 public void updateBuildOptionsFfsSectionsSections(int i
, int j
, String type
) {
2048 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2049 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2050 if (sections
== null) {
2053 XmlCursor cursor
= sections
.newCursor();
2054 QName qSections
= new QName(xmlNs
, "Sections");
2055 if (cursor
.toChild(qSections
)) {
2056 for (int k
= 0; k
< j
; ++k
) {
2057 cursor
.toNextSibling(qSections
);
2059 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2 sections2
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
)cursor
.getObject();
2060 sections2
.setEncapsulationType(type
);
2065 public void genBuildOptionsFfsSectionsSectionsSection(int i
, int j
, String type
) {
2066 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2070 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2071 XmlCursor cursor
= sections
.newCursor();
2072 QName qSections
= new QName(xmlNs
, "Sections");
2073 if (cursor
.toChild(qSections
)){
2074 for (int k
= 0; k
< j
; ++k
) {
2075 cursor
.toNextSibling(qSections
);
2077 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2 sections2
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
)cursor
.getObject();
2078 sections2
.addNewSection().setSectionType(EfiSectionType
.Enum
.forString(type
));
2083 public void removeBuildOptionsFfsSectionsSectionsSection(int i
, int j
, int k
) {
2084 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2085 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2086 if (sections
== null) {
2089 XmlCursor cursor
= sections
.newCursor();
2090 QName qSections
= new QName(xmlNs
, "Sections");
2091 if (cursor
.toChild(qSections
)) {
2092 for (int l
= 0; l
< j
; ++l
) {
2093 cursor
.toNextSibling(qSections
);
2095 if (cursor
.toFirstChild()) {
2097 for (; m
< k
; ++m
) {
2098 cursor
.toNextSibling();
2110 public void updateBuildOptionsFfsSectionsSectionsSection(int i
, int j
, int k
, String type
) {
2111 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2112 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2113 if (sections
== null) {
2116 XmlCursor cursor
= sections
.newCursor();
2117 QName qSections
= new QName(xmlNs
, "Sections");
2118 if (cursor
.toChild(qSections
)) {
2119 for (int l
= 0; l
< j
; ++l
) {
2120 cursor
.toNextSibling(qSections
);
2122 if (cursor
.toFirstChild()) {
2123 for (int m
= 0; m
< k
; ++m
) {
2124 cursor
.toNextSibling();
2126 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section section
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section
)cursor
.getObject();
2127 section
.setSectionType(EfiSectionType
.Enum
.forString(type
));
2133 public void getBuildOptionsFfsSectionsSectionsSection(int i
, int j
, ArrayList
<String
> al
) {
2134 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2138 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2139 XmlCursor cursor
= sections
.newCursor();
2140 QName qSections
= new QName(xmlNs
, "Sections");
2141 if (cursor
.toChild(qSections
)){
2142 for (int k
= 0; k
< j
; ++k
) {
2143 cursor
.toNextSibling(qSections
);
2145 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2 sections2
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
)cursor
.getObject();
2146 if (sections2
.getSectionList() == null){
2150 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section
> li
= sections2
.getSectionList().listIterator();
2151 while(li
.hasNext()) {
2152 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section section
= li
.next();
2153 if (section
.isSetSectionType()) {
2154 al
.add(section
.getSectionType().toString());
2163 public int getBuildOptionsFfsCount(){
2164 if (getfpdBuildOpts().getFfsList() == null) {
2167 return getfpdBuildOpts().getFfsList().size();
2170 public void getBuildOptionsFfsKey(String
[][] saa
) {
2171 if (getfpdBuildOpts().getFfsList() == null) {
2174 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
> li
= getfpdBuildOpts().getFfsList().listIterator();
2176 while(li
.hasNext()){
2177 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= li
.next();
2178 saa
[i
][0] = ffs
.getFfsKey();
2183 public void updateBuildOptionsFfsKey(int i
, String key
) {
2184 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2188 /**Get ith FFS key and contents.
2191 public void getBuildOptionsFfs(int i
, String
[] sa
, LinkedHashMap
<String
, String
> ffsAttribMap
, ArrayList
<String
> firstLevelSections
, ArrayList
<String
> firstLevelSection
) {
2192 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2196 sa
[0] = ffs
.getFfsKey();
2197 if (ffs
.getSections() != null) {
2198 if(ffs
.getSections().getEncapsulationType() != null){
2199 sa
[1] = ffs
.getSections().getEncapsulationType();
2201 if (ffs
.getSections().getSectionList() != null){
2202 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Section
> li
= ffs
.getSections().getSectionList().listIterator();
2203 while (li
.hasNext()) {
2204 firstLevelSection
.add(li
.next().getSectionType().toString());
2207 if (ffs
.getSections().getSectionsList() != null) {
2208 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
> li
= ffs
.getSections().getSectionsList().listIterator();
2209 while(li
.hasNext()) {
2210 firstLevelSections
.add(li
.next().getEncapsulationType());
2214 if (ffs
.getAttributeList() != null) {
2215 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute
> li
= ffs
.getAttributeList().listIterator();
2216 while(li
.hasNext()) {
2217 BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute attrib
= li
.next();
2218 ffsAttribMap
.put(attrib
.getName(), attrib
.getValue());
2227 private BuildOptionsDocument
.BuildOptions
.Ffs
getFfs(int i
) {
2228 XmlObject o
= getfpdBuildOpts();
2229 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= null;
2231 XmlCursor cursor
= o
.newCursor();
2232 QName qFfs
= new QName(xmlNs
, "Ffs");
2233 if (cursor
.toChild(qFfs
)) {
2234 for (int j
= 0; j
< i
; ++j
) {
2235 cursor
.toNextSibling(qFfs
);
2237 ffs
= (BuildOptionsDocument
.BuildOptions
.Ffs
)cursor
.getObject();
2243 public void removeBuildOptionsFfs(int i
) {
2244 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2249 XmlCursor cursor
= ffs
.newCursor();
2256 public PlatformDefinitionsDocument
.PlatformDefinitions
getfpdPlatformDefs(){
2257 if (fpdPlatformDefs
== null){
2258 fpdPlatformDefs
= fpdRoot
.addNewPlatformDefinitions();
2260 return fpdPlatformDefs
;
2263 public void getPlatformDefsSupportedArchs(Vector
<Object
> archs
){
2264 if (getfpdPlatformDefs().getSupportedArchitectures() == null) {
2267 ListIterator li
= getfpdPlatformDefs().getSupportedArchitectures().listIterator();
2268 while(li
.hasNext()) {
2269 archs
.add(li
.next());
2273 public void setPlatformDefsSupportedArchs(Vector
<Object
> archs
) {
2274 if (archs
!= null) {
2275 getfpdPlatformDefs().setSupportedArchitectures(archs
);
2278 // XmlCursor cursor = getfpdPlatformDefs().newCursor();
2279 // if (cursor.toChild(xmlNs, "SupportedArchitectures")) {
2280 // cursor.removeXml();
2282 // cursor.dispose();
2286 public void getPlatformDefsBuildTargets(Vector
<Object
> targets
) {
2287 if (getfpdPlatformDefs().getBuildTargets() == null) {
2290 ListIterator li
= getfpdPlatformDefs().getBuildTargets().listIterator();
2291 while(li
.hasNext()) {
2292 targets
.add(li
.next());
2296 public void setPlatformDefsBuildTargets(Vector
<Object
> targets
) {
2297 getfpdPlatformDefs().setBuildTargets(targets
);
2300 public void genPlatformDefsSkuInfo(String id
, String name
) {
2301 SkuInfoDocument
.SkuInfo skuInfo
= null;
2302 if (getfpdPlatformDefs().getSkuInfo() == null) {
2303 skuInfo
= getfpdPlatformDefs().addNewSkuInfo();
2305 skuInfo
= getfpdPlatformDefs().getSkuInfo();
2306 if (skuInfo
.getUiSkuNameList() == null || skuInfo
.getUiSkuNameList().size() == 0) {
2307 SkuInfoDocument
.SkuInfo
.UiSkuName skuName
= skuInfo
.addNewUiSkuName();
2308 skuName
.setSkuID(new BigInteger("0"));
2309 skuName
.setStringValue("DEFAULT");
2311 if (id
.equals("0")) {
2314 SkuInfoDocument
.SkuInfo
.UiSkuName skuName
= skuInfo
.addNewUiSkuName();
2315 skuName
.setSkuID(new BigInteger(id
));
2316 skuName
.setStringValue(name
);
2319 public int getPlatformDefsSkuInfoCount(){
2320 if (getfpdPlatformDefs().getSkuInfo() == null || getfpdPlatformDefs().getSkuInfo().getUiSkuNameList() == null) {
2323 return getfpdPlatformDefs().getSkuInfo().getUiSkuNameList().size();
2326 public void getPlatformDefsSkuInfos(String
[][] saa
){
2327 if (getfpdPlatformDefs().getSkuInfo() == null || getfpdPlatformDefs().getSkuInfo().getUiSkuNameList() == null) {
2328 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null) {
2329 removeElement(getfpdDynPcdBuildDefs());
2330 fpdDynPcdBuildDefs
= null;
2335 List
<SkuInfoDocument
.SkuInfo
.UiSkuName
> l
= getfpdPlatformDefs().getSkuInfo().getUiSkuNameList();
2336 ListIterator
<SkuInfoDocument
.SkuInfo
.UiSkuName
> li
= l
.listIterator();
2338 while(li
.hasNext()) {
2339 SkuInfoDocument
.SkuInfo
.UiSkuName sku
= li
.next();
2340 saa
[i
][0] = sku
.getSkuID()+"";
2341 saa
[i
][1] = sku
.getStringValue();
2346 public void removePlatformDefsSkuInfo(int i
) {
2347 SkuInfoDocument
.SkuInfo skuInfo
= getfpdPlatformDefs().getSkuInfo();
2348 if (skuInfo
== null || i
== 0) {
2352 XmlCursor cursor
= skuInfo
.newCursor();
2353 if (cursor
.toFirstChild()) {
2354 for (int j
= 0; j
< i
; ++j
) {
2355 cursor
.toNextSibling();
2362 public void updatePlatformDefsSkuInfo(int i
, String id
, String name
) {
2363 SkuInfoDocument
.SkuInfo skuInfo
= getfpdPlatformDefs().getSkuInfo();
2364 if (skuInfo
== null || i
== 0) {
2368 XmlCursor cursor
= skuInfo
.newCursor();
2369 if (cursor
.toFirstChild()) {
2370 for (int j
= 0; j
< i
; ++j
) {
2371 cursor
.toNextSibling();
2373 SkuInfoDocument
.SkuInfo
.UiSkuName sku
= (SkuInfoDocument
.SkuInfo
.UiSkuName
)cursor
.getObject();
2374 sku
.setSkuID(new BigInteger(id
));
2375 sku
.setStringValue(name
);
2380 public String
getPlatformDefsInterDir(){
2381 if (getfpdPlatformDefs().getIntermediateDirectories() == null) {
2384 return getfpdPlatformDefs().getIntermediateDirectories().toString();
2387 public void setPlatformDefsInterDir(String interDir
){
2388 getfpdPlatformDefs().setIntermediateDirectories(IntermediateOutputType
.Enum
.forString(interDir
));
2391 public String
getPlatformDefsOutputDir() {
2392 return getfpdPlatformDefs().getOutputDirectory();
2395 public void setPlatformDefsOutputDir(String outputDir
) {
2396 if (outputDir
!= null && outputDir
.length() > 0) {
2397 getfpdPlatformDefs().setOutputDirectory(outputDir
);
2400 XmlCursor cursor
= getfpdPlatformDefs().newCursor();
2401 if (cursor
.toChild(new QName(xmlNs
, "OutputDirectory"))) {
2408 public FlashDocument
.Flash
getfpdFlash() {
2409 if (fpdFlash
== null) {
2410 fpdFlash
= fpdRoot
.addNewFlash();
2415 public void genFlashDefinitionFile(String file
) {
2416 FlashDefinitionFileDocument
.FlashDefinitionFile fdf
= getfpdFlash().getFlashDefinitionFile();
2418 fdf
= getfpdFlash().addNewFlashDefinitionFile();
2421 fdf
.setStringValue(file
);
2424 public String
getFlashDefinitionFile() {
2425 FlashDefinitionFileDocument
.FlashDefinitionFile fdf
= getfpdFlash().getFlashDefinitionFile();
2430 return fdf
.getStringValue();
2433 public void genFvImagesNameValue(String name
, String value
) {
2435 FvImagesDocument
.FvImages fi
= getfpdFlash().getFvImages();
2437 fi
= getfpdFlash().addNewFvImages();
2440 FvImagesDocument
.FvImages
.NameValue nv
= fi
.addNewNameValue();
2445 public void removeFvImagesNameValue(int i
){
2447 XmlObject o
= getfpdFlash().getFvImages();
2452 QName qNameValue
= new QName(xmlNs
, "NameValue");
2453 XmlCursor cursor
= o
.newCursor();
2454 if (cursor
.toChild(qNameValue
)) {
2455 for (int j
= 0; j
< i
; ++j
) {
2456 cursor
.toNextSibling(qNameValue
);
2463 public void updateFvImagesNameValue(int i
, String name
, String value
){
2465 XmlObject o
= getfpdFlash().getFvImages();
2470 QName qNameValue
= new QName(xmlNs
, "NameValue");
2471 XmlCursor cursor
= o
.newCursor();
2472 if (cursor
.toChild(qNameValue
)) {
2473 for (int j
= 0; j
< i
; ++j
) {
2474 cursor
.toNextSibling(qNameValue
);
2476 FvImagesDocument
.FvImages
.NameValue nv
= (FvImagesDocument
.FvImages
.NameValue
)cursor
.getObject();
2483 public int getFvImagesNameValueCount() {
2485 FvImagesDocument
.FvImages fi
= null;
2486 if ((fi
= getfpdFlash().getFvImages()) == null || fi
.getNameValueList() == null) {
2489 return fi
.getNameValueList().size();
2492 public void getFvImagesNameValues(String
[][] nv
) {
2494 FvImagesDocument
.FvImages fi
= getfpdFlash().getFvImages();
2498 List
<FvImagesDocument
.FvImages
.NameValue
> l
= fi
.getNameValueList();
2500 ListIterator li
= l
.listIterator();
2501 while (li
.hasNext()) {
2502 FvImagesDocument
.FvImages
.NameValue e
= (FvImagesDocument
.FvImages
.NameValue
) li
2504 nv
[i
][0] = e
.getName();
2505 nv
[i
][1] = e
.getValue();
2511 public void genFvImagesFvImage(String
[] names
, String types
, Map
<String
, String
> options
) {
2513 FvImagesDocument
.FvImages fis
= null;
2514 if ((fis
= getfpdFlash().getFvImages()) == null) {
2515 fis
= getfpdFlash().addNewFvImages();
2519 //gen FvImage with FvImageNames array
2521 FvImagesDocument
.FvImages
.FvImage fi
= fis
.addNewFvImage();
2522 for (int i
= 0; i
< names
.length
; ++i
) {
2523 fi
.addFvImageNames(names
[i
]);
2525 fi
.setType(FvImageTypes
.Enum
.forString(types
));
2526 if (options
!= null){
2527 setFvImagesFvImageFvImageOptions(options
, fi
);
2531 private void setFvImagesFvImageFvImageOptions(Map
<String
, String
> options
, FvImagesDocument
.FvImages
.FvImage fi
){
2532 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions fio
= fi
.getFvImageOptions();
2534 fio
= fi
.addNewFvImageOptions();
2537 Set
<String
> key
= options
.keySet();
2538 Iterator
<String
> i
= key
.iterator();
2539 while (i
.hasNext()) {
2541 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nv
= fio
.addNewNameValue();
2542 String k
= (String
)i
.next();
2545 nv
.setValue((String
)options
.get(k
));
2552 public void removeFvImagesFvImage(int i
) {
2554 XmlObject o
= getfpdFlash().getFvImages();
2559 QName qFvImage
= new QName(xmlNs
, "FvImage");
2560 XmlCursor cursor
= o
.newCursor();
2561 if (cursor
.toChild(qFvImage
)) {
2562 for (int j
= 0; j
< i
; ++j
) {
2563 cursor
.toNextSibling(qFvImage
);
2570 public void updateFvImagesFvImage(int i
, String
[] names
, String types
, Map
<String
, String
> options
){
2572 XmlObject o
= getfpdFlash().getFvImages();
2576 XmlCursor cursor
= o
.newCursor();
2577 QName qFvImage
= new QName(xmlNs
, "FvImage");
2578 if (cursor
.toChild(qFvImage
)) {
2579 for (int j
= 0; j
< i
; ++j
) {
2580 cursor
.toNextSibling(qFvImage
);
2582 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
2583 fi
.setType(FvImageTypes
.Enum
.forString(types
));
2586 // remove old FvImageNames before adding new ones
2588 QName qFvImageNames
= new QName(xmlNs
, "FvImageNames");
2589 cursor
.toChild(qFvImageNames
);
2591 while (cursor
.toNextSibling(qFvImageNames
)) {
2595 for (int k
= 0; k
< names
.length
; ++k
) {
2596 fi
.addFvImageNames(names
[k
]);
2599 // remove old FvImageOptions before adding new options
2601 QName qFvImageOptions
= new QName(xmlNs
, "FvImageOptions");
2602 cursor
.toNextSibling(qFvImageOptions
);
2605 setFvImagesFvImageFvImageOptions(options
, fi
);
2610 public int getFvImagesFvImageCount() {
2612 if (getfpdFlash().getFvImages() == null || getfpdFlash().getFvImages().getFvImageList() == null) {
2615 return getfpdFlash().getFvImages().getFvImageList().size();
2618 /**Only Get Fv image setting - name and type.
2621 public void getFvImagesFvImages(String
[][] saa
) {
2623 if (getfpdFlash().getFvImages() == null) {
2626 List
<FvImagesDocument
.FvImages
.FvImage
> l
= getfpdFlash().getFvImages().getFvImageList();
2630 ListIterator li
= l
.listIterator();
2632 while(li
.hasNext()) {
2633 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)li
.next();
2635 // get FvImageNames array, space separated
2637 List
<String
> lfn
= fi
.getFvImageNamesList();
2638 ListIterator lfni
= lfn
.listIterator();
2640 while (lfni
.hasNext()) {
2641 saa
[i
][0] += (String
)lfni
.next();
2644 saa
[i
][0] = saa
[i
][0].trim();
2646 saa
[i
][1] = fi
.getType()+"";
2652 /**Get FvImage Options for FvImage i
2653 * @param i the ith FvImage
2655 public void getFvImagesFvImageOptions(int i
, Map
<String
, String
> m
) {
2656 XmlObject o
= getfpdFlash().getFvImages();
2660 XmlCursor cursor
= o
.newCursor();
2661 QName qFvImage
= new QName(xmlNs
, "FvImage");
2662 if (cursor
.toChild(qFvImage
)) {
2663 for (int j
= 0; j
< i
; ++j
) {
2664 cursor
.toNextSibling(qFvImage
);
2666 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
2667 if (fi
.getFvImageOptions() == null || fi
.getFvImageOptions().getNameValueList() == null){
2670 ListIterator
<FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
> li
= fi
.getFvImageOptions().getNameValueList().listIterator();
2671 while(li
.hasNext()){
2672 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nv
= li
.next();
2673 m
.put(nv
.getName(), nv
.getValue());
2679 Get platform header element
2680 @return PlatformHeaderDocument.PlatformHeader
2682 public PlatformHeaderDocument
.PlatformHeader
getFpdHdr() {
2683 if (fpdHdr
== null) {
2684 fpdHdr
= fpdRoot
.addNewPlatformHeader();
2690 public String
getFpdHdrPlatformName() {
2691 return getFpdHdr().getPlatformName();
2694 public String
getFpdHdrGuidValue() {
2695 return getFpdHdr().getGuidValue();
2698 public String
getFpdHdrVer() {
2699 return getFpdHdr().getVersion();
2702 public String
getFpdHdrAbs() {
2703 return getFpdHdr().getAbstract();
2706 public String
getFpdHdrDescription() {
2707 return getFpdHdr().getDescription();
2710 public String
getFpdHdrCopyright() {
2711 return getFpdHdr().getCopyright();
2714 public String
getFpdHdrLicense() {
2715 LicenseDocument
.License l
= getFpdHdr().getLicense();
2719 return l
.getStringValue();
2722 public String
getFpdHdrUrl() {
2723 LicenseDocument
.License l
= getFpdHdr().getLicense();
2730 public String
getFpdHdrSpec() {
2732 return "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052";
2733 // return getFpdHdr().getSpecification();
2736 public void setFpdHdrPlatformName(String name
){
2737 getFpdHdr().setPlatformName(name
);
2740 public void setFpdHdrGuidValue(String guid
){
2741 getFpdHdr().setGuidValue(guid
);
2744 public void setFpdHdrVer(String v
){
2745 getFpdHdr().setVersion(v
);
2748 public void setFpdHdrAbs(String abs
) {
2749 getFpdHdr().setAbstract(abs
);
2752 public void setFpdHdrDescription(String desc
){
2753 getFpdHdr().setDescription(desc
);
2756 public void setFpdHdrCopyright(String cr
) {
2757 getFpdHdr().setCopyright(cr
);
2760 public void setFpdHdrLicense(String license
){
2761 LicenseDocument
.License l
= getFpdHdr().getLicense();
2763 getFpdHdr().addNewLicense().setStringValue(license
);
2766 l
.setStringValue(license
);
2770 public void setFpdHdrUrl(String url
){
2771 LicenseDocument
.License l
= getFpdHdr().getLicense();
2777 public void setFpdHdrSpec(String s
){
2778 s
= "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052";
2779 getFpdHdr().setSpecification(s
);
2782 Save the processed xml contents to file
2784 @param fpdFile The file to save xml contents
2785 @throws IOException Exceptions during file operation
2787 public void saveAs(File fpdFile
) throws IOException
{
2789 XmlOptions options
= new XmlOptions();
2791 options
.setCharacterEncoding("UTF-8");
2792 options
.setSavePrettyPrint();
2793 options
.setSavePrettyPrintIndent(2);
2795 fpdd
.save(fpdFile
, options
);
2796 } catch (IOException e
) {
2797 e
.printStackTrace();
2802 private String
listToString(List l
) {
2807 ListIterator li
= l
.listIterator();
2808 while(li
.hasNext()) {
2815 private void removeElement(XmlObject o
) {
2816 XmlCursor cursor
= o
.newCursor();
2822 class PcdItemTypeConflictException
extends Exception
{
2827 private static final long serialVersionUID
= 1L;
2828 private String details
= null;
2830 PcdItemTypeConflictException(String pcdName
, String info
){
2831 ModuleIdentification mi
= WorkspaceProfile
.getModuleId(info
);
2832 details
= pcdName
+ " ItemType Conflicts with " + mi
.getName() + " in Pkg " + mi
.getPackageId().getName();
2835 public String
getMessage() {
2840 class PcdDeclNotFound
extends Exception
{
2845 private static final long serialVersionUID
= 1L;
2846 private String details
= null;
2848 PcdDeclNotFound(String info
) {
2849 details
= "PcdDeclNotFound: " + info
;
2852 public String
getMessage() {
2857 class PcdValueMalFormed
extends Exception
{
2862 private static final long serialVersionUID
= 1L;
2863 private String details
= null;
2865 PcdValueMalFormed(String info
) {
2866 details
= "PcdValueMalFormed: " + info
;
2869 public String
getMessage() {