]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFileContents.java
Added two optional attributes to the Cloned element, FarGuid and Id that can be used...
[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
27 import javax.xml.namespace.QName;
28
29 import org.apache.xmlbeans.XmlCursor;
30 import org.apache.xmlbeans.XmlObject;
31 import org.apache.xmlbeans.XmlOptions;
32 import org.tianocore.AntTaskDocument;
33 import org.tianocore.BuildOptionsDocument;
34 import org.tianocore.DynamicPcdBuildDefinitionsDocument;
35 import org.tianocore.EfiSectionType;
36 import org.tianocore.FlashDefinitionFileDocument;
37 import org.tianocore.FlashDocument;
38 import org.tianocore.FrameworkModulesDocument;
39 import org.tianocore.LibrariesDocument;
40 import org.tianocore.ModuleSADocument;
41 import org.tianocore.ModuleSurfaceAreaDocument;
42 import org.tianocore.OptionDocument;
43 import org.tianocore.OptionsDocument;
44 import org.tianocore.PcdBuildDefinitionDocument;
45 import org.tianocore.PcdCodedDocument;
46 import org.tianocore.PcdDataTypes;
47 import org.tianocore.PcdDeclarationsDocument;
48 import org.tianocore.PcdItemTypes;
49 import org.tianocore.PlatformDefinitionsDocument;
50 import org.tianocore.PlatformSurfaceAreaDocument;
51 import org.tianocore.FvImageTypes;
52 import org.tianocore.FvImagesDocument;
53 import org.tianocore.LicenseDocument;
54 import org.tianocore.PlatformHeaderDocument;
55 import org.tianocore.SkuInfoDocument;
56 import org.tianocore.UserDefinedAntTasksDocument;
57 import org.tianocore.frameworkwizard.platform.ui.global.GlobalData;
58 import org.tianocore.frameworkwizard.platform.ui.global.SurfaceAreaQuery;
59 import org.tianocore.frameworkwizard.platform.ui.id.ModuleIdentification;
60 import org.tianocore.frameworkwizard.platform.ui.id.PackageIdentification;
61
62 /**
63 This class processes fpd file contents such as add remove xml elements.
64 @since PackageEditor 1.0
65 **/
66 public class FpdFileContents {
67
68 static final String xmlNs = "http://www.TianoCore.org/2006/Edk2.0";
69
70 private PlatformSurfaceAreaDocument fpdd = null;
71
72 private PlatformSurfaceAreaDocument.PlatformSurfaceArea fpdRoot = null;
73
74 private PlatformHeaderDocument.PlatformHeader fpdHdr = null;
75
76 private PlatformDefinitionsDocument.PlatformDefinitions fpdPlatformDefs = null;
77
78 private FlashDocument.Flash fpdFlash = null;
79
80 private BuildOptionsDocument.BuildOptions fpdBuildOpts = null;
81
82 private FrameworkModulesDocument.FrameworkModules fpdFrameworkModules = null;
83
84 private DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions fpdDynPcdBuildDefs = null;
85
86 public static HashMap<String, ArrayList<String>> dynPcdMap = null;
87
88 /**
89 * look through all pcd data in all ModuleSA, create pcd -> ModuleSA mappings.
90 */
91 public void initDynPcdMap() {
92 if (dynPcdMap == null) {
93 dynPcdMap = new HashMap<String, ArrayList<String>>();
94 List<ModuleSADocument.ModuleSA> l = getfpdFrameworkModules().getModuleSAList();
95 if (l == null) {
96 return;
97 }
98 ListIterator<ModuleSADocument.ModuleSA> li = l.listIterator();
99 while (li.hasNext()) {
100 ModuleSADocument.ModuleSA msa = li.next();
101 if (msa.getPcdBuildDefinition() == null || msa.getPcdBuildDefinition().getPcdDataList() == null) {
102 continue;
103 }
104 String ModuleInfo = msa.getModuleGuid() + " " + msa.getModuleVersion() +
105 " " + msa.getPackageGuid() + " " + msa.getPackageVersion();
106 List<PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData> lp = msa.getPcdBuildDefinition().getPcdDataList();
107 ListIterator<PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData> lpi = lp.listIterator();
108 while (lpi.hasNext()) {
109 PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData pcdData = lpi.next();
110 String pcdKey = pcdData.getCName() + " " + pcdData.getTokenSpaceGuidCName();
111 if (dynPcdMap.get(pcdKey) == null) {
112 ArrayList<String> al = new ArrayList<String>();
113 al.add(ModuleInfo + " " + pcdData.getItemType().toString());
114 dynPcdMap.put(pcdKey, al);
115 }
116 else{
117 dynPcdMap.get(pcdKey).add(ModuleInfo + " " + pcdData.getItemType().toString());
118 }
119 }
120 }
121 }
122 }
123 /**
124 Constructor to create a new spd file
125 **/
126 public FpdFileContents() {
127
128 fpdd = PlatformSurfaceAreaDocument.Factory.newInstance();
129 fpdRoot = fpdd.addNewPlatformSurfaceArea();
130
131 }
132
133 /**
134 Constructor for existing document object
135 @param psa
136 **/
137 public FpdFileContents(PlatformSurfaceAreaDocument.PlatformSurfaceArea fpd) {
138 fpdRoot = fpd;
139 fpdHdr = fpdRoot.getPlatformHeader();
140 fpdPlatformDefs = fpdRoot.getPlatformDefinitions();
141 fpdBuildOpts = fpdRoot.getBuildOptions();
142 fpdFrameworkModules = fpdRoot.getFrameworkModules();
143 fpdDynPcdBuildDefs = fpdRoot.getDynamicPcdBuildDefinitions();
144 fpdFlash = fpdRoot.getFlash();
145 }
146
147 /**
148 Constructor based on an existing spd file
149
150 @param f Existing spd file
151 **/
152 public FpdFileContents(File f) {
153 try {
154 fpdd = PlatformSurfaceAreaDocument.Factory.parse(f);
155 fpdRoot = fpdd.getPlatformSurfaceArea();
156 } catch (Exception e) {
157 System.out.println(e.toString());
158 }
159 }
160
161 public DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions getfpdDynPcdBuildDefs() {
162 if (fpdDynPcdBuildDefs == null){
163 fpdDynPcdBuildDefs = fpdRoot.addNewDynamicPcdBuildDefinitions();
164 }
165 return fpdDynPcdBuildDefs;
166 }
167
168 public FrameworkModulesDocument.FrameworkModules getfpdFrameworkModules() {
169 if (fpdFrameworkModules == null){
170 fpdFrameworkModules = fpdRoot.addNewFrameworkModules();
171 }
172 return fpdFrameworkModules;
173 }
174
175 public int getPlatformDefsSkuInfoCount(){
176 if (getfpdPlatformDefs().getSkuInfo() == null || getfpdPlatformDefs().getSkuInfo().getUiSkuNameList() == null) {
177 return 0;
178 }
179 return getfpdPlatformDefs().getSkuInfo().getUiSkuNameList().size();
180 }
181
182 public void getPlatformDefsSkuInfos(String[][] saa){
183 if (getfpdPlatformDefs().getSkuInfo() == null || getfpdPlatformDefs().getSkuInfo().getUiSkuNameList() == null) {
184 return ;
185 }
186
187 List<SkuInfoDocument.SkuInfo.UiSkuName> l = getfpdPlatformDefs().getSkuInfo().getUiSkuNameList();
188 ListIterator<SkuInfoDocument.SkuInfo.UiSkuName> li = l.listIterator();
189 int i = 0;
190 while(li.hasNext()) {
191 SkuInfoDocument.SkuInfo.UiSkuName sku = li.next();
192 saa[i][0] = sku.getSkuID()+"";
193 saa[i][1] = sku.getStringValue();
194 ++i;
195 }
196 }
197
198 public int getFrameworkModulesCount() {
199 if (getfpdFrameworkModules().getModuleSAList() == null){
200 return 0;
201 }
202 return getfpdFrameworkModules().getModuleSAList().size();
203 }
204
205 public void getFrameworkModulesInfo(String[][] saa) {
206 if (getFrameworkModulesCount() == 0){
207 return;
208 }
209
210 ListIterator li = getfpdFrameworkModules().getModuleSAList().listIterator();
211 int i = 0;
212 while(li.hasNext()) {
213 ModuleSADocument.ModuleSA msa = (ModuleSADocument.ModuleSA)li.next();
214 saa[i][1] = msa.getModuleGuid();
215 saa[i][2] = msa.getModuleVersion();
216
217 saa[i][3] = msa.getPackageGuid();
218 saa[i][4] = msa.getPackageVersion();
219 // saa[i][4] = listToString(msa.getSupArchList());
220 ++i;
221 }
222 }
223
224 public ModuleSADocument.ModuleSA getModuleSA(String key) {
225 String[] s = key.split(" ");
226 if (getfpdFrameworkModules().getModuleSAList() == null) {
227 return null;
228 }
229 ListIterator li = getfpdFrameworkModules().getModuleSAList().listIterator();
230 while(li.hasNext()) {
231 ModuleSADocument.ModuleSA msa = (ModuleSADocument.ModuleSA)li.next();
232 if (msa.getModuleGuid().equals(s[0]) && msa.getModuleVersion().equals(s[1])
233 && msa.getPackageGuid().equals(s[2]) && msa.getPackageVersion().equals(s[3])) {
234
235 return msa;
236 }
237 }
238 return null;
239 }
240 public void removeModuleSA(int i) {
241 XmlObject o = getfpdFrameworkModules();
242 if (o == null) {
243 return;
244 }
245
246 XmlCursor cursor = o.newCursor();
247 if (cursor.toFirstChild()) {
248 for (int j = 0; j < i; ++j) {
249 cursor.toNextSibling();
250 }
251 //
252 // remove pcd from dynPcdMap, if DynamicPcdBuildData exists, remove them too.
253 //
254 ModuleSADocument.ModuleSA moduleSa = (ModuleSADocument.ModuleSA)cursor.getObject();
255 String moduleInfo = moduleSa.getModuleGuid() + " " + moduleSa.getModuleVersion() + " " +
256 moduleSa.getPackageGuid()+ " " + moduleSa.getPackageVersion();
257 PcdBuildDefinitionDocument.PcdBuildDefinition pcdBuildDef = moduleSa.getPcdBuildDefinition();
258 if (pcdBuildDef != null) {
259 maintainDynPcdMap(pcdBuildDef, moduleInfo);
260 }
261 cursor.removeXml();
262 }
263 cursor.dispose();
264 }
265
266 private void maintainDynPcdMap(PcdBuildDefinitionDocument.PcdBuildDefinition o, String moduleInfo) {
267 XmlCursor cursor = o.newCursor();
268 boolean fromLibInstance = false;
269 if (!cursor.toFirstChild()){
270 return;
271 }
272 //
273 // deal with first child, same process in the while loop below for siblings.
274 //
275 PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData pcdData = (PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData)cursor.getObject();
276 String pcdKey = pcdData.getCName() + " " + pcdData.getTokenSpaceGuidCName();
277 ArrayList<String> al = dynPcdMap.get(pcdKey);
278 for(int i = 0; i < al.size(); ++i){
279 if (al.get(i).startsWith(moduleInfo)){
280 fromLibInstance = true;
281 break;
282 }
283 }
284 al.remove(moduleInfo + " " + pcdData.getItemType().toString());
285 if (al.size() == 0) {
286 dynPcdMap.remove(pcdKey);
287 }
288
289 if (pcdData.getItemType().toString().equals("DYNAMIC")) {
290 if (dynPcdMap.get(pcdKey) == null) {
291 removeDynamicPcdBuildData(pcdData.getCName(), pcdData.getTokenSpaceGuidCName());
292 }
293 }
294 if (fromLibInstance){
295 cursor.removeXml();
296 }
297 while(cursor.toNextSibling()) {
298 fromLibInstance = false;
299 pcdData = (PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData)cursor.getObject();
300 //
301 // remove each pcd record from dynPcdMap
302 //
303 pcdKey = pcdData.getCName() + " " + pcdData.getTokenSpaceGuidCName();
304 al = dynPcdMap.get(pcdKey);
305 for(int i = 0; i < al.size(); ++i){
306 if (al.get(i).startsWith(moduleInfo)){
307 fromLibInstance = true;
308 break;
309 }
310 }
311 al.remove(moduleInfo + " " + pcdData.getItemType().toString());
312 if (al.size() == 0) {
313 dynPcdMap.remove(pcdKey);
314 }
315
316 if (pcdData.getItemType().toString().equals("DYNAMIC")) {
317 //
318 // First check whether this is the only consumer of this dyn pcd.
319 //
320 if (dynPcdMap.get(pcdKey) == null) {
321 //
322 // delete corresponding entry in DynamicPcdBuildData
323 //
324 removeDynamicPcdBuildData(pcdData.getCName(), pcdData.getTokenSpaceGuidCName());
325 }
326 }
327 if (fromLibInstance){
328 cursor.removeXml();
329 }
330 }
331 }
332 //
333 // key for ModuleSA : "ModuleGuid ModuleVer PackageGuid PackageVer"
334 //
335 public int getPcdDataCount(String key){
336 ModuleSADocument.ModuleSA msa = getModuleSA(key);
337 if (msa == null || msa.getPcdBuildDefinition() == null || msa.getPcdBuildDefinition().getPcdDataList() == null){
338 return 0;
339 }
340 return msa.getPcdBuildDefinition().getPcdDataList().size();
341 }
342
343 public void getPcdData(String key, String[][] saa) {
344 ModuleSADocument.ModuleSA msa = getModuleSA(key);
345 if (msa == null || msa.getPcdBuildDefinition() == null || msa.getPcdBuildDefinition().getPcdDataList() == null){
346 return;
347 }
348 ListIterator<PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData>li = msa.getPcdBuildDefinition().getPcdDataList().listIterator();
349 for (int i = 0; i < saa.length; ++i) {
350 PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData pcdData = li.next();
351 saa[i][0] = pcdData.getCName();
352 saa[i][1] = pcdData.getTokenSpaceGuidCName();
353 saa[i][2] = pcdData.getItemType().toString();
354 saa[i][3] = pcdData.getToken().toString();
355 saa[i][4] = pcdData.getDatumType().toString();
356 saa[i][5] = pcdData.getValue();
357
358 }
359 }
360 //
361 // key for ModuleSA : "ModuleGuid ModuleVer PackageGuid PackageVer"
362 //
363 public int getLibraryInstancesCount(String key) {
364 ModuleSADocument.ModuleSA msa = getModuleSA(key);
365 if (msa == null || msa.getLibraries() == null || msa.getLibraries().getInstanceList() == null){
366 return 0;
367 }
368 return msa.getLibraries().getInstanceList().size();
369 }
370
371 public void getLibraryInstances(String key, String[][] saa){
372 ModuleSADocument.ModuleSA msa = getModuleSA(key);
373 if (msa == null || msa.getLibraries() == null || msa.getLibraries().getInstanceList() == null){
374 return ;
375 }
376
377 ListIterator<LibrariesDocument.Libraries.Instance> li = msa.getLibraries().getInstanceList().listIterator();
378 for (int i = 0; i < saa.length; ++i) {
379 LibrariesDocument.Libraries.Instance instance = li.next();
380 saa[i][1] = instance.getModuleGuid();
381 saa[i][2] = instance.getModuleVersion();
382 saa[i][3] = instance.getPackageGuid();
383 saa[i][4] = instance.getPackageVersion();
384 }
385 }
386
387 public void removeLibraryInstances(String key) {
388 ModuleSADocument.ModuleSA msa = getModuleSA(key);
389 if (msa == null || msa.getLibraries() == null){
390 return ;
391 }
392
393 XmlCursor cursor = msa.getLibraries().newCursor();
394 cursor.removeXml();
395 cursor.dispose();
396 }
397
398 public void genLibraryInstance(String mg, String mv, String pg, String pv, String key) {
399 ModuleSADocument.ModuleSA msa = getModuleSA(key);
400 if (msa == null){
401 msa = getfpdFrameworkModules().addNewModuleSA();
402 }
403 LibrariesDocument.Libraries libs = msa.getLibraries();
404 if(libs == null){
405 libs = msa.addNewLibraries();
406 }
407
408 LibrariesDocument.Libraries.Instance instance = libs.addNewInstance();
409 instance.setModuleGuid(mg);
410 instance.setModuleVersion(mv);
411 instance.setPackageGuid(pg);
412 instance.setPackageVersion(pv);
413
414 }
415 /**add pcd information of module mi to a ModuleSA.
416 * @param mi
417 * @param moduleSa if null, generate a new ModuleSA.
418 */
419 public void addFrameworkModulesPcdBuildDefs(ModuleIdentification mi, ModuleSADocument.ModuleSA moduleSa){
420 //ToDo add Arch filter
421
422 try {
423 ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = (ModuleSurfaceAreaDocument.ModuleSurfaceArea)GlobalData.getModuleXmlObject(mi);
424 if (msa.getPcdCoded() == null) {
425 return;
426 }
427 if (moduleSa == null) {
428 moduleSa = genModuleSA(mi);
429 }
430 Map<String, XmlObject> m = new HashMap<String, XmlObject>();
431 m.put("ModuleSurfaceArea", msa);
432 SurfaceAreaQuery.setDoc(m);
433 PackageIdentification[] depPkgs = SurfaceAreaQuery.getDependencePkg(null);
434 //
435 // Implementing InitializePlatformPcdBuildDefinitions
436 //
437 List<PcdCodedDocument.PcdCoded.PcdEntry> l = msa.getPcdCoded().getPcdEntryList();
438 ListIterator li = l.listIterator();
439 while(li.hasNext()) {
440 PcdCodedDocument.PcdCoded.PcdEntry msaPcd = (PcdCodedDocument.PcdCoded.PcdEntry)li.next();
441 PcdDeclarationsDocument.PcdDeclarations.PcdEntry spdPcd = LookupPcdDeclaration(msaPcd, depPkgs);
442 if (spdPcd == null) {
443 //
444 // ToDo Error
445 //
446 break;
447 }
448 //
449 // AddItem to ModuleSA PcdBuildDefinitions
450 //
451 String defaultVal = msaPcd.getDefaultValue() == null ? spdPcd.getDefaultValue() : msaPcd.getDefaultValue();
452 genPcdData(msaPcd.getCName(), spdPcd.getToken(), msaPcd.getTokenSpaceGuidCName(), msaPcd.getPcdItemType().toString(), spdPcd.getDatumType()+"", defaultVal, moduleSa);
453 }
454
455 }
456 catch (Exception e){
457 e.printStackTrace();
458 }
459
460 }
461
462 private PcdDeclarationsDocument.PcdDeclarations.PcdEntry LookupPcdDeclaration (PcdCodedDocument.PcdCoded.PcdEntry msaPcd, PackageIdentification[] depPkgs) {
463
464 Map<String, XmlObject> m = new HashMap<String, XmlObject>();
465 PcdDeclarationsDocument.PcdDeclarations.PcdEntry spdPcd = null;
466 for (int i = 0; i < depPkgs.length; ++i) {
467 m.put("PackageSurfaceArea", GlobalData.getPackageXmlObject(depPkgs[i]));
468 SurfaceAreaQuery.setDoc(m);
469 XmlObject[] xo = SurfaceAreaQuery.getSpdPcdDeclarations();
470 if (xo == null) {
471 continue;
472 }
473 for (int j = 0; j < xo.length; ++j) {
474 spdPcd = (PcdDeclarationsDocument.PcdDeclarations.PcdEntry)xo[j];
475 if (msaPcd.getTokenSpaceGuidCName() == null) {
476 if (spdPcd.getCName().equals(msaPcd.getCName())) {
477 return spdPcd;
478 }
479 }
480 else{
481 if (spdPcd.getCName().equals(msaPcd.getCName()) && spdPcd.getTokenSpaceGuidCName().equals(msaPcd.getTokenSpaceGuidCName())) {
482 return spdPcd;
483 }
484 }
485
486 }
487
488 }
489 return null;
490 }
491
492 private ModuleSADocument.ModuleSA genModuleSA (ModuleIdentification mi) {
493 PackageIdentification pi = GlobalData.getPackageForModule(mi);
494 ModuleSADocument.ModuleSA msa = getfpdFrameworkModules().addNewModuleSA();
495 msa.setModuleGuid(mi.getGuid());
496 msa.setModuleVersion(mi.getVersion());
497 msa.setPackageGuid(pi.getGuid());
498 msa.setPackageVersion(pi.getVersion());
499
500 return msa;
501 }
502
503 private void genPcdData (String cName, Object token, String tsGuid, String itemType, String dataType, String defaultVal, ModuleSADocument.ModuleSA moduleSa) {
504 if (moduleSa.getPcdBuildDefinition() == null){
505 moduleSa.addNewPcdBuildDefinition();
506 }
507 //
508 // constructe pcd to modulesa mapping first.
509 // Attention : for any error condition, remove from map this pcd.
510 //
511 ArrayList<String> pcdConsumer = LookupPlatformPcdData(cName + " " + tsGuid);
512 if (pcdConsumer == null) {
513 pcdConsumer = new ArrayList<String>();
514 }
515 String listValue = moduleSa.getModuleGuid() + " " + moduleSa.getModuleVersion()
516 + " " + moduleSa.getPackageGuid() + " " + moduleSa.getPackageVersion()
517 + " " + itemType;
518 pcdConsumer.add(listValue);
519 dynPcdMap.put(cName + " " + tsGuid, pcdConsumer);
520 //
521 // Special dynamic type, if this pcd already exists in other ModuleSA
522 //
523 if (itemType.equals("DYNAMIC")) {
524
525 ListIterator li = pcdConsumer.listIterator();
526 while(li.hasNext()) {
527 String value = li.next().toString();
528 String[] valuePart= value.split(" ");
529 if (!valuePart[4].equals("DYNAMIC")) {
530 //ToDo error for same pcd, other type than dynamic
531 pcdConsumer.remove(listValue);
532 return;
533 }
534 }
535 }
536 else {
537 ListIterator li = pcdConsumer.listIterator();
538 while(li.hasNext()) {
539 String value = li.next().toString();
540 String[] valuePart= value.split(" ");
541 if (valuePart[4].equals("DYNAMIC")) {
542 //ToDo error for same pcd, other type than non-dynamic
543 pcdConsumer.remove(listValue);
544 return;
545 }
546 }
547 }
548
549 PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData fpdPcd = moduleSa.getPcdBuildDefinition().addNewPcdData();
550 fpdPcd.setCName(cName);
551 fpdPcd.setToken(token);
552 fpdPcd.setTokenSpaceGuidCName(tsGuid);
553 fpdPcd.setDatumType(PcdDataTypes.Enum.forString(dataType));
554 fpdPcd.setItemType(PcdItemTypes.Enum.forString(itemType));
555
556 if (itemType.equals("DYNAMIC") || itemType.equals("DYNAMIC_EX")) {
557 ArrayList<String> al = LookupDynamicPcdBuildDefinition(cName + " " + tsGuid);
558 //
559 // if only one module mapped to this pcd, then the one is myself. so no other module mapped.
560 // so need to add one dyn pcd.
561 //
562 if (al.size() == 1) {
563 addDynamicPcdBuildData(cName, token, tsGuid, itemType, dataType, defaultVal);
564 }
565 }
566 else {
567 if (defaultVal != null){
568 fpdPcd.setValue(defaultVal);
569 }
570 else {
571 if (dataType.equals("UINT8") || dataType.equals("UINT16") || dataType.equals("UINT32") || dataType.equals("UINT64")) {
572 fpdPcd.setValue("0");
573 }
574 if (dataType.equals("BOOLEAN")){
575 fpdPcd.setValue("false");
576 }
577 if (dataType.equals("VOID*")) {
578 fpdPcd.setValue("");
579 }
580 }
581 if (dataType.equals("UINT8")){
582 fpdPcd.setMaxDatumSize(1);
583 }
584 if (dataType.equals("UINT16")) {
585 fpdPcd.setMaxDatumSize(2);
586 }
587 if (dataType.equals("UINT32")) {
588 fpdPcd.setMaxDatumSize(4);
589 }
590 if (dataType.equals("UINT64")){
591 fpdPcd.setMaxDatumSize(8);
592 }
593 if (dataType.equals("BOOLEAN")){
594 fpdPcd.setMaxDatumSize(1);
595 }
596 if (dataType.equals("VOID*")) {
597 int maxSize = setMaxSizeForPointer(fpdPcd.getValue());
598 fpdPcd.setMaxDatumSize(maxSize);
599 }
600 }
601 }
602
603 private int setMaxSizeForPointer(String datum) {
604 if (datum == null) {
605 return 0;
606 }
607 char ch = datum.charAt(0);
608 int start, end;
609 String strValue;
610 //
611 // For void* type PCD, only three datum is support:
612 // 1) Unicode: string with start char is "L"
613 // 2) Ansci: String is ""
614 // 3) byte array: String start char "{"
615 //
616 if (ch == 'L') {
617 start = datum.indexOf('\"');
618 end = datum.lastIndexOf('\"');
619 if ((start > end) ||
620 (end > datum.length())||
621 ((start == end) && (datum.length() > 0))) {
622 //ToDo Error handling here
623 }
624
625 strValue = datum.substring(start + 1, end);
626 return strValue.length() * 2;
627 } else if (ch == '\"'){
628 start = datum.indexOf('\"');
629 end = datum.lastIndexOf('\"');
630 if ((start > end) ||
631 (end > datum.length())||
632 ((start == end) && (datum.length() > 0))) {
633
634 }
635 strValue = datum.substring(start + 1, end);
636 return strValue.length();
637 } else if (ch =='{') {
638 String[] strValueArray;
639
640 start = datum.indexOf('{');
641 end = datum.lastIndexOf('}');
642 strValue = datum.substring(start + 1, end);
643 strValue = strValue.trim();
644 if (strValue.length() == 0) {
645 return 0;
646 }
647 strValueArray = strValue.split(",");
648 for (int index = 0; index < strValueArray.length; index ++) {
649 Integer value = Integer.decode(strValueArray[index].trim());
650
651 if (value > 0xFF) {
652 // "[FPD file error] The datum type of PCD %s in %s is VOID*, "+
653 // "it is byte array in fact. But the element of %s exceed the byte range",
654
655 }
656 }
657 return strValueArray.length;
658
659
660 } else {
661 // "[FPD file error] The datum type of PCD %s in %s is VOID*. For VOID* type, you have three format choise:\n "+
662 // "1) UNICODE string: like L\"xxxx\";\r\n"+
663 // "2) ANSIC string: like \"xxx\";\r\n"+
664 // "3) Byte array: like {0x2, 0x45, 0x23}\r\n"+
665 // "but the datum in seems does not following above format!",
666 return -1;
667
668 }
669 }
670
671 private ArrayList<String> LookupDynamicPcdBuildDefinition(String dynPcdKey) {
672 ArrayList<String> al = dynPcdMap.get(dynPcdKey);
673
674 return al;
675 }
676
677 private ArrayList<String> LookupPlatformPcdData(String pcdKey) {
678
679 return dynPcdMap.get("pcdKey");
680 }
681
682 public int getDynamicPcdBuildDataCount() {
683 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null) {
684 return 0;
685 }
686 return getfpdDynPcdBuildDefs().getPcdBuildDataList().size();
687 }
688
689 public void getDynamicPcdBuildData(String[][] saa) {
690 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null) {
691 return ;
692 }
693 List<DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData> l = getfpdDynPcdBuildDefs().getPcdBuildDataList();
694 ListIterator<DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData> li = l.listIterator();
695 int i = 0;
696 while(li.hasNext()) {
697 DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData dynPcd = li.next();
698 saa[i][0] = dynPcd.getCName();
699 saa[i][1] = dynPcd.getToken().toString();
700 saa[i][2] = dynPcd.getTokenSpaceGuidCName();
701 saa[i][3] = dynPcd.getMaxDatumSize()+"";
702 saa[i][4] = dynPcd.getDatumType().toString();
703
704 ++i;
705 }
706 }
707
708 private void addDynamicPcdBuildData(String cName, Object token, String tsGuid, String itemType, String dataType, String defaultVal) {
709 DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData dynPcdData = getfpdDynPcdBuildDefs().addNewPcdBuildData();
710 dynPcdData.setItemType(PcdItemTypes.Enum.forString(itemType));
711 dynPcdData.setCName(cName);
712 dynPcdData.setToken(token);
713 dynPcdData.setTokenSpaceGuidCName(tsGuid);
714 dynPcdData.setDatumType(PcdDataTypes.Enum.forString(dataType));
715
716 BigInteger bigInt = new BigInteger("0");
717 DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData.SkuInfo skuInfo = dynPcdData.addNewSkuInfo();
718 skuInfo.setSkuId(bigInt);
719 if (defaultVal != null){
720 skuInfo.setValue(defaultVal);
721 }
722 else {
723 if (dataType.equals("UINT8")){
724 skuInfo.setValue("0");
725 }
726 if (dataType.equals("UINT16")) {
727 skuInfo.setValue("0");
728 }
729 if (dataType.equals("UINT32")) {
730 skuInfo.setValue("0");
731 }
732 if (dataType.equals("UINT64")){
733 skuInfo.setValue("0");
734 }
735 if (dataType.equals("BOOLEAN")){
736 skuInfo.setValue("false");
737 }
738 if (dataType.equals("VOID*")) {
739 skuInfo.setValue("");
740 }
741 }
742 if (dataType.equals("UINT8")){
743 dynPcdData.setMaxDatumSize(1);
744 }
745 if (dataType.equals("UINT16")) {
746 dynPcdData.setMaxDatumSize(2);
747 }
748 if (dataType.equals("UINT32")) {
749 dynPcdData.setMaxDatumSize(4);
750 }
751 if (dataType.equals("UINT64")){
752 dynPcdData.setMaxDatumSize(8);
753 }
754 if (dataType.equals("BOOLEAN")){
755 dynPcdData.setMaxDatumSize(1);
756 }
757 if (dataType.equals("VOID*")) {
758 int maxSize = setMaxSizeForPointer(defaultVal);
759 dynPcdData.setMaxDatumSize(maxSize);
760 }
761 }
762
763 private void removeDynamicPcdBuildData(String cName, String tsGuid) {
764 XmlObject o = getfpdDynPcdBuildDefs();
765
766 XmlCursor cursor = o.newCursor();
767 if (cursor.toFirstChild()) {
768 DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData pcdBuildData =
769 (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject();
770 while (!(pcdBuildData.getCName().equals(cName) && pcdBuildData.getTokenSpaceGuidCName().equals(tsGuid))) {
771 cursor.toNextSibling();
772 pcdBuildData = (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject();
773 }
774
775 cursor.removeXml();
776 }
777 cursor.dispose();
778 }
779 //
780 // Get the Sku Info count of ith dyn pcd element.
781 //
782 public int getDynamicPcdSkuInfoCount(int i){
783 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
784 return 0;
785 }
786
787 int skuInfoCount = 0;
788 XmlCursor cursor = getfpdDynPcdBuildDefs().newCursor();
789 if (cursor.toFirstChild()) {
790 for (int j = 0; j < i; ++j) {
791 cursor.toNextSibling();
792 }
793 DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData pcdData = (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject();
794 if (pcdData.getSkuInfoList() == null) {
795 skuInfoCount = 0;
796 }
797 else {
798 skuInfoCount = pcdData.getSkuInfoList().size();
799 }
800 }
801 cursor.dispose();
802 return skuInfoCount;
803 }
804
805 public void getDynamicPcdSkuInfos(int i, String[][] saa){
806 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
807 return;
808 }
809
810 XmlCursor cursor = getfpdDynPcdBuildDefs().newCursor();
811 if (cursor.toFirstChild()) {
812 for (int j = 0; j < i; ++j) {
813 cursor.toNextSibling();
814 }
815 DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData pcdData = (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject();
816 if (pcdData.getSkuInfoList() == null) {
817 cursor.dispose();
818 return;
819 }
820 else {
821 ListIterator<DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData.SkuInfo> li = pcdData.getSkuInfoList().listIterator();
822 int k = 0;
823 while (li.hasNext()) {
824 DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData.SkuInfo skuInfo = li.next();
825 saa[k][0] = skuInfo.getSkuId()+"";
826 saa[k][1] = skuInfo.getVariableName();
827 saa[k][2] = skuInfo.getVariableGuid();
828 saa[k][3] = skuInfo.getVariableOffset();
829 saa[k][4] = skuInfo.getHiiDefaultValue();
830 saa[k][5] = skuInfo.getVpdOffset();
831 saa[k][6] = skuInfo.getValue();
832 ++k;
833 }
834
835 }
836 }
837 cursor.dispose();
838
839 }
840
841 public String getDynamicPcdBuildDataValue(int i){
842 String value = null;
843 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
844 return value;
845 }
846
847 XmlCursor cursor = getfpdDynPcdBuildDefs().newCursor();
848 if (cursor.toFirstChild()) {
849 for (int j = 0; j < i; ++j) {
850 cursor.toNextSibling();
851 }
852 DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData pcdData = (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject();
853 if (pcdData.getSkuInfoList() == null) {
854 value = null;
855 }
856 else {
857 value = pcdData.getSkuInfoArray(0).getValue();
858 }
859 }
860 cursor.dispose();
861 return value;
862 }
863
864 public String getDynamicPcdBuildDataVpdOffset(int i){
865 String vpdOffset = null;
866 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
867 return vpdOffset;
868 }
869
870 XmlCursor cursor = getfpdDynPcdBuildDefs().newCursor();
871 if (cursor.toFirstChild()) {
872 for (int j = 0; j < i; ++j) {
873 cursor.toNextSibling();
874 }
875 DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData pcdData = (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject();
876 if (pcdData.getSkuInfoList() == null) {
877 vpdOffset = null;
878 }
879 else {
880 vpdOffset = pcdData.getSkuInfoArray(0).getVpdOffset();
881 }
882 }
883 cursor.dispose();
884 return vpdOffset;
885 }
886
887 public void removeDynamicPcdBuildDataSkuInfo(int i) {
888 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
889 return;
890 }
891
892 XmlCursor cursor = getfpdDynPcdBuildDefs().newCursor();
893 if (cursor.toFirstChild()) {
894 for (int j = 0; j < i; ++j) {
895 cursor.toNextSibling();
896 }
897 DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData pcdData = (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject();
898 if (pcdData.getSkuInfoList() == null) {
899 cursor.dispose();
900 return;
901 }
902 else {
903 QName qSkuInfo = new QName(xmlNs, "SkuInfo");
904 cursor.toChild(qSkuInfo);
905 cursor.removeXml();
906 }
907 }
908 cursor.dispose();
909 }
910 //
911 // generate sku info for ith dyn pcd build data.
912 //
913 public void genDynamicPcdBuildDataSkuInfo(String id, String varName, String varGuid, String varOffset,
914 String hiiDefault, String vpdOffset, String value, int i) {
915 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
916 return;
917 }
918
919 XmlCursor cursor = getfpdDynPcdBuildDefs().newCursor();
920 if (cursor.toFirstChild()) {
921 for (int j = 0; j < i; ++j) {
922 cursor.toNextSibling();
923 }
924 DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData pcdData = (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject();
925 DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData.SkuInfo skuInfo = pcdData.addNewSkuInfo();
926 skuInfo.setSkuId(new BigInteger(id));
927 if (varName != null){
928 skuInfo.setVariableName(varName);
929 skuInfo.setVariableGuid(varGuid);
930 skuInfo.setVariableOffset(varOffset);
931 skuInfo.setHiiDefaultValue(hiiDefault);
932 }
933 else if (vpdOffset != null){
934 skuInfo.setVpdOffset(vpdOffset);
935 }
936 else{
937 skuInfo.setValue(value);
938 }
939 }
940 }
941
942 public void updateDynamicPcdBuildDataSkuInfo(String id, String varName, String varGuid, String varOffset,
943 String hiiDefault, String vpdOffset, String value, int i){
944 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
945 return;
946 }
947
948 XmlCursor cursor = getfpdDynPcdBuildDefs().newCursor();
949 if (cursor.toFirstChild()) {
950 for (int j = 0; j < i; ++j) {
951 cursor.toNextSibling();
952 }
953 DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData pcdData = (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject();
954 ListIterator<DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData.SkuInfo> li = pcdData.getSkuInfoList().listIterator();
955 while (li.hasNext()) {
956 DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData.SkuInfo skuInfo = li.next();
957 if (skuInfo.getSkuId().toString().equals(id)){
958 if (varName != null){
959 skuInfo.setVariableName(varName);
960 skuInfo.setVariableGuid(varGuid);
961 skuInfo.setVariableOffset(varOffset);
962 skuInfo.setHiiDefaultValue(hiiDefault);
963 }
964 else if (vpdOffset != null){
965 skuInfo.setVpdOffset(vpdOffset);
966 }
967 else{
968 skuInfo.setValue(value);
969 }
970 break;
971 }
972 }
973 }
974 }
975
976 public void removePcdDataFromLibraryInstance(String moduleKey, String libInstanceKey){
977 ModuleSADocument.ModuleSA moduleSa = getModuleSA(moduleKey);
978 //
979 // should better maintain pcd from lib instance only, but maintain all is acceptable now.
980 //
981 maintainDynPcdMap(moduleSa.getPcdBuildDefinition(), libInstanceKey);
982
983 }
984
985 public BuildOptionsDocument.BuildOptions getfpdBuildOpts() {
986 if (fpdBuildOpts == null) {
987 fpdBuildOpts = fpdRoot.addNewBuildOptions();
988 }
989 return fpdBuildOpts;
990 }
991
992 public void genBuildOptionsUserDefAntTask (String id, String fileName, String execOrder) {
993 UserDefinedAntTasksDocument.UserDefinedAntTasks udats = getfpdBuildOpts().getUserDefinedAntTasks();
994 if (udats == null) {
995 udats = getfpdBuildOpts().addNewUserDefinedAntTasks();
996 }
997
998 AntTaskDocument.AntTask at = udats.addNewAntTask();
999 setBuildOptionsUserDefAntTask(id, fileName, execOrder, at);
1000 }
1001
1002 private void setBuildOptionsUserDefAntTask(String id, String fileName, String execOrder, AntTaskDocument.AntTask at) {
1003 at.setId(new Integer(id));
1004 if (fileName != null){
1005 at.setFilename(fileName);
1006 }
1007 if (execOrder != null) {
1008 at.setAntCmdOptions(execOrder);
1009 }
1010 }
1011
1012 public void removeBuildOptionsUserDefAntTask(int i) {
1013 XmlObject o = getfpdBuildOpts().getUserDefinedAntTasks();
1014 if (o == null) {
1015 return;
1016 }
1017 XmlCursor cursor = o.newCursor();
1018 if (cursor.toFirstChild()) {
1019 for (int j = 0; j < i; ++j) {
1020 cursor.toNextSibling();
1021 }
1022 cursor.removeXml();
1023 }
1024 cursor.dispose();
1025 }
1026
1027 public void updateBuildOptionsUserDefAntTask(int i, String id, String fileName, String execOrder){
1028 XmlObject o = getfpdBuildOpts().getUserDefinedAntTasks();
1029 if (o == null) {
1030 return;
1031 }
1032 XmlCursor cursor = o.newCursor();
1033 if (cursor.toFirstChild()) {
1034 for (int j = 0; j < i; ++j) {
1035 cursor.toNextSibling();
1036 }
1037 AntTaskDocument.AntTask at = (AntTaskDocument.AntTask)cursor.getObject();
1038 setBuildOptionsUserDefAntTask(id, fileName, execOrder, at);
1039 }
1040 cursor.dispose();
1041 }
1042
1043 public int getBuildOptionsUserDefAntTaskCount() {
1044 UserDefinedAntTasksDocument.UserDefinedAntTasks udats = getfpdBuildOpts().getUserDefinedAntTasks();
1045 if (udats == null || udats.getAntTaskList() == null) {
1046 return 0;
1047 }
1048
1049 return udats.getAntTaskList().size();
1050 }
1051
1052 public void getBuildOptionsUserDefAntTasks(String[][] saa) {
1053 UserDefinedAntTasksDocument.UserDefinedAntTasks udats = getfpdBuildOpts().getUserDefinedAntTasks();
1054 if (udats == null || udats.getAntTaskList() == null) {
1055 return ;
1056 }
1057
1058 List<AntTaskDocument.AntTask> l = udats.getAntTaskList();
1059 ListIterator li = l.listIterator();
1060 int i = 0;
1061 while (li.hasNext()) {
1062 AntTaskDocument.AntTask at = (AntTaskDocument.AntTask)li.next();
1063 saa[i][0] = at.getId() + "";
1064 saa[i][1] = saa[i][2] = "";
1065 if (at.getFilename() != null){
1066 saa[i][1] = at.getFilename();
1067 }
1068 if (at.getAntCmdOptions() != null) {
1069 saa[i][2] = at.getAntCmdOptions();
1070 }
1071 ++i;
1072 }
1073 }
1074 public void genBuildOptionsOpt(String buildTargets, String toolChain, String tagName, String toolCmd, String archList, String contents) {
1075 OptionsDocument.Options opts = getfpdBuildOpts().getOptions();
1076 if (opts == null) {
1077 opts = getfpdBuildOpts().addNewOptions();
1078 }
1079 OptionDocument.Option opt = opts.addNewOption();
1080 setBuildOptionsOpt(buildTargets, toolChain, tagName, toolCmd, archList, contents, opt);
1081 }
1082
1083 private void setBuildOptionsOpt(String buildTargets, String toolChain, String tagName, String toolCmd, String archList, String contents, OptionDocument.Option opt){
1084 opt.setStringValue(contents);
1085 // opt.setBuildTargets(buildTargets);
1086 opt.setToolChainFamily(toolChain);
1087 opt.setTagName(tagName);
1088 opt.setToolCode(toolCmd);
1089 String[] s = archList.split(" ");
1090 ArrayList<String> al = new ArrayList<String>();
1091 for (int i = 0; i < s.length; ++i) {
1092 al.add(s[i]);
1093 }
1094 opt.setSupArchList(al);
1095 }
1096
1097 public void removeBuildOptionsOpt(int i){
1098
1099 XmlObject o = getfpdBuildOpts().getOptions();
1100 if (o == null) {
1101 return;
1102 }
1103
1104 XmlCursor cursor = o.newCursor();
1105 if (cursor.toFirstChild()) {
1106 for (int j = 0; j < i; ++j) {
1107 cursor.toNextSibling();
1108 }
1109 cursor.removeXml();
1110 }
1111 cursor.dispose();
1112 }
1113
1114 public void updateBuildOptionsOpt(int i, String buildTargets, String toolChain, String tagName, String toolCmd, String archList, String contents) {
1115 XmlObject o = getfpdBuildOpts().getOptions();
1116 if (o == null) {
1117 return;
1118 }
1119
1120 XmlCursor cursor = o.newCursor();
1121 if (cursor.toFirstChild()) {
1122 for (int j = 0; j < i; ++j) {
1123 cursor.toNextSibling();
1124 }
1125 OptionDocument.Option opt = (OptionDocument.Option)cursor.getObject();
1126 setBuildOptionsOpt(buildTargets, toolChain, tagName, toolCmd, archList, contents, opt);
1127 }
1128 cursor.dispose();
1129 }
1130
1131 public int getBuildOptionsOptCount(){
1132 if (getfpdBuildOpts().getOptions() == null || getfpdBuildOpts().getOptions().getOptionList() == null) {
1133 return 0;
1134 }
1135 return getfpdBuildOpts().getOptions().getOptionList().size();
1136 }
1137
1138 public void getBuildOptionsOpts(String[][] saa) {
1139 if (getfpdBuildOpts().getOptions() == null || getfpdBuildOpts().getOptions().getOptionList() == null) {
1140 return ;
1141 }
1142
1143 List<OptionDocument.Option> lOpt = getfpdBuildOpts().getOptions().getOptionList();
1144 ListIterator li = lOpt.listIterator();
1145 int i = 0;
1146 while(li.hasNext()) {
1147 OptionDocument.Option opt = (OptionDocument.Option)li.next();
1148 if (opt.getBuildTargets() != null) {
1149 saa[i][0] = listToString(opt.getBuildTargets());
1150 }
1151 saa[i][1] = opt.getToolChainFamily();
1152 if (opt.getSupArchList() != null){
1153 saa[i][2] = listToString(opt.getSupArchList());
1154
1155 }
1156 saa[i][3] = opt.getToolCode();
1157 saa[i][4] = opt.getTagName();
1158 saa[i][5] = opt.getStringValue();
1159
1160 ++i;
1161 }
1162 }
1163
1164 public void genBuildOptionsFfs(String ffsKey, String type) {
1165 BuildOptionsDocument.BuildOptions.Ffs ffs = getfpdBuildOpts().addNewFfs();
1166 ffs.setFfsKey(ffsKey);
1167 if (type != null) {
1168 ffs.addNewSections().setEncapsulationType(type);
1169 }
1170 }
1171
1172 public void genBuildOptionsFfsAttribute(int i, String name, String value) {
1173 BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);
1174 BuildOptionsDocument.BuildOptions.Ffs.Attribute attrib = ffs.addNewAttribute();
1175 attrib.setName(name);
1176 attrib.setValue(value);
1177 }
1178
1179 /**update jth attribute of ith ffs.
1180 * @param i
1181 * @param j
1182 */
1183 public void updateBuildOptionsFfsAttribute(int i, int j, String name, String value){
1184 BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);
1185 XmlCursor cursor = ffs.newCursor();
1186 QName qAttrib = new QName(xmlNs, "Attribute");
1187 if (cursor.toChild(qAttrib)) {
1188 for (int k = 0; k < j; ++k) {
1189 cursor.toNextSibling(qAttrib);
1190 }
1191 BuildOptionsDocument.BuildOptions.Ffs.Attribute attrib = (BuildOptionsDocument.BuildOptions.Ffs.Attribute)cursor.getObject();
1192 attrib.setName(name);
1193 attrib.setValue(value);
1194 }
1195 cursor.dispose();
1196 }
1197
1198 public void removeBuildOptionsFfsAttribute(int i, int j){
1199 BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);
1200 XmlCursor cursor = ffs.newCursor();
1201 QName qAttrib = new QName(xmlNs, "Attribute");
1202 if (cursor.toChild(qAttrib)) {
1203 for (int k = 0; k < j; ++k) {
1204 cursor.toNextSibling(qAttrib);
1205 }
1206 cursor.removeXml();
1207 }
1208 cursor.dispose();
1209 }
1210
1211 public void genBuildOptionsFfsSectionsSection(int i, String sectionType) {
1212 BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);
1213 if (ffs == null) {
1214 return;
1215 }
1216 BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections();
1217
1218 if (sections == null){
1219 sections = ffs.addNewSections();
1220 }
1221 sections.addNewSection().setSectionType(EfiSectionType.Enum.forString(sectionType));
1222 }
1223
1224 public void genBuildOptionsFfsSectionsSections(int i, String encapType) {
1225 BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);
1226 if (ffs == null) {
1227 return;
1228 }
1229 BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections();
1230
1231 if (sections == null){
1232 sections = ffs.addNewSections();
1233 }
1234 sections.addNewSections().setEncapsulationType(encapType);
1235 }
1236
1237 public void genBuildOptionsFfsSectionsSectionsSection(int i, int j, String type) {
1238 BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);
1239 if (ffs == null) {
1240 return;
1241 }
1242 BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections();
1243 XmlCursor cursor = sections.newCursor();
1244 QName qSections = new QName(xmlNs, "Sections");
1245 if (cursor.toChild(qSections)){
1246 for (int k = 0; k < j; ++k) {
1247 cursor.toNextSibling(qSections);
1248 }
1249 BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2 sections2 = (BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2)cursor.getObject();
1250 sections2.addNewSection().setSectionType(EfiSectionType.Enum.forString(type));
1251 }
1252 cursor.dispose();
1253 }
1254
1255 public void getBuildOptionsFfsSectionsSectionsSection(int i, int j, ArrayList<String> al) {
1256 BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);
1257 if (ffs == null) {
1258 return;
1259 }
1260 BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections();
1261 XmlCursor cursor = sections.newCursor();
1262 QName qSections = new QName(xmlNs, "Sections");
1263 if (cursor.toChild(qSections)){
1264 for (int k = 0; k < j; ++k) {
1265 cursor.toNextSibling(qSections);
1266 }
1267 BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2 sections2 = (BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2)cursor.getObject();
1268 if (sections2.getSectionList() == null){
1269 cursor.dispose();
1270 return;
1271 }
1272 ListIterator<BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2.Section> li = sections2.getSectionList().listIterator();
1273 while(li.hasNext()) {
1274 BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2.Section section = li.next();
1275 al.add(section.getSectionType().toString());
1276 }
1277 }
1278 cursor.dispose();
1279
1280 }
1281
1282 public int getBuildOptionsFfsCount(){
1283 if (getfpdBuildOpts().getFfsList() == null) {
1284 return 0;
1285 }
1286 return getfpdBuildOpts().getFfsList().size();
1287 }
1288
1289 public void getBuildOptionsFfsKey(String[][] saa) {
1290 if (getfpdBuildOpts().getFfsList() == null) {
1291 return;
1292 }
1293 ListIterator<BuildOptionsDocument.BuildOptions.Ffs> li = getfpdBuildOpts().getFfsList().listIterator();
1294 int i = 0;
1295 while(li.hasNext()){
1296 BuildOptionsDocument.BuildOptions.Ffs ffs = li.next();
1297 saa[i][0] = ffs.getFfsKey();
1298 ++i;
1299 }
1300 }
1301
1302 /**Get ith FFS key and contents.
1303 * @param saa
1304 */
1305 public void getBuildOptionsFfs(int i, String[] sa, LinkedHashMap<String, String> ffsAttribMap, ArrayList<String> firstLevelSections, ArrayList<String> firstLevelSection) {
1306 BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);
1307
1308 if (ffs != null) {
1309
1310 sa[0] = ffs.getFfsKey();
1311 if (ffs.getSections() != null) {
1312 if(ffs.getSections().getEncapsulationType() != null){
1313 sa[1] = ffs.getSections().getEncapsulationType();
1314 }
1315 if (ffs.getSections().getSectionList() != null){
1316 ListIterator<BuildOptionsDocument.BuildOptions.Ffs.Sections.Section> li = ffs.getSections().getSectionList().listIterator();
1317 while (li.hasNext()) {
1318 firstLevelSection.add(li.next().getSectionType().toString());
1319 }
1320 }
1321 if (ffs.getSections().getSectionsList() != null) {
1322 ListIterator<BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2> li = ffs.getSections().getSectionsList().listIterator();
1323 while(li.hasNext()) {
1324 firstLevelSections.add(li.next().getEncapsulationType());
1325 }
1326 }
1327 }
1328 if (ffs.getAttributeList() != null) {
1329 ListIterator<BuildOptionsDocument.BuildOptions.Ffs.Attribute> li = ffs.getAttributeList().listIterator();
1330 while(li.hasNext()) {
1331 BuildOptionsDocument.BuildOptions.Ffs.Attribute attrib = li.next();
1332 ffsAttribMap.put(attrib.getName(), attrib.getValue());
1333 }
1334
1335 }
1336 }
1337
1338
1339 }
1340
1341 private BuildOptionsDocument.BuildOptions.Ffs getFfs(int i) {
1342 XmlObject o = getfpdBuildOpts();
1343 BuildOptionsDocument.BuildOptions.Ffs ffs = null;
1344
1345 XmlCursor cursor = o.newCursor();
1346 QName qFfs = new QName(xmlNs, "Ffs");
1347 if (cursor.toChild(qFfs)) {
1348 for (int j = 0; j < i; ++j) {
1349 cursor.toNextSibling(qFfs);
1350 }
1351 ffs = (BuildOptionsDocument.BuildOptions.Ffs)cursor.getObject();
1352 }
1353 cursor.dispose();
1354 return ffs;
1355 }
1356
1357 public void removeBuildOptionsFfs(int i) {
1358 BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);
1359 if (ffs == null){
1360 return;
1361 }
1362
1363 XmlCursor cursor = ffs.newCursor();
1364 cursor.removeXml();
1365 cursor.dispose();
1366 }
1367
1368 public PlatformDefinitionsDocument.PlatformDefinitions getfpdPlatformDefs(){
1369 if (fpdPlatformDefs == null){
1370 fpdPlatformDefs = fpdRoot.addNewPlatformDefinitions();
1371 }
1372 return fpdPlatformDefs;
1373 }
1374
1375 public FlashDocument.Flash getfpdFlash() {
1376 if (fpdFlash == null) {
1377 fpdFlash = fpdRoot.addNewFlash();
1378 }
1379 return fpdFlash;
1380 }
1381
1382 public void genFlashDefinitionFile(String file) {
1383 FlashDefinitionFileDocument.FlashDefinitionFile fdf = getfpdFlash().getFlashDefinitionFile();
1384 if (fdf == null) {
1385 fdf = getfpdFlash().addNewFlashDefinitionFile();
1386 }
1387
1388 fdf.setStringValue(file);
1389 }
1390
1391 public String getFlashDefinitionFile() {
1392 FlashDefinitionFileDocument.FlashDefinitionFile fdf = getfpdFlash().getFlashDefinitionFile();
1393 if (fdf == null) {
1394 return "";
1395 }
1396
1397 return fdf.getStringValue();
1398 }
1399
1400
1401
1402 public void genFvImagesNameValue(String name, String value) {
1403
1404 FvImagesDocument.FvImages fi = getfpdFlash().getFvImages();
1405 if (fi == null) {
1406 fi = getfpdFlash().addNewFvImages();
1407 }
1408
1409 FvImagesDocument.FvImages.NameValue nv = fi.addNewNameValue();
1410 nv.setName(name);
1411 nv.setValue(value);
1412 }
1413
1414 public void removeFvImagesNameValue(int i){
1415
1416 XmlObject o = getfpdFlash().getFvImages();
1417 if (o == null) {
1418 return;
1419 }
1420
1421 QName qNameValue = new QName(xmlNs, "NameValue");
1422 XmlCursor cursor = o.newCursor();
1423 if (cursor.toChild(qNameValue)) {
1424 for (int j = 0; j < i; ++j) {
1425 cursor.toNextSibling(qNameValue);
1426 }
1427 cursor.removeXml();
1428 }
1429 cursor.dispose();
1430 }
1431
1432 public void updateFvImagesNameValue(int i, String name, String value){
1433
1434 XmlObject o = getfpdFlash().getFvImages();
1435 if (o == null) {
1436 return;
1437 }
1438
1439 QName qNameValue = new QName(xmlNs, "NameValue");
1440 XmlCursor cursor = o.newCursor();
1441 if (cursor.toChild(qNameValue)) {
1442 for (int j = 0; j < i; ++j) {
1443 cursor.toNextSibling(qNameValue);
1444 }
1445 FvImagesDocument.FvImages.NameValue nv = (FvImagesDocument.FvImages.NameValue)cursor.getObject();
1446 nv.setName(name);
1447 nv.setValue(value);
1448 }
1449 cursor.dispose();
1450 }
1451
1452 public int getFvImagesNameValueCount() {
1453
1454 FvImagesDocument.FvImages fi = null;
1455 if ((fi = getfpdFlash().getFvImages()) == null || fi.getNameValueList() == null) {
1456 return 0;
1457 }
1458 return fi.getNameValueList().size();
1459 }
1460
1461 public void getFvImagesNameValues(String[][] nv) {
1462
1463 FvImagesDocument.FvImages fi = getfpdFlash().getFvImages();
1464 if (fi == null){
1465 return;
1466 }
1467 List<FvImagesDocument.FvImages.NameValue> l = fi.getNameValueList();
1468 int i = 0;
1469 ListIterator li = l.listIterator();
1470 while (li.hasNext()) {
1471 FvImagesDocument.FvImages.NameValue e = (FvImagesDocument.FvImages.NameValue) li
1472 .next();
1473 nv[i][0] = e.getName();
1474 nv[i][1] = e.getValue();
1475
1476 i++;
1477 }
1478 }
1479
1480 public void genFvImagesFvImage(String[] names, String types, Map<String, String> options) {
1481
1482 FvImagesDocument.FvImages fis = null;
1483 if ((fis = getfpdFlash().getFvImages()) == null) {
1484 fis = getfpdFlash().addNewFvImages();
1485 }
1486
1487 //
1488 //gen FvImage with FvImageNames array
1489 //
1490 FvImagesDocument.FvImages.FvImage fi = fis.addNewFvImage();
1491 for (int i = 0; i < names.length; ++i) {
1492 fi.addFvImageNames(names[i]);
1493 }
1494 fi.setType(FvImageTypes.Enum.forString(types));
1495 if (options != null){
1496 setFvImagesFvImageFvImageOptions(options, fi);
1497 }
1498 }
1499
1500 private void setFvImagesFvImageFvImageOptions(Map<String, String> options, FvImagesDocument.FvImages.FvImage fi){
1501 FvImagesDocument.FvImages.FvImage.FvImageOptions fio = fi.getFvImageOptions();
1502 if (fio == null){
1503 fio = fi.addNewFvImageOptions();
1504 }
1505
1506 Set<String> key = options.keySet();
1507 Iterator<String> i = key.iterator();
1508 while (i.hasNext()) {
1509
1510 FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue nv = fio.addNewNameValue();
1511 String k = (String)i.next();
1512
1513 nv.setName(k);
1514 nv.setValue((String)options.get(k));
1515
1516 }
1517
1518 }
1519
1520
1521 public void removeFvImagesFvImage(int i) {
1522
1523 XmlObject o = getfpdFlash().getFvImages();
1524 if (o == null) {
1525 return;
1526 }
1527
1528 QName qFvImage = new QName(xmlNs, "FvImage");
1529 XmlCursor cursor = o.newCursor();
1530 if (cursor.toChild(qFvImage)) {
1531 for (int j = 0; j < i; ++j) {
1532 cursor.toNextSibling(qFvImage);
1533 }
1534 cursor.removeXml();
1535 }
1536 cursor.dispose();
1537 }
1538
1539 public void updateFvImagesFvImage(int i, String[] names, String types, Map<String, String> options){
1540
1541 XmlObject o = getfpdFlash().getFvImages();
1542 if (o == null) {
1543 return;
1544 }
1545 XmlCursor cursor = o.newCursor();
1546 QName qFvImage = new QName(xmlNs, "FvImage");
1547 if (cursor.toChild(qFvImage)) {
1548 for (int j = 0; j < i; ++j) {
1549 cursor.toNextSibling(qFvImage);
1550 }
1551 FvImagesDocument.FvImages.FvImage fi = (FvImagesDocument.FvImages.FvImage)cursor.getObject();
1552 fi.setType(FvImageTypes.Enum.forString(types));
1553
1554 //
1555 // remove old FvImageNames before adding new ones
1556 //
1557 QName qFvImageNames = new QName(xmlNs, "FvImageNames");
1558 cursor.toChild(qFvImageNames);
1559 cursor.removeXml();
1560 while (cursor.toNextSibling(qFvImageNames)) {
1561 cursor.removeXml();
1562 }
1563
1564 for (int k = 0; k < names.length; ++k) {
1565 fi.addFvImageNames(names[k]);
1566 }
1567 //
1568 // remove old FvImageOptions before adding new options
1569 //
1570 QName qFvImageOptions = new QName(xmlNs, "FvImageOptions");
1571 cursor.toNextSibling(qFvImageOptions);
1572 cursor.removeXml();
1573
1574 setFvImagesFvImageFvImageOptions(options, fi);
1575 }
1576 cursor.dispose();
1577 }
1578
1579 public int getFvImagesFvImageCount() {
1580
1581 if (getfpdFlash().getFvImages() == null || getfpdFlash().getFvImages().getFvImageList() == null) {
1582 return 0;
1583 }
1584 return getfpdFlash().getFvImages().getFvImageList().size();
1585 }
1586
1587 /**Only Get Fv image setting - name and type.
1588 * @param saa
1589 */
1590 public void getFvImagesFvImages(String[][] saa) {
1591
1592 if (getfpdFlash().getFvImages() == null) {
1593 return;
1594 }
1595 List<FvImagesDocument.FvImages.FvImage> l = getfpdFlash().getFvImages().getFvImageList();
1596 if (l == null) {
1597 return;
1598 }
1599 ListIterator li = l.listIterator();
1600 int i = 0;
1601 while(li.hasNext()) {
1602 FvImagesDocument.FvImages.FvImage fi = (FvImagesDocument.FvImages.FvImage)li.next();
1603 //
1604 // get FvImageNames array, space separated
1605 //
1606 List<String> lfn = fi.getFvImageNamesList();
1607 ListIterator lfni = lfn.listIterator();
1608 saa[i][0] = " ";
1609 while (lfni.hasNext()) {
1610 saa[i][0] += (String)lfni.next();
1611 saa[i][0] += " ";
1612 }
1613 saa[i][0] = saa[i][0].trim();
1614
1615 saa[i][1] = fi.getType()+"";
1616
1617 ++i;
1618 }
1619 }
1620
1621 /**Get FvImage Options for FvImage i
1622 * @param i the ith FvImage
1623 */
1624 public void getFvImagesFvImageOptions(int i, Map<String, String> m) {
1625 XmlObject o = getfpdFlash().getFvImages();
1626 if (o == null) {
1627 return;
1628 }
1629 XmlCursor cursor = o.newCursor();
1630 QName qFvImage = new QName(xmlNs, "FvImage");
1631 if (cursor.toChild(qFvImage)) {
1632 for (int j = 0; j < i; ++j) {
1633 cursor.toNextSibling(qFvImage);
1634 }
1635 FvImagesDocument.FvImages.FvImage fi = (FvImagesDocument.FvImages.FvImage)cursor.getObject();
1636 if (fi.getFvImageOptions() == null || fi.getFvImageOptions().getNameValueList() == null){
1637 return;
1638 }
1639 ListIterator<FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue> li = fi.getFvImageOptions().getNameValueList().listIterator();
1640 while(li.hasNext()){
1641 FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue nv = li.next();
1642 m.put(nv.getName(), nv.getValue());
1643 }
1644 }
1645 }
1646
1647 /**
1648 Get platform header element
1649 @return PlatformHeaderDocument.PlatformHeader
1650 **/
1651 public PlatformHeaderDocument.PlatformHeader getFpdHdr() {
1652 if (fpdHdr == null) {
1653 fpdHdr = fpdRoot.addNewPlatformHeader();
1654 }
1655 genPlatformDefsSkuInfo("0", "DEFAULT");
1656 return fpdHdr;
1657 }
1658
1659 public void genPlatformDefsSkuInfo(String id, String name) {
1660 SkuInfoDocument.SkuInfo skuInfo = null;
1661 if (getfpdPlatformDefs().getSkuInfo() == null) {
1662 skuInfo = getfpdPlatformDefs().addNewSkuInfo();
1663 }
1664 skuInfo = getfpdPlatformDefs().getSkuInfo();
1665 if (skuInfo.getUiSkuNameList() == null || skuInfo.getUiSkuNameList().size() == 0) {
1666 SkuInfoDocument.SkuInfo.UiSkuName skuName = skuInfo.addNewUiSkuName();
1667 skuName.setSkuID(new BigInteger("0"));
1668 skuName.setStringValue("DEFAULT");
1669 }
1670 if (id.equals("0")) {
1671 return;
1672 }
1673 SkuInfoDocument.SkuInfo.UiSkuName skuName = skuInfo.addNewUiSkuName();
1674 skuName.setSkuID(new BigInteger(id));
1675 skuName.setStringValue(name);
1676
1677
1678 }
1679 public String getFpdHdrPlatformName() {
1680 return getFpdHdr().getPlatformName();
1681 }
1682
1683 public String getFpdHdrGuidValue() {
1684 return getFpdHdr().getGuidValue();
1685 }
1686
1687 public String getFpdHdrVer() {
1688 return getFpdHdr().getVersion();
1689 }
1690
1691 public String getFpdHdrAbs() {
1692 return getFpdHdr().getAbstract();
1693 }
1694
1695 public String getFpdHdrDescription() {
1696 return getFpdHdr().getDescription();
1697 }
1698
1699 public String getFpdHdrCopyright() {
1700 return getFpdHdr().getCopyright();
1701 }
1702
1703 public String getFpdHdrLicense() {
1704 LicenseDocument.License l = getFpdHdr().getLicense();
1705 if (l == null) {
1706 return null;
1707 }
1708 return l.getStringValue();
1709 }
1710
1711 public String getFpdHdrUrl() {
1712 LicenseDocument.License l = getFpdHdr().getLicense();
1713 if (l == null) {
1714 return null;
1715 }
1716 return l.getURL();
1717 }
1718
1719 public String getFpdHdrSpec() {
1720
1721 return "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052";
1722 // return getFpdHdr().getSpecification();
1723 }
1724
1725 public void setFpdHdrPlatformName(String name){
1726 getFpdHdr().setPlatformName(name);
1727 }
1728
1729 public void setFpdHdrGuidValue(String guid){
1730 getFpdHdr().setGuidValue(guid);
1731 }
1732
1733 public void setFpdHdrVer(String v){
1734 getFpdHdr().setVersion(v);
1735 }
1736
1737 public void setFpdHdrAbs(String abs) {
1738 getFpdHdr().setAbstract(abs);
1739 }
1740
1741 public void setFpdHdrDescription(String desc){
1742 getFpdHdr().setDescription(desc);
1743 }
1744
1745 public void setFpdHdrCopyright(String cr) {
1746 getFpdHdr().setCopyright(cr);
1747 }
1748
1749 public void setFpdHdrLicense(String license){
1750 LicenseDocument.License l = getFpdHdr().getLicense();
1751 if (l == null) {
1752 getFpdHdr().addNewLicense().setStringValue(license);
1753 }
1754 else {
1755 l.setStringValue(license);
1756 }
1757 }
1758
1759 public void setFpdHdrUrl(String url){
1760 LicenseDocument.License l = getFpdHdr().getLicense();
1761
1762 l.setURL(url);
1763
1764 }
1765
1766 public void setFpdHdrSpec(String s){
1767 s = "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052";
1768 getFpdHdr().setSpecification(s);
1769 }
1770 /**
1771 Save the processed xml contents to file
1772
1773 @param fpdFile The file to save xml contents
1774 @throws IOException Exceptions during file operation
1775 **/
1776 public void saveAs(File fpdFile) throws IOException {
1777
1778 XmlOptions options = new XmlOptions();
1779
1780 options.setCharacterEncoding("UTF-8");
1781 options.setSavePrettyPrint();
1782 options.setSavePrettyPrintIndent(2);
1783 try {
1784 fpdd.save(fpdFile, options);
1785 } catch (IOException e) {
1786 e.printStackTrace();
1787 }
1788
1789 }
1790
1791 private String listToString(List<String> l) {
1792 if (l == null) {
1793 return null;
1794 }
1795 String s = " ";
1796 ListIterator li = l.listIterator();
1797 while(li.hasNext()) {
1798 s += li.next();
1799 s += " ";
1800 }
1801 return s.trim();
1802 }
1803 }