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