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