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