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
.frameworkwizard
.platform
.ui
.global
.GlobalData
;
61 import org
.tianocore
.frameworkwizard
.platform
.ui
.global
.SurfaceAreaQuery
;
62 import org
.tianocore
.frameworkwizard
.platform
.ui
.id
.ModuleIdentification
;
63 import org
.tianocore
.frameworkwizard
.platform
.ui
.id
.PackageIdentification
;
66 This class processes fpd file contents such as add remove xml elements.
67 @since PackageEditor 1.0
69 public class FpdFileContents
{
71 static final String xmlNs
= "http://www.TianoCore.org/2006/Edk2.0";
73 private PlatformSurfaceAreaDocument fpdd
= null;
75 private PlatformSurfaceAreaDocument
.PlatformSurfaceArea fpdRoot
= null;
77 private PlatformHeaderDocument
.PlatformHeader fpdHdr
= null;
79 private PlatformDefinitionsDocument
.PlatformDefinitions fpdPlatformDefs
= null;
81 private FlashDocument
.Flash fpdFlash
= null;
83 private BuildOptionsDocument
.BuildOptions fpdBuildOpts
= null;
85 private FrameworkModulesDocument
.FrameworkModules fpdFrameworkModules
= null;
87 private DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions fpdDynPcdBuildDefs
= null;
89 private HashMap
<String
, ArrayList
<String
>> dynPcdMap
= null;
92 * look through all pcd data in all ModuleSA, create pcd -> ModuleSA mappings.
94 public void initDynPcdMap() {
95 if (dynPcdMap
== null) {
96 dynPcdMap
= new HashMap
<String
, ArrayList
<String
>>();
97 List
<ModuleSADocument
.ModuleSA
> l
= getfpdFrameworkModules().getModuleSAList();
101 ListIterator
<ModuleSADocument
.ModuleSA
> li
= l
.listIterator();
102 while (li
.hasNext()) {
103 ModuleSADocument
.ModuleSA msa
= li
.next();
104 if (msa
.getPcdBuildDefinition() == null || msa
.getPcdBuildDefinition().getPcdDataList() == null) {
107 String ModuleInfo
= msa
.getModuleGuid() + " " + msa
.getModuleVersion() +
108 " " + msa
.getPackageGuid() + " " + msa
.getPackageVersion() + " " + listToString(msa
.getSupArchList());
109 List
<PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
> lp
= msa
.getPcdBuildDefinition().getPcdDataList();
110 ListIterator
<PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
> lpi
= lp
.listIterator();
111 while (lpi
.hasNext()) {
112 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= lpi
.next();
113 String pcdKey
= pcdData
.getCName() + " " + pcdData
.getTokenSpaceGuidCName();
114 if (dynPcdMap
.get(pcdKey
) == null) {
115 ArrayList
<String
> al
= new ArrayList
<String
>();
116 al
.add(ModuleInfo
+ " " + pcdData
.getItemType().toString());
117 dynPcdMap
.put(pcdKey
, al
);
120 dynPcdMap
.get(pcdKey
).add(ModuleInfo
+ " " + pcdData
.getItemType().toString());
127 public ArrayList
<String
> getDynPcdMapValue(String key
) {
128 return dynPcdMap
.get(key
);
131 Constructor to create a new spd file
133 public FpdFileContents() {
135 fpdd
= PlatformSurfaceAreaDocument
.Factory
.newInstance();
136 fpdRoot
= fpdd
.addNewPlatformSurfaceArea();
141 Constructor for existing document object
144 public FpdFileContents(PlatformSurfaceAreaDocument
.PlatformSurfaceArea fpd
) {
146 fpdHdr
= fpdRoot
.getPlatformHeader();
147 fpdPlatformDefs
= fpdRoot
.getPlatformDefinitions();
148 fpdBuildOpts
= fpdRoot
.getBuildOptions();
149 fpdFrameworkModules
= fpdRoot
.getFrameworkModules();
150 fpdDynPcdBuildDefs
= fpdRoot
.getDynamicPcdBuildDefinitions();
151 fpdFlash
= fpdRoot
.getFlash();
155 Constructor based on an existing spd file
157 @param f Existing spd file
159 public FpdFileContents(File f
) {
161 fpdd
= PlatformSurfaceAreaDocument
.Factory
.parse(f
);
162 fpdRoot
= fpdd
.getPlatformSurfaceArea();
163 } catch (Exception e
) {
164 System
.out
.println(e
.toString());
168 public DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
getfpdDynPcdBuildDefs() {
169 if (fpdDynPcdBuildDefs
== null){
170 fpdDynPcdBuildDefs
= fpdRoot
.addNewDynamicPcdBuildDefinitions();
172 return fpdDynPcdBuildDefs
;
175 public FrameworkModulesDocument
.FrameworkModules
getfpdFrameworkModules() {
176 if (fpdFrameworkModules
== null){
177 fpdFrameworkModules
= fpdRoot
.addNewFrameworkModules();
179 return fpdFrameworkModules
;
182 public int getFrameworkModulesCount() {
183 if (getfpdFrameworkModules().getModuleSAList() == null){
186 return getfpdFrameworkModules().getModuleSAList().size();
189 public void getFrameworkModulesInfo(String
[][] saa
) {
190 if (getFrameworkModulesCount() == 0){
194 ListIterator li
= getfpdFrameworkModules().getModuleSAList().listIterator();
196 while(li
.hasNext()) {
197 ModuleSADocument
.ModuleSA msa
= (ModuleSADocument
.ModuleSA
)li
.next();
198 saa
[i
][0] = msa
.getModuleGuid();
199 saa
[i
][1] = msa
.getModuleVersion();
201 saa
[i
][2] = msa
.getPackageGuid();
202 saa
[i
][3] = msa
.getPackageVersion();
203 saa
[i
][4] = listToString(msa
.getSupArchList());
208 public void getFrameworkModuleInfo(int i
, String
[] sa
) {
209 ModuleSADocument
.ModuleSA msa
= getModuleSA(i
);
213 sa
[0] = msa
.getModuleGuid();
214 sa
[1] = msa
.getModuleVersion();
215 sa
[2] = msa
.getPackageGuid();
216 sa
[3] = msa
.getPackageVersion();
217 sa
[4] = listToString(msa
.getSupArchList());
220 public ModuleSADocument
.ModuleSA
getModuleSA(String key
) {
221 String
[] s
= key
.split(" ");
222 if (getfpdFrameworkModules().getModuleSAList() == null) {
225 ListIterator li
= getfpdFrameworkModules().getModuleSAList().listIterator();
226 while(li
.hasNext()) {
227 ModuleSADocument
.ModuleSA msa
= (ModuleSADocument
.ModuleSA
)li
.next();
228 if (msa
.getModuleGuid().equals(s
[0]) && msa
.getPackageGuid().equals(s
[2])) {
229 if (msa
.getModuleVersion() != null) {
230 if (!msa
.getModuleVersion().equals(s
[1])) {
234 if (msa
.getPackageVersion() != null) {
235 if (!msa
.getPackageVersion().equals(s
[3])) {
239 //ToDo add arch check for s[4]
240 if (msa
.getSupArchList() != null) {
241 if (!listToString(msa
.getSupArchList()).equals(s
[4])) {
251 private ModuleSADocument
.ModuleSA
getModuleSA(int i
) {
252 ModuleSADocument
.ModuleSA msa
= null;
253 XmlCursor cursor
= getfpdFrameworkModules().newCursor();
254 if (cursor
.toFirstChild()) {
255 for (int j
= 0; j
< i
; ++j
) {
256 cursor
.toNextSibling();
258 msa
= (ModuleSADocument
.ModuleSA
)cursor
.getObject();
264 public void removeModuleSA(int i
) {
265 XmlObject o
= getfpdFrameworkModules();
270 XmlCursor cursor
= o
.newCursor();
271 if (cursor
.toFirstChild()) {
272 for (int j
= 0; j
< i
; ++j
) {
273 cursor
.toNextSibling();
276 // remove pcd from dynPcdMap, if DynamicPcdBuildData exists, remove them too.
278 ModuleSADocument
.ModuleSA moduleSa
= (ModuleSADocument
.ModuleSA
)cursor
.getObject();
279 String moduleInfo
= moduleSa
.getModuleGuid() + " " + moduleSa
.getModuleVersion() + " " +
280 moduleSa
.getPackageGuid()+ " " + moduleSa
.getPackageVersion() + " " + listToString(moduleSa
.getSupArchList());
281 PcdBuildDefinitionDocument
.PcdBuildDefinition pcdBuildDef
= moduleSa
.getPcdBuildDefinition();
282 if (pcdBuildDef
!= null && pcdBuildDef
.getPcdDataList() != null) {
283 ListIterator
<PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
> li
= pcdBuildDef
.getPcdDataList().listIterator();
284 while(li
.hasNext()) {
285 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= li
.next();
286 maintainDynPcdMap(pcdData
.getCName() + " " + pcdData
.getTokenSpaceGuidCName(), moduleInfo
);
291 cursor
.toPrevToken();
292 if (cursor
.isComment()) {
297 if (getFrameworkModulesCount() == 0) {
305 private void maintainDynPcdMap(String pcdKey
, String moduleInfo
) {
307 ArrayList
<String
> al
= dynPcdMap
.get(pcdKey
);
311 String
[] s
= moduleInfo
.split(" ");
312 for(int i
= 0; i
< al
.size(); ++i
){
313 String consumer
= al
.get(i
);
314 if (consumer
.contains(s
[0]) && consumer
.contains(s
[2])){
315 String
[] consumerPart
= consumer
.split(" ");
316 if (!consumerPart
[4].equals(s
[4])) {
324 if (al
.size() == 0) {
325 dynPcdMap
.remove(pcdKey
);
326 String
[] s1
= pcdKey
.split(" ");
327 removeDynamicPcdBuildData(s1
[0], s1
[1]);
332 // key for ModuleSA : "ModuleGuid ModuleVer PackageGuid PackageVer Arch"
334 public int getPcdDataCount(int i
){
335 ModuleSADocument
.ModuleSA msa
= getModuleSA(i
);
337 if (msa
== null || msa
.getPcdBuildDefinition() == null || msa
.getPcdBuildDefinition().getPcdDataList() == null){
340 return msa
.getPcdBuildDefinition().getPcdDataList().size();
344 public void getPcdData(int i
, String
[][] saa
) {
345 ModuleSADocument
.ModuleSA msa
= getModuleSA(i
);
347 if (msa
== null || msa
.getPcdBuildDefinition() == null || msa
.getPcdBuildDefinition().getPcdDataList() == null){
350 ListIterator
<PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
>li
= msa
.getPcdBuildDefinition().getPcdDataList().listIterator();
351 for (int k
= 0; k
< saa
.length
; ++k
) {
352 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= li
.next();
353 saa
[k
][0] = pcdData
.getCName();
354 saa
[k
][1] = pcdData
.getTokenSpaceGuidCName();
355 saa
[k
][2] = pcdData
.getItemType()+"";
356 saa
[k
][3] = pcdData
.getToken().toString();
357 saa
[k
][4] = pcdData
.getMaxDatumSize()+"";
358 saa
[k
][5] = pcdData
.getDatumType()+"";
359 saa
[k
][6] = pcdData
.getValue();
364 public void updatePcdData(String key
, String cName
, String tsGuid
, String itemType
, String maxSize
, String value
){
365 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
366 if (msa
== null || msa
.getPcdBuildDefinition() == null){
370 XmlCursor cursor
= msa
.getPcdBuildDefinition().newCursor();
371 if (cursor
.toFirstChild()){
373 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= (PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
)cursor
.getObject();
374 if (pcdData
.getCName().equals(cName
) && pcdData
.getTokenSpaceGuidCName().equals(tsGuid
)) {
375 pcdData
.setItemType(PcdItemTypes
.Enum
.forString(itemType
));
376 if(pcdData
.getDatumType().equals("VOID*")) {
377 pcdData
.setMaxDatumSize(new Integer(maxSize
));
379 pcdData
.setValue(value
);
383 while(cursor
.toNextSibling());
388 /**Get original Pcd info from MSA & SPD files.
389 * @param mi ModuleIdentification from which MSA & SPD come
390 * @param cName PCD cName
391 * @param sa Results: HelpText, Original item type.
394 public boolean getPcdBuildDataInfo(ModuleIdentification mi
, String cName
, String
[] sa
) throws Exception
{
397 ModuleSurfaceAreaDocument
.ModuleSurfaceArea msa
= (ModuleSurfaceAreaDocument
.ModuleSurfaceArea
)GlobalData
.getModuleXmlObject(mi
);
398 if (msa
.getPcdCoded() == null) {
402 Map
<String
, XmlObject
> m
= new HashMap
<String
, XmlObject
>();
403 m
.put("ModuleSurfaceArea", msa
);
404 SurfaceAreaQuery
.setDoc(m
);
405 PackageIdentification
[] depPkgs
= SurfaceAreaQuery
.getDependencePkg(null);
407 // First look through MSA pcd entries.
409 List
<PcdCodedDocument
.PcdCoded
.PcdEntry
> l
= msa
.getPcdCoded().getPcdEntryList();
410 ListIterator li
= l
.listIterator();
411 while(li
.hasNext()) {
412 PcdCodedDocument
.PcdCoded
.PcdEntry msaPcd
= (PcdCodedDocument
.PcdCoded
.PcdEntry
)li
.next();
413 if (!msaPcd
.getCName().equals(cName
)) {
416 PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry spdPcd
= LookupPcdDeclaration(msaPcd
, depPkgs
);
417 if (spdPcd
== null) {
421 throw new PcdDeclNotFound(mi
.getName() + " " + msaPcd
.getCName());
424 // Get Pcd help text and original item type.
426 sa
[0] = spdPcd
.getHelpText() + msaPcd
.getHelpText();
427 sa
[1] = msaPcd
.getPcdItemType()+"";
434 // e.printStackTrace();
441 /**Remove PCDBuildDefinition entries from ModuleSA
442 * @param moduleKey identifier of ModuleSA.
443 * @param consumer where these entries come from.
445 public void removePcdData(String moduleKey
, ModuleIdentification consumer
) {
447 ModuleSurfaceAreaDocument
.ModuleSurfaceArea msa
= (ModuleSurfaceAreaDocument
.ModuleSurfaceArea
)GlobalData
.getModuleXmlObject(consumer
);
448 if (msa
.getPcdCoded() == null) {
452 List
<PcdCodedDocument
.PcdCoded
.PcdEntry
> l
= msa
.getPcdCoded().getPcdEntryList();
453 ListIterator li
= l
.listIterator();
455 while(li
.hasNext()) {
456 PcdCodedDocument
.PcdCoded
.PcdEntry msaPcd
= (PcdCodedDocument
.PcdCoded
.PcdEntry
)li
.next();
457 ModuleSADocument
.ModuleSA moduleSA
= getModuleSA(moduleKey
);
458 if (moduleSA
.getPcdBuildDefinition() != null) {
459 XmlCursor cursor
= moduleSA
.getPcdBuildDefinition().newCursor();
460 if (cursor
.toFirstChild()) {
461 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= (PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
) cursor
463 if (msaPcd
.getCName().equals(pcdData
.getCName())
464 && msaPcd
.getTokenSpaceGuidCName().equals(pcdData
.getTokenSpaceGuidCName())) {
466 maintainDynPcdMap(pcdData
.getCName() + " " + pcdData
.getTokenSpaceGuidCName(), moduleKey
);
470 while (cursor
.toNextSibling()) {
471 pcdData
= (PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
) cursor
.getObject();
472 if (msaPcd
.getCName().equals(pcdData
.getCName())
473 && msaPcd
.getTokenSpaceGuidCName().equals(pcdData
.getTokenSpaceGuidCName())) {
474 maintainDynPcdMap(pcdData
.getCName() + " " + pcdData
.getTokenSpaceGuidCName(),
492 // key for ModuleSA : "ModuleGuid ModuleVer PackageGuid PackageVer Arch"
494 public int getLibraryInstancesCount(String key
) {
495 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
496 if (msa
== null || msa
.getLibraries() == null || msa
.getLibraries().getInstanceList() == null){
499 return msa
.getLibraries().getInstanceList().size();
502 public void getLibraryInstances(String key
, String
[][] saa
){
503 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
504 if (msa
== null || msa
.getLibraries() == null || msa
.getLibraries().getInstanceList() == null){
508 ListIterator
<LibrariesDocument
.Libraries
.Instance
> li
= msa
.getLibraries().getInstanceList().listIterator();
509 for (int i
= 0; i
< saa
.length
; ++i
) {
510 LibrariesDocument
.Libraries
.Instance instance
= li
.next();
511 saa
[i
][1] = instance
.getModuleGuid();
512 saa
[i
][2] = instance
.getModuleVersion();
513 saa
[i
][3] = instance
.getPackageGuid();
514 saa
[i
][4] = instance
.getPackageVersion();
518 public void removeLibraryInstance(String key
, int i
) {
519 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
520 if (msa
== null || msa
.getLibraries() == null){
524 XmlCursor cursor
= msa
.getLibraries().newCursor();
525 if (cursor
.toFirstChild()) {
526 for (int j
= 0; j
< i
; ++j
) {
527 cursor
.toNextSibling();
530 cursor
.toPrevToken();
531 if (cursor
.isComment()) {
536 if (getLibraryInstancesCount(key
) == 0) {
545 public void genLibraryInstance(ModuleIdentification libMi
, String key
) {
546 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
548 msa
= getfpdFrameworkModules().addNewModuleSA();
550 LibrariesDocument
.Libraries libs
= msa
.getLibraries();
552 libs
= msa
.addNewLibraries();
555 String mn
= libMi
.getName();
556 String mg
= libMi
.getGuid();
557 String mv
= libMi
.getVersion();
558 String pn
= libMi
.getPackage().getName();
559 String pg
= libMi
.getPackage().getGuid();
560 String pv
= libMi
.getPackage().getVersion();
561 LibrariesDocument
.Libraries
.Instance instance
= libs
.addNewInstance();
562 XmlCursor cursor
= instance
.newCursor();
564 String comment
= "Pkg: " + pn
+ " Mod: " + mn
565 + " Path: " + GlobalData
.getMsaFile(libMi
).getPath();
566 cursor
.insertComment(comment
);
575 instance
.setModuleGuid(mg
);
576 instance
.setModuleVersion(mv
);
577 instance
.setPackageGuid(pg
);
578 instance
.setPackageVersion(pv
);
582 public String
getFvBinding(String moduleKey
){
583 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
584 if (msa
== null || msa
.getModuleSaBuildOptions() == null) {
587 return msa
.getModuleSaBuildOptions().getFvBinding();
590 public void setFvBinding(String moduleKey
, String fvBinding
){
591 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
595 if(msa
.getModuleSaBuildOptions() == null){
596 msa
.addNewModuleSaBuildOptions().setFvBinding(fvBinding
);
599 msa
.getModuleSaBuildOptions().setFvBinding(fvBinding
);
602 public String
getFfsFileNameGuid(String moduleKey
){
603 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
604 if (msa
== null || msa
.getModuleSaBuildOptions() == null) {
607 return msa
.getModuleSaBuildOptions().getFfsFileNameGuid();
610 public void setFfsFileNameGuid(String moduleKey
, String fileGuid
){
611 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
615 if(msa
.getModuleSaBuildOptions() == null){
616 msa
.addNewModuleSaBuildOptions();
619 ModuleSaBuildOptionsDocument
.ModuleSaBuildOptions msaBuildOpts
= msa
.getModuleSaBuildOptions();
620 if (fileGuid
!= null) {
621 msaBuildOpts
.setFfsFileNameGuid(fileGuid
);
624 XmlCursor cursor
= msaBuildOpts
.newCursor();
625 if (cursor
.toChild(xmlNs
, "FfsFileNameGuid")) {
633 public String
getFfsFormatKey(String moduleKey
){
634 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
635 if (msa
== null || msa
.getModuleSaBuildOptions() == null) {
638 return msa
.getModuleSaBuildOptions().getFfsFormatKey();
641 public void setFfsFormatKey(String moduleKey
, String ffsKey
){
642 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
646 if(msa
.getModuleSaBuildOptions() == null){
647 msa
.addNewModuleSaBuildOptions().setFfsFormatKey(ffsKey
);
650 msa
.getModuleSaBuildOptions().setFfsFormatKey(ffsKey
);
653 public void getModuleSAOptions(String moduleKey
, String
[][] saa
) {
654 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
655 if (msa
.getModuleSaBuildOptions() == null || msa
.getModuleSaBuildOptions().getOptions() == null
656 || msa
.getModuleSaBuildOptions().getOptions().getOptionList() == null) {
660 List
<OptionDocument
.Option
> lOpt
= msa
.getModuleSaBuildOptions().getOptions().getOptionList();
661 ListIterator li
= lOpt
.listIterator();
663 while(li
.hasNext()) {
664 OptionDocument
.Option opt
= (OptionDocument
.Option
)li
.next();
665 if (opt
.getBuildTargets() != null) {
666 saa
[i
][0] = listToString(opt
.getBuildTargets());
668 saa
[i
][1] = opt
.getToolChainFamily();
669 saa
[i
][2] = opt
.getTagName();
670 saa
[i
][3] = opt
.getToolCode();
672 if (opt
.getSupArchList() != null){
673 saa
[i
][4] = listToString(opt
.getSupArchList());
677 saa
[i
][5] = opt
.getStringValue();
683 public int getModuleSAOptionsCount(String moduleKey
){
684 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
685 if (msa
.getModuleSaBuildOptions() == null || msa
.getModuleSaBuildOptions().getOptions() == null
686 || msa
.getModuleSaBuildOptions().getOptions().getOptionList() == null) {
689 return msa
.getModuleSaBuildOptions().getOptions().getOptionList().size();
692 public void genModuleSAOptionsOpt(String moduleKey
, Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
) {
693 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
694 if (msa
.getModuleSaBuildOptions() == null) {
695 msa
.addNewModuleSaBuildOptions();
697 if (msa
.getModuleSaBuildOptions().getOptions() == null){
698 msa
.getModuleSaBuildOptions().addNewOptions();
700 OptionDocument
.Option opt
= msa
.getModuleSaBuildOptions().getOptions().addNewOption();
701 setBuildOptionsOpt(buildTargets
, toolChain
, tagName
, toolCmd
, archList
, contents
, opt
);
704 public void removeModuleSAOptionsOpt(String moduleKey
, int i
) {
705 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
706 if (msa
.getModuleSaBuildOptions() == null || msa
.getModuleSaBuildOptions().getOptions() == null) {
709 OptionsDocument
.Options opts
= msa
.getModuleSaBuildOptions().getOptions();
710 XmlCursor cursor
= opts
.newCursor();
711 if (cursor
.toFirstChild()) {
712 for (int j
= 0; j
< i
; ++j
){
713 cursor
.toNextSibling();
720 public void updateModuleSAOptionsOpt(String moduleKey
, int i
, Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
) {
721 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
722 if (msa
.getModuleSaBuildOptions() == null || msa
.getModuleSaBuildOptions().getOptions() == null) {
725 OptionsDocument
.Options opts
= msa
.getModuleSaBuildOptions().getOptions();
726 XmlCursor cursor
= opts
.newCursor();
727 if (cursor
.toFirstChild()) {
728 for (int j
= 0; j
< i
; ++j
){
729 cursor
.toNextSibling();
731 OptionDocument
.Option opt
= (OptionDocument
.Option
)cursor
.getObject();
732 setBuildOptionsOpt(buildTargets
, toolChain
, tagName
, toolCmd
, archList
, contents
, opt
);
737 /**add pcd information of module mi to a ModuleSA.
739 * @param moduleSa if null, generate a new ModuleSA.
741 public void addFrameworkModulesPcdBuildDefs(ModuleIdentification mi
, String arch
, ModuleSADocument
.ModuleSA moduleSa
) throws Exception
{
742 //ToDo add Arch filter
745 if (moduleSa
== null) {
746 moduleSa
= genModuleSA(mi
, arch
);
749 ModuleSurfaceAreaDocument
.ModuleSurfaceArea msa
= (ModuleSurfaceAreaDocument
.ModuleSurfaceArea
)GlobalData
.getModuleXmlObject(mi
);
750 if (msa
.getPcdCoded() == null) {
754 Map
<String
, XmlObject
> m
= new HashMap
<String
, XmlObject
>();
755 m
.put("ModuleSurfaceArea", msa
);
756 SurfaceAreaQuery
.setDoc(m
);
757 PackageIdentification
[] depPkgs
= SurfaceAreaQuery
.getDependencePkg(null);
759 // Implementing InitializePlatformPcdBuildDefinitions
761 List
<PcdCodedDocument
.PcdCoded
.PcdEntry
> l
= msa
.getPcdCoded().getPcdEntryList();
762 ListIterator li
= l
.listIterator();
763 while(li
.hasNext()) {
764 PcdCodedDocument
.PcdCoded
.PcdEntry msaPcd
= (PcdCodedDocument
.PcdCoded
.PcdEntry
)li
.next();
765 PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry spdPcd
= LookupPcdDeclaration(msaPcd
, depPkgs
);
766 if (spdPcd
== null) {
770 throw new PcdDeclNotFound(mi
.getName() + " " + msaPcd
.getCName());
773 // AddItem to ModuleSA PcdBuildDefinitions
775 String defaultVal
= msaPcd
.getDefaultValue() == null ? spdPcd
.getDefaultValue() : msaPcd
.getDefaultValue();
777 genPcdData(msaPcd
.getCName(), spdPcd
.getToken(), msaPcd
.getTokenSpaceGuidCName(), msaPcd
.getPcdItemType().toString(), spdPcd
.getDatumType()+"", defaultVal
, moduleSa
);
782 // e.printStackTrace();
788 private PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry
LookupPcdDeclaration (PcdCodedDocument
.PcdCoded
.PcdEntry msaPcd
, PackageIdentification
[] depPkgs
) {
790 Map
<String
, XmlObject
> m
= new HashMap
<String
, XmlObject
>();
791 PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry spdPcd
= null;
792 for (int i
= 0; i
< depPkgs
.length
; ++i
) {
793 m
.put("PackageSurfaceArea", GlobalData
.getPackageXmlObject(depPkgs
[i
]));
794 SurfaceAreaQuery
.setDoc(m
);
795 XmlObject
[] xo
= SurfaceAreaQuery
.getSpdPcdDeclarations();
799 for (int j
= 0; j
< xo
.length
; ++j
) {
800 spdPcd
= (PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry
)xo
[j
];
801 if (msaPcd
.getTokenSpaceGuidCName() == null) {
802 if (spdPcd
.getCName().equals(msaPcd
.getCName())) {
807 if (spdPcd
.getCName().equals(msaPcd
.getCName()) && spdPcd
.getTokenSpaceGuidCName().equals(msaPcd
.getTokenSpaceGuidCName())) {
818 private ModuleSADocument
.ModuleSA
genModuleSA (ModuleIdentification mi
, String arch
) {
819 PackageIdentification pi
= GlobalData
.getPackageForModule(mi
);
820 ModuleSADocument
.ModuleSA msa
= getfpdFrameworkModules().addNewModuleSA();
821 XmlCursor cursor
= msa
.newCursor();
823 String comment
= "Mod: " + mi
.getName() + " Type: " + mi
.getModuleType() + " Path: "
824 + GlobalData
.getMsaFile(mi
).getPath();
825 cursor
.insertComment(comment
);
833 msa
.setModuleGuid(mi
.getGuid());
834 msa
.setModuleVersion(mi
.getVersion());
835 msa
.setPackageGuid(pi
.getGuid());
836 msa
.setPackageVersion(pi
.getVersion());
838 Vector
<String
> v
= new Vector
<String
>();
840 msa
.setSupArchList(v
);
846 private void genPcdData (String cName
, Object token
, String tsGuid
, String itemType
, String dataType
, String defaultVal
, ModuleSADocument
.ModuleSA moduleSa
)
847 throws PcdItemTypeConflictException
, PcdValueMalFormed
{
848 if (moduleSa
.getPcdBuildDefinition() == null){
849 moduleSa
.addNewPcdBuildDefinition();
852 // constructe pcd to modulesa mapping first.
853 // Attention : for any error condition, remove from map this pcd.
855 ArrayList
<String
> pcdConsumer
= LookupPlatformPcdData(cName
+ " " + tsGuid
);
856 if (pcdConsumer
== null) {
857 pcdConsumer
= new ArrayList
<String
>();
859 String listValue
= moduleSa
.getModuleGuid() + " " + moduleSa
.getModuleVersion()
860 + " " + moduleSa
.getPackageGuid() + " " + moduleSa
.getPackageVersion() + " " + listToString(moduleSa
.getSupArchList())
862 pcdConsumer
.add(listValue
);
863 dynPcdMap
.put(cName
+ " " + tsGuid
, pcdConsumer
);
865 // Special dynamic type, if this pcd already exists in other ModuleSA
867 if (itemType
.equals("DYNAMIC")) {
869 ListIterator li
= pcdConsumer
.listIterator();
870 while(li
.hasNext()) {
871 String value
= li
.next().toString();
872 String
[] valuePart
= value
.split(" ");
873 if (!valuePart
[4].equals("DYNAMIC")) {
874 //ToDo error for same pcd, other type than dynamic
875 pcdConsumer
.remove(listValue
);
876 throw new PcdItemTypeConflictException(value
);
881 ListIterator li
= pcdConsumer
.listIterator();
882 while(li
.hasNext()) {
883 String value
= li
.next().toString();
884 String
[] valuePart
= value
.split(" ");
885 if (valuePart
[4].equals("DYNAMIC")) {
886 //ToDo error for same pcd, other type than non-dynamic
887 pcdConsumer
.remove(listValue
);
888 throw new PcdItemTypeConflictException(value
);
893 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData fpdPcd
= moduleSa
.getPcdBuildDefinition().addNewPcdData();
894 fpdPcd
.setCName(cName
);
895 fpdPcd
.setToken(token
);
896 fpdPcd
.setTokenSpaceGuidCName(tsGuid
);
897 fpdPcd
.setDatumType(PcdDataTypes
.Enum
.forString(dataType
));
898 fpdPcd
.setItemType(PcdItemTypes
.Enum
.forString(itemType
));
900 if (itemType
.equals("DYNAMIC") || itemType
.equals("DYNAMIC_EX")) {
901 ArrayList
<String
> al
= LookupDynamicPcdBuildDefinition(cName
+ " " + tsGuid
);
903 // if only one module mapped to this pcd, then the one is myself. so no other module mapped.
904 // so need to add one dyn pcd.
906 if (al
.size() == 1) {
907 addDynamicPcdBuildData(cName
, token
, tsGuid
, itemType
, dataType
, defaultVal
);
911 if (defaultVal
!= null){
912 fpdPcd
.setValue(defaultVal
);
915 if (dataType
.equals("UINT8") || dataType
.equals("UINT16") || dataType
.equals("UINT32") || dataType
.equals("UINT64")) {
916 fpdPcd
.setValue("0");
918 if (dataType
.equals("BOOLEAN")){
919 fpdPcd
.setValue("false");
921 if (dataType
.equals("VOID*")) {
925 if (dataType
.equals("UINT8")){
926 fpdPcd
.setMaxDatumSize(1);
928 if (dataType
.equals("UINT16")) {
929 fpdPcd
.setMaxDatumSize(2);
931 if (dataType
.equals("UINT32")) {
932 fpdPcd
.setMaxDatumSize(4);
934 if (dataType
.equals("UINT64")){
935 fpdPcd
.setMaxDatumSize(8);
937 if (dataType
.equals("BOOLEAN")){
938 fpdPcd
.setMaxDatumSize(1);
940 if (dataType
.equals("VOID*")) {
941 int maxSize
= setMaxSizeForPointer(fpdPcd
.getValue());
942 fpdPcd
.setMaxDatumSize(maxSize
);
947 public int setMaxSizeForPointer(String datum
) throws PcdValueMalFormed
{
951 char ch
= datum
.charAt(0);
955 // For void* type PCD, only three datum is support:
956 // 1) Unicode: string with start char is "L"
957 // 2) Ansci: String is ""
958 // 3) byte array: String start char "{"
961 start
= datum
.indexOf('\"');
962 end
= datum
.lastIndexOf('\"');
964 (end
> datum
.length())||
965 ((start
== end
) && (datum
.length() > 0))) {
966 //ToDo Error handling here
967 throw new PcdValueMalFormed (datum
);
970 strValue
= datum
.substring(start
+ 1, end
);
971 return strValue
.length() * 2;
972 } else if (ch
== '\"'){
973 start
= datum
.indexOf('\"');
974 end
= datum
.lastIndexOf('\"');
976 (end
> datum
.length())||
977 ((start
== end
) && (datum
.length() > 0))) {
978 throw new PcdValueMalFormed (datum
);
980 strValue
= datum
.substring(start
+ 1, end
);
981 return strValue
.length();
982 } else if (ch
=='{') {
983 String
[] strValueArray
;
985 start
= datum
.indexOf('{');
986 end
= datum
.lastIndexOf('}');
987 strValue
= datum
.substring(start
+ 1, end
);
988 strValue
= strValue
.trim();
989 if (strValue
.length() == 0) {
992 strValueArray
= strValue
.split(",");
993 for (int index
= 0; index
< strValueArray
.length
; index
++) {
994 Integer value
= Integer
.decode(strValueArray
[index
].trim());
997 // "[FPD file error] The datum type of PCD %s in %s is VOID*, "+
998 // "it is byte array in fact. But the element of %s exceed the byte range",
999 throw new PcdValueMalFormed (datum
);
1002 return strValueArray
.length
;
1006 // "[FPD file error] The datum type of PCD %s in %s is VOID*. For VOID* type, you have three format choise:\n "+
1007 // "1) UNICODE string: like L\"xxxx\";\r\n"+
1008 // "2) ANSIC string: like \"xxx\";\r\n"+
1009 // "3) Byte array: like {0x2, 0x45, 0x23}\r\n"+
1010 // "but the datum in seems does not following above format!",
1011 throw new PcdValueMalFormed (datum
);
1016 private ArrayList
<String
> LookupDynamicPcdBuildDefinition(String dynPcdKey
) {
1017 ArrayList
<String
> al
= dynPcdMap
.get(dynPcdKey
);
1022 private ArrayList
<String
> LookupPlatformPcdData(String pcdKey
) {
1024 return dynPcdMap
.get("pcdKey");
1027 public int getDynamicPcdBuildDataCount() {
1028 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null) {
1031 return getfpdDynPcdBuildDefs().getPcdBuildDataList().size();
1034 public void getDynamicPcdBuildData(String
[][] saa
) {
1035 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null) {
1038 List
<DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
> l
= getfpdDynPcdBuildDefs().getPcdBuildDataList();
1039 ListIterator
<DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
> li
= l
.listIterator();
1041 while(li
.hasNext()) {
1042 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData dynPcd
= li
.next();
1043 saa
[i
][0] = dynPcd
.getCName();
1044 saa
[i
][1] = dynPcd
.getToken().toString();
1045 saa
[i
][2] = dynPcd
.getTokenSpaceGuidCName();
1046 saa
[i
][3] = dynPcd
.getMaxDatumSize()+"";
1047 saa
[i
][4] = dynPcd
.getDatumType().toString();
1053 public void addDynamicPcdBuildData(String cName
, Object token
, String tsGuid
, String itemType
, String dataType
, String defaultVal
)
1054 throws PcdValueMalFormed
{
1055 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData dynPcdData
= getfpdDynPcdBuildDefs().addNewPcdBuildData();
1056 dynPcdData
.setItemType(PcdItemTypes
.Enum
.forString(itemType
));
1057 dynPcdData
.setCName(cName
);
1058 dynPcdData
.setToken(token
);
1059 dynPcdData
.setTokenSpaceGuidCName(tsGuid
);
1060 dynPcdData
.setDatumType(PcdDataTypes
.Enum
.forString(dataType
));
1062 BigInteger bigInt
= new BigInteger("0");
1063 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo skuInfo
= dynPcdData
.addNewSkuInfo();
1064 skuInfo
.setSkuId(bigInt
);
1065 if (defaultVal
!= null){
1066 skuInfo
.setValue(defaultVal
);
1069 if (dataType
.equals("UINT8")){
1070 skuInfo
.setValue("0");
1072 if (dataType
.equals("UINT16")) {
1073 skuInfo
.setValue("0");
1075 if (dataType
.equals("UINT32")) {
1076 skuInfo
.setValue("0");
1078 if (dataType
.equals("UINT64")){
1079 skuInfo
.setValue("0");
1081 if (dataType
.equals("BOOLEAN")){
1082 skuInfo
.setValue("false");
1084 if (dataType
.equals("VOID*")) {
1085 skuInfo
.setValue("");
1088 if (dataType
.equals("UINT8")){
1089 dynPcdData
.setMaxDatumSize(1);
1091 if (dataType
.equals("UINT16")) {
1092 dynPcdData
.setMaxDatumSize(2);
1094 if (dataType
.equals("UINT32")) {
1095 dynPcdData
.setMaxDatumSize(4);
1097 if (dataType
.equals("UINT64")){
1098 dynPcdData
.setMaxDatumSize(8);
1100 if (dataType
.equals("BOOLEAN")){
1101 dynPcdData
.setMaxDatumSize(1);
1103 if (dataType
.equals("VOID*")) {
1104 int maxSize
= setMaxSizeForPointer(defaultVal
);
1105 dynPcdData
.setMaxDatumSize(maxSize
);
1109 public void removeDynamicPcdBuildData(String cName
, String tsGuid
) {
1110 XmlObject o
= getfpdDynPcdBuildDefs();
1112 XmlCursor cursor
= o
.newCursor();
1113 if (cursor
.toFirstChild()) {
1115 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdBuildData
=
1116 (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1117 if (pcdBuildData
.getCName().equals(cName
) && pcdBuildData
.getTokenSpaceGuidCName().equals(tsGuid
)) {
1119 if (getDynamicPcdBuildDataCount() == 0) {
1127 while (cursor
.toNextSibling());
1132 // Get the Sku Info count of ith dyn pcd element.
1134 public int getDynamicPcdSkuInfoCount(int i
){
1135 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1139 int skuInfoCount
= 0;
1140 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1141 if (cursor
.toFirstChild()) {
1142 for (int j
= 0; j
< i
; ++j
) {
1143 cursor
.toNextSibling();
1145 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1146 if (pcdData
.getSkuInfoList() == null) {
1150 skuInfoCount
= pcdData
.getSkuInfoList().size();
1154 return skuInfoCount
;
1157 public void getDynamicPcdSkuInfos(int i
, String
[][] saa
){
1158 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1162 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1163 if (cursor
.toFirstChild()) {
1164 for (int j
= 0; j
< i
; ++j
) {
1165 cursor
.toNextSibling();
1167 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1168 if (pcdData
.getSkuInfoList() == null) {
1173 ListIterator
<DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo
> li
= pcdData
.getSkuInfoList().listIterator();
1175 while (li
.hasNext()) {
1176 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo skuInfo
= li
.next();
1177 saa
[k
][0] = skuInfo
.getSkuId()+"";
1178 saa
[k
][1] = skuInfo
.getVariableName();
1179 saa
[k
][2] = skuInfo
.getVariableGuid();
1180 saa
[k
][3] = skuInfo
.getVariableOffset();
1181 saa
[k
][4] = skuInfo
.getHiiDefaultValue();
1182 saa
[k
][5] = skuInfo
.getVpdOffset();
1183 saa
[k
][6] = skuInfo
.getValue();
1193 public String
getDynamicPcdBuildDataValue(int i
){
1194 String value
= null;
1195 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1199 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1200 if (cursor
.toFirstChild()) {
1201 for (int j
= 0; j
< i
; ++j
) {
1202 cursor
.toNextSibling();
1204 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1205 if (pcdData
.getSkuInfoList() == null) {
1209 value
= pcdData
.getSkuInfoArray(0).getValue();
1216 public String
getDynamicPcdBuildDataVpdOffset(int i
){
1217 String vpdOffset
= null;
1218 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1222 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1223 if (cursor
.toFirstChild()) {
1224 for (int j
= 0; j
< i
; ++j
) {
1225 cursor
.toNextSibling();
1227 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1228 if (pcdData
.getSkuInfoList() == null) {
1232 vpdOffset
= pcdData
.getSkuInfoArray(0).getVpdOffset();
1239 public void removeDynamicPcdBuildDataSkuInfo(int i
) {
1240 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1244 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1245 if (cursor
.toFirstChild()) {
1246 for (int j
= 0; j
< i
; ++j
) {
1247 cursor
.toNextSibling();
1249 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1250 if (pcdData
.getSkuInfoList() == null) {
1255 QName qSkuInfo
= new QName(xmlNs
, "SkuInfo");
1256 cursor
.toChild(qSkuInfo
);
1263 // generate sku info for ith dyn pcd build data.
1265 public void genDynamicPcdBuildDataSkuInfo(String id
, String varName
, String varGuid
, String varOffset
,
1266 String hiiDefault
, String vpdOffset
, String value
, int i
) {
1267 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1271 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1272 if (cursor
.toFirstChild()) {
1273 for (int j
= 0; j
< i
; ++j
) {
1274 cursor
.toNextSibling();
1276 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1277 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo skuInfo
= pcdData
.addNewSkuInfo();
1278 skuInfo
.setSkuId(new BigInteger(id
));
1279 if (varName
!= null){
1280 skuInfo
.setVariableName(varName
);
1281 skuInfo
.setVariableGuid(varGuid
);
1282 skuInfo
.setVariableOffset(varOffset
);
1283 skuInfo
.setHiiDefaultValue(hiiDefault
);
1285 else if (vpdOffset
!= null){
1286 skuInfo
.setVpdOffset(vpdOffset
);
1289 skuInfo
.setValue(value
);
1294 public void updateDynamicPcdBuildDataSkuInfo(String id
, String varName
, String varGuid
, String varOffset
,
1295 String hiiDefault
, String vpdOffset
, String value
, int i
){
1296 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1300 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1301 if (cursor
.toFirstChild()) {
1302 for (int j
= 0; j
< i
; ++j
) {
1303 cursor
.toNextSibling();
1305 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1306 ListIterator
<DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo
> li
= pcdData
.getSkuInfoList().listIterator();
1307 while (li
.hasNext()) {
1308 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo skuInfo
= li
.next();
1309 if (skuInfo
.getSkuId().toString().equals(id
)){
1310 if (varName
!= null){
1311 skuInfo
.setVariableName(varName
);
1312 skuInfo
.setVariableGuid(varGuid
);
1313 skuInfo
.setVariableOffset(varOffset
);
1314 skuInfo
.setHiiDefaultValue(hiiDefault
);
1316 else if (vpdOffset
!= null){
1317 skuInfo
.setVpdOffset(vpdOffset
);
1320 skuInfo
.setValue(value
);
1328 public BuildOptionsDocument
.BuildOptions
getfpdBuildOpts() {
1329 if (fpdBuildOpts
== null) {
1330 fpdBuildOpts
= fpdRoot
.addNewBuildOptions();
1332 return fpdBuildOpts
;
1335 public void genBuildOptionsUserDefAntTask (String id
, String fileName
, String execOrder
) {
1336 UserDefinedAntTasksDocument
.UserDefinedAntTasks udats
= getfpdBuildOpts().getUserDefinedAntTasks();
1337 if (udats
== null) {
1338 udats
= getfpdBuildOpts().addNewUserDefinedAntTasks();
1341 AntTaskDocument
.AntTask at
= udats
.addNewAntTask();
1342 setBuildOptionsUserDefAntTask(id
, fileName
, execOrder
, at
);
1345 private void setBuildOptionsUserDefAntTask(String id
, String fileName
, String execOrder
, AntTaskDocument
.AntTask at
) {
1346 at
.setId(new Integer(id
));
1347 XmlCursor cursor
= at
.newCursor();
1348 if (fileName
!= null){
1349 at
.setFilename(fileName
);
1351 else if (cursor
.toChild(xmlNs
, "Filename")) {
1354 if (execOrder
!= null) {
1355 at
.setAntCmdOptions(execOrder
);
1357 else if (cursor
.toChild(xmlNs
, "AntCmdOptions")) {
1363 public void removeBuildOptionsUserDefAntTask(int i
) {
1364 XmlObject o
= getfpdBuildOpts().getUserDefinedAntTasks();
1368 XmlCursor cursor
= o
.newCursor();
1369 if (cursor
.toFirstChild()) {
1370 for (int j
= 0; j
< i
; ++j
) {
1371 cursor
.toNextSibling();
1374 if (getBuildOptionsUserDefAntTaskCount() == 0) {
1382 public void updateBuildOptionsUserDefAntTask(int i
, String id
, String fileName
, String execOrder
){
1383 XmlObject o
= getfpdBuildOpts().getUserDefinedAntTasks();
1387 XmlCursor cursor
= o
.newCursor();
1388 if (cursor
.toFirstChild()) {
1389 for (int j
= 0; j
< i
; ++j
) {
1390 cursor
.toNextSibling();
1392 AntTaskDocument
.AntTask at
= (AntTaskDocument
.AntTask
)cursor
.getObject();
1393 setBuildOptionsUserDefAntTask(id
, fileName
, execOrder
, at
);
1398 public int getBuildOptionsUserDefAntTaskCount() {
1399 UserDefinedAntTasksDocument
.UserDefinedAntTasks udats
= getfpdBuildOpts().getUserDefinedAntTasks();
1400 if (udats
== null || udats
.getAntTaskList() == null) {
1404 return udats
.getAntTaskList().size();
1407 public void getBuildOptionsUserDefAntTasks(String
[][] saa
) {
1408 UserDefinedAntTasksDocument
.UserDefinedAntTasks udats
= getfpdBuildOpts().getUserDefinedAntTasks();
1409 if (udats
== null || udats
.getAntTaskList() == null) {
1413 List
<AntTaskDocument
.AntTask
> l
= udats
.getAntTaskList();
1414 ListIterator li
= l
.listIterator();
1416 while (li
.hasNext()) {
1417 AntTaskDocument
.AntTask at
= (AntTaskDocument
.AntTask
)li
.next();
1418 saa
[i
][0] = at
.getId() + "";
1419 saa
[i
][1] = saa
[i
][2] = "";
1420 if (at
.getFilename() != null){
1421 saa
[i
][1] = at
.getFilename();
1423 if (at
.getAntCmdOptions() != null) {
1424 saa
[i
][2] = at
.getAntCmdOptions();
1429 public void genBuildOptionsOpt(Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
) {
1430 OptionsDocument
.Options opts
= getfpdBuildOpts().getOptions();
1432 opts
= getfpdBuildOpts().addNewOptions();
1434 OptionDocument
.Option opt
= opts
.addNewOption();
1435 setBuildOptionsOpt(buildTargets
, toolChain
, tagName
, toolCmd
, archList
, contents
, opt
);
1438 private void setBuildOptionsOpt(Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
, OptionDocument
.Option opt
){
1439 opt
.setStringValue(contents
);
1441 opt
.setBuildTargets(buildTargets
);
1442 opt
.setToolChainFamily(toolChain
);
1443 opt
.setTagName(tagName
);
1444 opt
.setToolCode(toolCmd
);
1446 if (archList
!= null) {
1447 opt
.setSupArchList(archList
);
1450 if (opt
.isSetSupArchList()) {
1451 opt
.unsetSupArchList();
1456 public void removeBuildOptionsOpt(int i
){
1458 XmlObject o
= getfpdBuildOpts().getOptions();
1463 XmlCursor cursor
= o
.newCursor();
1464 if (cursor
.toFirstChild()) {
1465 for (int j
= 0; j
< i
; ++j
) {
1466 cursor
.toNextSibling();
1469 if (getBuildOptionsOptCount() == 0) {
1477 public void updateBuildOptionsOpt(int i
, Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
) {
1478 XmlObject o
= getfpdBuildOpts().getOptions();
1483 XmlCursor cursor
= o
.newCursor();
1484 if (cursor
.toFirstChild()) {
1485 for (int j
= 0; j
< i
; ++j
) {
1486 cursor
.toNextSibling();
1488 OptionDocument
.Option opt
= (OptionDocument
.Option
)cursor
.getObject();
1489 setBuildOptionsOpt(buildTargets
, toolChain
, tagName
, toolCmd
, archList
, contents
, opt
);
1494 public int getBuildOptionsOptCount(){
1495 if (getfpdBuildOpts().getOptions() == null || getfpdBuildOpts().getOptions().getOptionList() == null) {
1498 return getfpdBuildOpts().getOptions().getOptionList().size();
1501 public void getBuildOptionsOpts(String
[][] saa
) {
1502 if (getfpdBuildOpts().getOptions() == null || getfpdBuildOpts().getOptions().getOptionList() == null) {
1506 List
<OptionDocument
.Option
> lOpt
= getfpdBuildOpts().getOptions().getOptionList();
1507 ListIterator li
= lOpt
.listIterator();
1509 while(li
.hasNext()) {
1510 OptionDocument
.Option opt
= (OptionDocument
.Option
)li
.next();
1511 if (opt
.getBuildTargets() != null) {
1512 saa
[i
][0] = listToString(opt
.getBuildTargets());
1514 saa
[i
][1] = opt
.getToolChainFamily();
1515 if (opt
.getSupArchList() != null){
1516 saa
[i
][2] = listToString(opt
.getSupArchList());
1519 saa
[i
][3] = opt
.getToolCode();
1520 saa
[i
][4] = opt
.getTagName();
1521 saa
[i
][5] = opt
.getStringValue();
1527 public void genBuildOptionsFfs(String ffsKey
, String type
) {
1528 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getfpdBuildOpts().addNewFfs();
1529 ffs
.setFfsKey(ffsKey
);
1531 ffs
.addNewSections().setEncapsulationType(type
);
1535 public void updateBuildOptionsFfsSectionsType(int i
, String type
) {
1536 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getfpdBuildOpts().addNewFfs();
1538 ffs
.addNewSections().setEncapsulationType(type
);
1542 public void genBuildOptionsFfsAttribute(int i
, String name
, String value
) {
1543 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1544 BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute attrib
= ffs
.addNewAttribute();
1545 attrib
.setName(name
);
1546 attrib
.setValue(value
);
1549 /**update jth attribute of ith ffs.
1553 public void updateBuildOptionsFfsAttribute(int i
, int j
, String name
, String value
){
1554 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1555 XmlCursor cursor
= ffs
.newCursor();
1556 QName qAttrib
= new QName(xmlNs
, "Attribute");
1557 if (cursor
.toChild(qAttrib
)) {
1558 for (int k
= 0; k
< j
; ++k
) {
1559 cursor
.toNextSibling(qAttrib
);
1561 BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute attrib
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute
)cursor
.getObject();
1562 attrib
.setName(name
);
1563 attrib
.setValue(value
);
1568 public void removeBuildOptionsFfsAttribute(int i
, int j
){
1569 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1570 XmlCursor cursor
= ffs
.newCursor();
1571 QName qAttrib
= new QName(xmlNs
, "Attribute");
1572 if (cursor
.toChild(qAttrib
)) {
1573 for (int k
= 0; k
< j
; ++k
) {
1574 cursor
.toNextSibling(qAttrib
);
1581 public void genBuildOptionsFfsSectionsSection(int i
, String sectionType
) {
1582 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1586 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1588 if (sections
== null){
1589 sections
= ffs
.addNewSections();
1591 sections
.addNewSection().setSectionType(EfiSectionType
.Enum
.forString(sectionType
));
1594 public void removeBuildOptionsFfsSectionsSection(int i
, int j
) {
1595 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1596 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1597 if (sections
== null) {
1600 XmlCursor cursor
= sections
.newCursor();
1601 QName qSection
= new QName(xmlNs
, "Section");
1602 if (cursor
.toChild(qSection
)) {
1603 for (int k
= 0; k
< j
; ++k
) {
1604 cursor
.toNextSibling(qSection
);
1611 public void updateBuildOptionsFfsSectionsSection(int i
, int j
, String type
){
1612 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1613 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1614 if (sections
== null) {
1617 XmlCursor cursor
= sections
.newCursor();
1618 QName qSection
= new QName(xmlNs
, "Section");
1619 if (cursor
.toChild(qSection
)) {
1620 for (int k
= 0; k
< j
; ++k
) {
1621 cursor
.toNextSibling(qSection
);
1623 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Section section
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Section
)cursor
.getObject();
1624 section
.setSectionType(EfiSectionType
.Enum
.forString(type
));
1629 public void genBuildOptionsFfsSectionsSections(int i
, String encapType
) {
1630 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1634 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1636 if (sections
== null){
1637 sections
= ffs
.addNewSections();
1639 sections
.addNewSections().setEncapsulationType(encapType
);
1642 public void removeBuildOptionsFfsSectionsSections(int i
, int j
) {
1643 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1644 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1645 if (sections
== null) {
1648 XmlCursor cursor
= sections
.newCursor();
1649 QName qSections
= new QName(xmlNs
, "Sections");
1650 if (cursor
.toChild(qSections
)) {
1651 for (int k
= 0; k
< j
; ++k
) {
1652 cursor
.toNextSibling(qSections
);
1659 public void updateBuildOptionsFfsSectionsSections(int i
, int j
, String type
) {
1660 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1661 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1662 if (sections
== null) {
1665 XmlCursor cursor
= sections
.newCursor();
1666 QName qSections
= new QName(xmlNs
, "Sections");
1667 if (cursor
.toChild(qSections
)) {
1668 for (int k
= 0; k
< j
; ++k
) {
1669 cursor
.toNextSibling(qSections
);
1671 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2 sections2
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
)cursor
.getObject();
1672 sections2
.setEncapsulationType(type
);
1677 public void genBuildOptionsFfsSectionsSectionsSection(int i
, int j
, String type
) {
1678 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1682 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1683 XmlCursor cursor
= sections
.newCursor();
1684 QName qSections
= new QName(xmlNs
, "Sections");
1685 if (cursor
.toChild(qSections
)){
1686 for (int k
= 0; k
< j
; ++k
) {
1687 cursor
.toNextSibling(qSections
);
1689 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2 sections2
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
)cursor
.getObject();
1690 sections2
.addNewSection().setSectionType(EfiSectionType
.Enum
.forString(type
));
1695 public void removeBuildOptionsFfsSectionsSectionsSection(int i
, int j
, int k
) {
1696 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1697 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1698 if (sections
== null) {
1701 XmlCursor cursor
= sections
.newCursor();
1702 QName qSections
= new QName(xmlNs
, "Sections");
1703 if (cursor
.toChild(qSections
)) {
1704 for (int l
= 0; l
< j
; ++l
) {
1705 cursor
.toNextSibling(qSections
);
1707 if (cursor
.toFirstChild()) {
1709 for (; m
< k
; ++m
) {
1710 cursor
.toNextSibling();
1722 public void updateBuildOptionsFfsSectionsSectionsSection(int i
, int j
, int k
, String type
) {
1723 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1724 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1725 if (sections
== null) {
1728 XmlCursor cursor
= sections
.newCursor();
1729 QName qSections
= new QName(xmlNs
, "Sections");
1730 if (cursor
.toChild(qSections
)) {
1731 for (int l
= 0; l
< j
; ++l
) {
1732 cursor
.toNextSibling(qSections
);
1734 if (cursor
.toFirstChild()) {
1735 for (int m
= 0; m
< k
; ++m
) {
1736 cursor
.toNextSibling();
1738 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section section
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section
)cursor
.getObject();
1739 section
.setSectionType(EfiSectionType
.Enum
.forString(type
));
1745 public void getBuildOptionsFfsSectionsSectionsSection(int i
, int j
, ArrayList
<String
> al
) {
1746 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1750 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1751 XmlCursor cursor
= sections
.newCursor();
1752 QName qSections
= new QName(xmlNs
, "Sections");
1753 if (cursor
.toChild(qSections
)){
1754 for (int k
= 0; k
< j
; ++k
) {
1755 cursor
.toNextSibling(qSections
);
1757 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2 sections2
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
)cursor
.getObject();
1758 if (sections2
.getSectionList() == null){
1762 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section
> li
= sections2
.getSectionList().listIterator();
1763 while(li
.hasNext()) {
1764 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section section
= li
.next();
1765 if (section
.isSetSectionType()) {
1766 al
.add(section
.getSectionType().toString());
1775 public int getBuildOptionsFfsCount(){
1776 if (getfpdBuildOpts().getFfsList() == null) {
1779 return getfpdBuildOpts().getFfsList().size();
1782 public void getBuildOptionsFfsKey(String
[][] saa
) {
1783 if (getfpdBuildOpts().getFfsList() == null) {
1786 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
> li
= getfpdBuildOpts().getFfsList().listIterator();
1788 while(li
.hasNext()){
1789 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= li
.next();
1790 saa
[i
][0] = ffs
.getFfsKey();
1795 public void updateBuildOptionsFfsKey(int i
, String key
) {
1796 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1800 /**Get ith FFS key and contents.
1803 public void getBuildOptionsFfs(int i
, String
[] sa
, LinkedHashMap
<String
, String
> ffsAttribMap
, ArrayList
<String
> firstLevelSections
, ArrayList
<String
> firstLevelSection
) {
1804 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1808 sa
[0] = ffs
.getFfsKey();
1809 if (ffs
.getSections() != null) {
1810 if(ffs
.getSections().getEncapsulationType() != null){
1811 sa
[1] = ffs
.getSections().getEncapsulationType();
1813 if (ffs
.getSections().getSectionList() != null){
1814 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Section
> li
= ffs
.getSections().getSectionList().listIterator();
1815 while (li
.hasNext()) {
1816 firstLevelSection
.add(li
.next().getSectionType().toString());
1819 if (ffs
.getSections().getSectionsList() != null) {
1820 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
> li
= ffs
.getSections().getSectionsList().listIterator();
1821 while(li
.hasNext()) {
1822 firstLevelSections
.add(li
.next().getEncapsulationType());
1826 if (ffs
.getAttributeList() != null) {
1827 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute
> li
= ffs
.getAttributeList().listIterator();
1828 while(li
.hasNext()) {
1829 BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute attrib
= li
.next();
1830 ffsAttribMap
.put(attrib
.getName(), attrib
.getValue());
1839 private BuildOptionsDocument
.BuildOptions
.Ffs
getFfs(int i
) {
1840 XmlObject o
= getfpdBuildOpts();
1841 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= null;
1843 XmlCursor cursor
= o
.newCursor();
1844 QName qFfs
= new QName(xmlNs
, "Ffs");
1845 if (cursor
.toChild(qFfs
)) {
1846 for (int j
= 0; j
< i
; ++j
) {
1847 cursor
.toNextSibling(qFfs
);
1849 ffs
= (BuildOptionsDocument
.BuildOptions
.Ffs
)cursor
.getObject();
1855 public void removeBuildOptionsFfs(int i
) {
1856 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1861 XmlCursor cursor
= ffs
.newCursor();
1868 public PlatformDefinitionsDocument
.PlatformDefinitions
getfpdPlatformDefs(){
1869 if (fpdPlatformDefs
== null){
1870 fpdPlatformDefs
= fpdRoot
.addNewPlatformDefinitions();
1872 return fpdPlatformDefs
;
1875 public void getPlatformDefsSupportedArchs(Vector
<Object
> archs
){
1876 if (getfpdPlatformDefs().getSupportedArchitectures() == null) {
1879 ListIterator li
= getfpdPlatformDefs().getSupportedArchitectures().listIterator();
1880 while(li
.hasNext()) {
1881 archs
.add(li
.next());
1885 public void setPlatformDefsSupportedArchs(Vector
<Object
> archs
) {
1886 if (archs
!= null) {
1887 getfpdPlatformDefs().setSupportedArchitectures(archs
);
1890 // XmlCursor cursor = getfpdPlatformDefs().newCursor();
1891 // if (cursor.toChild(xmlNs, "SupportedArchitectures")) {
1892 // cursor.removeXml();
1894 // cursor.dispose();
1898 public void getPlatformDefsBuildTargets(Vector
<Object
> targets
) {
1899 if (getfpdPlatformDefs().getBuildTargets() == null) {
1902 ListIterator li
= getfpdPlatformDefs().getBuildTargets().listIterator();
1903 while(li
.hasNext()) {
1904 targets
.add(li
.next());
1908 public void setPlatformDefsBuildTargets(Vector
<Object
> targets
) {
1909 getfpdPlatformDefs().setBuildTargets(targets
);
1912 public void genPlatformDefsSkuInfo(String id
, String name
) {
1913 SkuInfoDocument
.SkuInfo skuInfo
= null;
1914 if (getfpdPlatformDefs().getSkuInfo() == null) {
1915 skuInfo
= getfpdPlatformDefs().addNewSkuInfo();
1917 skuInfo
= getfpdPlatformDefs().getSkuInfo();
1918 if (skuInfo
.getUiSkuNameList() == null || skuInfo
.getUiSkuNameList().size() == 0) {
1919 SkuInfoDocument
.SkuInfo
.UiSkuName skuName
= skuInfo
.addNewUiSkuName();
1920 skuName
.setSkuID(new BigInteger("0"));
1921 skuName
.setStringValue("DEFAULT");
1923 if (id
.equals("0")) {
1926 SkuInfoDocument
.SkuInfo
.UiSkuName skuName
= skuInfo
.addNewUiSkuName();
1927 skuName
.setSkuID(new BigInteger(id
));
1928 skuName
.setStringValue(name
);
1931 public int getPlatformDefsSkuInfoCount(){
1932 if (getfpdPlatformDefs().getSkuInfo() == null || getfpdPlatformDefs().getSkuInfo().getUiSkuNameList() == null) {
1935 return getfpdPlatformDefs().getSkuInfo().getUiSkuNameList().size();
1938 public void getPlatformDefsSkuInfos(String
[][] saa
){
1939 if (getfpdPlatformDefs().getSkuInfo() == null || getfpdPlatformDefs().getSkuInfo().getUiSkuNameList() == null) {
1943 List
<SkuInfoDocument
.SkuInfo
.UiSkuName
> l
= getfpdPlatformDefs().getSkuInfo().getUiSkuNameList();
1944 ListIterator
<SkuInfoDocument
.SkuInfo
.UiSkuName
> li
= l
.listIterator();
1946 while(li
.hasNext()) {
1947 SkuInfoDocument
.SkuInfo
.UiSkuName sku
= li
.next();
1948 saa
[i
][0] = sku
.getSkuID()+"";
1949 saa
[i
][1] = sku
.getStringValue();
1954 public void removePlatformDefsSkuInfo(int i
) {
1955 SkuInfoDocument
.SkuInfo skuInfo
= getfpdPlatformDefs().getSkuInfo();
1956 if (skuInfo
== null || i
== 0) {
1960 XmlCursor cursor
= skuInfo
.newCursor();
1961 if (cursor
.toFirstChild()) {
1962 for (int j
= 0; j
< i
; ++j
) {
1963 cursor
.toNextSibling();
1970 public void updatePlatformDefsSkuInfo(int i
, String id
, String name
) {
1971 SkuInfoDocument
.SkuInfo skuInfo
= getfpdPlatformDefs().getSkuInfo();
1972 if (skuInfo
== null || i
== 0) {
1976 XmlCursor cursor
= skuInfo
.newCursor();
1977 if (cursor
.toFirstChild()) {
1978 for (int j
= 0; j
< i
; ++j
) {
1979 cursor
.toNextSibling();
1981 SkuInfoDocument
.SkuInfo
.UiSkuName sku
= (SkuInfoDocument
.SkuInfo
.UiSkuName
)cursor
.getObject();
1982 sku
.setSkuID(new BigInteger(id
));
1983 sku
.setStringValue(name
);
1988 public String
getPlatformDefsInterDir(){
1989 if (getfpdPlatformDefs().getIntermediateDirectories() == null) {
1992 return getfpdPlatformDefs().getIntermediateDirectories().toString();
1995 public void setPlatformDefsInterDir(String interDir
){
1996 getfpdPlatformDefs().setIntermediateDirectories(IntermediateOutputType
.Enum
.forString(interDir
));
1999 public String
getPlatformDefsOutputDir() {
2000 return getfpdPlatformDefs().getOutputDirectory();
2003 public void setPlatformDefsOutputDir(String outputDir
) {
2004 if (outputDir
!= null && outputDir
.length() > 0) {
2005 getfpdPlatformDefs().setOutputDirectory(outputDir
);
2008 XmlCursor cursor
= getfpdPlatformDefs().newCursor();
2009 if (cursor
.toChild(new QName(xmlNs
, "OutputDirectory"))) {
2016 public FlashDocument
.Flash
getfpdFlash() {
2017 if (fpdFlash
== null) {
2018 fpdFlash
= fpdRoot
.addNewFlash();
2023 public void genFlashDefinitionFile(String file
) {
2024 FlashDefinitionFileDocument
.FlashDefinitionFile fdf
= getfpdFlash().getFlashDefinitionFile();
2026 fdf
= getfpdFlash().addNewFlashDefinitionFile();
2029 fdf
.setStringValue(file
);
2032 public String
getFlashDefinitionFile() {
2033 FlashDefinitionFileDocument
.FlashDefinitionFile fdf
= getfpdFlash().getFlashDefinitionFile();
2038 return fdf
.getStringValue();
2041 public void genFvImagesNameValue(String name
, String value
) {
2043 FvImagesDocument
.FvImages fi
= getfpdFlash().getFvImages();
2045 fi
= getfpdFlash().addNewFvImages();
2048 FvImagesDocument
.FvImages
.NameValue nv
= fi
.addNewNameValue();
2053 public void removeFvImagesNameValue(int i
){
2055 XmlObject o
= getfpdFlash().getFvImages();
2060 QName qNameValue
= new QName(xmlNs
, "NameValue");
2061 XmlCursor cursor
= o
.newCursor();
2062 if (cursor
.toChild(qNameValue
)) {
2063 for (int j
= 0; j
< i
; ++j
) {
2064 cursor
.toNextSibling(qNameValue
);
2071 public void updateFvImagesNameValue(int i
, String name
, String value
){
2073 XmlObject o
= getfpdFlash().getFvImages();
2078 QName qNameValue
= new QName(xmlNs
, "NameValue");
2079 XmlCursor cursor
= o
.newCursor();
2080 if (cursor
.toChild(qNameValue
)) {
2081 for (int j
= 0; j
< i
; ++j
) {
2082 cursor
.toNextSibling(qNameValue
);
2084 FvImagesDocument
.FvImages
.NameValue nv
= (FvImagesDocument
.FvImages
.NameValue
)cursor
.getObject();
2091 public int getFvImagesNameValueCount() {
2093 FvImagesDocument
.FvImages fi
= null;
2094 if ((fi
= getfpdFlash().getFvImages()) == null || fi
.getNameValueList() == null) {
2097 return fi
.getNameValueList().size();
2100 public void getFvImagesNameValues(String
[][] nv
) {
2102 FvImagesDocument
.FvImages fi
= getfpdFlash().getFvImages();
2106 List
<FvImagesDocument
.FvImages
.NameValue
> l
= fi
.getNameValueList();
2108 ListIterator li
= l
.listIterator();
2109 while (li
.hasNext()) {
2110 FvImagesDocument
.FvImages
.NameValue e
= (FvImagesDocument
.FvImages
.NameValue
) li
2112 nv
[i
][0] = e
.getName();
2113 nv
[i
][1] = e
.getValue();
2119 public void genFvImagesFvImage(String
[] names
, String types
, Map
<String
, String
> options
) {
2121 FvImagesDocument
.FvImages fis
= null;
2122 if ((fis
= getfpdFlash().getFvImages()) == null) {
2123 fis
= getfpdFlash().addNewFvImages();
2127 //gen FvImage with FvImageNames array
2129 FvImagesDocument
.FvImages
.FvImage fi
= fis
.addNewFvImage();
2130 for (int i
= 0; i
< names
.length
; ++i
) {
2131 fi
.addFvImageNames(names
[i
]);
2133 fi
.setType(FvImageTypes
.Enum
.forString(types
));
2134 if (options
!= null){
2135 setFvImagesFvImageFvImageOptions(options
, fi
);
2139 private void setFvImagesFvImageFvImageOptions(Map
<String
, String
> options
, FvImagesDocument
.FvImages
.FvImage fi
){
2140 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions fio
= fi
.getFvImageOptions();
2142 fio
= fi
.addNewFvImageOptions();
2145 Set
<String
> key
= options
.keySet();
2146 Iterator
<String
> i
= key
.iterator();
2147 while (i
.hasNext()) {
2149 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nv
= fio
.addNewNameValue();
2150 String k
= (String
)i
.next();
2153 nv
.setValue((String
)options
.get(k
));
2160 public void removeFvImagesFvImage(int i
) {
2162 XmlObject o
= getfpdFlash().getFvImages();
2167 QName qFvImage
= new QName(xmlNs
, "FvImage");
2168 XmlCursor cursor
= o
.newCursor();
2169 if (cursor
.toChild(qFvImage
)) {
2170 for (int j
= 0; j
< i
; ++j
) {
2171 cursor
.toNextSibling(qFvImage
);
2178 public void updateFvImagesFvImage(int i
, String
[] names
, String types
, Map
<String
, String
> options
){
2180 XmlObject o
= getfpdFlash().getFvImages();
2184 XmlCursor cursor
= o
.newCursor();
2185 QName qFvImage
= new QName(xmlNs
, "FvImage");
2186 if (cursor
.toChild(qFvImage
)) {
2187 for (int j
= 0; j
< i
; ++j
) {
2188 cursor
.toNextSibling(qFvImage
);
2190 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
2191 fi
.setType(FvImageTypes
.Enum
.forString(types
));
2194 // remove old FvImageNames before adding new ones
2196 QName qFvImageNames
= new QName(xmlNs
, "FvImageNames");
2197 cursor
.toChild(qFvImageNames
);
2199 while (cursor
.toNextSibling(qFvImageNames
)) {
2203 for (int k
= 0; k
< names
.length
; ++k
) {
2204 fi
.addFvImageNames(names
[k
]);
2207 // remove old FvImageOptions before adding new options
2209 QName qFvImageOptions
= new QName(xmlNs
, "FvImageOptions");
2210 cursor
.toNextSibling(qFvImageOptions
);
2213 setFvImagesFvImageFvImageOptions(options
, fi
);
2218 public int getFvImagesFvImageCount() {
2220 if (getfpdFlash().getFvImages() == null || getfpdFlash().getFvImages().getFvImageList() == null) {
2223 return getfpdFlash().getFvImages().getFvImageList().size();
2226 /**Only Get Fv image setting - name and type.
2229 public void getFvImagesFvImages(String
[][] saa
) {
2231 if (getfpdFlash().getFvImages() == null) {
2234 List
<FvImagesDocument
.FvImages
.FvImage
> l
= getfpdFlash().getFvImages().getFvImageList();
2238 ListIterator li
= l
.listIterator();
2240 while(li
.hasNext()) {
2241 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)li
.next();
2243 // get FvImageNames array, space separated
2245 List
<String
> lfn
= fi
.getFvImageNamesList();
2246 ListIterator lfni
= lfn
.listIterator();
2248 while (lfni
.hasNext()) {
2249 saa
[i
][0] += (String
)lfni
.next();
2252 saa
[i
][0] = saa
[i
][0].trim();
2254 saa
[i
][1] = fi
.getType()+"";
2260 /**Get FvImage Options for FvImage i
2261 * @param i the ith FvImage
2263 public void getFvImagesFvImageOptions(int i
, Map
<String
, String
> m
) {
2264 XmlObject o
= getfpdFlash().getFvImages();
2268 XmlCursor cursor
= o
.newCursor();
2269 QName qFvImage
= new QName(xmlNs
, "FvImage");
2270 if (cursor
.toChild(qFvImage
)) {
2271 for (int j
= 0; j
< i
; ++j
) {
2272 cursor
.toNextSibling(qFvImage
);
2274 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
2275 if (fi
.getFvImageOptions() == null || fi
.getFvImageOptions().getNameValueList() == null){
2278 ListIterator
<FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
> li
= fi
.getFvImageOptions().getNameValueList().listIterator();
2279 while(li
.hasNext()){
2280 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nv
= li
.next();
2281 m
.put(nv
.getName(), nv
.getValue());
2287 Get platform header element
2288 @return PlatformHeaderDocument.PlatformHeader
2290 public PlatformHeaderDocument
.PlatformHeader
getFpdHdr() {
2291 if (fpdHdr
== null) {
2292 fpdHdr
= fpdRoot
.addNewPlatformHeader();
2294 genPlatformDefsSkuInfo("0", "DEFAULT");
2298 public String
getFpdHdrPlatformName() {
2299 return getFpdHdr().getPlatformName();
2302 public String
getFpdHdrGuidValue() {
2303 return getFpdHdr().getGuidValue();
2306 public String
getFpdHdrVer() {
2307 return getFpdHdr().getVersion();
2310 public String
getFpdHdrAbs() {
2311 return getFpdHdr().getAbstract();
2314 public String
getFpdHdrDescription() {
2315 return getFpdHdr().getDescription();
2318 public String
getFpdHdrCopyright() {
2319 return getFpdHdr().getCopyright();
2322 public String
getFpdHdrLicense() {
2323 LicenseDocument
.License l
= getFpdHdr().getLicense();
2327 return l
.getStringValue();
2330 public String
getFpdHdrUrl() {
2331 LicenseDocument
.License l
= getFpdHdr().getLicense();
2338 public String
getFpdHdrSpec() {
2340 return "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052";
2341 // return getFpdHdr().getSpecification();
2344 public void setFpdHdrPlatformName(String name
){
2345 getFpdHdr().setPlatformName(name
);
2348 public void setFpdHdrGuidValue(String guid
){
2349 getFpdHdr().setGuidValue(guid
);
2352 public void setFpdHdrVer(String v
){
2353 getFpdHdr().setVersion(v
);
2356 public void setFpdHdrAbs(String abs
) {
2357 getFpdHdr().setAbstract(abs
);
2360 public void setFpdHdrDescription(String desc
){
2361 getFpdHdr().setDescription(desc
);
2364 public void setFpdHdrCopyright(String cr
) {
2365 getFpdHdr().setCopyright(cr
);
2368 public void setFpdHdrLicense(String license
){
2369 LicenseDocument
.License l
= getFpdHdr().getLicense();
2371 getFpdHdr().addNewLicense().setStringValue(license
);
2374 l
.setStringValue(license
);
2378 public void setFpdHdrUrl(String url
){
2379 LicenseDocument
.License l
= getFpdHdr().getLicense();
2385 public void setFpdHdrSpec(String s
){
2386 s
= "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052";
2387 getFpdHdr().setSpecification(s
);
2390 Save the processed xml contents to file
2392 @param fpdFile The file to save xml contents
2393 @throws IOException Exceptions during file operation
2395 public void saveAs(File fpdFile
) throws IOException
{
2397 XmlOptions options
= new XmlOptions();
2399 options
.setCharacterEncoding("UTF-8");
2400 options
.setSavePrettyPrint();
2401 options
.setSavePrettyPrintIndent(2);
2403 fpdd
.save(fpdFile
, options
);
2404 } catch (IOException e
) {
2405 e
.printStackTrace();
2410 private String
listToString(List l
) {
2415 ListIterator li
= l
.listIterator();
2416 while(li
.hasNext()) {
2424 class PcdItemTypeConflictException
extends Exception
{
2429 private static final long serialVersionUID
= 1L;
2430 private String details
= null;
2432 PcdItemTypeConflictException(String info
){
2436 public String
getMessage() {
2441 class PcdDeclNotFound
extends Exception
{
2446 private static final long serialVersionUID
= 1L;
2447 private String details
= null;
2449 PcdDeclNotFound(String info
) {
2453 public String
getMessage() {
2458 class PcdValueMalFormed
extends Exception
{
2463 private static final long serialVersionUID
= 1L;
2464 private String details
= null;
2466 PcdValueMalFormed(String info
) {
2470 public String
getMessage() {