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