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 regNewLineAndSpaces
= "((\n)|(\r\n)|(\r)|(\u0085)|(\u2028)|(\u2029))(\\s)*";
75 private PlatformSurfaceAreaDocument fpdd
= null;
77 private PlatformSurfaceAreaDocument
.PlatformSurfaceArea fpdRoot
= null;
79 private PlatformHeaderDocument
.PlatformHeader fpdHdr
= null;
81 private PlatformDefinitionsDocument
.PlatformDefinitions fpdPlatformDefs
= null;
83 private FlashDocument
.Flash fpdFlash
= null;
85 private BuildOptionsDocument
.BuildOptions fpdBuildOpts
= null;
87 private FrameworkModulesDocument
.FrameworkModules fpdFrameworkModules
= null;
89 private DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions fpdDynPcdBuildDefs
= null;
91 private HashMap
<String
, ArrayList
<String
>> dynPcdMap
= null;
93 private HashMap
<String
, String
> defaultPcdValue
= new HashMap
<String
, String
>();
95 private String
itemType (String pcdInfo
) {
97 return pcdInfo
.substring(pcdInfo
.lastIndexOf(" ") + 1);
101 * look through all pcd data in all ModuleSA, create pcd -> ModuleSA mappings.
103 public void initDynPcdMap() {
104 if (dynPcdMap
== null) {
105 dynPcdMap
= new HashMap
<String
, ArrayList
<String
>>();
106 List
<ModuleSADocument
.ModuleSA
> l
= getfpdFrameworkModules().getModuleSAList();
108 removeElement(getfpdFrameworkModules());
109 fpdFrameworkModules
= null;
112 ListIterator
<ModuleSADocument
.ModuleSA
> li
= l
.listIterator();
113 while (li
.hasNext()) {
114 ModuleSADocument
.ModuleSA moduleSa
= li
.next();
115 if (moduleSa
.getPcdBuildDefinition() == null || moduleSa
.getPcdBuildDefinition().getPcdDataList() == null) {
118 String ModuleInfo
= moduleSa
.getModuleGuid() + " " + moduleSa
.getModuleVersion() +
119 " " + moduleSa
.getPackageGuid() + " " + moduleSa
.getPackageVersion() + " " + listToString(moduleSa
.getSupArchList());
120 List
<PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
> lp
= moduleSa
.getPcdBuildDefinition().getPcdDataList();
121 ListIterator
<PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
> lpi
= lp
.listIterator();
122 while (lpi
.hasNext()) {
123 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= lpi
.next();
124 String pcdKey
= pcdData
.getCName() + " " + pcdData
.getTokenSpaceGuidCName();
125 if (dynPcdMap
.get(pcdKey
) == null) {
126 ArrayList
<String
> al
= new ArrayList
<String
>();
127 al
.add(ModuleInfo
+ " " + pcdData
.getItemType().toString());
128 dynPcdMap
.put(pcdKey
, al
);
131 dynPcdMap
.get(pcdKey
).add(ModuleInfo
+ " " + pcdData
.getItemType().toString());
138 public ArrayList
<String
> getDynPcdMapValue(String key
) {
139 return dynPcdMap
.get(key
);
142 Constructor to create a new spd file
144 public FpdFileContents() {
146 fpdd
= PlatformSurfaceAreaDocument
.Factory
.newInstance();
147 fpdRoot
= fpdd
.addNewPlatformSurfaceArea();
152 Constructor for existing document object
155 public FpdFileContents(PlatformSurfaceAreaDocument
.PlatformSurfaceArea fpd
) {
157 fpdHdr
= fpdRoot
.getPlatformHeader();
158 fpdPlatformDefs
= fpdRoot
.getPlatformDefinitions();
159 fpdBuildOpts
= fpdRoot
.getBuildOptions();
160 fpdFrameworkModules
= fpdRoot
.getFrameworkModules();
161 fpdDynPcdBuildDefs
= fpdRoot
.getDynamicPcdBuildDefinitions();
162 fpdFlash
= fpdRoot
.getFlash();
166 Constructor based on an existing spd file
168 @param f Existing spd file
170 public FpdFileContents(File f
) {
172 fpdd
= PlatformSurfaceAreaDocument
.Factory
.parse(f
);
173 fpdRoot
= fpdd
.getPlatformSurfaceArea();
174 } catch (Exception e
) {
175 System
.out
.println(e
.toString());
179 public DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
getfpdDynPcdBuildDefs() {
180 if (fpdDynPcdBuildDefs
== null){
181 fpdDynPcdBuildDefs
= fpdRoot
.addNewDynamicPcdBuildDefinitions();
183 return fpdDynPcdBuildDefs
;
186 public FrameworkModulesDocument
.FrameworkModules
getfpdFrameworkModules() {
187 if (fpdFrameworkModules
== null){
188 fpdFrameworkModules
= fpdRoot
.addNewFrameworkModules();
190 return fpdFrameworkModules
;
193 public void getFrameworkModuleGuid (String fvName
, Vector
<String
> vGuid
) {
194 if (getFrameworkModulesCount() == 0){
198 ListIterator li
= getfpdFrameworkModules().getModuleSAList().listIterator();
199 while(li
.hasNext()) {
200 ModuleSADocument
.ModuleSA moduleSa
= (ModuleSADocument
.ModuleSA
)li
.next();
201 if (moduleSa
.getModuleSaBuildOptions() == null) {
204 String fvBinding
= moduleSa
.getModuleSaBuildOptions().getFvBinding();
205 if (fvBinding
== null) {
209 String
[] fvNames
= fvBinding
.split(" ");
210 for (int i
= 0; i
< fvNames
.length
; ++i
) {
211 if (fvNames
[i
].equals(fvName
) || fvNames
[i
].replaceAll("_", "").equals(fvName
)) {
212 vGuid
.add(moduleSa
.getModuleGuid());
219 public int getFrameworkModulesCount() {
220 if (getfpdFrameworkModules().getModuleSAList() == null || getfpdFrameworkModules().getModuleSAList().size() == 0){
221 removeElement(getfpdFrameworkModules());
222 fpdFrameworkModules
= null;
225 return getfpdFrameworkModules().getModuleSAList().size();
228 public void getFrameworkModulesInfo(String
[][] saa
) {
229 if (getFrameworkModulesCount() == 0){
233 ListIterator li
= getfpdFrameworkModules().getModuleSAList().listIterator();
235 while(li
.hasNext()) {
236 ModuleSADocument
.ModuleSA moduleSa
= (ModuleSADocument
.ModuleSA
)li
.next();
237 saa
[i
][0] = moduleSa
.getModuleGuid();
238 saa
[i
][1] = moduleSa
.getModuleVersion();
240 saa
[i
][2] = moduleSa
.getPackageGuid();
241 saa
[i
][3] = moduleSa
.getPackageVersion();
242 saa
[i
][4] = listToString(moduleSa
.getSupArchList());
247 public void getFrameworkModuleInfo(int i
, String
[] sa
) {
248 ModuleSADocument
.ModuleSA msa
= getModuleSA(i
);
252 sa
[0] = msa
.getModuleGuid();
253 sa
[1] = msa
.getModuleVersion();
254 sa
[2] = msa
.getPackageGuid();
255 sa
[3] = msa
.getPackageVersion();
256 sa
[4] = listToString(msa
.getSupArchList());
259 public ModuleSADocument
.ModuleSA
getModuleSA(String key
) {
261 if (getfpdFrameworkModules().getModuleSAList() == null || getfpdFrameworkModules().getModuleSAList().size() == 0) {
262 removeElement(getfpdFrameworkModules());
263 fpdFrameworkModules
= null;
266 String
[] s
= key
.split(" ");
267 String archsInKey
= "";
269 for (int i
= 4; i
< s
.length
; ++i
) {
273 archsInKey
= archsInKey
.trim();
276 ListIterator li
= getfpdFrameworkModules().getModuleSAList().listIterator();
277 while(li
.hasNext()) {
278 ModuleSADocument
.ModuleSA moduleSa
= (ModuleSADocument
.ModuleSA
)li
.next();
279 if (moduleSa
.getModuleGuid().equalsIgnoreCase(s
[0]) && moduleSa
.getPackageGuid().equalsIgnoreCase(s
[2])) {
280 if (moduleSa
.getModuleVersion() != null) {
281 if (!moduleSa
.getModuleVersion().equals(s
[1])) {
285 if (moduleSa
.getPackageVersion() != null) {
286 if (!moduleSa
.getPackageVersion().equals(s
[3])) {
290 //ToDo add arch check .
291 if (moduleSa
.getSupArchList() != null) {
292 if (listToString(moduleSa
.getSupArchList()).equals(archsInKey
)) {
297 if (archsInKey
.length() == 0) {
306 private ModuleSADocument
.ModuleSA
getModuleSA(int i
) {
307 ModuleSADocument
.ModuleSA moduleSa
= null;
308 if (fpdRoot
.getFrameworkModules() == null) {
311 XmlCursor cursor
= fpdRoot
.getFrameworkModules().newCursor();
312 if (cursor
.toFirstChild()) {
313 for (int j
= 0; j
< i
; ++j
) {
314 cursor
.toNextSibling();
316 moduleSa
= (ModuleSADocument
.ModuleSA
)cursor
.getObject();
322 public void removeModuleSA(int i
) {
323 XmlObject o
= fpdRoot
.getFrameworkModules();
328 XmlCursor cursor
= o
.newCursor();
329 if (cursor
.toFirstChild()) {
330 for (int j
= 0; j
< i
; ++j
) {
331 cursor
.toNextSibling();
334 // remove pcd from dynPcdMap, if DynamicPcdBuildData exists, remove them too.
336 ModuleSADocument
.ModuleSA moduleSa
= (ModuleSADocument
.ModuleSA
)cursor
.getObject();
337 String moduleInfo
= moduleSa
.getModuleGuid() + " " + moduleSa
.getModuleVersion() + " " +
338 moduleSa
.getPackageGuid()+ " " + moduleSa
.getPackageVersion() + " " + listToString(moduleSa
.getSupArchList());
339 PcdBuildDefinitionDocument
.PcdBuildDefinition pcdBuildDef
= moduleSa
.getPcdBuildDefinition();
340 if (pcdBuildDef
!= null && pcdBuildDef
.getPcdDataList() != null) {
341 ListIterator
<PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
> li
= pcdBuildDef
.getPcdDataList().listIterator();
342 while(li
.hasNext()) {
343 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= li
.next();
344 maintainDynPcdMap(pcdData
.getCName() + " " + pcdData
.getTokenSpaceGuidCName(), moduleInfo
);
349 while (cursor
.hasPrevToken()) {
350 cursor
.toPrevToken();
351 if (!cursor
.isText()) {
354 String s
= cursor
.getTextValue();
355 if (s
.matches(regNewLineAndSpaces
)) {
360 if (cursor
.isComment()) {
366 if (getFrameworkModulesCount() == 0) {
374 public boolean adjustPcd (int seqModuleSa
) throws Exception
{
375 boolean dataModified
= false;
376 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(seqModuleSa
);
377 int pcdCount
= getPcdDataCount(seqModuleSa
);
378 String
[][] saaModuleSaPcd
= new String
[pcdCount
][7];
379 getPcdData(seqModuleSa
, saaModuleSaPcd
);
380 String mg
= moduleSa
.getModuleGuid();
381 String mv
= moduleSa
.getModuleVersion();
382 String pg
= moduleSa
.getPackageGuid();
383 String pv
= moduleSa
.getPackageVersion();
384 String arch
= listToString(moduleSa
.getSupArchList());
386 // delete pcd in ModuleSA but not in MSA files any longer.
388 String moduleKey
= mg
+ " " + mv
+ " " + pg
+ " " + pv
+ " " + arch
;
389 int libCount
= getLibraryInstancesCount(moduleKey
);
390 String
[][] saaLib
= new String
[libCount
][5];
391 getLibraryInstances(moduleKey
, saaLib
);
392 ModuleIdentification mi
= WorkspaceProfile
.getModuleId(moduleKey
);
393 Vector
<ModuleIdentification
> vMi
= new Vector
<ModuleIdentification
>();
395 // create vector for module & library instance MIs.
398 for (int j
= 0; j
< saaLib
.length
; ++j
) {
399 String libKey
= saaLib
[j
][1] + " " + saaLib
[j
][2] + " " + saaLib
[j
][3] + " " + saaLib
[j
][4];
400 ModuleIdentification libMi
= WorkspaceProfile
.getModuleId(libKey
);
405 nextPcd
:for (int i
= 0; i
< saaModuleSaPcd
.length
; ++i
) {
407 for (int j
= 0; j
< vMi
.size(); ++j
) {
408 ModuleIdentification nextMi
= vMi
.get(j
);
409 if (WorkspaceProfile
.pcdInMsa(saaModuleSaPcd
[i
][0], saaModuleSaPcd
[i
][1], nextMi
)) {
413 removePcdData(seqModuleSa
, saaModuleSaPcd
[i
][0], saaModuleSaPcd
[i
][1]);
417 catch (Exception e
) {
421 // add new Pcd from MSA file to ModuleSA.
425 for (int i
= 0; i
< vMi
.size(); ++i
) {
426 ModuleSurfaceAreaDocument
.ModuleSurfaceArea msa
= (ModuleSurfaceAreaDocument
.ModuleSurfaceArea
) WorkspaceProfile
427 .getModuleXmlObject(vMi
429 if (msa
.getPcdCoded() == null || msa
.getPcdCoded().getPcdEntryList() == null) {
432 ListIterator li
= msa
.getPcdCoded().getPcdEntryList().listIterator();
433 msaPcdIter
:while (li
.hasNext()) {
434 PcdCodedDocument
.PcdCoded
.PcdEntry msaPcd
= (PcdCodedDocument
.PcdCoded
.PcdEntry
) li
.next();
435 ArrayList
<String
> al
= getDynPcdMapValue(msaPcd
.getCName() + " " + msaPcd
.getTokenSpaceGuidCName());
437 for (int j
= 0; j
< al
.size(); ++j
) {
438 if (al
.get(j
).contains(moduleKey
)) {
444 PackageIdentification
[] depPkgs
= SurfaceAreaQuery
.getDependencePkg(null, vMi
.get(i
));
445 PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry spdPcd
= LookupPcdDeclaration(msaPcd
, depPkgs
);
446 if (spdPcd
== null) {
450 throw new PcdDeclNotFound("No Declaration for PCD Entry " + msaPcd
.getCName() + " in Module "
454 // AddItem to ModuleSA PcdBuildDefinitions
456 String defaultVal
= msaPcd
.getDefaultValue() == null ? spdPcd
.getDefaultValue()
457 : msaPcd
.getDefaultValue();
459 genPcdData(msaPcd
.getCName(), spdPcd
.getToken(), msaPcd
.getTokenSpaceGuidCName(),
460 msaPcd
.getPcdItemType().toString(), spdPcd
.getDatumType() + "", defaultVal
, moduleSa
);
473 private void maintainDynPcdMap(String pcdKey
, String moduleInfo
) {
475 ArrayList
<String
> al
= dynPcdMap
.get(pcdKey
);
479 String
[] s
= moduleInfo
.split(" ");
480 for(int i
= 0; i
< al
.size(); ++i
){
481 String consumer
= al
.get(i
);
482 if (consumer
.contains(s
[0]) && consumer
.contains(s
[2])){
483 String
[] consumerPart
= consumer
.split(" ");
484 if (!consumerPart
[4].equals(s
[4])) {
492 if (al
.size() == 0) {
493 defaultPcdValue
.remove(pcdKey
);
494 dynPcdMap
.remove(pcdKey
);
495 String
[] s1
= pcdKey
.split(" ");
496 removeDynamicPcdBuildData(s1
[0], s1
[1]);
501 // key for ModuleSA : "ModuleGuid ModuleVer PackageGuid PackageVer Arch"
503 public int getPcdDataCount (int i
){
504 ModuleSADocument
.ModuleSA msa
= getModuleSA(i
);
506 if (msa
== null || msa
.getPcdBuildDefinition() == null || msa
.getPcdBuildDefinition().getPcdDataList() == null){
509 return msa
.getPcdBuildDefinition().getPcdDataList().size();
513 public void getPcdData (int i
, String
[][] saa
) {
514 ModuleSADocument
.ModuleSA msa
= getModuleSA(i
);
516 if (msa
== null || msa
.getPcdBuildDefinition() == null || msa
.getPcdBuildDefinition().getPcdDataList() == null){
519 ListIterator
<PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
>li
= msa
.getPcdBuildDefinition().getPcdDataList().listIterator();
520 for (int k
= 0; k
< saa
.length
; ++k
) {
521 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= li
.next();
522 saa
[k
][0] = pcdData
.getCName();
523 saa
[k
][1] = pcdData
.getTokenSpaceGuidCName();
524 saa
[k
][2] = pcdData
.getItemType()+"";
525 saa
[k
][3] = pcdData
.getToken().toString();
526 saa
[k
][4] = pcdData
.getMaxDatumSize()+"";
527 saa
[k
][5] = pcdData
.getDatumType()+"";
528 saa
[k
][6] = pcdData
.getValue();
533 public void removePcdData (int seqModuleSa
, String cName
, String tsGuid
) {
534 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(seqModuleSa
);
535 if (moduleSa
== null || moduleSa
.getPcdBuildDefinition() == null){
539 String mg
= moduleSa
.getModuleGuid();
540 String mv
= moduleSa
.getModuleVersion();
541 String pg
= moduleSa
.getPackageGuid();
542 String pv
= moduleSa
.getPackageVersion();
543 String arch
= listToString(moduleSa
.getSupArchList());
544 String moduleKey
= mg
+ " " + mv
+ " " + pg
+ " " + pv
+ " " + arch
;
546 XmlCursor cursor
= moduleSa
.getPcdBuildDefinition().newCursor();
547 if (cursor
.toFirstChild()){
550 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= (PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
)cursor
.getObject();
551 if (pcdData
.getCName().equals(cName
) && pcdData
.getTokenSpaceGuidCName().equals(tsGuid
)) {
552 maintainDynPcdMap(cName
+ " " + tsGuid
, moduleKey
);
553 if (getPcdDataCount(seqModuleSa
) == 1) {
560 while(cursor
.toNextSibling());
566 public void updatePcdData (String key
, String cName
, String tsGuid
, String itemType
, String maxSize
, String value
){
567 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(key
);
568 if (moduleSa
== null || moduleSa
.getPcdBuildDefinition() == null){
572 XmlCursor cursor
= moduleSa
.getPcdBuildDefinition().newCursor();
573 if (cursor
.toFirstChild()){
575 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= (PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
)cursor
.getObject();
576 if (pcdData
.getCName().equals(cName
) && pcdData
.getTokenSpaceGuidCName().equals(tsGuid
)) {
578 // change item type while not updating dynPcdData????
580 pcdData
.setItemType(PcdItemTypes
.Enum
.forString(itemType
));
581 if(pcdData
.getDatumType().equals("VOID*")) {
582 pcdData
.setMaxDatumSize(new Integer(maxSize
));
584 pcdData
.setValue(value
);
585 defaultPcdValue
.put(cName
+ " " + tsGuid
, value
);
589 while(cursor
.toNextSibling());
594 /**Get original Pcd info from MSA & SPD files.
595 * @param mi ModuleIdentification from which MSA & SPD come
596 * @param cName PCD cName
597 * @param sa Results: HelpText, Original item type.
600 public boolean getPcdBuildDataInfo(ModuleIdentification mi
, String cName
, String tsGuid
, String
[] sa
) throws Exception
{
603 ModuleSurfaceAreaDocument
.ModuleSurfaceArea msa
= (ModuleSurfaceAreaDocument
.ModuleSurfaceArea
)WorkspaceProfile
.getModuleXmlObject(mi
);
604 if (msa
.getPcdCoded() == null) {
608 Map
<String
, XmlObject
> m
= new HashMap
<String
, XmlObject
>();
609 m
.put("ModuleSurfaceArea", msa
);
610 SurfaceAreaQuery
.setDoc(m
);
611 PackageIdentification
[] depPkgs
= SurfaceAreaQuery
.getDependencePkg(null, mi
);
613 // First look through MSA pcd entries.
615 List
<PcdCodedDocument
.PcdCoded
.PcdEntry
> l
= msa
.getPcdCoded().getPcdEntryList();
616 ListIterator li
= l
.listIterator();
617 while(li
.hasNext()) {
618 PcdCodedDocument
.PcdCoded
.PcdEntry msaPcd
= (PcdCodedDocument
.PcdCoded
.PcdEntry
)li
.next();
619 if (!msaPcd
.getCName().equals(cName
)) {
622 if (!msaPcd
.getTokenSpaceGuidCName().equals(tsGuid
)) {
625 PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry spdPcd
= LookupPcdDeclaration(msaPcd
, depPkgs
);
626 if (spdPcd
== null) {
630 throw new PcdDeclNotFound(mi
.getName() + " " + msaPcd
.getCName());
633 // Get Pcd help text and original item type.
635 sa
[0] = spdPcd
.getHelpText() + msaPcd
.getHelpText();
636 sa
[1] = msaPcd
.getPcdItemType()+"";
637 sa
[2] = msa
.getModuleDefinitions().getBinaryModule()+"";
651 /**Remove PCDBuildDefinition entries from ModuleSA
652 * @param moduleKey identifier of ModuleSA.
653 * @param consumer where these entries come from.
655 public void removePcdData(String moduleKey
, ModuleIdentification consumer
) {
657 ModuleSurfaceAreaDocument
.ModuleSurfaceArea msa
= (ModuleSurfaceAreaDocument
.ModuleSurfaceArea
)WorkspaceProfile
.getModuleXmlObject(consumer
);
658 if (msa
.getPcdCoded() == null) {
662 List
<PcdCodedDocument
.PcdCoded
.PcdEntry
> l
= msa
.getPcdCoded().getPcdEntryList();
663 ListIterator li
= l
.listIterator();
665 while(li
.hasNext()) {
666 PcdCodedDocument
.PcdCoded
.PcdEntry msaPcd
= (PcdCodedDocument
.PcdCoded
.PcdEntry
)li
.next();
667 ModuleSADocument
.ModuleSA moduleSA
= getModuleSA(moduleKey
);
668 if (moduleSA
.getPcdBuildDefinition() != null) {
669 XmlCursor cursor
= moduleSA
.getPcdBuildDefinition().newCursor();
671 if (cursor
.toFirstChild()) {
673 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= (PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
) cursor
675 if (msaPcd
.getCName().equals(pcdData
.getCName())
676 && msaPcd
.getTokenSpaceGuidCName().equals(pcdData
.getTokenSpaceGuidCName())) {
678 maintainDynPcdMap(pcdData
.getCName() + " " + pcdData
.getTokenSpaceGuidCName(),
683 } while (cursor
.toNextSibling());
687 if (moduleSA
.getPcdBuildDefinition().getPcdDataList().size() == 0) {
701 // key for ModuleSA : "ModuleGuid ModuleVer PackageGuid PackageVer Arch"
703 public int getLibraryInstancesCount(String key
) {
704 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
705 if (msa
== null || msa
.getLibraries() == null || msa
.getLibraries().getInstanceList() == null){
708 return msa
.getLibraries().getInstanceList().size();
711 public void getLibraryInstances(String key
, String
[][] saa
){
712 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
713 if (msa
== null || msa
.getLibraries() == null || msa
.getLibraries().getInstanceList() == null){
717 ListIterator
<LibrariesDocument
.Libraries
.Instance
> li
= msa
.getLibraries().getInstanceList().listIterator();
718 for (int i
= 0; i
< saa
.length
; ++i
) {
719 LibrariesDocument
.Libraries
.Instance instance
= li
.next();
720 saa
[i
][1] = instance
.getModuleGuid();
721 saa
[i
][2] = instance
.getModuleVersion();
722 saa
[i
][3] = instance
.getPackageGuid();
723 saa
[i
][4] = instance
.getPackageVersion();
727 public void removeLibraryInstance(String key
, int i
) {
728 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
729 if (msa
== null || msa
.getLibraries() == null){
733 XmlCursor cursor
= msa
.getLibraries().newCursor();
734 if (cursor
.toFirstChild()) {
735 for (int j
= 0; j
< i
; ++j
) {
736 cursor
.toNextSibling();
739 while (cursor
.hasPrevToken()) {
740 cursor
.toPrevToken();
741 if (!cursor
.isText()) {
744 String s
= cursor
.getTextValue();
745 if (s
.matches(regNewLineAndSpaces
)) {
750 if (cursor
.isComment()) {
755 if (getLibraryInstancesCount(key
) == 0) {
764 public void genLibraryInstance(ModuleIdentification libMi
, String key
) {
765 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
767 msa
= getfpdFrameworkModules().addNewModuleSA();
769 LibrariesDocument
.Libraries libs
= msa
.getLibraries();
771 libs
= msa
.addNewLibraries();
774 String mn
= libMi
.getName();
775 String mg
= libMi
.getGuid();
776 String mv
= libMi
.getVersion();
777 String pn
= libMi
.getPackageId().getName();
778 String pg
= libMi
.getPackageId().getGuid();
779 String pv
= libMi
.getPackageId().getVersion();
780 LibrariesDocument
.Libraries
.Instance instance
= libs
.addNewInstance();
781 XmlCursor cursor
= instance
.newCursor();
783 String comment
= "Pkg: " + pn
+ " Mod: " + mn
784 + " Path: " + libMi
.getPath().substring(System
.getenv("WORKSPACE").length() + 1);
785 cursor
.insertComment(comment
);
794 instance
.setModuleGuid(mg
);
795 instance
.setModuleVersion(mv
);
796 instance
.setPackageGuid(pg
);
797 instance
.setPackageVersion(pv
);
801 public String
getFvBinding(String moduleKey
){
802 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(moduleKey
);
803 return getFvBinding (moduleSa
);
806 public String
getFvBinding (ModuleSADocument
.ModuleSA moduleSa
) {
807 if (moduleSa
== null || moduleSa
.getModuleSaBuildOptions() == null) {
810 return moduleSa
.getModuleSaBuildOptions().getFvBinding();
813 public void setFvBinding(ModuleSADocument
.ModuleSA moduleSa
, String fvBinding
) {
814 if (moduleSa
== null ) {
817 if (fvBinding
== null || fvBinding
.length() == 0) {
818 if(moduleSa
.getModuleSaBuildOptions() != null){
819 moduleSa
.getModuleSaBuildOptions().unsetFvBinding();
823 if(moduleSa
.getModuleSaBuildOptions() == null){
824 moduleSa
.addNewModuleSaBuildOptions().setFvBinding(fvBinding
);
827 moduleSa
.getModuleSaBuildOptions().setFvBinding(fvBinding
);
831 public void setFvBinding(String moduleKey
, String fvBinding
){
832 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(moduleKey
);
833 setFvBinding (moduleSa
, fvBinding
);
836 private int fvBindingForModuleSA (ModuleSADocument
.ModuleSA moduleSa
, String fvName
) {
837 if (moduleSa
== null || moduleSa
.getModuleSaBuildOptions() == null || moduleSa
.getModuleSaBuildOptions().getFvBinding() == null) {
841 String fvNameList
= moduleSa
.getModuleSaBuildOptions().getFvBinding();
842 String
[] fvNamesArray
= fvNameList
.split(" ");
844 for (int i
= 0; i
< fvNamesArray
.length
; ++i
) {
845 if (fvNamesArray
[i
].equals(fvName
)) {
853 public void removeFvBinding (ModuleSADocument
.ModuleSA moduleSa
, String fvName
) {
854 if (moduleSa
== null || moduleSa
.getModuleSaBuildOptions() == null || moduleSa
.getModuleSaBuildOptions().getFvBinding() == null) {
858 String fvNameList
= moduleSa
.getModuleSaBuildOptions().getFvBinding();
859 String
[] fvNamesArray
= fvNameList
.split(" ");
861 for (int i
= 0; i
< fvNamesArray
.length
; ++i
) {
862 if (fvNamesArray
[i
].equals(fvName
)) {
867 // jump over where the input fvName occurs in the original Fv list.
868 if (occursAt
!= -1) {
869 String newFvNameList
= " ";
870 for (int i
= 0; i
< fvNamesArray
.length
; ++i
) {
874 newFvNameList
+= fvNamesArray
[i
];
876 setFvBinding (moduleSa
, newFvNameList
.trim());
882 * @param fvName The FV name that to be removed from FvBinding List.
884 public void removeFvBindingAll (String fvName
) {
885 if (getfpdFrameworkModules().getModuleSAList() == null || getfpdFrameworkModules().getModuleSAList().size() == 0){
886 removeElement(getfpdFrameworkModules());
887 fpdFrameworkModules
= null;
891 Iterator
<ModuleSADocument
.ModuleSA
> li
= getfpdFrameworkModules().getModuleSAList().iterator();
892 while (li
.hasNext()) {
893 ModuleSADocument
.ModuleSA moduleSa
= li
.next();
894 removeFvBinding (moduleSa
, fvName
);
898 public void appendFvBindingAll (String fvName
) {
899 if (getfpdFrameworkModules().getModuleSAList() == null || getfpdFrameworkModules().getModuleSAList().size() == 0){
900 removeElement(getfpdFrameworkModules());
901 fpdFrameworkModules
= null;
905 Iterator
<ModuleSADocument
.ModuleSA
> li
= getfpdFrameworkModules().getModuleSAList().iterator();
906 while (li
.hasNext()) {
907 ModuleSADocument
.ModuleSA moduleSa
= li
.next();
908 appendFvBinding (moduleSa
, fvName
);
912 public void appendFvBindingFor (String oldFvName
, String newFvName
) {
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 String fvBinding
= getFvBinding (moduleSa
);
923 if (fvBinding
!= null && fvBindingForModuleSA (moduleSa
, oldFvName
) >= 0) {
924 appendFvBinding (moduleSa
, newFvName
);
929 public void appendFvBinding (String moduleKey
, String fvName
) {
930 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(moduleKey
);
931 appendFvBinding (moduleSa
, fvName
);
934 public void appendFvBinding (ModuleSADocument
.ModuleSA moduleSa
, String fvName
) {
935 if (moduleSa
== null) {
939 if (moduleSa
.getModuleSaBuildOptions() == null || moduleSa
.getModuleSaBuildOptions().getFvBinding() == null) {
940 setFvBinding(moduleSa
, fvName
);
944 String fvNameList
= moduleSa
.getModuleSaBuildOptions().getFvBinding();
945 String newFvNameList
= fvNameList
+ " " + fvName
;
946 setFvBinding (moduleSa
, newFvNameList
.trim());
949 public void updateFvBindingInModuleSA (ModuleIdentification mi
, String fvName
) {
950 Vector
<Object
> vSupArchs
= new Vector
<Object
>();
951 getPlatformDefsSupportedArchs(vSupArchs
);
952 String moduleInfo
= mi
.getGuid() + " " + mi
.getVersion() + " " + mi
.getPackageId().getGuid() + " " + mi
.getPackageId().getVersion();
953 for (int i
= 0; i
< vSupArchs
.size(); ++i
) {
954 String moduleKey
= moduleInfo
+ " " + vSupArchs
.get(i
);
955 appendFvBinding (moduleKey
, fvName
);
959 public String
getFfsFileNameGuid(String moduleKey
){
960 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(moduleKey
);
961 if (moduleSa
== null || moduleSa
.getModuleSaBuildOptions() == null) {
964 return moduleSa
.getModuleSaBuildOptions().getFfsFileNameGuid();
967 public void setFfsFileNameGuid(String moduleKey
, String fileGuid
){
968 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
972 if(msa
.getModuleSaBuildOptions() == null){
973 msa
.addNewModuleSaBuildOptions();
976 ModuleSaBuildOptionsDocument
.ModuleSaBuildOptions msaBuildOpts
= msa
.getModuleSaBuildOptions();
977 if (fileGuid
!= null) {
978 msaBuildOpts
.setFfsFileNameGuid(fileGuid
);
981 XmlCursor cursor
= msaBuildOpts
.newCursor();
982 if (cursor
.toChild(xmlNs
, "FfsFileNameGuid")) {
990 public String
getFfsFormatKey(String moduleKey
){
991 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
992 if (msa
== null || msa
.getModuleSaBuildOptions() == null) {
995 return msa
.getModuleSaBuildOptions().getFfsFormatKey();
998 public void setFfsFormatKey(String moduleKey
, String ffsKey
){
999 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
1003 if(msa
.getModuleSaBuildOptions() == null){
1004 msa
.addNewModuleSaBuildOptions().setFfsFormatKey(ffsKey
);
1007 msa
.getModuleSaBuildOptions().setFfsFormatKey(ffsKey
);
1010 public void setModuleSAForceDebug(int i
, boolean dbgEnable
) {
1011 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(i
);
1012 moduleSa
.setForceDebug(dbgEnable
);
1015 public boolean getModuleSAForceDebug (int i
) {
1016 ModuleSADocument
.ModuleSA moduleSa
= getModuleSA(i
);
1017 if (moduleSa
.getForceDebug() == true) {
1023 public void getModuleSAOptions(String moduleKey
, String
[][] saa
) {
1024 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
1025 if (msa
== null || msa
.getModuleSaBuildOptions() == null || msa
.getModuleSaBuildOptions().getOptions() == null
1026 || msa
.getModuleSaBuildOptions().getOptions().getOptionList() == null) {
1030 List
<OptionDocument
.Option
> lOpt
= msa
.getModuleSaBuildOptions().getOptions().getOptionList();
1031 ListIterator li
= lOpt
.listIterator();
1033 while(li
.hasNext()) {
1034 OptionDocument
.Option opt
= (OptionDocument
.Option
)li
.next();
1035 if (opt
.getBuildTargets() != null) {
1036 saa
[i
][0] = listToString(opt
.getBuildTargets());
1038 saa
[i
][1] = opt
.getToolChainFamily();
1039 saa
[i
][2] = opt
.getTagName();
1040 saa
[i
][3] = opt
.getToolCode();
1042 if (opt
.getSupArchList() != null){
1043 saa
[i
][4] = listToString(opt
.getSupArchList());
1049 saa
[i
][5] = opt
.getStringValue();
1055 public int getModuleSAOptionsCount(String moduleKey
){
1056 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
1057 if (msa
== null || msa
.getModuleSaBuildOptions() == null || msa
.getModuleSaBuildOptions().getOptions() == null
1058 || msa
.getModuleSaBuildOptions().getOptions().getOptionList() == null) {
1061 return msa
.getModuleSaBuildOptions().getOptions().getOptionList().size();
1064 public void genModuleSAOptionsOpt(String moduleKey
, Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
) {
1065 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
1066 if (msa
.getModuleSaBuildOptions() == null) {
1067 msa
.addNewModuleSaBuildOptions();
1069 if (msa
.getModuleSaBuildOptions().getOptions() == null){
1070 msa
.getModuleSaBuildOptions().addNewOptions();
1072 OptionDocument
.Option opt
= msa
.getModuleSaBuildOptions().getOptions().addNewOption();
1073 setBuildOptionsOpt(buildTargets
, toolChain
, tagName
, toolCmd
, archList
, contents
, opt
);
1076 public void removeModuleSAOptionsOpt(String moduleKey
, int i
) {
1077 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
1078 if (msa
.getModuleSaBuildOptions() == null || msa
.getModuleSaBuildOptions().getOptions() == null) {
1081 OptionsDocument
.Options opts
= msa
.getModuleSaBuildOptions().getOptions();
1082 XmlCursor cursor
= opts
.newCursor();
1083 if (cursor
.toFirstChild()) {
1084 for (int j
= 0; j
< i
; ++j
){
1085 cursor
.toNextSibling();
1092 public void updateModuleSAOptionsOpt(String moduleKey
, int i
, Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
) {
1093 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
1094 if (msa
.getModuleSaBuildOptions() == null || msa
.getModuleSaBuildOptions().getOptions() == null) {
1097 OptionsDocument
.Options opts
= msa
.getModuleSaBuildOptions().getOptions();
1098 XmlCursor cursor
= opts
.newCursor();
1099 if (cursor
.toFirstChild()) {
1100 for (int j
= 0; j
< i
; ++j
){
1101 cursor
.toNextSibling();
1103 OptionDocument
.Option opt
= (OptionDocument
.Option
)cursor
.getObject();
1104 setBuildOptionsOpt(buildTargets
, toolChain
, tagName
, toolCmd
, archList
, contents
, opt
);
1109 /**add pcd information of module mi to a ModuleSA.
1111 * @param moduleSa if null, generate a new ModuleSA.
1113 public void addFrameworkModulesPcdBuildDefs(ModuleIdentification mi
, String arch
, ModuleSADocument
.ModuleSA moduleSa
) throws Exception
{
1114 //ToDo add Arch filter
1117 if (moduleSa
== null) {
1118 moduleSa
= genModuleSA(mi
, arch
);
1121 ModuleSurfaceAreaDocument
.ModuleSurfaceArea msa
= (ModuleSurfaceAreaDocument
.ModuleSurfaceArea
)WorkspaceProfile
.getModuleXmlObject(mi
);
1122 if (msa
.getPcdCoded() == null) {
1126 Map
<String
, XmlObject
> m
= new HashMap
<String
, XmlObject
>();
1127 m
.put("ModuleSurfaceArea", msa
);
1128 SurfaceAreaQuery
.setDoc(m
);
1129 PackageIdentification
[] depPkgs
= SurfaceAreaQuery
.getDependencePkg(null, mi
);
1131 // Implementing InitializePlatformPcdBuildDefinitions
1133 List
<PcdCodedDocument
.PcdCoded
.PcdEntry
> l
= msa
.getPcdCoded().getPcdEntryList();
1134 ListIterator li
= l
.listIterator();
1135 while(li
.hasNext()) {
1136 PcdCodedDocument
.PcdCoded
.PcdEntry msaPcd
= (PcdCodedDocument
.PcdCoded
.PcdEntry
)li
.next();
1137 PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry spdPcd
= LookupPcdDeclaration(msaPcd
, depPkgs
);
1138 if (spdPcd
== null) {
1142 throw new PcdDeclNotFound("No Declaration for PCD Entry " + msaPcd
.getCName() + " in Module " + mi
.getName());
1145 // AddItem to ModuleSA PcdBuildDefinitions
1147 String defaultVal
= msaPcd
.getDefaultValue() == null ? spdPcd
.getDefaultValue() : msaPcd
.getDefaultValue();
1149 genPcdData(msaPcd
.getCName(), spdPcd
.getToken(), msaPcd
.getTokenSpaceGuidCName(), msaPcd
.getPcdItemType().toString(), spdPcd
.getDatumType()+"", defaultVal
, moduleSa
);
1153 catch (Exception e
){
1160 private PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry
LookupPcdDeclaration (PcdCodedDocument
.PcdCoded
.PcdEntry msaPcd
, PackageIdentification
[] depPkgs
) {
1162 PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry spdPcd
= null;
1163 for (int i
= 0; i
< depPkgs
.length
; ++i
) {
1165 XmlObject
[] xo
= SurfaceAreaQuery
.getSpdPcdDeclarations(depPkgs
[i
]);
1169 for (int j
= 0; j
< xo
.length
; ++j
) {
1170 spdPcd
= (PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry
)xo
[j
];
1171 if (msaPcd
.getTokenSpaceGuidCName() == null) {
1172 if (spdPcd
.getCName().equals(msaPcd
.getCName())) {
1177 if (spdPcd
.getCName().equals(msaPcd
.getCName()) && spdPcd
.getTokenSpaceGuidCName().equals(msaPcd
.getTokenSpaceGuidCName())) {
1188 private ModuleSADocument
.ModuleSA
genModuleSA (ModuleIdentification mi
, String arch
) {
1189 PackageIdentification pi
= WorkspaceProfile
.getPackageForModule(mi
);
1190 ModuleSADocument
.ModuleSA msa
= getfpdFrameworkModules().addNewModuleSA();
1191 XmlCursor cursor
= msa
.newCursor();
1193 String comment
= "Mod: " + mi
.getName() + " Type: " + SurfaceAreaQuery
.getModuleType(mi
) + " Path: "
1194 + mi
.getPath().substring(System
.getenv("WORKSPACE").length() + 1);
1195 cursor
.insertComment(comment
);
1198 e
.printStackTrace();
1203 msa
.setModuleGuid(mi
.getGuid());
1204 msa
.setModuleVersion(mi
.getVersion());
1205 msa
.setPackageGuid(pi
.getGuid());
1206 msa
.setPackageVersion(pi
.getVersion());
1208 Vector
<String
> v
= new Vector
<String
>();
1210 msa
.setSupArchList(v
);
1216 private void genPcdData (String cName
, Object token
, String tsGuid
, String itemType
, String dataType
, String defaultVal
, ModuleSADocument
.ModuleSA moduleSa
)
1217 throws PcdItemTypeConflictException
, PcdValueMalFormed
{
1218 if (moduleSa
.getPcdBuildDefinition() == null){
1219 moduleSa
.addNewPcdBuildDefinition();
1222 // constructe pcd to modulesa mapping first.
1223 // Attention : for any error condition, remove from map this pcd.
1225 ArrayList
<String
> pcdConsumer
= LookupPlatformPcdData(cName
+ " " + tsGuid
);
1226 if (pcdConsumer
== null) {
1227 pcdConsumer
= new ArrayList
<String
>();
1230 // Using existing Pcd type, if this pcd already exists in other ModuleSA
1232 if (pcdConsumer
.size() > 0) {
1234 itemType
= itemType (pcdConsumer
.get(0));
1236 String listValue
= moduleSa
.getModuleGuid() + " " + moduleSa
.getModuleVersion()
1237 + " " + moduleSa
.getPackageGuid() + " " + moduleSa
.getPackageVersion() + " " + listToString(moduleSa
.getSupArchList())
1239 pcdConsumer
.add(listValue
);
1240 dynPcdMap
.put(cName
+ " " + tsGuid
, pcdConsumer
);
1242 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData fpdPcd
= moduleSa
.getPcdBuildDefinition().addNewPcdData();
1243 fpdPcd
.setCName(cName
);
1244 fpdPcd
.setToken(token
);
1245 fpdPcd
.setTokenSpaceGuidCName(tsGuid
);
1246 fpdPcd
.setDatumType(PcdDataTypes
.Enum
.forString(dataType
));
1247 fpdPcd
.setItemType(PcdItemTypes
.Enum
.forString(itemType
));
1249 if (defaultVal
!= null){
1250 fpdPcd
.setValue(defaultVal
);
1253 if (dataType
.equals("UINT8") || dataType
.equals("UINT16") || dataType
.equals("UINT32") || dataType
.equals("UINT64")) {
1254 fpdPcd
.setValue("0");
1256 if (dataType
.equals("BOOLEAN")){
1257 fpdPcd
.setValue("FALSE");
1259 if (dataType
.equals("VOID*")) {
1260 fpdPcd
.setValue("");
1264 // Using existing pcd value, if this pcd already exists in other moduleSa.
1266 if (defaultPcdValue
.get(cName
+ " " + tsGuid
) == null) {
1267 defaultPcdValue
.put(cName
+ " " + tsGuid
, fpdPcd
.getValue());
1270 fpdPcd
.setValue(defaultPcdValue
.get(cName
+ " " + tsGuid
));
1273 if (dataType
.equals("UINT8")){
1274 fpdPcd
.setMaxDatumSize(1);
1276 if (dataType
.equals("UINT16")) {
1277 fpdPcd
.setMaxDatumSize(2);
1279 if (dataType
.equals("UINT32")) {
1280 fpdPcd
.setMaxDatumSize(4);
1282 if (dataType
.equals("UINT64")){
1283 fpdPcd
.setMaxDatumSize(8);
1285 if (dataType
.equals("BOOLEAN")){
1286 fpdPcd
.setMaxDatumSize(1);
1288 if (dataType
.equals("VOID*")) {
1289 int maxSize
= setMaxSizeForPointer(fpdPcd
.getValue());
1290 fpdPcd
.setMaxDatumSize(maxSize
);
1294 if (itemType
.equals("DYNAMIC") || itemType
.equals("DYNAMIC_EX")) {
1295 ArrayList
<String
> al
= LookupDynamicPcdBuildDefinition(cName
+ " " + tsGuid
);
1297 // if only one module mapped to this pcd, then the one is myself. so no other module mapped.
1298 // so need to add one dyn pcd.
1300 if (al
.size() == 1) {
1301 addDynamicPcdBuildData(cName
, token
, tsGuid
, itemType
, dataType
, defaultVal
);
1307 public int setMaxSizeForPointer(String datum
) throws PcdValueMalFormed
{
1308 if (datum
== null) {
1311 char ch
= datum
.charAt(0);
1315 // For void* type PCD, only three datum is support:
1316 // 1) Unicode: string with start char is "L"
1317 // 2) Ansci: String is ""
1318 // 3) byte array: String start char "{"
1321 start
= datum
.indexOf('\"');
1322 end
= datum
.lastIndexOf('\"');
1323 if ((start
> end
) ||
1324 (end
> datum
.length())||
1325 ((start
== end
) && (datum
.length() > 0))) {
1326 //ToDo Error handling here
1327 throw new PcdValueMalFormed (datum
);
1330 strValue
= datum
.substring(start
+ 1, end
);
1331 return strValue
.length() * 2;
1332 } else if (ch
== '\"'){
1333 start
= datum
.indexOf('\"');
1334 end
= datum
.lastIndexOf('\"');
1335 if ((start
> end
) ||
1336 (end
> datum
.length())||
1337 ((start
== end
) && (datum
.length() > 0))) {
1338 throw new PcdValueMalFormed (datum
);
1340 strValue
= datum
.substring(start
+ 1, end
);
1341 return strValue
.length();
1342 } else if (ch
=='{') {
1343 String
[] strValueArray
;
1345 start
= datum
.indexOf('{');
1346 end
= datum
.lastIndexOf('}');
1347 strValue
= datum
.substring(start
+ 1, end
);
1348 strValue
= strValue
.trim();
1349 if (strValue
.length() == 0) {
1352 strValueArray
= strValue
.split(",");
1353 for (int index
= 0; index
< strValueArray
.length
; index
++) {
1354 Integer value
= Integer
.decode(strValueArray
[index
].trim());
1357 // "[FPD file error] The datum type of PCD %s in %s is VOID*, "+
1358 // "it must be a byte array. But the element of %s exceed the byte range",
1359 throw new PcdValueMalFormed (datum
);
1362 return strValueArray
.length
;
1366 // "[FPD file error] The datum type of PCD %s in %s is VOID*. For VOID* type, you have three format choise:\n "+
1367 // "1) UNICODE string: like L\"xxxx\";\r\n"+
1368 // "2) ANSIC string: like \"xxx\";\r\n"+
1369 // "3) Byte array: like {0x2, 0x45, 0x23}\r\n"+
1370 // "but the datum in seems does not following above format!",
1371 throw new PcdValueMalFormed (datum
);
1376 private ArrayList
<String
> LookupDynamicPcdBuildDefinition(String dynPcdKey
) {
1377 ArrayList
<String
> al
= dynPcdMap
.get(dynPcdKey
);
1382 private ArrayList
<String
> LookupPlatformPcdData(String pcdKey
) {
1384 return dynPcdMap
.get(pcdKey
);
1387 public int getDynamicPcdBuildDataCount() {
1388 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1389 removeElement(getfpdDynPcdBuildDefs());
1390 fpdDynPcdBuildDefs
= null;
1393 return getfpdDynPcdBuildDefs().getPcdBuildDataList().size();
1396 public void getDynamicPcdBuildData(String
[][] saa
) {
1397 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1398 removeElement(getfpdDynPcdBuildDefs());
1399 fpdDynPcdBuildDefs
= null;
1402 List
<DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
> l
= getfpdDynPcdBuildDefs().getPcdBuildDataList();
1403 ListIterator
<DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
> li
= l
.listIterator();
1405 while(li
.hasNext()) {
1406 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData dynPcd
= li
.next();
1407 saa
[i
][0] = dynPcd
.getCName();
1408 saa
[i
][1] = dynPcd
.getToken().toString();
1409 saa
[i
][2] = dynPcd
.getTokenSpaceGuidCName();
1410 saa
[i
][3] = dynPcd
.getMaxDatumSize()+"";
1411 saa
[i
][4] = dynPcd
.getDatumType().toString();
1417 public void addDynamicPcdBuildData(String cName
, Object token
, String tsGuid
, String itemType
, String dataType
, String defaultVal
)
1418 throws PcdValueMalFormed
{
1419 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData dynPcdData
= getfpdDynPcdBuildDefs().addNewPcdBuildData();
1420 dynPcdData
.setItemType(PcdItemTypes
.Enum
.forString(itemType
));
1421 dynPcdData
.setCName(cName
);
1422 dynPcdData
.setToken(token
);
1423 dynPcdData
.setTokenSpaceGuidCName(tsGuid
);
1424 dynPcdData
.setDatumType(PcdDataTypes
.Enum
.forString(dataType
));
1426 BigInteger bigInt
= new BigInteger("0");
1427 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo skuInfo
= dynPcdData
.addNewSkuInfo();
1428 skuInfo
.setSkuId(bigInt
);
1429 if (defaultVal
!= null){
1430 skuInfo
.setValue(defaultVal
);
1433 if (dataType
.equals("UINT8")){
1434 skuInfo
.setValue("0");
1436 if (dataType
.equals("UINT16")) {
1437 skuInfo
.setValue("0");
1439 if (dataType
.equals("UINT32")) {
1440 skuInfo
.setValue("0");
1442 if (dataType
.equals("UINT64")){
1443 skuInfo
.setValue("0");
1445 if (dataType
.equals("BOOLEAN")){
1446 skuInfo
.setValue("false");
1448 if (dataType
.equals("VOID*")) {
1449 skuInfo
.setValue("");
1452 if (dataType
.equals("UINT8")){
1453 dynPcdData
.setMaxDatumSize(1);
1455 if (dataType
.equals("UINT16")) {
1456 dynPcdData
.setMaxDatumSize(2);
1458 if (dataType
.equals("UINT32")) {
1459 dynPcdData
.setMaxDatumSize(4);
1461 if (dataType
.equals("UINT64")){
1462 dynPcdData
.setMaxDatumSize(8);
1464 if (dataType
.equals("BOOLEAN")){
1465 dynPcdData
.setMaxDatumSize(1);
1467 if (dataType
.equals("VOID*")) {
1468 int maxSize
= setMaxSizeForPointer(defaultVal
);
1469 dynPcdData
.setMaxDatumSize(maxSize
);
1473 public void removeDynamicPcdBuildData(String cName
, String tsGuid
) {
1474 XmlObject o
= fpdRoot
.getDynamicPcdBuildDefinitions();
1479 XmlCursor cursor
= o
.newCursor();
1480 if (cursor
.toFirstChild()) {
1482 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdBuildData
=
1483 (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1484 if (pcdBuildData
.getCName().equals(cName
) && pcdBuildData
.getTokenSpaceGuidCName().equals(tsGuid
)) {
1486 if (getDynamicPcdBuildDataCount() == 1) {
1494 while (cursor
.toNextSibling());
1499 // Get the Sku Info count of ith dyn pcd element.
1501 public int getDynamicPcdSkuInfoCount(int i
){
1502 if (fpdRoot
.getDynamicPcdBuildDefinitions() == null || fpdRoot
.getDynamicPcdBuildDefinitions().getPcdBuildDataList() == null
1503 || fpdRoot
.getDynamicPcdBuildDefinitions().getPcdBuildDataList().size() == 0) {
1507 int skuInfoCount
= 0;
1508 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1509 if (cursor
.toFirstChild()) {
1510 for (int j
= 0; j
< i
; ++j
) {
1511 cursor
.toNextSibling();
1513 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1514 if (pcdData
.getSkuInfoList() == null) {
1518 skuInfoCount
= pcdData
.getSkuInfoList().size();
1522 return skuInfoCount
;
1525 public void getDynamicPcdSkuInfos(int i
, String
[][] saa
){
1526 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1527 removeElement(getfpdDynPcdBuildDefs());
1528 fpdDynPcdBuildDefs
= null;
1532 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1533 if (cursor
.toFirstChild()) {
1534 for (int j
= 0; j
< i
; ++j
) {
1535 cursor
.toNextSibling();
1537 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1538 if (pcdData
.getSkuInfoList() == null) {
1543 ListIterator
<DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo
> li
= pcdData
.getSkuInfoList().listIterator();
1545 while (li
.hasNext()) {
1546 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo skuInfo
= li
.next();
1547 saa
[k
][0] = skuInfo
.getSkuId()+"";
1548 saa
[k
][1] = skuInfo
.getVariableName();
1549 saa
[k
][2] = skuInfo
.getVariableGuid();
1550 saa
[k
][3] = skuInfo
.getVariableOffset();
1551 saa
[k
][4] = skuInfo
.getHiiDefaultValue();
1552 saa
[k
][5] = skuInfo
.getVpdOffset();
1553 saa
[k
][6] = skuInfo
.getValue();
1563 public String
getDynamicPcdBuildDataValue(int i
){
1564 String value
= null;
1565 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1566 removeElement(getfpdDynPcdBuildDefs());
1567 fpdDynPcdBuildDefs
= null;
1571 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1572 if (cursor
.toFirstChild()) {
1573 for (int j
= 0; j
< i
; ++j
) {
1574 cursor
.toNextSibling();
1576 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1577 if (pcdData
.getSkuInfoList() == null) {
1581 value
= pcdData
.getSkuInfoArray(0).getValue();
1588 public String
getDynamicPcdBuildDataVpdOffset(int i
){
1589 String vpdOffset
= null;
1590 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1591 removeElement(getfpdDynPcdBuildDefs());
1592 fpdDynPcdBuildDefs
= null;
1596 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1597 if (cursor
.toFirstChild()) {
1598 for (int j
= 0; j
< i
; ++j
) {
1599 cursor
.toNextSibling();
1601 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1602 if (pcdData
.getSkuInfoList() == null) {
1606 vpdOffset
= pcdData
.getSkuInfoArray(0).getVpdOffset();
1613 public void removeDynamicPcdBuildDataSkuInfo(int i
) {
1614 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1615 removeElement(getfpdDynPcdBuildDefs());
1616 fpdDynPcdBuildDefs
= null;
1620 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1621 if (cursor
.toFirstChild()) {
1622 for (int j
= 0; j
< i
; ++j
) {
1623 cursor
.toNextSibling();
1625 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1626 if (pcdData
.getSkuInfoList() == null) {
1631 QName qSkuInfo
= new QName(xmlNs
, "SkuInfo");
1632 cursor
.toChild(qSkuInfo
);
1639 // generate sku info for ith dyn pcd build data.
1641 public void genDynamicPcdBuildDataSkuInfo(String id
, String varName
, String varGuid
, String varOffset
,
1642 String hiiDefault
, String vpdOffset
, String value
, int i
) {
1643 // if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1647 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1648 if (cursor
.toFirstChild()) {
1649 for (int j
= 0; j
< i
; ++j
) {
1650 cursor
.toNextSibling();
1652 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1653 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo skuInfo
= pcdData
.addNewSkuInfo();
1654 skuInfo
.setSkuId(new BigInteger(id
));
1655 if (varName
!= null){
1656 skuInfo
.setVariableName(varName
);
1657 skuInfo
.setVariableGuid(varGuid
);
1658 skuInfo
.setVariableOffset(varOffset
);
1659 skuInfo
.setHiiDefaultValue(hiiDefault
);
1661 else if (vpdOffset
!= null){
1662 skuInfo
.setVpdOffset(vpdOffset
);
1665 skuInfo
.setValue(value
);
1670 public void updateDynamicPcdBuildDataSkuInfo(String id
, String varName
, String varGuid
, String varOffset
,
1671 String hiiDefault
, String vpdOffset
, String value
, int i
){
1672 // if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1676 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1677 if (cursor
.toFirstChild()) {
1678 for (int j
= 0; j
< i
; ++j
) {
1679 cursor
.toNextSibling();
1681 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1682 ListIterator
<DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo
> li
= pcdData
.getSkuInfoList().listIterator();
1683 while (li
.hasNext()) {
1684 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo skuInfo
= li
.next();
1685 if (skuInfo
.getSkuId().toString().equals(id
)){
1686 if (varName
!= null){
1687 skuInfo
.setVariableName(varName
);
1688 skuInfo
.setVariableGuid(varGuid
);
1689 skuInfo
.setVariableOffset(varOffset
);
1690 skuInfo
.setHiiDefaultValue(hiiDefault
);
1692 else if (vpdOffset
!= null){
1693 skuInfo
.setVpdOffset(vpdOffset
);
1696 skuInfo
.setValue(value
);
1704 public BuildOptionsDocument
.BuildOptions
getfpdBuildOpts() {
1705 if (fpdBuildOpts
== null) {
1706 fpdBuildOpts
= fpdRoot
.addNewBuildOptions();
1708 return fpdBuildOpts
;
1711 public void genBuildOptionsUserExtensions(String fvName
, String outputFileName
, Vector
<String
[]> includeModules
) {
1712 QName elementFvName
= new QName (xmlNs
, "FvName");
1713 QName elementIncludeModules
= new QName(xmlNs
, "IncludeModules");
1714 QName elementInfFileName
= new QName(xmlNs
, "InfFileName");
1715 QName elementModule
= new QName(xmlNs
, "Module");
1717 UserExtensionsDocument
.UserExtensions userExts
= getfpdBuildOpts().addNewUserExtensions();
1718 userExts
.setUserID("IMAGES");
1719 userExts
.setIdentifier(new BigInteger("1"));
1720 XmlCursor cursor
= userExts
.newCursor();
1721 cursor
.toEndToken();
1723 cursor
.beginElement(elementFvName
);
1724 cursor
.insertChars(fvName
);
1725 cursor
.toNextToken();
1727 cursor
.beginElement(elementInfFileName
);
1728 cursor
.insertChars(fvName
+ ".inf");
1729 cursor
.toNextToken();
1731 cursor
.beginElement(elementIncludeModules
);
1732 for (int i
= 0; i
< includeModules
.size(); ++i
) {
1733 cursor
.beginElement(elementModule
);
1734 cursor
.insertAttributeWithValue("ModuleGuid", includeModules
.get(i
)[0]);
1735 cursor
.insertAttributeWithValue("BaseName", includeModules
.get(i
)[1]);
1736 cursor
.toEndToken();
1737 cursor
.toNextToken();
1742 public int getUserExtsIncModCount (String fvName
) {
1743 if (getfpdBuildOpts().getUserExtensionsList() == null) {
1746 ListIterator
<UserExtensionsDocument
.UserExtensions
> li
= getfpdBuildOpts().getUserExtensionsList().listIterator();
1747 QName elementIncludeModules
= new QName(xmlNs
, "IncludeModules");
1748 while (li
.hasNext()) {
1749 UserExtensionsDocument
.UserExtensions ues
= li
.next();
1750 if (!ues
.getUserID().equals("IMAGES")) {
1753 XmlCursor cursor
= ues
.newCursor();
1754 cursor
.toFirstChild();
1755 String elementName
= cursor
.getTextValue();
1756 if (elementName
.equals(fvName
)) {
1757 cursor
.toNextSibling(elementIncludeModules
);
1758 if (cursor
.toFirstChild()) {
1760 for (i
= 1; cursor
.toNextSibling(); ++i
);
1772 public void getUserExtsIncMods(String fvName
, String
[][] saa
) {
1773 if (getfpdBuildOpts().getUserExtensionsList() == null) {
1777 XmlCursor cursor
= getfpdBuildOpts().newCursor();
1778 QName elementUserExts
= new QName (xmlNs
, "UserExtensions");
1779 QName attribUserId
= new QName ("UserID");
1780 QName elementFvName
= new QName (xmlNs
, "FvName");
1781 QName elementIncludeModules
= new QName(xmlNs
, "IncludeModules");
1782 QName attribModuleGuid
= new QName("ModuleGuid");
1783 QName attribBaseName
= new QName("BaseName");
1785 if (cursor
.toChild(elementUserExts
)) {
1788 if (cursor
.getAttributeText(attribUserId
).equals("IMAGES")) {
1789 cursor
.toChild(elementFvName
);
1790 String elementName
= cursor
.getTextValue();
1791 if (elementName
.equals(fvName
)) {
1792 cursor
.toNextSibling(elementIncludeModules
);
1793 if (cursor
.toFirstChild()) {
1796 saa
[i
][0] = cursor
.getAttributeText(attribModuleGuid
);
1797 saa
[i
][1] = cursor
.getAttributeText(attribBaseName
);
1799 }while (cursor
.toNextSibling());
1805 }while (cursor
.toNextSibling(elementUserExts
));
1811 public void updateBuildOptionsUserExtensions (String oldFvName
, String newFvName
) {
1812 if (getfpdBuildOpts().getUserExtensionsList() == null) {
1815 ListIterator
<UserExtensionsDocument
.UserExtensions
> li
= getfpdBuildOpts().getUserExtensionsList().listIterator();
1816 while (li
.hasNext()) {
1817 UserExtensionsDocument
.UserExtensions ues
= li
.next();
1818 if (!ues
.getUserID().equals("IMAGES")) {
1821 XmlCursor cursor
= ues
.newCursor();
1822 cursor
.toFirstChild();
1823 String elementName
= cursor
.getTextValue();
1824 if (elementName
.equals(oldFvName
)) {
1825 cursor
.setTextValue(newFvName
);
1832 public void removeBuildOptionsUserExtensions (String fvName
) {
1833 if (getfpdBuildOpts().getUserExtensionsList() == null) {
1837 ListIterator
<UserExtensionsDocument
.UserExtensions
> li
= getfpdBuildOpts().getUserExtensionsList().listIterator();
1838 while (li
.hasNext()) {
1839 UserExtensionsDocument
.UserExtensions ues
= li
.next();
1840 if (!ues
.getUserID().equals("IMAGES")) {
1843 XmlCursor cursor
= ues
.newCursor();
1844 cursor
.toFirstChild();
1845 String elementName
= cursor
.getTextValue();
1846 if (elementName
.equals(fvName
)) {
1858 public void genBuildOptionsUserDefAntTask (String id
, String fileName
, String execOrder
) {
1859 UserDefinedAntTasksDocument
.UserDefinedAntTasks udats
= getfpdBuildOpts().getUserDefinedAntTasks();
1860 if (udats
== null) {
1861 udats
= getfpdBuildOpts().addNewUserDefinedAntTasks();
1864 AntTaskDocument
.AntTask at
= udats
.addNewAntTask();
1865 setBuildOptionsUserDefAntTask(id
, fileName
, execOrder
, at
);
1868 private void setBuildOptionsUserDefAntTask(String id
, String fileName
, String execOrder
, AntTaskDocument
.AntTask at
) {
1869 at
.setId(new Integer(id
));
1870 XmlCursor cursor
= at
.newCursor();
1871 if (fileName
!= null){
1872 at
.setFilename(fileName
);
1874 else if (cursor
.toChild(xmlNs
, "Filename")) {
1877 if (execOrder
!= null) {
1878 at
.setAntCmdOptions(execOrder
);
1880 else if (cursor
.toChild(xmlNs
, "AntCmdOptions")) {
1886 public void removeBuildOptionsUserDefAntTask(int i
) {
1887 XmlObject o
= getfpdBuildOpts().getUserDefinedAntTasks();
1891 XmlCursor cursor
= o
.newCursor();
1892 if (cursor
.toFirstChild()) {
1893 for (int j
= 0; j
< i
; ++j
) {
1894 cursor
.toNextSibling();
1897 if (getBuildOptionsUserDefAntTaskCount() == 0) {
1905 public void updateBuildOptionsUserDefAntTask(int i
, String id
, String fileName
, String execOrder
){
1906 XmlObject o
= getfpdBuildOpts().getUserDefinedAntTasks();
1910 XmlCursor cursor
= o
.newCursor();
1911 if (cursor
.toFirstChild()) {
1912 for (int j
= 0; j
< i
; ++j
) {
1913 cursor
.toNextSibling();
1915 AntTaskDocument
.AntTask at
= (AntTaskDocument
.AntTask
)cursor
.getObject();
1916 setBuildOptionsUserDefAntTask(id
, fileName
, execOrder
, at
);
1921 public int getBuildOptionsUserDefAntTaskCount() {
1922 UserDefinedAntTasksDocument
.UserDefinedAntTasks udats
= getfpdBuildOpts().getUserDefinedAntTasks();
1923 if (udats
== null || udats
.getAntTaskList() == null) {
1927 return udats
.getAntTaskList().size();
1930 public void getBuildOptionsUserDefAntTasks(String
[][] saa
) {
1931 UserDefinedAntTasksDocument
.UserDefinedAntTasks udats
= getfpdBuildOpts().getUserDefinedAntTasks();
1932 if (udats
== null || udats
.getAntTaskList() == null) {
1936 List
<AntTaskDocument
.AntTask
> l
= udats
.getAntTaskList();
1937 ListIterator li
= l
.listIterator();
1939 while (li
.hasNext()) {
1940 AntTaskDocument
.AntTask at
= (AntTaskDocument
.AntTask
)li
.next();
1941 saa
[i
][0] = at
.getId() + "";
1942 saa
[i
][1] = saa
[i
][2] = "";
1943 if (at
.getFilename() != null){
1944 saa
[i
][1] = at
.getFilename();
1946 if (at
.getAntCmdOptions() != null) {
1947 saa
[i
][2] = at
.getAntCmdOptions();
1952 public void genBuildOptionsOpt(Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
) {
1953 OptionsDocument
.Options opts
= getfpdBuildOpts().getOptions();
1955 opts
= getfpdBuildOpts().addNewOptions();
1957 OptionDocument
.Option opt
= opts
.addNewOption();
1958 setBuildOptionsOpt(buildTargets
, toolChain
, tagName
, toolCmd
, archList
, contents
, opt
);
1961 private void setBuildOptionsOpt(Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
, OptionDocument
.Option opt
){
1962 opt
.setStringValue(contents
);
1964 opt
.setBuildTargets(buildTargets
);
1965 opt
.setToolChainFamily(toolChain
);
1966 opt
.setTagName(tagName
);
1967 opt
.setToolCode(toolCmd
);
1969 if (archList
!= null) {
1970 opt
.setSupArchList(archList
);
1973 if (opt
.isSetSupArchList()) {
1974 opt
.unsetSupArchList();
1979 public void removeBuildOptionsOpt(int i
){
1981 XmlObject o
= getfpdBuildOpts().getOptions();
1986 XmlCursor cursor
= o
.newCursor();
1987 if (cursor
.toFirstChild()) {
1988 for (int j
= 0; j
< i
; ++j
) {
1989 cursor
.toNextSibling();
1992 if (getBuildOptionsOptCount() == 0) {
2000 public void updateBuildOptionsOpt(int i
, Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
) {
2001 XmlObject o
= getfpdBuildOpts().getOptions();
2006 XmlCursor cursor
= o
.newCursor();
2007 if (cursor
.toFirstChild()) {
2008 for (int j
= 0; j
< i
; ++j
) {
2009 cursor
.toNextSibling();
2011 OptionDocument
.Option opt
= (OptionDocument
.Option
)cursor
.getObject();
2012 setBuildOptionsOpt(buildTargets
, toolChain
, tagName
, toolCmd
, archList
, contents
, opt
);
2017 public int getBuildOptionsOptCount(){
2018 if (getfpdBuildOpts().getOptions() == null || getfpdBuildOpts().getOptions().getOptionList() == null) {
2021 return getfpdBuildOpts().getOptions().getOptionList().size();
2024 public void getBuildOptionsOpts(String
[][] saa
) {
2025 if (getfpdBuildOpts().getOptions() == null || getfpdBuildOpts().getOptions().getOptionList() == null) {
2029 List
<OptionDocument
.Option
> lOpt
= getfpdBuildOpts().getOptions().getOptionList();
2030 ListIterator li
= lOpt
.listIterator();
2032 while(li
.hasNext()) {
2033 OptionDocument
.Option opt
= (OptionDocument
.Option
)li
.next();
2034 if (opt
.getBuildTargets() != null) {
2035 saa
[i
][0] = listToString(opt
.getBuildTargets());
2037 saa
[i
][1] = opt
.getToolChainFamily();
2038 if (opt
.getSupArchList() != null){
2039 saa
[i
][2] = listToString(opt
.getSupArchList());
2042 saa
[i
][3] = opt
.getToolCode();
2043 saa
[i
][4] = opt
.getTagName();
2044 saa
[i
][5] = opt
.getStringValue();
2050 public void genBuildOptionsFfs(String ffsKey
, String type
) {
2051 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getfpdBuildOpts().addNewFfs();
2052 ffs
.setFfsKey(ffsKey
);
2054 ffs
.addNewSections().setEncapsulationType(type
);
2058 public void updateBuildOptionsFfsSectionsType(int i
, String type
) {
2059 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getfpdBuildOpts().addNewFfs();
2061 ffs
.addNewSections().setEncapsulationType(type
);
2065 public void genBuildOptionsFfsAttribute(int i
, String name
, String value
) {
2066 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2067 BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute attrib
= ffs
.addNewAttribute();
2068 attrib
.setName(name
);
2069 attrib
.setValue(value
);
2072 /**update jth attribute of ith ffs.
2076 public void updateBuildOptionsFfsAttribute(int i
, int j
, String name
, String value
){
2077 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2078 XmlCursor cursor
= ffs
.newCursor();
2079 QName qAttrib
= new QName(xmlNs
, "Attribute");
2080 if (cursor
.toChild(qAttrib
)) {
2081 for (int k
= 0; k
< j
; ++k
) {
2082 cursor
.toNextSibling(qAttrib
);
2084 BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute attrib
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute
)cursor
.getObject();
2085 attrib
.setName(name
);
2086 attrib
.setValue(value
);
2091 public void removeBuildOptionsFfsAttribute(int i
, int j
){
2092 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2093 XmlCursor cursor
= ffs
.newCursor();
2094 QName qAttrib
= new QName(xmlNs
, "Attribute");
2095 if (cursor
.toChild(qAttrib
)) {
2096 for (int k
= 0; k
< j
; ++k
) {
2097 cursor
.toNextSibling(qAttrib
);
2104 public void genBuildOptionsFfsSectionsSection(int i
, String sectionType
) {
2105 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2109 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2111 if (sections
== null){
2112 sections
= ffs
.addNewSections();
2114 sections
.addNewSection().setSectionType(EfiSectionType
.Enum
.forString(sectionType
));
2117 public void removeBuildOptionsFfsSectionsSection(int i
, int j
) {
2118 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2119 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2120 if (sections
== null) {
2123 XmlCursor cursor
= sections
.newCursor();
2124 QName qSection
= new QName(xmlNs
, "Section");
2125 if (cursor
.toChild(qSection
)) {
2126 for (int k
= 0; k
< j
; ++k
) {
2127 cursor
.toNextSibling(qSection
);
2134 public void updateBuildOptionsFfsSectionsSection(int i
, int j
, String type
){
2135 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2136 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2137 if (sections
== null) {
2140 XmlCursor cursor
= sections
.newCursor();
2141 QName qSection
= new QName(xmlNs
, "Section");
2142 if (cursor
.toChild(qSection
)) {
2143 for (int k
= 0; k
< j
; ++k
) {
2144 cursor
.toNextSibling(qSection
);
2146 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Section section
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Section
)cursor
.getObject();
2147 section
.setSectionType(EfiSectionType
.Enum
.forString(type
));
2152 public void genBuildOptionsFfsSectionsSections(int i
, String encapType
) {
2153 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2157 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2159 if (sections
== null){
2160 sections
= ffs
.addNewSections();
2162 sections
.addNewSections().setEncapsulationType(encapType
);
2165 public void removeBuildOptionsFfsSectionsSections(int i
, int j
) {
2166 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2167 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2168 if (sections
== null) {
2171 XmlCursor cursor
= sections
.newCursor();
2172 QName qSections
= new QName(xmlNs
, "Sections");
2173 if (cursor
.toChild(qSections
)) {
2174 for (int k
= 0; k
< j
; ++k
) {
2175 cursor
.toNextSibling(qSections
);
2182 public void updateBuildOptionsFfsSectionsSections(int i
, int j
, String type
) {
2183 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2184 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2185 if (sections
== null) {
2188 XmlCursor cursor
= sections
.newCursor();
2189 QName qSections
= new QName(xmlNs
, "Sections");
2190 if (cursor
.toChild(qSections
)) {
2191 for (int k
= 0; k
< j
; ++k
) {
2192 cursor
.toNextSibling(qSections
);
2194 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2 sections2
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
)cursor
.getObject();
2195 sections2
.setEncapsulationType(type
);
2200 public void genBuildOptionsFfsSectionsSectionsSection(int i
, int j
, String type
) {
2201 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2205 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2206 XmlCursor cursor
= sections
.newCursor();
2207 QName qSections
= new QName(xmlNs
, "Sections");
2208 if (cursor
.toChild(qSections
)){
2209 for (int k
= 0; k
< j
; ++k
) {
2210 cursor
.toNextSibling(qSections
);
2212 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2 sections2
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
)cursor
.getObject();
2213 sections2
.addNewSection().setSectionType(EfiSectionType
.Enum
.forString(type
));
2218 public void removeBuildOptionsFfsSectionsSectionsSection(int i
, int j
, int k
) {
2219 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2220 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2221 if (sections
== null) {
2224 XmlCursor cursor
= sections
.newCursor();
2225 QName qSections
= new QName(xmlNs
, "Sections");
2226 if (cursor
.toChild(qSections
)) {
2227 for (int l
= 0; l
< j
; ++l
) {
2228 cursor
.toNextSibling(qSections
);
2230 if (cursor
.toFirstChild()) {
2232 for (; m
< k
; ++m
) {
2233 cursor
.toNextSibling();
2245 public void updateBuildOptionsFfsSectionsSectionsSection(int i
, int j
, int k
, String type
) {
2246 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2247 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2248 if (sections
== null) {
2251 XmlCursor cursor
= sections
.newCursor();
2252 QName qSections
= new QName(xmlNs
, "Sections");
2253 if (cursor
.toChild(qSections
)) {
2254 for (int l
= 0; l
< j
; ++l
) {
2255 cursor
.toNextSibling(qSections
);
2257 if (cursor
.toFirstChild()) {
2258 for (int m
= 0; m
< k
; ++m
) {
2259 cursor
.toNextSibling();
2261 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section section
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section
)cursor
.getObject();
2262 section
.setSectionType(EfiSectionType
.Enum
.forString(type
));
2268 public void getBuildOptionsFfsSectionsSectionsSection(int i
, int j
, ArrayList
<String
> al
) {
2269 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2273 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
2274 XmlCursor cursor
= sections
.newCursor();
2275 QName qSections
= new QName(xmlNs
, "Sections");
2276 if (cursor
.toChild(qSections
)){
2277 for (int k
= 0; k
< j
; ++k
) {
2278 cursor
.toNextSibling(qSections
);
2280 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2 sections2
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
)cursor
.getObject();
2281 if (sections2
.getSectionList() == null){
2285 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section
> li
= sections2
.getSectionList().listIterator();
2286 while(li
.hasNext()) {
2287 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section section
= li
.next();
2288 if (section
.isSetSectionType()) {
2289 al
.add(section
.getSectionType().toString());
2298 public int getBuildOptionsFfsCount(){
2299 if (getfpdBuildOpts().getFfsList() == null) {
2302 return getfpdBuildOpts().getFfsList().size();
2305 public void getBuildOptionsFfsKey(String
[][] saa
) {
2306 if (getfpdBuildOpts().getFfsList() == null) {
2309 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
> li
= getfpdBuildOpts().getFfsList().listIterator();
2311 while(li
.hasNext()){
2312 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= li
.next();
2313 saa
[i
][0] = ffs
.getFfsKey();
2318 public void updateBuildOptionsFfsKey(int i
, String key
) {
2319 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2323 /**Get ith FFS key and contents.
2326 public void getBuildOptionsFfs(int i
, String
[] sa
, LinkedHashMap
<String
, String
> ffsAttribMap
, ArrayList
<String
> firstLevelSections
, ArrayList
<String
> firstLevelSection
) {
2327 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2331 sa
[0] = ffs
.getFfsKey();
2332 if (ffs
.getSections() != null) {
2333 if(ffs
.getSections().getEncapsulationType() != null){
2334 sa
[1] = ffs
.getSections().getEncapsulationType();
2336 if (ffs
.getSections().getSectionList() != null){
2337 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Section
> li
= ffs
.getSections().getSectionList().listIterator();
2338 while (li
.hasNext()) {
2339 firstLevelSection
.add(li
.next().getSectionType().toString());
2342 if (ffs
.getSections().getSectionsList() != null) {
2343 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
> li
= ffs
.getSections().getSectionsList().listIterator();
2344 while(li
.hasNext()) {
2345 firstLevelSections
.add(li
.next().getEncapsulationType());
2349 if (ffs
.getAttributeList() != null) {
2350 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute
> li
= ffs
.getAttributeList().listIterator();
2351 while(li
.hasNext()) {
2352 BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute attrib
= li
.next();
2353 ffsAttribMap
.put(attrib
.getName(), attrib
.getValue());
2362 private BuildOptionsDocument
.BuildOptions
.Ffs
getFfs(int i
) {
2363 XmlObject o
= getfpdBuildOpts();
2364 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= null;
2366 XmlCursor cursor
= o
.newCursor();
2367 QName qFfs
= new QName(xmlNs
, "Ffs");
2368 if (cursor
.toChild(qFfs
)) {
2369 for (int j
= 0; j
< i
; ++j
) {
2370 cursor
.toNextSibling(qFfs
);
2372 ffs
= (BuildOptionsDocument
.BuildOptions
.Ffs
)cursor
.getObject();
2378 public void removeBuildOptionsFfs(int i
) {
2379 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
2384 XmlCursor cursor
= ffs
.newCursor();
2391 public PlatformDefinitionsDocument
.PlatformDefinitions
getfpdPlatformDefs(){
2392 if (fpdPlatformDefs
== null){
2393 fpdPlatformDefs
= fpdRoot
.addNewPlatformDefinitions();
2395 return fpdPlatformDefs
;
2398 public void getPlatformDefsSupportedArchs(Vector
<Object
> archs
){
2399 if (getfpdPlatformDefs().getSupportedArchitectures() == null) {
2402 ListIterator li
= getfpdPlatformDefs().getSupportedArchitectures().listIterator();
2403 while(li
.hasNext()) {
2404 archs
.add(li
.next());
2408 public void setPlatformDefsSupportedArchs(Vector
<Object
> archs
) {
2409 if (archs
!= null) {
2410 getfpdPlatformDefs().setSupportedArchitectures(archs
);
2413 // XmlCursor cursor = getfpdPlatformDefs().newCursor();
2414 // if (cursor.toChild(xmlNs, "SupportedArchitectures")) {
2415 // cursor.removeXml();
2417 // cursor.dispose();
2421 public void getPlatformDefsBuildTargets(Vector
<Object
> targets
) {
2422 if (getfpdPlatformDefs().getBuildTargets() == null) {
2425 ListIterator li
= getfpdPlatformDefs().getBuildTargets().listIterator();
2426 while(li
.hasNext()) {
2427 targets
.add(li
.next());
2431 public void setPlatformDefsBuildTargets(Vector
<Object
> targets
) {
2432 getfpdPlatformDefs().setBuildTargets(targets
);
2435 public void genPlatformDefsSkuInfo(String id
, String name
) {
2436 SkuInfoDocument
.SkuInfo skuInfo
= null;
2437 if (getfpdPlatformDefs().getSkuInfo() == null) {
2438 skuInfo
= getfpdPlatformDefs().addNewSkuInfo();
2440 skuInfo
= getfpdPlatformDefs().getSkuInfo();
2441 if (skuInfo
.getUiSkuNameList() == null || skuInfo
.getUiSkuNameList().size() == 0) {
2442 SkuInfoDocument
.SkuInfo
.UiSkuName skuName
= skuInfo
.addNewUiSkuName();
2443 skuName
.setSkuID(new BigInteger("0"));
2444 skuName
.setStringValue("DEFAULT");
2446 if (id
.equals("0")) {
2449 SkuInfoDocument
.SkuInfo
.UiSkuName skuName
= skuInfo
.addNewUiSkuName();
2450 skuName
.setSkuID(new BigInteger(id
));
2451 skuName
.setStringValue(name
);
2454 public int getPlatformDefsSkuInfoCount(){
2455 if (getfpdPlatformDefs().getSkuInfo() == null || getfpdPlatformDefs().getSkuInfo().getUiSkuNameList() == null) {
2458 return getfpdPlatformDefs().getSkuInfo().getUiSkuNameList().size();
2461 public void getPlatformDefsSkuInfos(String
[][] saa
){
2462 if (getfpdPlatformDefs().getSkuInfo() == null || getfpdPlatformDefs().getSkuInfo().getUiSkuNameList() == null) {
2463 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null) {
2464 removeElement(getfpdDynPcdBuildDefs());
2465 fpdDynPcdBuildDefs
= null;
2470 List
<SkuInfoDocument
.SkuInfo
.UiSkuName
> l
= getfpdPlatformDefs().getSkuInfo().getUiSkuNameList();
2471 ListIterator
<SkuInfoDocument
.SkuInfo
.UiSkuName
> li
= l
.listIterator();
2473 while(li
.hasNext()) {
2474 SkuInfoDocument
.SkuInfo
.UiSkuName sku
= li
.next();
2475 saa
[i
][0] = sku
.getSkuID()+"";
2476 saa
[i
][1] = sku
.getStringValue();
2481 public void removePlatformDefsSkuInfo(int i
) {
2482 SkuInfoDocument
.SkuInfo skuInfo
= getfpdPlatformDefs().getSkuInfo();
2483 if (skuInfo
== null || i
== 0) {
2487 XmlCursor cursor
= skuInfo
.newCursor();
2488 if (cursor
.toFirstChild()) {
2489 for (int j
= 0; j
< i
; ++j
) {
2490 cursor
.toNextSibling();
2497 public void updatePlatformDefsSkuInfo(int i
, String id
, String name
) {
2498 SkuInfoDocument
.SkuInfo skuInfo
= getfpdPlatformDefs().getSkuInfo();
2499 if (skuInfo
== null || i
== 0) {
2503 XmlCursor cursor
= skuInfo
.newCursor();
2504 if (cursor
.toFirstChild()) {
2505 for (int j
= 0; j
< i
; ++j
) {
2506 cursor
.toNextSibling();
2508 SkuInfoDocument
.SkuInfo
.UiSkuName sku
= (SkuInfoDocument
.SkuInfo
.UiSkuName
)cursor
.getObject();
2509 sku
.setSkuID(new BigInteger(id
));
2510 sku
.setStringValue(name
);
2515 public String
getPlatformDefsInterDir(){
2516 if (getfpdPlatformDefs().getIntermediateDirectories() == null) {
2519 return getfpdPlatformDefs().getIntermediateDirectories().toString();
2522 public void setPlatformDefsInterDir(String interDir
){
2523 getfpdPlatformDefs().setIntermediateDirectories(IntermediateOutputType
.Enum
.forString(interDir
));
2526 public String
getPlatformDefsOutputDir() {
2527 return getfpdPlatformDefs().getOutputDirectory();
2530 public void setPlatformDefsOutputDir(String outputDir
) {
2531 if (outputDir
!= null && outputDir
.length() > 0) {
2532 getfpdPlatformDefs().setOutputDirectory(outputDir
);
2535 XmlCursor cursor
= getfpdPlatformDefs().newCursor();
2536 if (cursor
.toChild(new QName(xmlNs
, "OutputDirectory"))) {
2543 public FlashDocument
.Flash
getfpdFlash() {
2544 if (fpdFlash
== null) {
2545 fpdFlash
= fpdRoot
.addNewFlash();
2550 public void genFlashDefinitionFile(String file
) {
2551 FlashDefinitionFileDocument
.FlashDefinitionFile fdf
= getfpdFlash().getFlashDefinitionFile();
2553 fdf
= getfpdFlash().addNewFlashDefinitionFile();
2556 fdf
.setStringValue(file
);
2559 public String
getFlashDefinitionFile() {
2560 FlashDefinitionFileDocument
.FlashDefinitionFile fdf
= getfpdFlash().getFlashDefinitionFile();
2565 return fdf
.getStringValue();
2568 public void genFvImagesNameValue(String name
, String value
) {
2570 FvImagesDocument
.FvImages fi
= getfpdFlash().getFvImages();
2572 fi
= getfpdFlash().addNewFvImages();
2575 FvImagesDocument
.FvImages
.NameValue nv
= fi
.addNewNameValue();
2580 public void removeFvImagesNameValue(int i
){
2582 XmlObject o
= getfpdFlash().getFvImages();
2587 QName qNameValue
= new QName(xmlNs
, "NameValue");
2588 XmlCursor cursor
= o
.newCursor();
2589 if (cursor
.toChild(qNameValue
)) {
2590 for (int j
= 0; j
< i
; ++j
) {
2591 cursor
.toNextSibling(qNameValue
);
2598 public void updateFvImagesNameValue(int i
, String name
, String value
){
2600 XmlObject o
= getfpdFlash().getFvImages();
2605 QName qNameValue
= new QName(xmlNs
, "NameValue");
2606 XmlCursor cursor
= o
.newCursor();
2607 if (cursor
.toChild(qNameValue
)) {
2608 for (int j
= 0; j
< i
; ++j
) {
2609 cursor
.toNextSibling(qNameValue
);
2611 FvImagesDocument
.FvImages
.NameValue nv
= (FvImagesDocument
.FvImages
.NameValue
)cursor
.getObject();
2618 public int getFvImagesNameValueCount() {
2620 FvImagesDocument
.FvImages fi
= null;
2621 if ((fi
= getfpdFlash().getFvImages()) == null || fi
.getNameValueList() == null) {
2624 return fi
.getNameValueList().size();
2627 public void getFvImagesNameValues(String
[][] nv
) {
2629 FvImagesDocument
.FvImages fi
= getfpdFlash().getFvImages();
2633 List
<FvImagesDocument
.FvImages
.NameValue
> l
= fi
.getNameValueList();
2635 ListIterator li
= l
.listIterator();
2636 while (li
.hasNext()) {
2637 FvImagesDocument
.FvImages
.NameValue e
= (FvImagesDocument
.FvImages
.NameValue
) li
2639 nv
[i
][0] = e
.getName();
2640 nv
[i
][1] = e
.getValue();
2646 public void getFvImagesFvImageFvImageNames (Vector
<String
> vImageNames
) {
2647 FvImagesDocument
.FvImages fis
= getfpdFlash().getFvImages();
2648 if (fis
== null || fis
.getFvImageList() == null) {
2652 ListIterator
<FvImagesDocument
.FvImages
.FvImage
> li
= fis
.getFvImageList().listIterator();
2653 while (li
.hasNext()) {
2654 FvImagesDocument
.FvImages
.FvImage fi
= li
.next();
2655 if (fi
.getType().toString().equals("ImageName")) {
2656 vImageNames
.addAll(fi
.getFvImageNamesList());
2662 public void addFvImageFvImageNames (String
[] fvNames
) {
2663 FvImagesDocument
.FvImages fis
= getfpdFlash().getFvImages();
2664 if (fis
== null || fis
.getFvImageList() == null) {
2665 genFvImagesFvImage (fvNames
, "ImageName", null);
2669 ListIterator
<FvImagesDocument
.FvImages
.FvImage
> li
= fis
.getFvImageList().listIterator();
2670 while (li
.hasNext()) {
2671 FvImagesDocument
.FvImages
.FvImage fi
= li
.next();
2672 if (fi
.getType().toString().equals("ImageName")) {
2673 addFvImageNamesInFvImage (fi
, fvNames
);
2677 genFvImagesFvImage (fvNames
, "ImageName", null);
2680 public void addFvImageNamesInFvImage (FvImagesDocument
.FvImages
.FvImage fi
, String
[] fvNames
) {
2682 for (int i
= 0; i
< fvNames
.length
; ++i
) {
2683 fi
.addFvImageNames(fvNames
[i
]);
2687 public void addFvImageNamesInFvImage (int i
, String
[] fvNames
) {
2688 XmlObject o
= getfpdFlash().getFvImages();
2692 XmlCursor cursor
= o
.newCursor();
2693 QName qFvImage
= new QName(xmlNs
, "FvImage");
2694 if (cursor
.toChild(qFvImage
)) {
2695 for (int j
= 0; j
< i
; ++j
) {
2696 cursor
.toNextSibling(qFvImage
);
2698 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
2699 addFvImageNamesInFvImage(fi
, fvNames
);
2704 public void genFvImagesFvImage(String
[] names
, String types
, Map
<String
, String
> options
) {
2706 FvImagesDocument
.FvImages fis
= null;
2707 if ((fis
= getfpdFlash().getFvImages()) == null) {
2708 fis
= getfpdFlash().addNewFvImages();
2712 //gen FvImage with FvImageNames array
2714 FvImagesDocument
.FvImages
.FvImage fi
= fis
.addNewFvImage();
2715 for (int i
= 0; i
< names
.length
; ++i
) {
2716 fi
.addFvImageNames(names
[i
]);
2718 fi
.setType(FvImageTypes
.Enum
.forString(types
));
2719 if (options
!= null){
2720 setFvImagesFvImageFvImageOptions(options
, fi
);
2724 private void setFvImagesFvImageFvImageOptions(Map
<String
, String
> options
, FvImagesDocument
.FvImages
.FvImage fi
){
2725 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions fio
= fi
.getFvImageOptions();
2727 fio
= fi
.addNewFvImageOptions();
2730 Set
<String
> key
= options
.keySet();
2731 Iterator
<String
> i
= key
.iterator();
2732 while (i
.hasNext()) {
2734 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nv
= fio
.addNewNameValue();
2735 String k
= (String
)i
.next();
2738 nv
.setValue((String
)options
.get(k
));
2745 public void removeFvImagesFvImage(int i
) {
2747 XmlObject o
= getfpdFlash().getFvImages();
2752 QName qFvImage
= new QName(xmlNs
, "FvImage");
2753 XmlCursor cursor
= o
.newCursor();
2754 if (cursor
.toChild(qFvImage
)) {
2755 for (int j
= 0; j
< i
; ++j
) {
2756 cursor
.toNextSibling(qFvImage
);
2765 * @param newFvName The New FV Name. If null, remove the old FvImageNames entry.
2767 public void updateFvImageNameAll (String oldFvName
, String newFvName
) {
2768 if (getfpdFlash().getFvImages() == null || getfpdFlash().getFvImages().getFvImageList() == null) {
2771 ListIterator
<FvImagesDocument
.FvImages
.FvImage
> li
= getfpdFlash().getFvImages().getFvImageList().listIterator();
2772 while (li
.hasNext()) {
2773 FvImagesDocument
.FvImages
.FvImage fi
= li
.next();
2774 updateFvImageNamesInFvImage (fi
, oldFvName
, newFvName
);
2775 if (fi
.getFvImageNamesList().size() == 0) {
2781 public void updateFvImageNamesInFvImage (int i
, String oldFvName
, String newFvName
) {
2782 XmlObject o
= getfpdFlash().getFvImages();
2786 XmlCursor cursor
= o
.newCursor();
2787 QName qFvImage
= new QName(xmlNs
, "FvImage");
2788 if (cursor
.toChild(qFvImage
)) {
2789 for (int j
= 0; j
< i
; ++j
) {
2790 cursor
.toNextSibling(qFvImage
);
2792 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
2793 updateFvImageNamesInFvImage (fi
, oldFvName
, newFvName
);
2799 * @param oldFvName The FV Name to be replaced.
2800 * @param newFvName The New FV Name. If null, remove the old FvImageNames entry.
2802 public void updateFvImageNamesInFvImage (FvImagesDocument
.FvImages
.FvImage fi
, String oldFvName
, String newFvName
) {
2803 QName qFvImageNames
= new QName(xmlNs
, "FvImageNames");
2804 XmlCursor cursor
= fi
.newCursor();
2806 if (cursor
.toChild(qFvImageNames
)) {
2808 String xmlValue
= cursor
.getTextValue();
2809 if (xmlValue
.equals(oldFvName
)){
2810 if (newFvName
!= null) {
2811 cursor
.setTextValue(newFvName
);
2817 }while (cursor
.toNextSibling(qFvImageNames
));
2823 /**update the Type attribute of ith FvImage with new type.
2827 public void updateFvImagesFvImageType (int i
, String type
) {
2828 XmlObject o
= getfpdFlash().getFvImages();
2832 XmlCursor cursor
= o
.newCursor();
2833 QName qFvImage
= new QName(xmlNs
, "FvImage");
2834 if (cursor
.toChild(qFvImage
)) {
2835 for (int j
= 0; j
< i
; ++j
) {
2836 cursor
.toNextSibling(qFvImage
);
2838 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
2839 fi
.setType(FvImageTypes
.Enum
.forString(type
));
2844 public void updateFvImagesFvImage(int i
, String
[] names
, String types
, Map
<String
, String
> options
){
2846 XmlObject o
= getfpdFlash().getFvImages();
2850 XmlCursor cursor
= o
.newCursor();
2851 QName qFvImage
= new QName(xmlNs
, "FvImage");
2852 if (cursor
.toChild(qFvImage
)) {
2853 for (int j
= 0; j
< i
; ++j
) {
2854 cursor
.toNextSibling(qFvImage
);
2856 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
2857 fi
.setType(FvImageTypes
.Enum
.forString(types
));
2860 // remove old FvImageNames before adding new ones
2862 QName qFvImageNames
= new QName(xmlNs
, "FvImageNames");
2863 cursor
.toChild(qFvImageNames
);
2865 while (cursor
.toNextSibling(qFvImageNames
)) {
2869 for (int k
= 0; k
< names
.length
; ++k
) {
2870 fi
.addFvImageNames(names
[k
]);
2873 // remove old FvImageOptions before adding new options
2875 QName qFvImageOptions
= new QName(xmlNs
, "FvImageOptions");
2876 cursor
.toNextSibling(qFvImageOptions
);
2879 setFvImagesFvImageFvImageOptions(options
, fi
);
2884 public int getFvImagesFvImageCount(String type
) {
2886 if (getfpdFlash().getFvImages() == null || getfpdFlash().getFvImages().getFvImageList() == null) {
2889 List
<FvImagesDocument
.FvImages
.FvImage
> l
= getfpdFlash().getFvImages().getFvImageList();
2890 ListIterator li
= l
.listIterator();
2892 while(li
.hasNext()) {
2893 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)li
.next();
2894 if (!fi
.getType().toString().equals(type
) && !type
.equals("ALL")) {
2904 public Vector
<FvImagesDocument
.FvImages
.FvImage
> getFvImagesFvImageWithName (String fvName
, String type
) {
2905 Vector
<FvImagesDocument
.FvImages
.FvImage
> vFvImage
= new Vector
<FvImagesDocument
.FvImages
.FvImage
>();
2906 if (getfpdFlash().getFvImages() == null || getfpdFlash().getFvImages().getFvImageList() == null) {
2909 List
<FvImagesDocument
.FvImages
.FvImage
> l
= getfpdFlash().getFvImages().getFvImageList();
2910 ListIterator li
= l
.listIterator();
2911 while(li
.hasNext()) {
2912 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)li
.next();
2913 if (!fi
.getType().toString().equals(type
) && !type
.equals("ALL")) {
2916 if (fi
.getFvImageNamesList().contains(fvName
)) {
2925 * @param type "ALL" means all FvImage types: ImageName, Options, Attributes, Components.
2927 public void getFvImagesFvImages(String
[][] saa
, String type
) {
2929 if (getfpdFlash().getFvImages() == null) {
2932 List
<FvImagesDocument
.FvImages
.FvImage
> l
= getfpdFlash().getFvImages().getFvImageList();
2936 ListIterator li
= l
.listIterator();
2938 while(li
.hasNext()) {
2939 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)li
.next();
2940 if (!fi
.getType().toString().equals(type
) && !type
.equals("ALL")) {
2944 // get FvImageNames array, space separated
2946 List
<String
> lfn
= fi
.getFvImageNamesList();
2947 ListIterator lfni
= lfn
.listIterator();
2949 while (lfni
.hasNext()) {
2950 saa
[i
][0] += (String
)lfni
.next();
2953 saa
[i
][0] = saa
[i
][0].trim();
2955 saa
[i
][1] = fi
.getType()+"";
2961 public void removeFvImageNameValue (int i
, String attributeName
) {
2962 XmlObject o
= getfpdFlash().getFvImages();
2966 XmlCursor cursor
= o
.newCursor();
2967 QName qFvImage
= new QName(xmlNs
, "FvImage");
2968 if (cursor
.toChild(qFvImage
)) {
2969 for (int j
= 0; j
< i
; ++j
) {
2970 cursor
.toNextSibling(qFvImage
);
2972 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
2973 removeFvImageNameValue (fi
, attributeName
);
2977 /**Remove from fi the attribute pair with attributeName in FvImageOptions.
2979 * @param attributeName
2981 public void removeFvImageNameValue (FvImagesDocument
.FvImages
.FvImage fi
, String attributeName
) {
2982 if (fi
.getFvImageOptions() != null && fi
.getFvImageOptions().getNameValueList() != null) {
2983 ListIterator
<FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
> li
= fi
.getFvImageOptions().getNameValueList().listIterator();
2984 while (li
.hasNext()) {
2985 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nv
= li
.next();
2986 if (nv
.getName().equals(attributeName
)) {
2993 public void removeTypedNamedFvImageNameValue (String fvName
, String type
, String optName
) {
2994 Vector
<FvImagesDocument
.FvImages
.FvImage
> vFvImage
= getFvImagesFvImageWithName(fvName
, type
);
2995 for (int i
= 0; i
< vFvImage
.size(); ++i
) {
2996 FvImagesDocument
.FvImages
.FvImage fi
= vFvImage
.get(i
);
2997 removeFvImageNameValue (fi
, optName
);
3001 /**Add name-value pair to FvImage element with type.
3002 * @param fvName FV name to add name-value pair.
3003 * @param type FvImage attribute.
3007 public void setTypedNamedFvImageNameValue (String fvName
, String type
, String name
, String value
) {
3008 boolean fvImageExists
= false;
3009 if (getfpdFlash().getFvImages() == null) {
3012 List
<FvImagesDocument
.FvImages
.FvImage
> l
= getfpdFlash().getFvImages().getFvImageList();
3016 ListIterator li
= l
.listIterator();
3017 while(li
.hasNext()) {
3018 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)li
.next();
3019 if (!fi
.getType().toString().equals(type
) && !type
.equals("ALL")) {
3022 if (!fi
.getFvImageNamesList().contains(fvName
)) {
3025 fvImageExists
= true;
3026 setFvImagesFvImageNameValue (fi
, name
, value
, null);
3029 if (!fvImageExists
) {
3030 HashMap
<String
, String
> map
= new HashMap
<String
, String
>();
3031 map
.put(name
, value
);
3032 genFvImagesFvImage(new String
[]{fvName
}, type
, map
);
3036 /**Add to all FvImage elements with type, the name-value pair.
3041 public void setTypedFvImageNameValue (String type
, String name
, String value
) {
3042 if (getfpdFlash().getFvImages() == null) {
3045 List
<FvImagesDocument
.FvImages
.FvImage
> l
= getfpdFlash().getFvImages().getFvImageList();
3049 ListIterator li
= l
.listIterator();
3050 while(li
.hasNext()) {
3051 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)li
.next();
3052 if (!fi
.getType().toString().equals(type
) && !type
.equals("ALL")) {
3055 setFvImagesFvImageNameValue (fi
, name
, value
, null);
3060 public void setFvImagesFvImageNameValue (int i
, String name
, String value
) {
3061 XmlObject o
= getfpdFlash().getFvImages();
3065 XmlCursor cursor
= o
.newCursor();
3066 QName qFvImage
= new QName(xmlNs
, "FvImage");
3067 if (cursor
.toChild(qFvImage
)) {
3068 for (int j
= 0; j
< i
; ++j
) {
3069 cursor
.toNextSibling(qFvImage
);
3071 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
3072 setFvImagesFvImageNameValue (fi
, name
, value
, null);
3077 /**Add to FvImage the name-value pair, or replace old name with newName, or generate new name-value pair if not exists before.
3083 public void setFvImagesFvImageNameValue (FvImagesDocument
.FvImages
.FvImage fi
, String name
, String value
, String newName
) {
3084 if (fi
.getFvImageOptions() == null || fi
.getFvImageOptions().getNameValueList() == null) {
3085 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nv
= fi
.addNewFvImageOptions().addNewNameValue();
3088 if (newName
!= null) {
3089 nv
.setName(newName
);
3094 XmlCursor cursor
= fi
.getFvImageOptions().newCursor();
3095 if (cursor
.toFirstChild()) {
3097 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nv
= (FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
)cursor
.getObject();
3098 if (nv
.getName().equals(name
)) {
3100 if (newName
!= null) {
3101 nv
.setName(newName
);
3106 }while (cursor
.toNextSibling());
3109 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nv
= fi
.getFvImageOptions().addNewNameValue();
3112 if (newName
!= null) {
3113 nv
.setName(newName
);
3118 public void getFvImagesFvImageOptions (String fvName
, Map
<String
, String
> m
) {
3119 Vector
<FvImagesDocument
.FvImages
.FvImage
> vFvImage
= getFvImagesFvImageWithName (fvName
, "Options");
3120 for (int i
= 0; i
< vFvImage
.size(); ++i
) {
3121 FvImagesDocument
.FvImages
.FvImage fi
= vFvImage
.get(i
);
3122 if (fi
== null || fi
.getFvImageOptions() == null || fi
.getFvImageOptions().getNameValueList() == null) {
3126 ListIterator
<FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
> li
= fi
.getFvImageOptions()
3129 while (li
.hasNext()) {
3130 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nv
= li
.next();
3131 m
.put(nv
.getName(), nv
.getValue());
3136 public int getFvImagePosInFvImages (String fvNameList
, String type
) {
3137 XmlObject o
= getfpdFlash().getFvImages();
3143 String
[] fvNameArray
= fvNameList
.trim().split(" ");
3144 Vector
<String
> vFvNames
= new Vector
<String
>();
3147 XmlCursor cursor
= o
.newCursor();
3148 QName qFvImage
= new QName(xmlNs
, "FvImage");
3149 if (cursor
.toChild(qFvImage
)) {
3152 vFvNames
.removeAllElements();
3153 for (int i
= 0; i
< fvNameArray
.length
; ++i
) {
3154 vFvNames
.add(fvNameArray
[i
]);
3156 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
3157 if (!fi
.getType().toString().equals(type
)) {
3160 if (fi
.getFvImageNamesList() == null || fi
.getFvImageNamesList().size() != vFvNames
.size()) {
3163 ListIterator
<String
> li
= fi
.getFvImageNamesList().listIterator();
3164 while (li
.hasNext()) {
3165 String name
= li
.next();
3166 vFvNames
.remove(name
);
3168 if (vFvNames
.size() == 0) {
3173 }while (cursor
.toNextSibling(qFvImage
));
3179 /**Get FvImage Options for FvImage i
3180 * @param i the ith FvImage
3182 public void getFvImagesFvImageOptions(int i
, Map
<String
, String
> m
) {
3183 XmlObject o
= getfpdFlash().getFvImages();
3187 XmlCursor cursor
= o
.newCursor();
3188 QName qFvImage
= new QName(xmlNs
, "FvImage");
3189 if (cursor
.toChild(qFvImage
)) {
3190 for (int j
= 0; j
< i
; ++j
) {
3191 cursor
.toNextSibling(qFvImage
);
3193 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
3194 if (fi
.getFvImageOptions() == null || fi
.getFvImageOptions().getNameValueList() == null){
3198 ListIterator
<FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
> li
= fi
.getFvImageOptions().getNameValueList().listIterator();
3199 while(li
.hasNext()){
3200 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nv
= li
.next();
3201 m
.put(nv
.getName(), nv
.getValue());
3208 Get platform header element
3209 @return PlatformHeaderDocument.PlatformHeader
3211 public PlatformHeaderDocument
.PlatformHeader
getFpdHdr() {
3212 if (fpdHdr
== null) {
3213 fpdHdr
= fpdRoot
.addNewPlatformHeader();
3219 public String
getFpdHdrPlatformName() {
3220 return getFpdHdr().getPlatformName();
3223 public String
getFpdHdrGuidValue() {
3224 return getFpdHdr().getGuidValue();
3227 public String
getFpdHdrVer() {
3228 return getFpdHdr().getVersion();
3231 public String
getFpdHdrAbs() {
3232 return getFpdHdr().getAbstract();
3235 public String
getFpdHdrDescription() {
3236 return getFpdHdr().getDescription();
3239 public String
getFpdHdrCopyright() {
3240 return getFpdHdr().getCopyright();
3243 public String
getFpdHdrLicense() {
3244 LicenseDocument
.License l
= getFpdHdr().getLicense();
3248 return l
.getStringValue();
3251 public String
getFpdHdrUrl() {
3252 LicenseDocument
.License l
= getFpdHdr().getLicense();
3259 public String
getFpdHdrSpec() {
3261 return "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052";
3262 // return getFpdHdr().getSpecification();
3265 public void setFpdHdrPlatformName(String name
){
3266 getFpdHdr().setPlatformName(name
);
3269 public void setFpdHdrGuidValue(String guid
){
3270 getFpdHdr().setGuidValue(guid
);
3273 public void setFpdHdrVer(String v
){
3274 getFpdHdr().setVersion(v
);
3277 public void setFpdHdrAbs(String abs
) {
3278 getFpdHdr().setAbstract(abs
);
3281 public void setFpdHdrDescription(String desc
){
3282 getFpdHdr().setDescription(desc
);
3285 public void setFpdHdrCopyright(String cr
) {
3286 getFpdHdr().setCopyright(cr
);
3289 public void setFpdHdrLicense(String license
){
3290 LicenseDocument
.License l
= getFpdHdr().getLicense();
3292 getFpdHdr().addNewLicense().setStringValue(license
);
3295 l
.setStringValue(license
);
3299 public void setFpdHdrUrl(String url
){
3300 LicenseDocument
.License l
= getFpdHdr().getLicense();
3306 public void setFpdHdrSpec(String s
){
3307 s
= "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052";
3308 getFpdHdr().setSpecification(s
);
3311 Save the processed xml contents to file
3313 @param fpdFile The file to save xml contents
3314 @throws IOException Exceptions during file operation
3316 public void saveAs(File fpdFile
) throws IOException
{
3318 XmlOptions options
= new XmlOptions();
3320 options
.setCharacterEncoding("UTF-8");
3321 options
.setSavePrettyPrint();
3322 options
.setSavePrettyPrintIndent(2);
3324 fpdd
.save(fpdFile
, options
);
3325 } catch (IOException e
) {
3326 e
.printStackTrace();
3331 private String
listToString(List l
) {
3336 ListIterator li
= l
.listIterator();
3337 while(li
.hasNext()) {
3344 private void removeElement(XmlObject o
) {
3345 XmlCursor cursor
= o
.newCursor();
3351 class PcdItemTypeConflictException
extends Exception
{
3356 private static final long serialVersionUID
= 1L;
3357 private String details
= null;
3359 PcdItemTypeConflictException(String pcdName
, String info
){
3360 ModuleIdentification mi
= WorkspaceProfile
.getModuleId(info
);
3361 details
= pcdName
+ " ItemType Conflicts with " + mi
.getName() + " in Pkg " + mi
.getPackageId().getName();
3364 public String
getMessage() {
3369 class PcdDeclNotFound
extends Exception
{
3374 private static final long serialVersionUID
= 1L;
3375 private String details
= null;
3377 PcdDeclNotFound(String info
) {
3378 details
= "PcdDeclNotFound: " + info
;
3381 public String
getMessage() {
3386 class PcdValueMalFormed
extends Exception
{
3391 private static final long serialVersionUID
= 1L;
3392 private String details
= null;
3394 PcdValueMalFormed(String info
) {
3395 details
= "PcdValueMalFormed: " + info
;
3398 public String
getMessage() {