63b9d6713d45194295fb9fcf6e344c58d779f2a1
[mirror_edk2.git] / Tools / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / platform / ui / FpdFileContents.java
1 /** @file
2 Java class FpdFileContents is used to parse fpd xml file.
3
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
9
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.
12 **/
13 package org.tianocore.frameworkwizard.platform.ui;
14
15 import java.io.File;
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;
24 import java.util.Map;
25 import java.util.Set;
26 import java.util.Vector;
27
28 import javax.xml.namespace.QName;
29
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;
64
65 /**
66 This class processes fpd file contents such as add remove xml elements.
67 @since PackageEditor 1.0
68 **/
69 public class FpdFileContents {
70
71 static final String xmlNs = "http://www.TianoCore.org/2006/Edk2.0";
72
73 private PlatformSurfaceAreaDocument fpdd = null;
74
75 private PlatformSurfaceAreaDocument.PlatformSurfaceArea fpdRoot = null;
76
77 private PlatformHeaderDocument.PlatformHeader fpdHdr = null;
78
79 private PlatformDefinitionsDocument.PlatformDefinitions fpdPlatformDefs = null;
80
81 private FlashDocument.Flash fpdFlash = null;
82
83 private BuildOptionsDocument.BuildOptions fpdBuildOpts = null;
84
85 private FrameworkModulesDocument.FrameworkModules fpdFrameworkModules = null;
86
87 private DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions fpdDynPcdBuildDefs = null;
88
89 private HashMap<String, ArrayList<String>> dynPcdMap = null;
90
91 /**
92 * look through all pcd data in all ModuleSA, create pcd -> ModuleSA mappings.
93 */
94 public void initDynPcdMap() {
95 if (dynPcdMap == null) {
96 dynPcdMap = new HashMap<String, ArrayList<String>>();
97 List<ModuleSADocument.ModuleSA> l = getfpdFrameworkModules().getModuleSAList();
98 if (l == null) {
99 removeElement(getfpdFrameworkModules());
100 fpdFrameworkModules = null;
101 return;
102 }
103 ListIterator<ModuleSADocument.ModuleSA> li = l.listIterator();
104 while (li.hasNext()) {
105 ModuleSADocument.ModuleSA msa = li.next();
106 if (msa.getPcdBuildDefinition() == null || msa.getPcdBuildDefinition().getPcdDataList() == null) {
107 continue;
108 }
109 String ModuleInfo = msa.getModuleGuid() + " " + msa.getModuleVersion() +
110 " " + msa.getPackageGuid() + " " + msa.getPackageVersion() + " " + listToString(msa.getSupArchList());
111 List<PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData> lp = msa.getPcdBuildDefinition().getPcdDataList();
112 ListIterator<PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData> lpi = lp.listIterator();
113 while (lpi.hasNext()) {
114 PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData pcdData = lpi.next();
115 String pcdKey = pcdData.getCName() + " " + pcdData.getTokenSpaceGuidCName();
116 if (dynPcdMap.get(pcdKey) == null) {
117 ArrayList<String> al = new ArrayList<String>();
118 al.add(ModuleInfo + " " + pcdData.getItemType().toString());
119 dynPcdMap.put(pcdKey, al);
120 }
121 else{
122 dynPcdMap.get(pcdKey).add(ModuleInfo + " " + pcdData.getItemType().toString());
123 }
124 }
125 }
126 }
127 }
128
129 public ArrayList<String> getDynPcdMapValue(String key) {
130 return dynPcdMap.get(key);
131 }
132 /**
133 Constructor to create a new spd file
134 **/
135 public FpdFileContents() {
136
137 fpdd = PlatformSurfaceAreaDocument.Factory.newInstance();
138 fpdRoot = fpdd.addNewPlatformSurfaceArea();
139
140 }
141
142 /**
143 Constructor for existing document object
144 @param psa
145 **/
146 public FpdFileContents(PlatformSurfaceAreaDocument.PlatformSurfaceArea fpd) {
147 fpdRoot = fpd;
148 fpdHdr = fpdRoot.getPlatformHeader();
149 fpdPlatformDefs = fpdRoot.getPlatformDefinitions();
150 fpdBuildOpts = fpdRoot.getBuildOptions();
151 fpdFrameworkModules = fpdRoot.getFrameworkModules();
152 fpdDynPcdBuildDefs = fpdRoot.getDynamicPcdBuildDefinitions();
153 fpdFlash = fpdRoot.getFlash();
154 }
155
156 /**
157 Constructor based on an existing spd file
158
159 @param f Existing spd file
160 **/
161 public FpdFileContents(File f) {
162 try {
163 fpdd = PlatformSurfaceAreaDocument.Factory.parse(f);
164 fpdRoot = fpdd.getPlatformSurfaceArea();
165 } catch (Exception e) {
166 System.out.println(e.toString());
167 }
168 }
169
170 public DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions getfpdDynPcdBuildDefs() {
171 if (fpdDynPcdBuildDefs == null){
172 fpdDynPcdBuildDefs = fpdRoot.addNewDynamicPcdBuildDefinitions();
173 }
174 return fpdDynPcdBuildDefs;
175 }
176
177 public FrameworkModulesDocument.FrameworkModules getfpdFrameworkModules() {
178 if (fpdFrameworkModules == null){
179 fpdFrameworkModules = fpdRoot.addNewFrameworkModules();
180 }
181 return fpdFrameworkModules;
182 }
183
184 public int getFrameworkModulesCount() {
185 if (getfpdFrameworkModules().getModuleSAList() == null || getfpdFrameworkModules().getModuleSAList().size() == 0){
186 removeElement(getfpdFrameworkModules());
187 fpdFrameworkModules = null;
188 return 0;
189 }
190 return getfpdFrameworkModules().getModuleSAList().size();
191 }
192
193 public void getFrameworkModulesInfo(String[][] saa) {
194 if (getFrameworkModulesCount() == 0){
195 return;
196 }
197
198 ListIterator li = getfpdFrameworkModules().getModuleSAList().listIterator();
199 int i = 0;
200 while(li.hasNext()) {
201 ModuleSADocument.ModuleSA msa = (ModuleSADocument.ModuleSA)li.next();
202 saa[i][0] = msa.getModuleGuid();
203 saa[i][1] = msa.getModuleVersion();
204
205 saa[i][2] = msa.getPackageGuid();
206 saa[i][3] = msa.getPackageVersion();
207 saa[i][4] = listToString(msa.getSupArchList());
208 ++i;
209 }
210 }
211
212 public void getFrameworkModuleInfo(int i, String[] sa) {
213 ModuleSADocument.ModuleSA msa = getModuleSA(i);
214 if (msa == null) {
215 return;
216 }
217 sa[0] = msa.getModuleGuid();
218 sa[1] = msa.getModuleVersion();
219 sa[2] = msa.getPackageGuid();
220 sa[3] = msa.getPackageVersion();
221 sa[4] = listToString(msa.getSupArchList());
222 }
223
224 public ModuleSADocument.ModuleSA getModuleSA(String key) {
225 String[] s = key.split(" ");
226 if (getfpdFrameworkModules().getModuleSAList() == null || getfpdFrameworkModules().getModuleSAList().size() == 0) {
227 removeElement(getfpdFrameworkModules());
228 fpdFrameworkModules = null;
229 return null;
230 }
231 ListIterator li = getfpdFrameworkModules().getModuleSAList().listIterator();
232 while(li.hasNext()) {
233 ModuleSADocument.ModuleSA msa = (ModuleSADocument.ModuleSA)li.next();
234 if (msa.getModuleGuid().equalsIgnoreCase(s[0]) && msa.getPackageGuid().equalsIgnoreCase(s[2])) {
235 if (msa.getModuleVersion() != null) {
236 if (!msa.getModuleVersion().equals(s[1])) {
237 continue;
238 }
239 }
240 if (msa.getPackageVersion() != null) {
241 if (!msa.getPackageVersion().equals(s[3])) {
242 continue;
243 }
244 }
245 //ToDo add arch check for s[4]
246 if (msa.getSupArchList() != null) {
247 if (!listToString(msa.getSupArchList()).equals(s[4])) {
248 continue;
249 }
250 }
251 return msa;
252 }
253 }
254 return null;
255 }
256
257 private ModuleSADocument.ModuleSA getModuleSA(int i) {
258 ModuleSADocument.ModuleSA msa = null;
259 if (fpdRoot.getFrameworkModules() == null) {
260 return null;
261 }
262 XmlCursor cursor = fpdRoot.getFrameworkModules().newCursor();
263 if (cursor.toFirstChild()) {
264 for (int j = 0; j < i; ++j) {
265 cursor.toNextSibling();
266 }
267 msa = (ModuleSADocument.ModuleSA)cursor.getObject();
268 }
269 cursor.dispose();
270 return msa;
271 }
272
273 public void removeModuleSA(int i) {
274 XmlObject o = fpdRoot.getFrameworkModules();
275 if (o == null) {
276 return;
277 }
278
279 XmlCursor cursor = o.newCursor();
280 if (cursor.toFirstChild()) {
281 for (int j = 0; j < i; ++j) {
282 cursor.toNextSibling();
283 }
284 //
285 // remove pcd from dynPcdMap, if DynamicPcdBuildData exists, remove them too.
286 //
287 ModuleSADocument.ModuleSA moduleSa = (ModuleSADocument.ModuleSA)cursor.getObject();
288 String moduleInfo = moduleSa.getModuleGuid() + " " + moduleSa.getModuleVersion() + " " +
289 moduleSa.getPackageGuid()+ " " + moduleSa.getPackageVersion() + " " + listToString(moduleSa.getSupArchList());
290 PcdBuildDefinitionDocument.PcdBuildDefinition pcdBuildDef = moduleSa.getPcdBuildDefinition();
291 if (pcdBuildDef != null && pcdBuildDef.getPcdDataList() != null) {
292 ListIterator<PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData> li = pcdBuildDef.getPcdDataList().listIterator();
293 while(li.hasNext()) {
294 PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData pcdData = li.next();
295 maintainDynPcdMap(pcdData.getCName() + " " + pcdData.getTokenSpaceGuidCName(), moduleInfo);
296 }
297 }
298
299 cursor.push();
300 cursor.toPrevToken();
301 if (cursor.isComment()) {
302 cursor.removeXml();
303 }
304 cursor.pop();
305 cursor.removeXml();
306 if (getFrameworkModulesCount() == 0) {
307 cursor.toParent();
308 cursor.removeXml();
309 }
310 }
311 cursor.dispose();
312 }
313
314 private void maintainDynPcdMap(String pcdKey, String moduleInfo) {
315
316 ArrayList<String> al = dynPcdMap.get(pcdKey);
317 if (al == null) {
318 return;
319 }
320 String[] s = moduleInfo.split(" ");
321 for(int i = 0; i < al.size(); ++i){
322 String consumer = al.get(i);
323 if (consumer.contains(s[0]) && consumer.contains(s[2])){
324 String[] consumerPart = consumer.split(" ");
325 if (!consumerPart[4].equals(s[4])) {
326 continue;
327 }
328 al.remove(consumer);
329 break;
330 }
331 }
332
333 if (al.size() == 0) {
334 dynPcdMap.remove(pcdKey);
335 String[] s1 = pcdKey.split(" ");
336 removeDynamicPcdBuildData(s1[0], s1[1]);
337 }
338
339 }
340 //
341 // key for ModuleSA : "ModuleGuid ModuleVer PackageGuid PackageVer Arch"
342 //
343 public int getPcdDataCount(int i){
344 ModuleSADocument.ModuleSA msa = getModuleSA(i);
345
346 if (msa == null || msa.getPcdBuildDefinition() == null || msa.getPcdBuildDefinition().getPcdDataList() == null){
347 return 0;
348 }
349 return msa.getPcdBuildDefinition().getPcdDataList().size();
350
351 }
352
353 public void getPcdData(int i, String[][] saa) {
354 ModuleSADocument.ModuleSA msa = getModuleSA(i);
355
356 if (msa == null || msa.getPcdBuildDefinition() == null || msa.getPcdBuildDefinition().getPcdDataList() == null){
357 return;
358 }
359 ListIterator<PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData>li = msa.getPcdBuildDefinition().getPcdDataList().listIterator();
360 for (int k = 0; k < saa.length; ++k) {
361 PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData pcdData = li.next();
362 saa[k][0] = pcdData.getCName();
363 saa[k][1] = pcdData.getTokenSpaceGuidCName();
364 saa[k][2] = pcdData.getItemType()+"";
365 saa[k][3] = pcdData.getToken().toString();
366 saa[k][4] = pcdData.getMaxDatumSize()+"";
367 saa[k][5] = pcdData.getDatumType()+"";
368 saa[k][6] = pcdData.getValue();
369
370 }
371 }
372
373 public void updatePcdData(String key, String cName, String tsGuid, String itemType, String maxSize, String value){
374 ModuleSADocument.ModuleSA msa = getModuleSA(key);
375 if (msa == null || msa.getPcdBuildDefinition() == null){
376 return;
377 }
378
379 XmlCursor cursor = msa.getPcdBuildDefinition().newCursor();
380 if (cursor.toFirstChild()){
381 do {
382 PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData pcdData = (PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData)cursor.getObject();
383 if (pcdData.getCName().equals(cName) && pcdData.getTokenSpaceGuidCName().equals(tsGuid)) {
384 pcdData.setItemType(PcdItemTypes.Enum.forString(itemType));
385 if(pcdData.getDatumType().equals("VOID*")) {
386 pcdData.setMaxDatumSize(new Integer(maxSize));
387 }
388 pcdData.setValue(value);
389 break;
390 }
391 }
392 while(cursor.toNextSibling());
393 }
394 cursor.dispose();
395 }
396
397 /**Get original Pcd info from MSA & SPD files.
398 * @param mi ModuleIdentification from which MSA & SPD come
399 * @param cName PCD cName
400 * @param sa Results: HelpText, Original item type.
401 * @return
402 */
403 public boolean getPcdBuildDataInfo(ModuleIdentification mi, String cName, String[] sa) throws Exception{
404 try {
405
406 ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = (ModuleSurfaceAreaDocument.ModuleSurfaceArea)GlobalData.getModuleXmlObject(mi);
407 if (msa.getPcdCoded() == null) {
408 return false;
409 }
410
411 Map<String, XmlObject> m = new HashMap<String, XmlObject>();
412 m.put("ModuleSurfaceArea", msa);
413 SurfaceAreaQuery.setDoc(m);
414 PackageIdentification[] depPkgs = SurfaceAreaQuery.getDependencePkg(null);
415 //
416 // First look through MSA pcd entries.
417 //
418 List<PcdCodedDocument.PcdCoded.PcdEntry> l = msa.getPcdCoded().getPcdEntryList();
419 ListIterator li = l.listIterator();
420 while(li.hasNext()) {
421 PcdCodedDocument.PcdCoded.PcdEntry msaPcd = (PcdCodedDocument.PcdCoded.PcdEntry)li.next();
422 if (!msaPcd.getCName().equals(cName)) {
423 continue;
424 }
425 PcdDeclarationsDocument.PcdDeclarations.PcdEntry spdPcd = LookupPcdDeclaration(msaPcd, depPkgs);
426 if (spdPcd == null) {
427 //
428 // ToDo Error
429 //
430 throw new PcdDeclNotFound(mi.getName() + " " + msaPcd.getCName());
431 }
432 //
433 // Get Pcd help text and original item type.
434 //
435 sa[0] = spdPcd.getHelpText() + msaPcd.getHelpText();
436 sa[1] = msaPcd.getPcdItemType()+"";
437 return true;
438 }
439
440
441 }
442 catch (Exception e){
443 e.printStackTrace();
444 throw e;
445 }
446
447 return false;
448 }
449
450 /**Remove PCDBuildDefinition entries from ModuleSA
451 * @param moduleKey identifier of ModuleSA.
452 * @param consumer where these entries come from.
453 */
454 public void removePcdData(String moduleKey, ModuleIdentification consumer) {
455 try {
456 ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = (ModuleSurfaceAreaDocument.ModuleSurfaceArea)GlobalData.getModuleXmlObject(consumer);
457 if (msa.getPcdCoded() == null) {
458 return;
459 }
460
461 List<PcdCodedDocument.PcdCoded.PcdEntry> l = msa.getPcdCoded().getPcdEntryList();
462 ListIterator li = l.listIterator();
463
464 while(li.hasNext()) {
465 PcdCodedDocument.PcdCoded.PcdEntry msaPcd = (PcdCodedDocument.PcdCoded.PcdEntry)li.next();
466 ModuleSADocument.ModuleSA moduleSA = getModuleSA(moduleKey);
467 if (moduleSA.getPcdBuildDefinition() != null) {
468 XmlCursor cursor = moduleSA.getPcdBuildDefinition().newCursor();
469 if (cursor.toFirstChild()) {
470 PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData pcdData = (PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData) cursor
471 .getObject();
472 if (msaPcd.getCName().equals(pcdData.getCName())
473 && msaPcd.getTokenSpaceGuidCName().equals(pcdData.getTokenSpaceGuidCName())) {
474
475 maintainDynPcdMap(pcdData.getCName() + " " + pcdData.getTokenSpaceGuidCName(), moduleKey);
476 cursor.removeXml();
477 break;
478 }
479 while (cursor.toNextSibling()) {
480 pcdData = (PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData) cursor.getObject();
481 if (msaPcd.getCName().equals(pcdData.getCName())
482 && msaPcd.getTokenSpaceGuidCName().equals(pcdData.getTokenSpaceGuidCName())) {
483 maintainDynPcdMap(pcdData.getCName() + " " + pcdData.getTokenSpaceGuidCName(),
484 moduleKey);
485 cursor.removeXml();
486 break;
487 }
488 }
489 }
490 cursor.dispose();
491 }
492 }
493
494 }
495 catch (Exception e){
496 e.printStackTrace();
497
498 }
499 }
500 //
501 // key for ModuleSA : "ModuleGuid ModuleVer PackageGuid PackageVer Arch"
502 //
503 public int getLibraryInstancesCount(String key) {
504 ModuleSADocument.ModuleSA msa = getModuleSA(key);
505 if (msa == null || msa.getLibraries() == null || msa.getLibraries().getInstanceList() == null){
506 return 0;
507 }
508 return msa.getLibraries().getInstanceList().size();
509 }
510
511 public void getLibraryInstances(String key, String[][] saa){
512 ModuleSADocument.ModuleSA msa = getModuleSA(key);
513 if (msa == null || msa.getLibraries() == null || msa.getLibraries().getInstanceList() == null){
514 return ;
515 }
516
517 ListIterator<LibrariesDocument.Libraries.Instance> li = msa.getLibraries().getInstanceList().listIterator();
518 for (int i = 0; i < saa.length; ++i) {
519 LibrariesDocument.Libraries.Instance instance = li.next();
520 saa[i][1] = instance.getModuleGuid();
521 saa[i][2] = instance.getModuleVersion();
522 saa[i][3] = instance.getPackageGuid();
523 saa[i][4] = instance.getPackageVersion();
524 }
525 }
526
527 public void removeLibraryInstance(String key, int i) {
528 ModuleSADocument.ModuleSA msa = getModuleSA(key);
529 if (msa == null || msa.getLibraries() == null){
530 return ;
531 }
532
533 XmlCursor cursor = msa.getLibraries().newCursor();
534 if (cursor.toFirstChild()) {
535 for (int j = 0; j < i; ++j) {
536 cursor.toNextSibling();
537 }
538 cursor.push();
539 cursor.toPrevToken();
540 if (cursor.isComment()) {
541 cursor.removeXml();
542 }
543 cursor.pop();
544 cursor.removeXml();
545 if (getLibraryInstancesCount(key) == 0) {
546 cursor.toParent();
547 cursor.removeXml();
548 }
549 }
550
551 cursor.dispose();
552 }
553
554 public void genLibraryInstance(ModuleIdentification libMi, String key) {
555 ModuleSADocument.ModuleSA msa = getModuleSA(key);
556 if (msa == null){
557 msa = getfpdFrameworkModules().addNewModuleSA();
558 }
559 LibrariesDocument.Libraries libs = msa.getLibraries();
560 if(libs == null){
561 libs = msa.addNewLibraries();
562 }
563
564 String mn = libMi.getName();
565 String mg = libMi.getGuid();
566 String mv = libMi.getVersion();
567 String pn = libMi.getPackage().getName();
568 String pg = libMi.getPackage().getGuid();
569 String pv = libMi.getPackage().getVersion();
570 LibrariesDocument.Libraries.Instance instance = libs.addNewInstance();
571 XmlCursor cursor = instance.newCursor();
572 try{
573 String comment = "Pkg: " + pn + " Mod: " + mn
574 + " Path: " + GlobalData.getMsaFile(libMi).getPath();
575 cursor.insertComment(comment);
576 }
577 catch (Exception e){
578 e.printStackTrace();
579 }
580 finally {
581 cursor.dispose();
582 }
583
584 instance.setModuleGuid(mg);
585 instance.setModuleVersion(mv);
586 instance.setPackageGuid(pg);
587 instance.setPackageVersion(pv);
588
589 }
590
591 public String getFvBinding(String moduleKey){
592 ModuleSADocument.ModuleSA msa = getModuleSA(moduleKey);
593 if (msa == null || msa.getModuleSaBuildOptions() == null) {
594 return null;
595 }
596 return msa.getModuleSaBuildOptions().getFvBinding();
597 }
598
599 public void setFvBinding(String moduleKey, String fvBinding){
600 ModuleSADocument.ModuleSA msa = getModuleSA(moduleKey);
601 if (msa == null ) {
602 return;
603 }
604 if(msa.getModuleSaBuildOptions() == null){
605 msa.addNewModuleSaBuildOptions().setFvBinding(fvBinding);
606 return;
607 }
608 msa.getModuleSaBuildOptions().setFvBinding(fvBinding);
609 }
610
611 public String getFfsFileNameGuid(String moduleKey){
612 ModuleSADocument.ModuleSA msa = getModuleSA(moduleKey);
613 if (msa == null || msa.getModuleSaBuildOptions() == null) {
614 return null;
615 }
616 return msa.getModuleSaBuildOptions().getFfsFileNameGuid();
617 }
618
619 public void setFfsFileNameGuid(String moduleKey, String fileGuid){
620 ModuleSADocument.ModuleSA msa = getModuleSA(moduleKey);
621 if (msa == null ) {
622 return;
623 }
624 if(msa.getModuleSaBuildOptions() == null){
625 msa.addNewModuleSaBuildOptions();
626
627 }
628 ModuleSaBuildOptionsDocument.ModuleSaBuildOptions msaBuildOpts= msa.getModuleSaBuildOptions();
629 if (fileGuid != null) {
630 msaBuildOpts.setFfsFileNameGuid(fileGuid);
631 }
632 else{
633 XmlCursor cursor = msaBuildOpts.newCursor();
634 if (cursor.toChild(xmlNs, "FfsFileNameGuid")) {
635 cursor.removeXml();
636 }
637 cursor.dispose();
638 }
639
640 }
641
642 public String getFfsFormatKey(String moduleKey){
643 ModuleSADocument.ModuleSA msa = getModuleSA(moduleKey);
644 if (msa == null || msa.getModuleSaBuildOptions() == null) {
645 return null;
646 }
647 return msa.getModuleSaBuildOptions().getFfsFormatKey();
648 }
649
650 public void setFfsFormatKey(String moduleKey, String ffsKey){
651 ModuleSADocument.ModuleSA msa = getModuleSA(moduleKey);
652 if (msa == null ) {
653 return;
654 }
655 if(msa.getModuleSaBuildOptions() == null){
656 msa.addNewModuleSaBuildOptions().setFfsFormatKey(ffsKey);
657 return;
658 }
659 msa.getModuleSaBuildOptions().setFfsFormatKey(ffsKey);
660 }
661
662 public void getModuleSAOptions(String moduleKey, String[][] saa) {
663 ModuleSADocument.ModuleSA msa = getModuleSA(moduleKey);
664 if (msa == null || msa.getModuleSaBuildOptions() == null || msa.getModuleSaBuildOptions().getOptions() == null
665 || msa.getModuleSaBuildOptions().getOptions().getOptionList() == null) {
666 return ;
667 }
668
669 List<OptionDocument.Option> lOpt = msa.getModuleSaBuildOptions().getOptions().getOptionList();
670 ListIterator li = lOpt.listIterator();
671 int i = 0;
672 while(li.hasNext()) {
673 OptionDocument.Option opt = (OptionDocument.Option)li.next();
674 if (opt.getBuildTargets() != null) {
675 saa[i][0] = listToString(opt.getBuildTargets());
676 }
677 saa[i][1] = opt.getToolChainFamily();
678 saa[i][2] = opt.getTagName();
679 saa[i][3] = opt.getToolCode();
680
681 if (opt.getSupArchList() != null){
682 saa[i][4] = listToString(opt.getSupArchList());
683
684 }
685
686 saa[i][5] = opt.getStringValue();
687
688 ++i;
689 }
690 }
691
692 public int getModuleSAOptionsCount(String moduleKey){
693 ModuleSADocument.ModuleSA msa = getModuleSA(moduleKey);
694 if (msa == null || msa.getModuleSaBuildOptions() == null || msa.getModuleSaBuildOptions().getOptions() == null
695 || msa.getModuleSaBuildOptions().getOptions().getOptionList() == null) {
696 return 0;
697 }
698 return msa.getModuleSaBuildOptions().getOptions().getOptionList().size();
699 }
700
701 public void genModuleSAOptionsOpt(String moduleKey, Vector<Object> buildTargets, String toolChain, String tagName, String toolCmd, Vector<Object> archList, String contents) {
702 ModuleSADocument.ModuleSA msa = getModuleSA(moduleKey);
703 if (msa.getModuleSaBuildOptions() == null) {
704 msa.addNewModuleSaBuildOptions();
705 }
706 if (msa.getModuleSaBuildOptions().getOptions() == null){
707 msa.getModuleSaBuildOptions().addNewOptions();
708 }
709 OptionDocument.Option opt = msa.getModuleSaBuildOptions().getOptions().addNewOption();
710 setBuildOptionsOpt(buildTargets, toolChain, tagName, toolCmd, archList, contents, opt);
711 }
712
713 public void removeModuleSAOptionsOpt(String moduleKey, int i) {
714 ModuleSADocument.ModuleSA msa = getModuleSA(moduleKey);
715 if (msa.getModuleSaBuildOptions() == null || msa.getModuleSaBuildOptions().getOptions() == null) {
716 return ;
717 }
718 OptionsDocument.Options opts = msa.getModuleSaBuildOptions().getOptions();
719 XmlCursor cursor = opts.newCursor();
720 if (cursor.toFirstChild()) {
721 for (int j = 0; j < i; ++j){
722 cursor.toNextSibling();
723 }
724 cursor.removeXml();
725 }
726 cursor.dispose();
727 }
728
729 public void updateModuleSAOptionsOpt(String moduleKey, int i, Vector<Object> buildTargets, String toolChain, String tagName, String toolCmd, Vector<Object> archList, String contents) {
730 ModuleSADocument.ModuleSA msa = getModuleSA(moduleKey);
731 if (msa.getModuleSaBuildOptions() == null || msa.getModuleSaBuildOptions().getOptions() == null) {
732 return ;
733 }
734 OptionsDocument.Options opts = msa.getModuleSaBuildOptions().getOptions();
735 XmlCursor cursor = opts.newCursor();
736 if (cursor.toFirstChild()) {
737 for (int j = 0; j < i; ++j){
738 cursor.toNextSibling();
739 }
740 OptionDocument.Option opt = (OptionDocument.Option)cursor.getObject();
741 setBuildOptionsOpt(buildTargets, toolChain, tagName, toolCmd, archList, contents, opt);
742 }
743 cursor.dispose();
744 }
745
746 /**add pcd information of module mi to a ModuleSA.
747 * @param mi
748 * @param moduleSa if null, generate a new ModuleSA.
749 */
750 public void addFrameworkModulesPcdBuildDefs(ModuleIdentification mi, String arch, ModuleSADocument.ModuleSA moduleSa) throws Exception {
751 //ToDo add Arch filter
752
753 try {
754 if (moduleSa == null) {
755 moduleSa = genModuleSA(mi, arch);
756 }
757
758 ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = (ModuleSurfaceAreaDocument.ModuleSurfaceArea)GlobalData.getModuleXmlObject(mi);
759 if (msa.getPcdCoded() == null) {
760 return;
761 }
762
763 Map<String, XmlObject> m = new HashMap<String, XmlObject>();
764 m.put("ModuleSurfaceArea", msa);
765 SurfaceAreaQuery.setDoc(m);
766 PackageIdentification[] depPkgs = SurfaceAreaQuery.getDependencePkg(null);
767 //
768 // Implementing InitializePlatformPcdBuildDefinitions
769 //
770 List<PcdCodedDocument.PcdCoded.PcdEntry> l = msa.getPcdCoded().getPcdEntryList();
771 ListIterator li = l.listIterator();
772 while(li.hasNext()) {
773 PcdCodedDocument.PcdCoded.PcdEntry msaPcd = (PcdCodedDocument.PcdCoded.PcdEntry)li.next();
774 PcdDeclarationsDocument.PcdDeclarations.PcdEntry spdPcd = LookupPcdDeclaration(msaPcd, depPkgs);
775 if (spdPcd == null) {
776 //
777 // ToDo Error
778 //
779 throw new PcdDeclNotFound("No Declaration for PCD Entry " + msaPcd.getCName() + " in Module " + mi.getName());
780 }
781 //
782 // AddItem to ModuleSA PcdBuildDefinitions
783 //
784 String defaultVal = msaPcd.getDefaultValue() == null ? spdPcd.getDefaultValue() : msaPcd.getDefaultValue();
785
786 genPcdData(msaPcd.getCName(), spdPcd.getToken(), msaPcd.getTokenSpaceGuidCName(), msaPcd.getPcdItemType().toString(), spdPcd.getDatumType()+"", defaultVal, moduleSa);
787 }
788
789 }
790 catch (Exception e){
791
792 throw e;
793 }
794
795 }
796
797 private PcdDeclarationsDocument.PcdDeclarations.PcdEntry LookupPcdDeclaration (PcdCodedDocument.PcdCoded.PcdEntry msaPcd, PackageIdentification[] depPkgs) {
798
799 Map<String, XmlObject> m = new HashMap<String, XmlObject>();
800 PcdDeclarationsDocument.PcdDeclarations.PcdEntry spdPcd = null;
801 for (int i = 0; i < depPkgs.length; ++i) {
802 m.put("PackageSurfaceArea", GlobalData.getPackageXmlObject(depPkgs[i]));
803 SurfaceAreaQuery.setDoc(m);
804 XmlObject[] xo = SurfaceAreaQuery.getSpdPcdDeclarations();
805 if (xo == null) {
806 continue;
807 }
808 for (int j = 0; j < xo.length; ++j) {
809 spdPcd = (PcdDeclarationsDocument.PcdDeclarations.PcdEntry)xo[j];
810 if (msaPcd.getTokenSpaceGuidCName() == null) {
811 if (spdPcd.getCName().equals(msaPcd.getCName())) {
812 return spdPcd;
813 }
814 }
815 else{
816 if (spdPcd.getCName().equals(msaPcd.getCName()) && spdPcd.getTokenSpaceGuidCName().equals(msaPcd.getTokenSpaceGuidCName())) {
817 return spdPcd;
818 }
819 }
820
821 }
822
823 }
824 return null;
825 }
826
827 private ModuleSADocument.ModuleSA genModuleSA (ModuleIdentification mi, String arch) {
828 PackageIdentification pi = GlobalData.getPackageForModule(mi);
829 ModuleSADocument.ModuleSA msa = getfpdFrameworkModules().addNewModuleSA();
830 XmlCursor cursor = msa.newCursor();
831 try{
832 String comment = "Mod: " + mi.getName() + " Type: " + mi.getModuleType() + " Path: "
833 + GlobalData.getMsaFile(mi).getPath();
834 cursor.insertComment(comment);
835 }
836 catch(Exception e){
837 e.printStackTrace();
838 }
839 finally {
840 cursor.dispose();
841 }
842 msa.setModuleGuid(mi.getGuid());
843 msa.setModuleVersion(mi.getVersion());
844 msa.setPackageGuid(pi.getGuid());
845 msa.setPackageVersion(pi.getVersion());
846 if (arch != null) {
847 Vector<String> v = new Vector<String>();
848 v.add(arch);
849 msa.setSupArchList(v);
850 }
851
852 return msa;
853 }
854
855 private void genPcdData (String cName, Object token, String tsGuid, String itemType, String dataType, String defaultVal, ModuleSADocument.ModuleSA moduleSa)
856 throws PcdItemTypeConflictException, PcdValueMalFormed{
857 if (moduleSa.getPcdBuildDefinition() == null){
858 moduleSa.addNewPcdBuildDefinition();
859 }
860 //
861 // constructe pcd to modulesa mapping first.
862 // Attention : for any error condition, remove from map this pcd.
863 //
864 ArrayList<String> pcdConsumer = LookupPlatformPcdData(cName + " " + tsGuid);
865 if (pcdConsumer == null) {
866 pcdConsumer = new ArrayList<String>();
867 }
868 String listValue = moduleSa.getModuleGuid() + " " + moduleSa.getModuleVersion()
869 + " " + moduleSa.getPackageGuid() + " " + moduleSa.getPackageVersion() + " " + listToString(moduleSa.getSupArchList())
870 + " " + itemType;
871 pcdConsumer.add(listValue);
872 dynPcdMap.put(cName + " " + tsGuid, pcdConsumer);
873 //
874 // Special dynamic type, if this pcd already exists in other ModuleSA
875 //
876 if (itemType.equals("DYNAMIC")) {
877
878 ListIterator li = pcdConsumer.listIterator();
879 while(li.hasNext()) {
880 String value = li.next().toString();
881 String[] valuePart= value.split(" ");
882 if (!valuePart[5].equals("DYNAMIC")) {
883 //ToDo error for same pcd, other type than dynamic
884 pcdConsumer.remove(listValue);
885 throw new PcdItemTypeConflictException(cName, value);
886 }
887 }
888 }
889 else {
890 ListIterator li = pcdConsumer.listIterator();
891 while(li.hasNext()) {
892 String value = li.next().toString();
893 String[] valuePart= value.split(" ");
894 if (valuePart[5].equals("DYNAMIC")) {
895 //ToDo error for same pcd, other type than non-dynamic
896 pcdConsumer.remove(listValue);
897 throw new PcdItemTypeConflictException(cName, value);
898 }
899 }
900 }
901
902 PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData fpdPcd = moduleSa.getPcdBuildDefinition().addNewPcdData();
903 fpdPcd.setCName(cName);
904 fpdPcd.setToken(token);
905 fpdPcd.setTokenSpaceGuidCName(tsGuid);
906 fpdPcd.setDatumType(PcdDataTypes.Enum.forString(dataType));
907 fpdPcd.setItemType(PcdItemTypes.Enum.forString(itemType));
908
909 if (itemType.equals("DYNAMIC") || itemType.equals("DYNAMIC_EX")) {
910 ArrayList<String> al = LookupDynamicPcdBuildDefinition(cName + " " + tsGuid);
911 //
912 // if only one module mapped to this pcd, then the one is myself. so no other module mapped.
913 // so need to add one dyn pcd.
914 //
915 if (al.size() == 1) {
916 addDynamicPcdBuildData(cName, token, tsGuid, itemType, dataType, defaultVal);
917 }
918 }
919 else {
920 if (defaultVal != null){
921 fpdPcd.setValue(defaultVal);
922 }
923 else {
924 if (dataType.equals("UINT8") || dataType.equals("UINT16") || dataType.equals("UINT32") || dataType.equals("UINT64")) {
925 fpdPcd.setValue("0");
926 }
927 if (dataType.equals("BOOLEAN")){
928 fpdPcd.setValue("false");
929 }
930 if (dataType.equals("VOID*")) {
931 fpdPcd.setValue("");
932 }
933 }
934 if (dataType.equals("UINT8")){
935 fpdPcd.setMaxDatumSize(1);
936 }
937 if (dataType.equals("UINT16")) {
938 fpdPcd.setMaxDatumSize(2);
939 }
940 if (dataType.equals("UINT32")) {
941 fpdPcd.setMaxDatumSize(4);
942 }
943 if (dataType.equals("UINT64")){
944 fpdPcd.setMaxDatumSize(8);
945 }
946 if (dataType.equals("BOOLEAN")){
947 fpdPcd.setMaxDatumSize(1);
948 }
949 if (dataType.equals("VOID*")) {
950 int maxSize = setMaxSizeForPointer(fpdPcd.getValue());
951 fpdPcd.setMaxDatumSize(maxSize);
952 }
953 }
954 }
955
956 public int setMaxSizeForPointer(String datum) throws PcdValueMalFormed{
957 if (datum == null) {
958 return 0;
959 }
960 char ch = datum.charAt(0);
961 int start, end;
962 String strValue;
963 //
964 // For void* type PCD, only three datum is support:
965 // 1) Unicode: string with start char is "L"
966 // 2) Ansci: String is ""
967 // 3) byte array: String start char "{"
968 //
969 if (ch == 'L') {
970 start = datum.indexOf('\"');
971 end = datum.lastIndexOf('\"');
972 if ((start > end) ||
973 (end > datum.length())||
974 ((start == end) && (datum.length() > 0))) {
975 //ToDo Error handling here
976 throw new PcdValueMalFormed (datum);
977 }
978
979 strValue = datum.substring(start + 1, end);
980 return strValue.length() * 2;
981 } else if (ch == '\"'){
982 start = datum.indexOf('\"');
983 end = datum.lastIndexOf('\"');
984 if ((start > end) ||
985 (end > datum.length())||
986 ((start == end) && (datum.length() > 0))) {
987 throw new PcdValueMalFormed (datum);
988 }
989 strValue = datum.substring(start + 1, end);
990 return strValue.length();
991 } else if (ch =='{') {
992 String[] strValueArray;
993
994 start = datum.indexOf('{');
995 end = datum.lastIndexOf('}');
996 strValue = datum.substring(start + 1, end);
997 strValue = strValue.trim();
998 if (strValue.length() == 0) {
999 return 0;
1000 }
1001 strValueArray = strValue.split(",");
1002 for (int index = 0; index < strValueArray.length; index ++) {
1003 Integer value = Integer.decode(strValueArray[index].trim());
1004
1005 if (value > 0xFF) {
1006 // "[FPD file error] The datum type of PCD %s in %s is VOID*, "+
1007 // "it is byte array in fact. But the element of %s exceed the byte range",
1008 throw new PcdValueMalFormed (datum);
1009 }
1010 }
1011 return strValueArray.length;
1012
1013
1014 } else {
1015 // "[FPD file error] The datum type of PCD %s in %s is VOID*. For VOID* type, you have three format choise:\n "+
1016 // "1) UNICODE string: like L\"xxxx\";\r\n"+
1017 // "2) ANSIC string: like \"xxx\";\r\n"+
1018 // "3) Byte array: like {0x2, 0x45, 0x23}\r\n"+
1019 // "but the datum in seems does not following above format!",
1020 throw new PcdValueMalFormed (datum);
1021
1022 }
1023 }
1024
1025 private ArrayList<String> LookupDynamicPcdBuildDefinition(String dynPcdKey) {
1026 ArrayList<String> al = dynPcdMap.get(dynPcdKey);
1027
1028 return al;
1029 }
1030
1031 private ArrayList<String> LookupPlatformPcdData(String pcdKey) {
1032
1033 return dynPcdMap.get(pcdKey);
1034 }
1035
1036 public int getDynamicPcdBuildDataCount() {
1037 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1038 removeElement(getfpdDynPcdBuildDefs());
1039 fpdDynPcdBuildDefs = null;
1040 return 0;
1041 }
1042 return getfpdDynPcdBuildDefs().getPcdBuildDataList().size();
1043 }
1044
1045 public void getDynamicPcdBuildData(String[][] saa) {
1046 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1047 removeElement(getfpdDynPcdBuildDefs());
1048 fpdDynPcdBuildDefs = null;
1049 return ;
1050 }
1051 List<DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData> l = getfpdDynPcdBuildDefs().getPcdBuildDataList();
1052 ListIterator<DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData> li = l.listIterator();
1053 int i = 0;
1054 while(li.hasNext()) {
1055 DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData dynPcd = li.next();
1056 saa[i][0] = dynPcd.getCName();
1057 saa[i][1] = dynPcd.getToken().toString();
1058 saa[i][2] = dynPcd.getTokenSpaceGuidCName();
1059 saa[i][3] = dynPcd.getMaxDatumSize()+"";
1060 saa[i][4] = dynPcd.getDatumType().toString();
1061
1062 ++i;
1063 }
1064 }
1065
1066 public void addDynamicPcdBuildData(String cName, Object token, String tsGuid, String itemType, String dataType, String defaultVal)
1067 throws PcdValueMalFormed{
1068 DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData dynPcdData = getfpdDynPcdBuildDefs().addNewPcdBuildData();
1069 dynPcdData.setItemType(PcdItemTypes.Enum.forString(itemType));
1070 dynPcdData.setCName(cName);
1071 dynPcdData.setToken(token);
1072 dynPcdData.setTokenSpaceGuidCName(tsGuid);
1073 dynPcdData.setDatumType(PcdDataTypes.Enum.forString(dataType));
1074
1075 BigInteger bigInt = new BigInteger("0");
1076 DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData.SkuInfo skuInfo = dynPcdData.addNewSkuInfo();
1077 skuInfo.setSkuId(bigInt);
1078 if (defaultVal != null){
1079 skuInfo.setValue(defaultVal);
1080 }
1081 else {
1082 if (dataType.equals("UINT8")){
1083 skuInfo.setValue("0");
1084 }
1085 if (dataType.equals("UINT16")) {
1086 skuInfo.setValue("0");
1087 }
1088 if (dataType.equals("UINT32")) {
1089 skuInfo.setValue("0");
1090 }
1091 if (dataType.equals("UINT64")){
1092 skuInfo.setValue("0");
1093 }
1094 if (dataType.equals("BOOLEAN")){
1095 skuInfo.setValue("false");
1096 }
1097 if (dataType.equals("VOID*")) {
1098 skuInfo.setValue("");
1099 }
1100 }
1101 if (dataType.equals("UINT8")){
1102 dynPcdData.setMaxDatumSize(1);
1103 }
1104 if (dataType.equals("UINT16")) {
1105 dynPcdData.setMaxDatumSize(2);
1106 }
1107 if (dataType.equals("UINT32")) {
1108 dynPcdData.setMaxDatumSize(4);
1109 }
1110 if (dataType.equals("UINT64")){
1111 dynPcdData.setMaxDatumSize(8);
1112 }
1113 if (dataType.equals("BOOLEAN")){
1114 dynPcdData.setMaxDatumSize(1);
1115 }
1116 if (dataType.equals("VOID*")) {
1117 int maxSize = setMaxSizeForPointer(defaultVal);
1118 dynPcdData.setMaxDatumSize(maxSize);
1119 }
1120 }
1121
1122 public void removeDynamicPcdBuildData(String cName, String tsGuid) {
1123 XmlObject o = fpdRoot.getDynamicPcdBuildDefinitions();
1124 if (o == null) {
1125 return;
1126 }
1127
1128 XmlCursor cursor = o.newCursor();
1129 if (cursor.toFirstChild()) {
1130 do {
1131 DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData pcdBuildData =
1132 (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject();
1133 if (pcdBuildData.getCName().equals(cName) && pcdBuildData.getTokenSpaceGuidCName().equals(tsGuid)) {
1134 cursor.removeXml();
1135 if (getDynamicPcdBuildDataCount() == 0) {
1136 cursor.toParent();
1137 cursor.removeXml();
1138 }
1139 cursor.dispose();
1140 return;
1141 }
1142 }
1143 while (cursor.toNextSibling());
1144 }
1145 cursor.dispose();
1146 }
1147 //
1148 // Get the Sku Info count of ith dyn pcd element.
1149 //
1150 public int getDynamicPcdSkuInfoCount(int i){
1151 if (fpdRoot.getDynamicPcdBuildDefinitions() == null || fpdRoot.getDynamicPcdBuildDefinitions().getPcdBuildDataList() == null
1152 || fpdRoot.getDynamicPcdBuildDefinitions().getPcdBuildDataList().size() == 0) {
1153 return 0;
1154 }
1155
1156 int skuInfoCount = 0;
1157 XmlCursor cursor = getfpdDynPcdBuildDefs().newCursor();
1158 if (cursor.toFirstChild()) {
1159 for (int j = 0; j < i; ++j) {
1160 cursor.toNextSibling();
1161 }
1162 DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData pcdData = (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject();
1163 if (pcdData.getSkuInfoList() == null) {
1164 skuInfoCount = 0;
1165 }
1166 else {
1167 skuInfoCount = pcdData.getSkuInfoList().size();
1168 }
1169 }
1170 cursor.dispose();
1171 return skuInfoCount;
1172 }
1173
1174 public void getDynamicPcdSkuInfos(int i, String[][] saa){
1175 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1176 removeElement(getfpdDynPcdBuildDefs());
1177 fpdDynPcdBuildDefs = null;
1178 return;
1179 }
1180
1181 XmlCursor cursor = getfpdDynPcdBuildDefs().newCursor();
1182 if (cursor.toFirstChild()) {
1183 for (int j = 0; j < i; ++j) {
1184 cursor.toNextSibling();
1185 }
1186 DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData pcdData = (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject();
1187 if (pcdData.getSkuInfoList() == null) {
1188 cursor.dispose();
1189 return;
1190 }
1191 else {
1192 ListIterator<DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData.SkuInfo> li = pcdData.getSkuInfoList().listIterator();
1193 int k = 0;
1194 while (li.hasNext()) {
1195 DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData.SkuInfo skuInfo = li.next();
1196 saa[k][0] = skuInfo.getSkuId()+"";
1197 saa[k][1] = skuInfo.getVariableName();
1198 saa[k][2] = skuInfo.getVariableGuid();
1199 saa[k][3] = skuInfo.getVariableOffset();
1200 saa[k][4] = skuInfo.getHiiDefaultValue();
1201 saa[k][5] = skuInfo.getVpdOffset();
1202 saa[k][6] = skuInfo.getValue();
1203 ++k;
1204 }
1205
1206 }
1207 }
1208 cursor.dispose();
1209
1210 }
1211
1212 public String getDynamicPcdBuildDataValue(int i){
1213 String value = null;
1214 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1215 removeElement(getfpdDynPcdBuildDefs());
1216 fpdDynPcdBuildDefs = null;
1217 return value;
1218 }
1219
1220 XmlCursor cursor = getfpdDynPcdBuildDefs().newCursor();
1221 if (cursor.toFirstChild()) {
1222 for (int j = 0; j < i; ++j) {
1223 cursor.toNextSibling();
1224 }
1225 DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData pcdData = (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject();
1226 if (pcdData.getSkuInfoList() == null) {
1227 value = null;
1228 }
1229 else {
1230 value = pcdData.getSkuInfoArray(0).getValue();
1231 }
1232 }
1233 cursor.dispose();
1234 return value;
1235 }
1236
1237 public String getDynamicPcdBuildDataVpdOffset(int i){
1238 String vpdOffset = null;
1239 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1240 removeElement(getfpdDynPcdBuildDefs());
1241 fpdDynPcdBuildDefs = null;
1242 return vpdOffset;
1243 }
1244
1245 XmlCursor cursor = getfpdDynPcdBuildDefs().newCursor();
1246 if (cursor.toFirstChild()) {
1247 for (int j = 0; j < i; ++j) {
1248 cursor.toNextSibling();
1249 }
1250 DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData pcdData = (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject();
1251 if (pcdData.getSkuInfoList() == null) {
1252 vpdOffset = null;
1253 }
1254 else {
1255 vpdOffset = pcdData.getSkuInfoArray(0).getVpdOffset();
1256 }
1257 }
1258 cursor.dispose();
1259 return vpdOffset;
1260 }
1261
1262 public void removeDynamicPcdBuildDataSkuInfo(int i) {
1263 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1264 removeElement(getfpdDynPcdBuildDefs());
1265 fpdDynPcdBuildDefs = null;
1266 return;
1267 }
1268
1269 XmlCursor cursor = getfpdDynPcdBuildDefs().newCursor();
1270 if (cursor.toFirstChild()) {
1271 for (int j = 0; j < i; ++j) {
1272 cursor.toNextSibling();
1273 }
1274 DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData pcdData = (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject();
1275 if (pcdData.getSkuInfoList() == null) {
1276 cursor.dispose();
1277 return;
1278 }
1279 else {
1280 QName qSkuInfo = new QName(xmlNs, "SkuInfo");
1281 cursor.toChild(qSkuInfo);
1282 cursor.removeXml();
1283 }
1284 }
1285 cursor.dispose();
1286 }
1287 //
1288 // generate sku info for ith dyn pcd build data.
1289 //
1290 public void genDynamicPcdBuildDataSkuInfo(String id, String varName, String varGuid, String varOffset,
1291 String hiiDefault, String vpdOffset, String value, int i) {
1292 // if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1293 // return;
1294 // }
1295
1296 XmlCursor cursor = getfpdDynPcdBuildDefs().newCursor();
1297 if (cursor.toFirstChild()) {
1298 for (int j = 0; j < i; ++j) {
1299 cursor.toNextSibling();
1300 }
1301 DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData pcdData = (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject();
1302 DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData.SkuInfo skuInfo = pcdData.addNewSkuInfo();
1303 skuInfo.setSkuId(new BigInteger(id));
1304 if (varName != null){
1305 skuInfo.setVariableName(varName);
1306 skuInfo.setVariableGuid(varGuid);
1307 skuInfo.setVariableOffset(varOffset);
1308 skuInfo.setHiiDefaultValue(hiiDefault);
1309 }
1310 else if (vpdOffset != null){
1311 skuInfo.setVpdOffset(vpdOffset);
1312 }
1313 else{
1314 skuInfo.setValue(value);
1315 }
1316 }
1317 }
1318
1319 public void updateDynamicPcdBuildDataSkuInfo(String id, String varName, String varGuid, String varOffset,
1320 String hiiDefault, String vpdOffset, String value, int i){
1321 // if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1322 // return;
1323 // }
1324
1325 XmlCursor cursor = getfpdDynPcdBuildDefs().newCursor();
1326 if (cursor.toFirstChild()) {
1327 for (int j = 0; j < i; ++j) {
1328 cursor.toNextSibling();
1329 }
1330 DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData pcdData = (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject();
1331 ListIterator<DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData.SkuInfo> li = pcdData.getSkuInfoList().listIterator();
1332 while (li.hasNext()) {
1333 DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData.SkuInfo skuInfo = li.next();
1334 if (skuInfo.getSkuId().toString().equals(id)){
1335 if (varName != null){
1336 skuInfo.setVariableName(varName);
1337 skuInfo.setVariableGuid(varGuid);
1338 skuInfo.setVariableOffset(varOffset);
1339 skuInfo.setHiiDefaultValue(hiiDefault);
1340 }
1341 else if (vpdOffset != null){
1342 skuInfo.setVpdOffset(vpdOffset);
1343 }
1344 else{
1345 skuInfo.setValue(value);
1346 }
1347 break;
1348 }
1349 }
1350 }
1351 }
1352
1353 public BuildOptionsDocument.BuildOptions getfpdBuildOpts() {
1354 if (fpdBuildOpts == null) {
1355 fpdBuildOpts = fpdRoot.addNewBuildOptions();
1356 }
1357 return fpdBuildOpts;
1358 }
1359
1360 public void genBuildOptionsUserDefAntTask (String id, String fileName, String execOrder) {
1361 UserDefinedAntTasksDocument.UserDefinedAntTasks udats = getfpdBuildOpts().getUserDefinedAntTasks();
1362 if (udats == null) {
1363 udats = getfpdBuildOpts().addNewUserDefinedAntTasks();
1364 }
1365
1366 AntTaskDocument.AntTask at = udats.addNewAntTask();
1367 setBuildOptionsUserDefAntTask(id, fileName, execOrder, at);
1368 }
1369
1370 private void setBuildOptionsUserDefAntTask(String id, String fileName, String execOrder, AntTaskDocument.AntTask at) {
1371 at.setId(new Integer(id));
1372 XmlCursor cursor = at.newCursor();
1373 if (fileName != null){
1374 at.setFilename(fileName);
1375 }
1376 else if (cursor.toChild(xmlNs, "Filename")) {
1377 cursor.removeXml();
1378 }
1379 if (execOrder != null) {
1380 at.setAntCmdOptions(execOrder);
1381 }
1382 else if (cursor.toChild(xmlNs, "AntCmdOptions")) {
1383 cursor.removeXml();
1384 }
1385 cursor.dispose();
1386 }
1387
1388 public void removeBuildOptionsUserDefAntTask(int i) {
1389 XmlObject o = getfpdBuildOpts().getUserDefinedAntTasks();
1390 if (o == null) {
1391 return;
1392 }
1393 XmlCursor cursor = o.newCursor();
1394 if (cursor.toFirstChild()) {
1395 for (int j = 0; j < i; ++j) {
1396 cursor.toNextSibling();
1397 }
1398 cursor.removeXml();
1399 if (getBuildOptionsUserDefAntTaskCount() == 0) {
1400 cursor.toParent();
1401 cursor.removeXml();
1402 }
1403 }
1404 cursor.dispose();
1405 }
1406
1407 public void updateBuildOptionsUserDefAntTask(int i, String id, String fileName, String execOrder){
1408 XmlObject o = getfpdBuildOpts().getUserDefinedAntTasks();
1409 if (o == null) {
1410 return;
1411 }
1412 XmlCursor cursor = o.newCursor();
1413 if (cursor.toFirstChild()) {
1414 for (int j = 0; j < i; ++j) {
1415 cursor.toNextSibling();
1416 }
1417 AntTaskDocument.AntTask at = (AntTaskDocument.AntTask)cursor.getObject();
1418 setBuildOptionsUserDefAntTask(id, fileName, execOrder, at);
1419 }
1420 cursor.dispose();
1421 }
1422
1423 public int getBuildOptionsUserDefAntTaskCount() {
1424 UserDefinedAntTasksDocument.UserDefinedAntTasks udats = getfpdBuildOpts().getUserDefinedAntTasks();
1425 if (udats == null || udats.getAntTaskList() == null) {
1426 return 0;
1427 }
1428
1429 return udats.getAntTaskList().size();
1430 }
1431
1432 public void getBuildOptionsUserDefAntTasks(String[][] saa) {
1433 UserDefinedAntTasksDocument.UserDefinedAntTasks udats = getfpdBuildOpts().getUserDefinedAntTasks();
1434 if (udats == null || udats.getAntTaskList() == null) {
1435 return ;
1436 }
1437
1438 List<AntTaskDocument.AntTask> l = udats.getAntTaskList();
1439 ListIterator li = l.listIterator();
1440 int i = 0;
1441 while (li.hasNext()) {
1442 AntTaskDocument.AntTask at = (AntTaskDocument.AntTask)li.next();
1443 saa[i][0] = at.getId() + "";
1444 saa[i][1] = saa[i][2] = "";
1445 if (at.getFilename() != null){
1446 saa[i][1] = at.getFilename();
1447 }
1448 if (at.getAntCmdOptions() != null) {
1449 saa[i][2] = at.getAntCmdOptions();
1450 }
1451 ++i;
1452 }
1453 }
1454 public void genBuildOptionsOpt(Vector<Object> buildTargets, String toolChain, String tagName, String toolCmd, Vector<Object> archList, String contents) {
1455 OptionsDocument.Options opts = getfpdBuildOpts().getOptions();
1456 if (opts == null) {
1457 opts = getfpdBuildOpts().addNewOptions();
1458 }
1459 OptionDocument.Option opt = opts.addNewOption();
1460 setBuildOptionsOpt(buildTargets, toolChain, tagName, toolCmd, archList, contents, opt);
1461 }
1462
1463 private void setBuildOptionsOpt(Vector<Object> buildTargets, String toolChain, String tagName, String toolCmd, Vector<Object> archList, String contents, OptionDocument.Option opt){
1464 opt.setStringValue(contents);
1465
1466 opt.setBuildTargets(buildTargets);
1467 opt.setToolChainFamily(toolChain);
1468 opt.setTagName(tagName);
1469 opt.setToolCode(toolCmd);
1470
1471 if (archList != null) {
1472 opt.setSupArchList(archList);
1473 }
1474 else {
1475 if (opt.isSetSupArchList()) {
1476 opt.unsetSupArchList();
1477 }
1478 }
1479 }
1480
1481 public void removeBuildOptionsOpt(int i){
1482
1483 XmlObject o = getfpdBuildOpts().getOptions();
1484 if (o == null) {
1485 return;
1486 }
1487
1488 XmlCursor cursor = o.newCursor();
1489 if (cursor.toFirstChild()) {
1490 for (int j = 0; j < i; ++j) {
1491 cursor.toNextSibling();
1492 }
1493 cursor.removeXml();
1494 if (getBuildOptionsOptCount() == 0) {
1495 cursor.toParent();
1496 cursor.removeXml();
1497 }
1498 }
1499 cursor.dispose();
1500 }
1501
1502 public void updateBuildOptionsOpt(int i, Vector<Object> buildTargets, String toolChain, String tagName, String toolCmd, Vector<Object> archList, String contents) {
1503 XmlObject o = getfpdBuildOpts().getOptions();
1504 if (o == null) {
1505 return;
1506 }
1507
1508 XmlCursor cursor = o.newCursor();
1509 if (cursor.toFirstChild()) {
1510 for (int j = 0; j < i; ++j) {
1511 cursor.toNextSibling();
1512 }
1513 OptionDocument.Option opt = (OptionDocument.Option)cursor.getObject();
1514 setBuildOptionsOpt(buildTargets, toolChain, tagName, toolCmd, archList, contents, opt);
1515 }
1516 cursor.dispose();
1517 }
1518
1519 public int getBuildOptionsOptCount(){
1520 if (getfpdBuildOpts().getOptions() == null || getfpdBuildOpts().getOptions().getOptionList() == null) {
1521 return 0;
1522 }
1523 return getfpdBuildOpts().getOptions().getOptionList().size();
1524 }
1525
1526 public void getBuildOptionsOpts(String[][] saa) {
1527 if (getfpdBuildOpts().getOptions() == null || getfpdBuildOpts().getOptions().getOptionList() == null) {
1528 return ;
1529 }
1530
1531 List<OptionDocument.Option> lOpt = getfpdBuildOpts().getOptions().getOptionList();
1532 ListIterator li = lOpt.listIterator();
1533 int i = 0;
1534 while(li.hasNext()) {
1535 OptionDocument.Option opt = (OptionDocument.Option)li.next();
1536 if (opt.getBuildTargets() != null) {
1537 saa[i][0] = listToString(opt.getBuildTargets());
1538 }
1539 saa[i][1] = opt.getToolChainFamily();
1540 if (opt.getSupArchList() != null){
1541 saa[i][2] = listToString(opt.getSupArchList());
1542
1543 }
1544 saa[i][3] = opt.getToolCode();
1545 saa[i][4] = opt.getTagName();
1546 saa[i][5] = opt.getStringValue();
1547
1548 ++i;
1549 }
1550 }
1551
1552 public void genBuildOptionsFfs(String ffsKey, String type) {
1553 BuildOptionsDocument.BuildOptions.Ffs ffs = getfpdBuildOpts().addNewFfs();
1554 ffs.setFfsKey(ffsKey);
1555 if (type != null) {
1556 ffs.addNewSections().setEncapsulationType(type);
1557 }
1558 }
1559
1560 public void updateBuildOptionsFfsSectionsType(int i, String type) {
1561 BuildOptionsDocument.BuildOptions.Ffs ffs = getfpdBuildOpts().addNewFfs();
1562 if (type != null) {
1563 ffs.addNewSections().setEncapsulationType(type);
1564 }
1565 }
1566
1567 public void genBuildOptionsFfsAttribute(int i, String name, String value) {
1568 BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);
1569 BuildOptionsDocument.BuildOptions.Ffs.Attribute attrib = ffs.addNewAttribute();
1570 attrib.setName(name);
1571 attrib.setValue(value);
1572 }
1573
1574 /**update jth attribute of ith ffs.
1575 * @param i
1576 * @param j
1577 */
1578 public void updateBuildOptionsFfsAttribute(int i, int j, String name, String value){
1579 BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);
1580 XmlCursor cursor = ffs.newCursor();
1581 QName qAttrib = new QName(xmlNs, "Attribute");
1582 if (cursor.toChild(qAttrib)) {
1583 for (int k = 0; k < j; ++k) {
1584 cursor.toNextSibling(qAttrib);
1585 }
1586 BuildOptionsDocument.BuildOptions.Ffs.Attribute attrib = (BuildOptionsDocument.BuildOptions.Ffs.Attribute)cursor.getObject();
1587 attrib.setName(name);
1588 attrib.setValue(value);
1589 }
1590 cursor.dispose();
1591 }
1592
1593 public void removeBuildOptionsFfsAttribute(int i, int j){
1594 BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);
1595 XmlCursor cursor = ffs.newCursor();
1596 QName qAttrib = new QName(xmlNs, "Attribute");
1597 if (cursor.toChild(qAttrib)) {
1598 for (int k = 0; k < j; ++k) {
1599 cursor.toNextSibling(qAttrib);
1600 }
1601 cursor.removeXml();
1602 }
1603 cursor.dispose();
1604 }
1605
1606 public void genBuildOptionsFfsSectionsSection(int i, String sectionType) {
1607 BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);
1608 if (ffs == null) {
1609 return;
1610 }
1611 BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections();
1612
1613 if (sections == null){
1614 sections = ffs.addNewSections();
1615 }
1616 sections.addNewSection().setSectionType(EfiSectionType.Enum.forString(sectionType));
1617 }
1618
1619 public void removeBuildOptionsFfsSectionsSection(int i, int j) {
1620 BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);
1621 BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections();
1622 if (sections == null) {
1623 return;
1624 }
1625 XmlCursor cursor = sections.newCursor();
1626 QName qSection = new QName(xmlNs, "Section");
1627 if (cursor.toChild(qSection)) {
1628 for (int k = 0; k < j; ++k) {
1629 cursor.toNextSibling(qSection);
1630 }
1631 cursor.removeXml();
1632 }
1633 cursor.dispose();
1634 }
1635
1636 public void updateBuildOptionsFfsSectionsSection(int i, int j, String type){
1637 BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);
1638 BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections();
1639 if (sections == null) {
1640 return;
1641 }
1642 XmlCursor cursor = sections.newCursor();
1643 QName qSection = new QName(xmlNs, "Section");
1644 if (cursor.toChild(qSection)) {
1645 for (int k = 0; k < j; ++k) {
1646 cursor.toNextSibling(qSection);
1647 }
1648 BuildOptionsDocument.BuildOptions.Ffs.Sections.Section section = (BuildOptionsDocument.BuildOptions.Ffs.Sections.Section)cursor.getObject();
1649 section.setSectionType(EfiSectionType.Enum.forString(type));
1650 }
1651 cursor.dispose();
1652 }
1653
1654 public void genBuildOptionsFfsSectionsSections(int i, String encapType) {
1655 BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);
1656 if (ffs == null) {
1657 return;
1658 }
1659 BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections();
1660
1661 if (sections == null){
1662 sections = ffs.addNewSections();
1663 }
1664 sections.addNewSections().setEncapsulationType(encapType);
1665 }
1666
1667 public void removeBuildOptionsFfsSectionsSections(int i, int j) {
1668 BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);
1669 BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections();
1670 if (sections == null) {
1671 return;
1672 }
1673 XmlCursor cursor = sections.newCursor();
1674 QName qSections = new QName(xmlNs, "Sections");
1675 if (cursor.toChild(qSections)) {
1676 for (int k = 0; k < j; ++k) {
1677 cursor.toNextSibling(qSections);
1678 }
1679 cursor.removeXml();
1680 }
1681 cursor.dispose();
1682 }
1683
1684 public void updateBuildOptionsFfsSectionsSections(int i, int j, String type) {
1685 BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);
1686 BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections();
1687 if (sections == null) {
1688 return;
1689 }
1690 XmlCursor cursor = sections.newCursor();
1691 QName qSections = new QName(xmlNs, "Sections");
1692 if (cursor.toChild(qSections)) {
1693 for (int k = 0; k < j; ++k) {
1694 cursor.toNextSibling(qSections);
1695 }
1696 BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2 sections2 = (BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2)cursor.getObject();
1697 sections2.setEncapsulationType(type);
1698 }
1699 cursor.dispose();
1700 }
1701
1702 public void genBuildOptionsFfsSectionsSectionsSection(int i, int j, String type) {
1703 BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);
1704 if (ffs == null) {
1705 return;
1706 }
1707 BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections();
1708 XmlCursor cursor = sections.newCursor();
1709 QName qSections = new QName(xmlNs, "Sections");
1710 if (cursor.toChild(qSections)){
1711 for (int k = 0; k < j; ++k) {
1712 cursor.toNextSibling(qSections);
1713 }
1714 BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2 sections2 = (BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2)cursor.getObject();
1715 sections2.addNewSection().setSectionType(EfiSectionType.Enum.forString(type));
1716 }
1717 cursor.dispose();
1718 }
1719
1720 public void removeBuildOptionsFfsSectionsSectionsSection(int i, int j, int k) {
1721 BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);
1722 BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections();
1723 if (sections == null) {
1724 return;
1725 }
1726 XmlCursor cursor = sections.newCursor();
1727 QName qSections = new QName(xmlNs, "Sections");
1728 if (cursor.toChild(qSections)) {
1729 for (int l = 0; l < j; ++l) {
1730 cursor.toNextSibling(qSections);
1731 }
1732 if (cursor.toFirstChild()) {
1733 int m = 0;
1734 for (; m < k; ++m) {
1735 cursor.toNextSibling();
1736 }
1737 cursor.removeXml();
1738 if (m == 0) {
1739 cursor.toParent();
1740 cursor.removeXml();
1741 }
1742 }
1743 }
1744 cursor.dispose();
1745 }
1746
1747 public void updateBuildOptionsFfsSectionsSectionsSection(int i, int j, int k, String type) {
1748 BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);
1749 BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections();
1750 if (sections == null) {
1751 return;
1752 }
1753 XmlCursor cursor = sections.newCursor();
1754 QName qSections = new QName(xmlNs, "Sections");
1755 if (cursor.toChild(qSections)) {
1756 for (int l = 0; l < j; ++l) {
1757 cursor.toNextSibling(qSections);
1758 }
1759 if (cursor.toFirstChild()) {
1760 for (int m = 0; m < k; ++m) {
1761 cursor.toNextSibling();
1762 }
1763 BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2.Section section = (BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2.Section)cursor.getObject();
1764 section.setSectionType(EfiSectionType.Enum.forString(type));
1765 }
1766 }
1767 cursor.dispose();
1768 }
1769
1770 public void getBuildOptionsFfsSectionsSectionsSection(int i, int j, ArrayList<String> al) {
1771 BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);
1772 if (ffs == null) {
1773 return;
1774 }
1775 BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections();
1776 XmlCursor cursor = sections.newCursor();
1777 QName qSections = new QName(xmlNs, "Sections");
1778 if (cursor.toChild(qSections)){
1779 for (int k = 0; k < j; ++k) {
1780 cursor.toNextSibling(qSections);
1781 }
1782 BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2 sections2 = (BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2)cursor.getObject();
1783 if (sections2.getSectionList() == null){
1784 cursor.dispose();
1785 return;
1786 }
1787 ListIterator<BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2.Section> li = sections2.getSectionList().listIterator();
1788 while(li.hasNext()) {
1789 BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2.Section section = li.next();
1790 if (section.isSetSectionType()) {
1791 al.add(section.getSectionType().toString());
1792 }
1793
1794 }
1795 }
1796 cursor.dispose();
1797
1798 }
1799
1800 public int getBuildOptionsFfsCount(){
1801 if (getfpdBuildOpts().getFfsList() == null) {
1802 return 0;
1803 }
1804 return getfpdBuildOpts().getFfsList().size();
1805 }
1806
1807 public void getBuildOptionsFfsKey(String[][] saa) {
1808 if (getfpdBuildOpts().getFfsList() == null) {
1809 return;
1810 }
1811 ListIterator<BuildOptionsDocument.BuildOptions.Ffs> li = getfpdBuildOpts().getFfsList().listIterator();
1812 int i = 0;
1813 while(li.hasNext()){
1814 BuildOptionsDocument.BuildOptions.Ffs ffs = li.next();
1815 saa[i][0] = ffs.getFfsKey();
1816 ++i;
1817 }
1818 }
1819
1820 public void updateBuildOptionsFfsKey(int i, String key) {
1821 BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);
1822 ffs.setFfsKey(key);
1823 }
1824
1825 /**Get ith FFS key and contents.
1826 * @param saa
1827 */
1828 public void getBuildOptionsFfs(int i, String[] sa, LinkedHashMap<String, String> ffsAttribMap, ArrayList<String> firstLevelSections, ArrayList<String> firstLevelSection) {
1829 BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);
1830
1831 if (ffs != null) {
1832
1833 sa[0] = ffs.getFfsKey();
1834 if (ffs.getSections() != null) {
1835 if(ffs.getSections().getEncapsulationType() != null){
1836 sa[1] = ffs.getSections().getEncapsulationType();
1837 }
1838 if (ffs.getSections().getSectionList() != null){
1839 ListIterator<BuildOptionsDocument.BuildOptions.Ffs.Sections.Section> li = ffs.getSections().getSectionList().listIterator();
1840 while (li.hasNext()) {
1841 firstLevelSection.add(li.next().getSectionType().toString());
1842 }
1843 }
1844 if (ffs.getSections().getSectionsList() != null) {
1845 ListIterator<BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2> li = ffs.getSections().getSectionsList().listIterator();
1846 while(li.hasNext()) {
1847 firstLevelSections.add(li.next().getEncapsulationType());
1848 }
1849 }
1850 }
1851 if (ffs.getAttributeList() != null) {
1852 ListIterator<BuildOptionsDocument.BuildOptions.Ffs.Attribute> li = ffs.getAttributeList().listIterator();
1853 while(li.hasNext()) {
1854 BuildOptionsDocument.BuildOptions.Ffs.Attribute attrib = li.next();
1855 ffsAttribMap.put(attrib.getName(), attrib.getValue());
1856 }
1857
1858 }
1859 }
1860
1861
1862 }
1863
1864 private BuildOptionsDocument.BuildOptions.Ffs getFfs(int i) {
1865 XmlObject o = getfpdBuildOpts();
1866 BuildOptionsDocument.BuildOptions.Ffs ffs = null;
1867
1868 XmlCursor cursor = o.newCursor();
1869 QName qFfs = new QName(xmlNs, "Ffs");
1870 if (cursor.toChild(qFfs)) {
1871 for (int j = 0; j < i; ++j) {
1872 cursor.toNextSibling(qFfs);
1873 }
1874 ffs = (BuildOptionsDocument.BuildOptions.Ffs)cursor.getObject();
1875 }
1876 cursor.dispose();
1877 return ffs;
1878 }
1879
1880 public void removeBuildOptionsFfs(int i) {
1881 BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);
1882 if (ffs == null){
1883 return;
1884 }
1885
1886 XmlCursor cursor = ffs.newCursor();
1887 cursor.removeXml();
1888 cursor.dispose();
1889 }
1890
1891
1892
1893 public PlatformDefinitionsDocument.PlatformDefinitions getfpdPlatformDefs(){
1894 if (fpdPlatformDefs == null){
1895 fpdPlatformDefs = fpdRoot.addNewPlatformDefinitions();
1896 }
1897 return fpdPlatformDefs;
1898 }
1899
1900 public void getPlatformDefsSupportedArchs(Vector<Object> archs){
1901 if (getfpdPlatformDefs().getSupportedArchitectures() == null) {
1902 return;
1903 }
1904 ListIterator li = getfpdPlatformDefs().getSupportedArchitectures().listIterator();
1905 while(li.hasNext()) {
1906 archs.add(li.next());
1907 }
1908 }
1909
1910 public void setPlatformDefsSupportedArchs(Vector<Object> archs) {
1911 if (archs != null) {
1912 getfpdPlatformDefs().setSupportedArchitectures(archs);
1913 }
1914 // else {
1915 // XmlCursor cursor = getfpdPlatformDefs().newCursor();
1916 // if (cursor.toChild(xmlNs, "SupportedArchitectures")) {
1917 // cursor.removeXml();
1918 // }
1919 // cursor.dispose();
1920 // }
1921 }
1922
1923 public void getPlatformDefsBuildTargets(Vector<Object> targets) {
1924 if (getfpdPlatformDefs().getBuildTargets() == null) {
1925 return;
1926 }
1927 ListIterator li = getfpdPlatformDefs().getBuildTargets().listIterator();
1928 while(li.hasNext()) {
1929 targets.add(li.next());
1930 }
1931 }
1932
1933 public void setPlatformDefsBuildTargets(Vector<Object> targets) {
1934 getfpdPlatformDefs().setBuildTargets(targets);
1935 }
1936
1937 public void genPlatformDefsSkuInfo(String id, String name) {
1938 SkuInfoDocument.SkuInfo skuInfo = null;
1939 if (getfpdPlatformDefs().getSkuInfo() == null) {
1940 skuInfo = getfpdPlatformDefs().addNewSkuInfo();
1941 }
1942 skuInfo = getfpdPlatformDefs().getSkuInfo();
1943 if (skuInfo.getUiSkuNameList() == null || skuInfo.getUiSkuNameList().size() == 0) {
1944 SkuInfoDocument.SkuInfo.UiSkuName skuName = skuInfo.addNewUiSkuName();
1945 skuName.setSkuID(new BigInteger("0"));
1946 skuName.setStringValue("DEFAULT");
1947 }
1948 if (id.equals("0")) {
1949 return;
1950 }
1951 SkuInfoDocument.SkuInfo.UiSkuName skuName = skuInfo.addNewUiSkuName();
1952 skuName.setSkuID(new BigInteger(id));
1953 skuName.setStringValue(name);
1954 }
1955
1956 public int getPlatformDefsSkuInfoCount(){
1957 if (getfpdPlatformDefs().getSkuInfo() == null || getfpdPlatformDefs().getSkuInfo().getUiSkuNameList() == null) {
1958 return 0;
1959 }
1960 return getfpdPlatformDefs().getSkuInfo().getUiSkuNameList().size();
1961 }
1962
1963 public void getPlatformDefsSkuInfos(String[][] saa){
1964 if (getfpdPlatformDefs().getSkuInfo() == null || getfpdPlatformDefs().getSkuInfo().getUiSkuNameList() == null) {
1965 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null) {
1966 removeElement(getfpdDynPcdBuildDefs());
1967 fpdDynPcdBuildDefs = null;
1968 }
1969 return ;
1970 }
1971
1972 List<SkuInfoDocument.SkuInfo.UiSkuName> l = getfpdPlatformDefs().getSkuInfo().getUiSkuNameList();
1973 ListIterator<SkuInfoDocument.SkuInfo.UiSkuName> li = l.listIterator();
1974 int i = 0;
1975 while(li.hasNext()) {
1976 SkuInfoDocument.SkuInfo.UiSkuName sku = li.next();
1977 saa[i][0] = sku.getSkuID()+"";
1978 saa[i][1] = sku.getStringValue();
1979 ++i;
1980 }
1981 }
1982
1983 public void removePlatformDefsSkuInfo(int i) {
1984 SkuInfoDocument.SkuInfo skuInfo = getfpdPlatformDefs().getSkuInfo();
1985 if (skuInfo == null || i == 0) {
1986 return ;
1987 }
1988
1989 XmlCursor cursor = skuInfo.newCursor();
1990 if (cursor.toFirstChild()) {
1991 for (int j = 0; j < i; ++j) {
1992 cursor.toNextSibling();
1993 }
1994 cursor.removeXml();
1995 }
1996 cursor.dispose();
1997 }
1998
1999 public void updatePlatformDefsSkuInfo(int i, String id, String name) {
2000 SkuInfoDocument.SkuInfo skuInfo = getfpdPlatformDefs().getSkuInfo();
2001 if (skuInfo == null || i == 0) {
2002 return ;
2003 }
2004
2005 XmlCursor cursor = skuInfo.newCursor();
2006 if (cursor.toFirstChild()) {
2007 for (int j = 0; j < i; ++j) {
2008 cursor.toNextSibling();
2009 }
2010 SkuInfoDocument.SkuInfo.UiSkuName sku = (SkuInfoDocument.SkuInfo.UiSkuName)cursor.getObject();
2011 sku.setSkuID(new BigInteger(id));
2012 sku.setStringValue(name);
2013 }
2014 cursor.dispose();
2015 }
2016
2017 public String getPlatformDefsInterDir(){
2018 if (getfpdPlatformDefs().getIntermediateDirectories() == null) {
2019 return null;
2020 }
2021 return getfpdPlatformDefs().getIntermediateDirectories().toString();
2022 }
2023
2024 public void setPlatformDefsInterDir(String interDir){
2025 getfpdPlatformDefs().setIntermediateDirectories(IntermediateOutputType.Enum.forString(interDir));
2026 }
2027
2028 public String getPlatformDefsOutputDir() {
2029 return getfpdPlatformDefs().getOutputDirectory();
2030 }
2031
2032 public void setPlatformDefsOutputDir(String outputDir) {
2033 if (outputDir != null && outputDir.length() > 0) {
2034 getfpdPlatformDefs().setOutputDirectory(outputDir);
2035 }
2036 else{
2037 XmlCursor cursor = getfpdPlatformDefs().newCursor();
2038 if (cursor.toChild(new QName(xmlNs, "OutputDirectory"))) {
2039 cursor.removeXml();
2040 }
2041 cursor.dispose();
2042 }
2043 }
2044
2045 public FlashDocument.Flash getfpdFlash() {
2046 if (fpdFlash == null) {
2047 fpdFlash = fpdRoot.addNewFlash();
2048 }
2049 return fpdFlash;
2050 }
2051
2052 public void genFlashDefinitionFile(String file) {
2053 FlashDefinitionFileDocument.FlashDefinitionFile fdf = getfpdFlash().getFlashDefinitionFile();
2054 if (fdf == null) {
2055 fdf = getfpdFlash().addNewFlashDefinitionFile();
2056 }
2057
2058 fdf.setStringValue(file);
2059 }
2060
2061 public String getFlashDefinitionFile() {
2062 FlashDefinitionFileDocument.FlashDefinitionFile fdf = getfpdFlash().getFlashDefinitionFile();
2063 if (fdf == null) {
2064 return "";
2065 }
2066
2067 return fdf.getStringValue();
2068 }
2069
2070 public void genFvImagesNameValue(String name, String value) {
2071
2072 FvImagesDocument.FvImages fi = getfpdFlash().getFvImages();
2073 if (fi == null) {
2074 fi = getfpdFlash().addNewFvImages();
2075 }
2076
2077 FvImagesDocument.FvImages.NameValue nv = fi.addNewNameValue();
2078 nv.setName(name);
2079 nv.setValue(value);
2080 }
2081
2082 public void removeFvImagesNameValue(int i){
2083
2084 XmlObject o = getfpdFlash().getFvImages();
2085 if (o == null) {
2086 return;
2087 }
2088
2089 QName qNameValue = new QName(xmlNs, "NameValue");
2090 XmlCursor cursor = o.newCursor();
2091 if (cursor.toChild(qNameValue)) {
2092 for (int j = 0; j < i; ++j) {
2093 cursor.toNextSibling(qNameValue);
2094 }
2095 cursor.removeXml();
2096 }
2097 cursor.dispose();
2098 }
2099
2100 public void updateFvImagesNameValue(int i, String name, String value){
2101
2102 XmlObject o = getfpdFlash().getFvImages();
2103 if (o == null) {
2104 return;
2105 }
2106
2107 QName qNameValue = new QName(xmlNs, "NameValue");
2108 XmlCursor cursor = o.newCursor();
2109 if (cursor.toChild(qNameValue)) {
2110 for (int j = 0; j < i; ++j) {
2111 cursor.toNextSibling(qNameValue);
2112 }
2113 FvImagesDocument.FvImages.NameValue nv = (FvImagesDocument.FvImages.NameValue)cursor.getObject();
2114 nv.setName(name);
2115 nv.setValue(value);
2116 }
2117 cursor.dispose();
2118 }
2119
2120 public int getFvImagesNameValueCount() {
2121
2122 FvImagesDocument.FvImages fi = null;
2123 if ((fi = getfpdFlash().getFvImages()) == null || fi.getNameValueList() == null) {
2124 return 0;
2125 }
2126 return fi.getNameValueList().size();
2127 }
2128
2129 public void getFvImagesNameValues(String[][] nv) {
2130
2131 FvImagesDocument.FvImages fi = getfpdFlash().getFvImages();
2132 if (fi == null){
2133 return;
2134 }
2135 List<FvImagesDocument.FvImages.NameValue> l = fi.getNameValueList();
2136 int i = 0;
2137 ListIterator li = l.listIterator();
2138 while (li.hasNext()) {
2139 FvImagesDocument.FvImages.NameValue e = (FvImagesDocument.FvImages.NameValue) li
2140 .next();
2141 nv[i][0] = e.getName();
2142 nv[i][1] = e.getValue();
2143
2144 i++;
2145 }
2146 }
2147
2148 public void genFvImagesFvImage(String[] names, String types, Map<String, String> options) {
2149
2150 FvImagesDocument.FvImages fis = null;
2151 if ((fis = getfpdFlash().getFvImages()) == null) {
2152 fis = getfpdFlash().addNewFvImages();
2153 }
2154
2155 //
2156 //gen FvImage with FvImageNames array
2157 //
2158 FvImagesDocument.FvImages.FvImage fi = fis.addNewFvImage();
2159 for (int i = 0; i < names.length; ++i) {
2160 fi.addFvImageNames(names[i]);
2161 }
2162 fi.setType(FvImageTypes.Enum.forString(types));
2163 if (options != null){
2164 setFvImagesFvImageFvImageOptions(options, fi);
2165 }
2166 }
2167
2168 private void setFvImagesFvImageFvImageOptions(Map<String, String> options, FvImagesDocument.FvImages.FvImage fi){
2169 FvImagesDocument.FvImages.FvImage.FvImageOptions fio = fi.getFvImageOptions();
2170 if (fio == null){
2171 fio = fi.addNewFvImageOptions();
2172 }
2173
2174 Set<String> key = options.keySet();
2175 Iterator<String> i = key.iterator();
2176 while (i.hasNext()) {
2177
2178 FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue nv = fio.addNewNameValue();
2179 String k = (String)i.next();
2180
2181 nv.setName(k);
2182 nv.setValue((String)options.get(k));
2183
2184 }
2185
2186 }
2187
2188
2189 public void removeFvImagesFvImage(int i) {
2190
2191 XmlObject o = getfpdFlash().getFvImages();
2192 if (o == null) {
2193 return;
2194 }
2195
2196 QName qFvImage = new QName(xmlNs, "FvImage");
2197 XmlCursor cursor = o.newCursor();
2198 if (cursor.toChild(qFvImage)) {
2199 for (int j = 0; j < i; ++j) {
2200 cursor.toNextSibling(qFvImage);
2201 }
2202 cursor.removeXml();
2203 }
2204 cursor.dispose();
2205 }
2206
2207 public void updateFvImagesFvImage(int i, String[] names, String types, Map<String, String> options){
2208
2209 XmlObject o = getfpdFlash().getFvImages();
2210 if (o == null) {
2211 return;
2212 }
2213 XmlCursor cursor = o.newCursor();
2214 QName qFvImage = new QName(xmlNs, "FvImage");
2215 if (cursor.toChild(qFvImage)) {
2216 for (int j = 0; j < i; ++j) {
2217 cursor.toNextSibling(qFvImage);
2218 }
2219 FvImagesDocument.FvImages.FvImage fi = (FvImagesDocument.FvImages.FvImage)cursor.getObject();
2220 fi.setType(FvImageTypes.Enum.forString(types));
2221
2222 //
2223 // remove old FvImageNames before adding new ones
2224 //
2225 QName qFvImageNames = new QName(xmlNs, "FvImageNames");
2226 cursor.toChild(qFvImageNames);
2227 cursor.removeXml();
2228 while (cursor.toNextSibling(qFvImageNames)) {
2229 cursor.removeXml();
2230 }
2231
2232 for (int k = 0; k < names.length; ++k) {
2233 fi.addFvImageNames(names[k]);
2234 }
2235 //
2236 // remove old FvImageOptions before adding new options
2237 //
2238 QName qFvImageOptions = new QName(xmlNs, "FvImageOptions");
2239 cursor.toNextSibling(qFvImageOptions);
2240 cursor.removeXml();
2241
2242 setFvImagesFvImageFvImageOptions(options, fi);
2243 }
2244 cursor.dispose();
2245 }
2246
2247 public int getFvImagesFvImageCount() {
2248
2249 if (getfpdFlash().getFvImages() == null || getfpdFlash().getFvImages().getFvImageList() == null) {
2250 return 0;
2251 }
2252 return getfpdFlash().getFvImages().getFvImageList().size();
2253 }
2254
2255 /**Only Get Fv image setting - name and type.
2256 * @param saa
2257 */
2258 public void getFvImagesFvImages(String[][] saa) {
2259
2260 if (getfpdFlash().getFvImages() == null) {
2261 return;
2262 }
2263 List<FvImagesDocument.FvImages.FvImage> l = getfpdFlash().getFvImages().getFvImageList();
2264 if (l == null) {
2265 return;
2266 }
2267 ListIterator li = l.listIterator();
2268 int i = 0;
2269 while(li.hasNext()) {
2270 FvImagesDocument.FvImages.FvImage fi = (FvImagesDocument.FvImages.FvImage)li.next();
2271 //
2272 // get FvImageNames array, space separated
2273 //
2274 List<String> lfn = fi.getFvImageNamesList();
2275 ListIterator lfni = lfn.listIterator();
2276 saa[i][0] = " ";
2277 while (lfni.hasNext()) {
2278 saa[i][0] += (String)lfni.next();
2279 saa[i][0] += " ";
2280 }
2281 saa[i][0] = saa[i][0].trim();
2282
2283 saa[i][1] = fi.getType()+"";
2284
2285 ++i;
2286 }
2287 }
2288
2289 /**Get FvImage Options for FvImage i
2290 * @param i the ith FvImage
2291 */
2292 public void getFvImagesFvImageOptions(int i, Map<String, String> m) {
2293 XmlObject o = getfpdFlash().getFvImages();
2294 if (o == null) {
2295 return;
2296 }
2297 XmlCursor cursor = o.newCursor();
2298 QName qFvImage = new QName(xmlNs, "FvImage");
2299 if (cursor.toChild(qFvImage)) {
2300 for (int j = 0; j < i; ++j) {
2301 cursor.toNextSibling(qFvImage);
2302 }
2303 FvImagesDocument.FvImages.FvImage fi = (FvImagesDocument.FvImages.FvImage)cursor.getObject();
2304 if (fi.getFvImageOptions() == null || fi.getFvImageOptions().getNameValueList() == null){
2305 return;
2306 }
2307 ListIterator<FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue> li = fi.getFvImageOptions().getNameValueList().listIterator();
2308 while(li.hasNext()){
2309 FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue nv = li.next();
2310 m.put(nv.getName(), nv.getValue());
2311 }
2312 }
2313 }
2314
2315 /**
2316 Get platform header element
2317 @return PlatformHeaderDocument.PlatformHeader
2318 **/
2319 public PlatformHeaderDocument.PlatformHeader getFpdHdr() {
2320 if (fpdHdr == null) {
2321 fpdHdr = fpdRoot.addNewPlatformHeader();
2322 }
2323 genPlatformDefsSkuInfo("0", "DEFAULT");
2324 return fpdHdr;
2325 }
2326
2327 public String getFpdHdrPlatformName() {
2328 return getFpdHdr().getPlatformName();
2329 }
2330
2331 public String getFpdHdrGuidValue() {
2332 return getFpdHdr().getGuidValue();
2333 }
2334
2335 public String getFpdHdrVer() {
2336 return getFpdHdr().getVersion();
2337 }
2338
2339 public String getFpdHdrAbs() {
2340 return getFpdHdr().getAbstract();
2341 }
2342
2343 public String getFpdHdrDescription() {
2344 return getFpdHdr().getDescription();
2345 }
2346
2347 public String getFpdHdrCopyright() {
2348 return getFpdHdr().getCopyright();
2349 }
2350
2351 public String getFpdHdrLicense() {
2352 LicenseDocument.License l = getFpdHdr().getLicense();
2353 if (l == null) {
2354 return null;
2355 }
2356 return l.getStringValue();
2357 }
2358
2359 public String getFpdHdrUrl() {
2360 LicenseDocument.License l = getFpdHdr().getLicense();
2361 if (l == null) {
2362 return null;
2363 }
2364 return l.getURL();
2365 }
2366
2367 public String getFpdHdrSpec() {
2368
2369 return "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052";
2370 // return getFpdHdr().getSpecification();
2371 }
2372
2373 public void setFpdHdrPlatformName(String name){
2374 getFpdHdr().setPlatformName(name);
2375 }
2376
2377 public void setFpdHdrGuidValue(String guid){
2378 getFpdHdr().setGuidValue(guid);
2379 }
2380
2381 public void setFpdHdrVer(String v){
2382 getFpdHdr().setVersion(v);
2383 }
2384
2385 public void setFpdHdrAbs(String abs) {
2386 getFpdHdr().setAbstract(abs);
2387 }
2388
2389 public void setFpdHdrDescription(String desc){
2390 getFpdHdr().setDescription(desc);
2391 }
2392
2393 public void setFpdHdrCopyright(String cr) {
2394 getFpdHdr().setCopyright(cr);
2395 }
2396
2397 public void setFpdHdrLicense(String license){
2398 LicenseDocument.License l = getFpdHdr().getLicense();
2399 if (l == null) {
2400 getFpdHdr().addNewLicense().setStringValue(license);
2401 }
2402 else {
2403 l.setStringValue(license);
2404 }
2405 }
2406
2407 public void setFpdHdrUrl(String url){
2408 LicenseDocument.License l = getFpdHdr().getLicense();
2409
2410 l.setURL(url);
2411
2412 }
2413
2414 public void setFpdHdrSpec(String s){
2415 s = "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052";
2416 getFpdHdr().setSpecification(s);
2417 }
2418 /**
2419 Save the processed xml contents to file
2420
2421 @param fpdFile The file to save xml contents
2422 @throws IOException Exceptions during file operation