Remove stand-alone module judge when parse FPD file.
[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
a094728f 634 do {\r
635 PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData pcdData = (PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData) cursor\r
636 .getObject();\r
82dcbb45 637 if (msaPcd.getCName().equals(pcdData.getCName())\r
638 && msaPcd.getTokenSpaceGuidCName().equals(pcdData.getTokenSpaceGuidCName())) {\r
a094728f 639\r
82dcbb45 640 maintainDynPcdMap(pcdData.getCName() + " " + pcdData.getTokenSpaceGuidCName(),\r
641 moduleKey);\r
642 cursor.removeXml();\r
643 break;\r
644 }\r
a094728f 645 } while (cursor.toNextSibling());\r
908b1c05 646 }\r
82dcbb45 647 cursor.dispose();\r
908b1c05 648 }\r
908b1c05 649 }\r
650 \r
651 }\r
652 catch (Exception e){\r
653 e.printStackTrace();\r
654 \r
655 }\r
656 }\r
a13899c5 657 //\r
bf5abaff 658 // key for ModuleSA : "ModuleGuid ModuleVer PackageGuid PackageVer Arch"\r
a13899c5 659 //\r
660 public int getLibraryInstancesCount(String key) {\r
661 ModuleSADocument.ModuleSA msa = getModuleSA(key);\r
662 if (msa == null || msa.getLibraries() == null || msa.getLibraries().getInstanceList() == null){\r
663 return 0;\r
664 }\r
665 return msa.getLibraries().getInstanceList().size();\r
666 }\r
667 \r
668 public void getLibraryInstances(String key, String[][] saa){\r
669 ModuleSADocument.ModuleSA msa = getModuleSA(key);\r
670 if (msa == null || msa.getLibraries() == null || msa.getLibraries().getInstanceList() == null){\r
671 return ;\r
672 }\r
673 \r
674 ListIterator<LibrariesDocument.Libraries.Instance> li = msa.getLibraries().getInstanceList().listIterator();\r
675 for (int i = 0; i < saa.length; ++i) {\r
676 LibrariesDocument.Libraries.Instance instance = li.next();\r
677 saa[i][1] = instance.getModuleGuid();\r
678 saa[i][2] = instance.getModuleVersion();\r
679 saa[i][3] = instance.getPackageGuid();\r
680 saa[i][4] = instance.getPackageVersion();\r
681 }\r
682 }\r
683 \r
908b1c05 684 public void removeLibraryInstance(String key, int i) {\r
a13899c5 685 ModuleSADocument.ModuleSA msa = getModuleSA(key);\r
686 if (msa == null || msa.getLibraries() == null){\r
687 return ;\r
688 }\r
689 \r
690 XmlCursor cursor = msa.getLibraries().newCursor();\r
908b1c05 691 if (cursor.toFirstChild()) {\r
692 for (int j = 0; j < i; ++j) {\r
693 cursor.toNextSibling();\r
694 }\r
82dcbb45 695 cursor.push();\r
696 cursor.toPrevToken();\r
697 if (cursor.isComment()) {\r
698 cursor.removeXml();\r
699 }\r
700 cursor.pop();\r
908b1c05 701 cursor.removeXml();\r
82dcbb45 702 if (getLibraryInstancesCount(key) == 0) {\r
703 cursor.toParent();\r
704 cursor.removeXml();\r
705 }\r
908b1c05 706 }\r
707 \r
a13899c5 708 cursor.dispose();\r
709 }\r
710 \r
82dcbb45 711 public void genLibraryInstance(ModuleIdentification libMi, String key) {\r
a13899c5 712 ModuleSADocument.ModuleSA msa = getModuleSA(key);\r
713 if (msa == null){\r
714 msa = getfpdFrameworkModules().addNewModuleSA();\r
715 }\r
716 LibrariesDocument.Libraries libs = msa.getLibraries();\r
717 if(libs == null){\r
718 libs = msa.addNewLibraries();\r
719 }\r
720 \r
82dcbb45 721 String mn = libMi.getName();\r
722 String mg = libMi.getGuid();\r
723 String mv = libMi.getVersion();\r
3658f95e 724 String pn = libMi.getPackageId().getName();\r
725 String pg = libMi.getPackageId().getGuid();\r
726 String pv = libMi.getPackageId().getVersion();\r
a13899c5 727 LibrariesDocument.Libraries.Instance instance = libs.addNewInstance();\r
82dcbb45 728 XmlCursor cursor = instance.newCursor();\r
729 try{\r
730 String comment = "Pkg: " + pn + " Mod: " + mn \r
3658f95e 731 + " Path: " + libMi.getPath().substring(System.getenv("WORKSPACE").length() + 1);\r
82dcbb45 732 cursor.insertComment(comment);\r
733 }\r
734 catch (Exception e){\r
735 e.printStackTrace();\r
736 }\r
737 finally {\r
738 cursor.dispose();\r
739 }\r
740 \r
a13899c5 741 instance.setModuleGuid(mg);\r
742 instance.setModuleVersion(mv);\r
743 instance.setPackageGuid(pg);\r
744 instance.setPackageVersion(pv);\r
745 \r
746 }\r
1800d80f 747 \r
748 public String getFvBinding(String moduleKey){\r
749 ModuleSADocument.ModuleSA msa = getModuleSA(moduleKey);\r
750 if (msa == null || msa.getModuleSaBuildOptions() == null) {\r
751 return null;\r
752 }\r
753 return msa.getModuleSaBuildOptions().getFvBinding();\r
754 }\r
755 \r
2b70a636 756 public void setFvBinding(ModuleSADocument.ModuleSA moduleSa, String fvBinding) {\r
757 if (moduleSa == null ) {\r
1800d80f 758 return;\r
759 }\r
61919f8c 760 if (fvBinding == null || fvBinding.length() == 0) {\r
2b70a636 761 if(moduleSa.getModuleSaBuildOptions() != null){\r
762 moduleSa.getModuleSaBuildOptions().unsetFvBinding();\r
61919f8c 763 }\r
764 }\r
765 else {\r
2b70a636 766 if(moduleSa.getModuleSaBuildOptions() == null){\r
767 moduleSa.addNewModuleSaBuildOptions().setFvBinding(fvBinding);\r
61919f8c 768 return;\r
769 }\r
2b70a636 770 moduleSa.getModuleSaBuildOptions().setFvBinding(fvBinding);\r
771 }\r
772 }\r
773 \r
774 public void setFvBinding(String moduleKey, String fvBinding){\r
775 ModuleSADocument.ModuleSA moduleSa = getModuleSA(moduleKey);\r
776 setFvBinding (moduleSa, fvBinding);\r
777 }\r
778 \r
779 public void removeFvBinding (ModuleSADocument.ModuleSA moduleSa, String fvName) {\r
780 if (moduleSa == null || moduleSa.getModuleSaBuildOptions() == null || moduleSa.getModuleSaBuildOptions().getFvBinding() == null) {\r
781 return;\r
782 }\r
783 \r
784 String fvNameList = moduleSa.getModuleSaBuildOptions().getFvBinding();\r
785 String[] fvNamesArray = fvNameList.split(" ");\r
786 int occursAt = -1;\r
787 for (int i = 0; i < fvNamesArray.length; ++i) {\r
788 if (fvNamesArray[i].equals(fvName)) {\r
789 occursAt = i;\r
790 break;\r
791 }\r
792 }\r
793 // jump over where the input fvName occurs in the original Fv list.\r
794 if (occursAt != -1) {\r
795 String newFvNameList = " ";\r
796 for (int i = 0; i < fvNamesArray.length; ++i) {\r
797 if (i == occursAt) {\r
798 continue;\r
799 }\r
800 newFvNameList += fvNamesArray[i];\r
801 }\r
802 setFvBinding (moduleSa, newFvNameList.trim());\r
803 }\r
804\r
805 }\r
806 \r
807 /**\r
808 * @param fvName The FV name that to be removed from FvBinding List.\r
809 */\r
810 public void removeFvBindingAll (String fvName) {\r
811 if (getfpdFrameworkModules().getModuleSAList() == null || getfpdFrameworkModules().getModuleSAList().size() == 0){\r
812 removeElement(getfpdFrameworkModules());\r
813 fpdFrameworkModules = null;\r
814 return;\r
815 }\r
816 \r
817 Iterator<ModuleSADocument.ModuleSA> li = getfpdFrameworkModules().getModuleSAList().iterator();\r
818 while (li.hasNext()) {\r
819 ModuleSADocument.ModuleSA moduleSa = li.next();\r
820 removeFvBinding (moduleSa, fvName); \r
821 }\r
822 }\r
823 \r
824 public void appendFvBinding (String moduleKey, String fvName) {\r
825 ModuleSADocument.ModuleSA moduleSa = getModuleSA(moduleKey);\r
826 appendFvBinding (moduleSa, fvName);\r
827 }\r
828 \r
829 public void appendFvBinding (ModuleSADocument.ModuleSA moduleSa, String fvName) {\r
830 if (moduleSa == null) {\r
831 return;\r
832 }\r
833 \r
834 if (moduleSa.getModuleSaBuildOptions() == null || moduleSa.getModuleSaBuildOptions().getFvBinding() == null) {\r
835 setFvBinding(moduleSa, fvName);\r
836 return;\r
837 }\r
838 \r
839 String fvNameList = moduleSa.getModuleSaBuildOptions().getFvBinding();\r
840 String newFvNameList = fvNameList + " " + fvName;\r
841 setFvBinding (moduleSa, newFvNameList.trim());\r
842 }\r
843 \r
844 public void updateFvBindingInModuleSA (ModuleIdentification mi, String fvName) {\r
845 Vector<Object> vSupArchs = new Vector<Object>();\r
846 getPlatformDefsSupportedArchs(vSupArchs);\r
847 String moduleInfo = mi.getGuid() + " " + mi.getVersion() + " " + mi.getPackageId().getGuid() + " " + mi.getPackageId().getVersion();\r
848 for (int i = 0; i < vSupArchs.size(); ++i) {\r
849 String moduleKey = moduleInfo + " " + vSupArchs.get(i);\r
850 appendFvBinding (moduleKey, fvName);\r
1800d80f 851 }\r
1800d80f 852 }\r
853 \r
854 public String getFfsFileNameGuid(String moduleKey){\r
2b70a636 855 ModuleSADocument.ModuleSA moduleSa = getModuleSA(moduleKey);\r
856 if (moduleSa == null || moduleSa.getModuleSaBuildOptions() == null) {\r
1800d80f 857 return null;\r
858 }\r
2b70a636 859 return moduleSa.getModuleSaBuildOptions().getFfsFileNameGuid();\r
1800d80f 860 }\r
861 \r
862 public void setFfsFileNameGuid(String moduleKey, String fileGuid){\r
863 ModuleSADocument.ModuleSA msa = getModuleSA(moduleKey);\r
864 if (msa == null ) {\r
865 return;\r
866 }\r
867 if(msa.getModuleSaBuildOptions() == null){\r
8f55ea73 868 msa.addNewModuleSaBuildOptions();\r
869 \r
1800d80f 870 }\r
8f55ea73 871 ModuleSaBuildOptionsDocument.ModuleSaBuildOptions msaBuildOpts= msa.getModuleSaBuildOptions();\r
872 if (fileGuid != null) {\r
873 msaBuildOpts.setFfsFileNameGuid(fileGuid);\r
874 }\r
875 else{\r
876 XmlCursor cursor = msaBuildOpts.newCursor();\r
877 if (cursor.toChild(xmlNs, "FfsFileNameGuid")) {\r
878 cursor.removeXml();\r
879 }\r
880 cursor.dispose();\r
881 }\r
882 \r
1800d80f 883 }\r
884 \r
885 public String getFfsFormatKey(String moduleKey){\r
886 ModuleSADocument.ModuleSA msa = getModuleSA(moduleKey);\r
887 if (msa == null || msa.getModuleSaBuildOptions() == null) {\r
888 return null;\r
889 }\r
890 return msa.getModuleSaBuildOptions().getFfsFormatKey();\r
891 }\r
892 \r
893 public void setFfsFormatKey(String moduleKey, String ffsKey){\r
894 ModuleSADocument.ModuleSA msa = getModuleSA(moduleKey);\r
895 if (msa == null ) {\r
896 return;\r
897 }\r
898 if(msa.getModuleSaBuildOptions() == null){\r
899 msa.addNewModuleSaBuildOptions().setFfsFormatKey(ffsKey);\r
900 return;\r
901 }\r
bf5abaff 902 msa.getModuleSaBuildOptions().setFfsFormatKey(ffsKey);\r
1800d80f 903 }\r
904 \r
e7cc0547 905 public void setModuleSAForceDebug(int i, boolean dbgEnable) {\r
906 ModuleSADocument.ModuleSA moduleSa = getModuleSA(i);\r
907 moduleSa.setForceDebug(dbgEnable);\r
908 }\r
909 \r
910 public boolean getModuleSAForceDebug (int i) {\r
911 ModuleSADocument.ModuleSA moduleSa = getModuleSA(i);\r
912 if (moduleSa.getForceDebug() == true) {\r
913 return true;\r
914 }\r
915 return false;\r
916 }\r
917 \r
1800d80f 918 public void getModuleSAOptions(String moduleKey, String[][] saa) {\r
919 ModuleSADocument.ModuleSA msa = getModuleSA(moduleKey);\r
e232295e 920 if (msa == null || msa.getModuleSaBuildOptions() == null || msa.getModuleSaBuildOptions().getOptions() == null\r
1800d80f 921 || msa.getModuleSaBuildOptions().getOptions().getOptionList() == null) {\r
922 return ;\r
923 }\r
924 \r
925 List<OptionDocument.Option> lOpt = msa.getModuleSaBuildOptions().getOptions().getOptionList();\r
926 ListIterator li = lOpt.listIterator();\r
927 int i = 0;\r
928 while(li.hasNext()) {\r
929 OptionDocument.Option opt = (OptionDocument.Option)li.next();\r
930 if (opt.getBuildTargets() != null) {\r
931 saa[i][0] = listToString(opt.getBuildTargets());\r
932 }\r
933 saa[i][1] = opt.getToolChainFamily();\r
bf5abaff 934 saa[i][2] = opt.getTagName();\r
935 saa[i][3] = opt.getToolCode();\r
936 \r
1800d80f 937 if (opt.getSupArchList() != null){\r
bf5abaff 938 saa[i][4] = listToString(opt.getSupArchList());\r
1800d80f 939\r
940 }\r
bf5abaff 941 \r
1800d80f 942 saa[i][5] = opt.getStringValue();\r
943 \r
944 ++i;\r
945 }\r
946 }\r
947 \r
948 public int getModuleSAOptionsCount(String moduleKey){\r
949 ModuleSADocument.ModuleSA msa = getModuleSA(moduleKey);\r
e232295e 950 if (msa == null || msa.getModuleSaBuildOptions() == null || msa.getModuleSaBuildOptions().getOptions() == null\r
1800d80f 951 || msa.getModuleSaBuildOptions().getOptions().getOptionList() == null) {\r
952 return 0;\r
953 }\r
954 return msa.getModuleSaBuildOptions().getOptions().getOptionList().size();\r
955 }\r
956 \r
957 public void genModuleSAOptionsOpt(String moduleKey, Vector<Object> buildTargets, String toolChain, String tagName, String toolCmd, Vector<Object> archList, String contents) {\r
958 ModuleSADocument.ModuleSA msa = getModuleSA(moduleKey);\r
959 if (msa.getModuleSaBuildOptions() == null) {\r
960 msa.addNewModuleSaBuildOptions();\r
961 }\r
962 if (msa.getModuleSaBuildOptions().getOptions() == null){\r
963 msa.getModuleSaBuildOptions().addNewOptions();\r
964 }\r
965 OptionDocument.Option opt = msa.getModuleSaBuildOptions().getOptions().addNewOption();\r
966 setBuildOptionsOpt(buildTargets, toolChain, tagName, toolCmd, archList, contents, opt);\r
967 }\r
968 \r
969 public void removeModuleSAOptionsOpt(String moduleKey, int i) {\r
970 ModuleSADocument.ModuleSA msa = getModuleSA(moduleKey);\r
971 if (msa.getModuleSaBuildOptions() == null || msa.getModuleSaBuildOptions().getOptions() == null) {\r
972 return ;\r
973 }\r
974 OptionsDocument.Options opts = msa.getModuleSaBuildOptions().getOptions();\r
975 XmlCursor cursor = opts.newCursor();\r
976 if (cursor.toFirstChild()) {\r
977 for (int j = 0; j < i; ++j){\r
978 cursor.toNextSibling();\r
979 }\r
980 cursor.removeXml();\r
981 }\r
982 cursor.dispose();\r
983 }\r
984 \r
985 public void updateModuleSAOptionsOpt(String moduleKey, int i, Vector<Object> buildTargets, String toolChain, String tagName, String toolCmd, Vector<Object> archList, String contents) {\r
986 ModuleSADocument.ModuleSA msa = getModuleSA(moduleKey);\r
987 if (msa.getModuleSaBuildOptions() == null || msa.getModuleSaBuildOptions().getOptions() == null) {\r
988 return ;\r
989 }\r
990 OptionsDocument.Options opts = msa.getModuleSaBuildOptions().getOptions();\r
991 XmlCursor cursor = opts.newCursor();\r
992 if (cursor.toFirstChild()) {\r
993 for (int j = 0; j < i; ++j){\r
994 cursor.toNextSibling();\r
995 }\r
996 OptionDocument.Option opt = (OptionDocument.Option)cursor.getObject();\r
997 setBuildOptionsOpt(buildTargets, toolChain, tagName, toolCmd, archList, contents, opt);\r
998 }\r
999 cursor.dispose();\r
1000 }\r
1001 \r
a13899c5 1002 /**add pcd information of module mi to a ModuleSA. \r
1003 * @param mi\r
1004 * @param moduleSa if null, generate a new ModuleSA.\r
1005 */\r
bf5abaff 1006 public void addFrameworkModulesPcdBuildDefs(ModuleIdentification mi, String arch, ModuleSADocument.ModuleSA moduleSa) throws Exception {\r
a13899c5 1007 //ToDo add Arch filter\r
1008 \r
1009 try {\r
af25df16 1010 if (moduleSa == null) {\r
bf5abaff 1011 moduleSa = genModuleSA(mi, arch);\r
af25df16 1012 }\r
1013 \r
1bf9fa5a 1014 ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = (ModuleSurfaceAreaDocument.ModuleSurfaceArea)WorkspaceProfile.getModuleXmlObject(mi);\r
a13899c5 1015 if (msa.getPcdCoded() == null) {\r
1016 return;\r
1017 }\r
af25df16 1018 \r
a13899c5 1019 Map<String, XmlObject> m = new HashMap<String, XmlObject>();\r
1020 m.put("ModuleSurfaceArea", msa);\r
1021 SurfaceAreaQuery.setDoc(m);\r
daa4663b 1022 PackageIdentification[] depPkgs = SurfaceAreaQuery.getDependencePkg(null, mi);\r
a13899c5 1023 //\r
1024 // Implementing InitializePlatformPcdBuildDefinitions\r
1025 //\r
1026 List<PcdCodedDocument.PcdCoded.PcdEntry> l = msa.getPcdCoded().getPcdEntryList();\r
1027 ListIterator li = l.listIterator();\r
1028 while(li.hasNext()) {\r
1029 PcdCodedDocument.PcdCoded.PcdEntry msaPcd = (PcdCodedDocument.PcdCoded.PcdEntry)li.next();\r
1030 PcdDeclarationsDocument.PcdDeclarations.PcdEntry spdPcd = LookupPcdDeclaration(msaPcd, depPkgs);\r
1031 if (spdPcd == null) {\r
1032 //\r
1033 // ToDo Error \r
1034 //\r
34c614e1 1035 throw new PcdDeclNotFound("No Declaration for PCD Entry " + msaPcd.getCName() + " in Module " + mi.getName());\r
a13899c5 1036 }\r
1037 //\r
1038 // AddItem to ModuleSA PcdBuildDefinitions\r
1039 //\r
1040 String defaultVal = msaPcd.getDefaultValue() == null ? spdPcd.getDefaultValue() : msaPcd.getDefaultValue();\r
908b1c05 1041 \r
a13899c5 1042 genPcdData(msaPcd.getCName(), spdPcd.getToken(), msaPcd.getTokenSpaceGuidCName(), msaPcd.getPcdItemType().toString(), spdPcd.getDatumType()+"", defaultVal, moduleSa);\r
1043 }\r
1044 \r
1045 }\r
1046 catch (Exception e){\r
34c614e1 1047 \r
82961247 1048 throw e; \r
a13899c5 1049 }\r
1050 \r
1051 }\r
1052 \r
1053 private PcdDeclarationsDocument.PcdDeclarations.PcdEntry LookupPcdDeclaration (PcdCodedDocument.PcdCoded.PcdEntry msaPcd, PackageIdentification[] depPkgs) {\r
1054 \r
a13899c5 1055 PcdDeclarationsDocument.PcdDeclarations.PcdEntry spdPcd = null;\r
1056 for (int i = 0; i < depPkgs.length; ++i) {\r
3658f95e 1057\r
1058 XmlObject[] xo = SurfaceAreaQuery.getSpdPcdDeclarations(depPkgs[i]);\r
a13899c5 1059 if (xo == null) {\r
1060 continue;\r
1061 }\r
1062 for (int j = 0; j < xo.length; ++j) {\r
1063 spdPcd = (PcdDeclarationsDocument.PcdDeclarations.PcdEntry)xo[j];\r
1064 if (msaPcd.getTokenSpaceGuidCName() == null) {\r
1065 if (spdPcd.getCName().equals(msaPcd.getCName())) {\r
1066 return spdPcd;\r
1067 }\r
1068 }\r
1069 else{\r
1070 if (spdPcd.getCName().equals(msaPcd.getCName()) && spdPcd.getTokenSpaceGuidCName().equals(msaPcd.getTokenSpaceGuidCName())) {\r
1071 return spdPcd;\r
1072 }\r
1073 }\r
1074 \r
1075 }\r
1076 \r
1077 }\r
1078 return null;\r
1079 }\r
1080 \r
bf5abaff 1081 private ModuleSADocument.ModuleSA genModuleSA (ModuleIdentification mi, String arch) {\r
1bf9fa5a 1082 PackageIdentification pi = WorkspaceProfile.getPackageForModule(mi);\r
a13899c5 1083 ModuleSADocument.ModuleSA msa = getfpdFrameworkModules().addNewModuleSA();\r
82dcbb45 1084 XmlCursor cursor = msa.newCursor();\r
1085 try{\r
3658f95e 1086 String comment = "Mod: " + mi.getName() + " Type: " + SurfaceAreaQuery.getModuleType(mi) + " Path: "\r
1087 + mi.getPath().substring(System.getenv("WORKSPACE").length() + 1);\r
82dcbb45 1088 cursor.insertComment(comment);\r
1089 }\r
1090 catch(Exception e){\r
1091 e.printStackTrace();\r
1092 }\r
1093 finally { \r
1094 cursor.dispose();\r
1095 }\r
a13899c5 1096 msa.setModuleGuid(mi.getGuid());\r
1097 msa.setModuleVersion(mi.getVersion());\r
1098 msa.setPackageGuid(pi.getGuid());\r
1099 msa.setPackageVersion(pi.getVersion());\r
bf5abaff 1100 if (arch != null) {\r
1101 Vector<String> v = new Vector<String>();\r
1102 v.add(arch);\r
1103 msa.setSupArchList(v); \r
1104 }\r
a13899c5 1105 \r
1106 return msa;\r
1107 }\r
1108 \r
82961247 1109 private void genPcdData (String cName, Object token, String tsGuid, String itemType, String dataType, String defaultVal, ModuleSADocument.ModuleSA moduleSa) \r
1110 throws PcdItemTypeConflictException, PcdValueMalFormed{\r
a13899c5 1111 if (moduleSa.getPcdBuildDefinition() == null){\r
1112 moduleSa.addNewPcdBuildDefinition();\r
1113 }\r
1114 //\r
1115 // constructe pcd to modulesa mapping first.\r
1116 // Attention : for any error condition, remove from map this pcd.\r
1117 //\r
1118 ArrayList<String> pcdConsumer = LookupPlatformPcdData(cName + " " + tsGuid);\r
1119 if (pcdConsumer == null) {\r
1120 pcdConsumer = new ArrayList<String>();\r
1121 }\r
1bf9fa5a 1122 //\r
1123 // Using existing Pcd type, if this pcd already exists in other ModuleSA\r
1124 //\r
1125 if (pcdConsumer.size() > 0) {\r
1126 String[] valPart = pcdConsumer.get(0).split(" ");\r
1127 itemType = valPart[5];\r
1128 }\r
a13899c5 1129 String listValue = moduleSa.getModuleGuid() + " " + moduleSa.getModuleVersion() \r
bf5abaff 1130 + " " + moduleSa.getPackageGuid() + " " + moduleSa.getPackageVersion() + " " + listToString(moduleSa.getSupArchList())\r
a13899c5 1131 + " " + itemType;\r
1132 pcdConsumer.add(listValue);\r
1133 dynPcdMap.put(cName + " " + tsGuid, pcdConsumer);\r
1bf9fa5a 1134 \r
a13899c5 1135 PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData fpdPcd = moduleSa.getPcdBuildDefinition().addNewPcdData();\r
1136 fpdPcd.setCName(cName);\r
1137 fpdPcd.setToken(token);\r
1138 fpdPcd.setTokenSpaceGuidCName(tsGuid);\r
1139 fpdPcd.setDatumType(PcdDataTypes.Enum.forString(dataType));\r
1140 fpdPcd.setItemType(PcdItemTypes.Enum.forString(itemType));\r
a390c35d 1141 \r
1142 if (defaultVal != null){\r
1143 fpdPcd.setValue(defaultVal);\r
1144 }\r
1145 else {\r
1146 if (dataType.equals("UINT8") || dataType.equals("UINT16") || dataType.equals("UINT32") || dataType.equals("UINT64")) {\r
1147 fpdPcd.setValue("0");\r
1148 }\r
1149 if (dataType.equals("BOOLEAN")){\r
b3151273 1150 fpdPcd.setValue("FALSE");\r
a390c35d 1151 }\r
1152 if (dataType.equals("VOID*")) {\r
1153 fpdPcd.setValue("");\r
1154 }\r
1155 }\r
1bf9fa5a 1156 //\r
1157 // Using existing pcd value, if this pcd already exists in other moduleSa.\r
1158 //\r
1159 if (defaultPcdValue.get(cName + " " + tsGuid) == null) {\r
1160 defaultPcdValue.put(cName + " " + tsGuid, fpdPcd.getValue());\r
1161 }\r
1162 else {\r
1163 fpdPcd.setValue(defaultPcdValue.get(cName + " " + tsGuid));\r
1164 }\r
1165 \r
802e0055 1166 if (dataType.equals("UINT8")){\r
1167 fpdPcd.setMaxDatumSize(1);\r
1168 }\r
1169 if (dataType.equals("UINT16")) {\r
1170 fpdPcd.setMaxDatumSize(2);\r
1171 }\r
1172 if (dataType.equals("UINT32")) {\r
1173 fpdPcd.setMaxDatumSize(4);\r
1174 }\r
1175 if (dataType.equals("UINT64")){\r
1176 fpdPcd.setMaxDatumSize(8);\r
1177 }\r
1178 if (dataType.equals("BOOLEAN")){\r
1179 fpdPcd.setMaxDatumSize(1);\r
1180 }\r
1181 if (dataType.equals("VOID*")) {\r
1182 int maxSize = setMaxSizeForPointer(fpdPcd.getValue());\r
1183 fpdPcd.setMaxDatumSize(maxSize);\r
1184 }\r
a13899c5 1185 \r
a390c35d 1186 \r
a13899c5 1187 if (itemType.equals("DYNAMIC") || itemType.equals("DYNAMIC_EX")) {\r
1188 ArrayList<String> al = LookupDynamicPcdBuildDefinition(cName + " " + tsGuid);\r
1189 //\r
1190 // if only one module mapped to this pcd, then the one is myself. so no other module mapped.\r
1191 // so need to add one dyn pcd.\r
1192 //\r
1193 if (al.size() == 1) {\r
1194 addDynamicPcdBuildData(cName, token, tsGuid, itemType, dataType, defaultVal);\r
1195 }\r
1196 }\r
1bf9fa5a 1197 \r
a13899c5 1198 }\r
1199 \r
908b1c05 1200 public int setMaxSizeForPointer(String datum) throws PcdValueMalFormed{\r
a13899c5 1201 if (datum == null) {\r
1202 return 0;\r
1203 }\r
1204 char ch = datum.charAt(0);\r
1205 int start, end;\r
1206 String strValue;\r
1207 //\r
1208 // For void* type PCD, only three datum is support:\r
1209 // 1) Unicode: string with start char is "L"\r
1210 // 2) Ansci: String is ""\r
1211 // 3) byte array: String start char "{"\r
1212 // \r
1213 if (ch == 'L') {\r
1214 start = datum.indexOf('\"');\r
1215 end = datum.lastIndexOf('\"');\r
1216 if ((start > end) || \r
1217 (end > datum.length())||\r
1218 ((start == end) && (datum.length() > 0))) {\r
1219 //ToDo Error handling here\r
82961247 1220 throw new PcdValueMalFormed (datum);\r
a13899c5 1221 }\r
1222\r
1223 strValue = datum.substring(start + 1, end);\r
1224 return strValue.length() * 2;\r
1225 } else if (ch == '\"'){\r
1226 start = datum.indexOf('\"');\r
1227 end = datum.lastIndexOf('\"');\r
1228 if ((start > end) || \r
1229 (end > datum.length())||\r
1230 ((start == end) && (datum.length() > 0))) {\r
82961247 1231 throw new PcdValueMalFormed (datum);\r
a13899c5 1232 }\r
1233 strValue = datum.substring(start + 1, end);\r
1234 return strValue.length();\r
1235 } else if (ch =='{') {\r
1236 String[] strValueArray;\r
1237\r
1238 start = datum.indexOf('{');\r
1239 end = datum.lastIndexOf('}');\r
1240 strValue = datum.substring(start + 1, end);\r
1241 strValue = strValue.trim();\r
1242 if (strValue.length() == 0) {\r
1243 return 0;\r
1244 }\r
1245 strValueArray = strValue.split(",");\r
1246 for (int index = 0; index < strValueArray.length; index ++) {\r
1247 Integer value = Integer.decode(strValueArray[index].trim());\r
1248 \r
1249 if (value > 0xFF) {\r
1250// "[FPD file error] The datum type of PCD %s in %s is VOID*, "+\r
a70d444e 1251// "it must be a byte array. But the element of %s exceed the byte range",\r
82961247 1252 throw new PcdValueMalFormed (datum); \r
a13899c5 1253 }\r
1254 }\r
1255 return strValueArray.length;\r
1256\r
1257\r
1258 } else {\r
1259// "[FPD file error] The datum type of PCD %s in %s is VOID*. For VOID* type, you have three format choise:\n "+\r
1260// "1) UNICODE string: like L\"xxxx\";\r\n"+\r
1261// "2) ANSIC string: like \"xxx\";\r\n"+\r
1262// "3) Byte array: like {0x2, 0x45, 0x23}\r\n"+\r
1263// "but the datum in seems does not following above format!",\r
82961247 1264 throw new PcdValueMalFormed (datum);\r
a13899c5 1265 \r
1266 }\r
1267 }\r
1268 \r
1269 private ArrayList<String> LookupDynamicPcdBuildDefinition(String dynPcdKey) {\r
1270 ArrayList<String> al = dynPcdMap.get(dynPcdKey);\r
1271 \r
1272 return al;\r
1273 }\r
1274 \r
1275 private ArrayList<String> LookupPlatformPcdData(String pcdKey) {\r
1276 \r
34c614e1 1277 return dynPcdMap.get(pcdKey);\r
a13899c5 1278 }\r
1279 \r
1280 public int getDynamicPcdBuildDataCount() {\r
5af6b67f 1281 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {\r
e232295e 1282 removeElement(getfpdDynPcdBuildDefs());\r
1283 fpdDynPcdBuildDefs = null;\r
a13899c5 1284 return 0;\r
1285 }\r
1286 return getfpdDynPcdBuildDefs().getPcdBuildDataList().size();\r
1287 }\r
1288 \r
1289 public void getDynamicPcdBuildData(String[][] saa) {\r
5af6b67f 1290 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {\r
e232295e 1291 removeElement(getfpdDynPcdBuildDefs());\r
1292 fpdDynPcdBuildDefs = null;\r
a13899c5 1293 return ;\r
1294 }\r
1295 List<DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData> l = getfpdDynPcdBuildDefs().getPcdBuildDataList();\r
1296 ListIterator<DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData> li = l.listIterator();\r
1297 int i = 0;\r
1298 while(li.hasNext()) {\r
1299 DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData dynPcd = li.next();\r
1300 saa[i][0] = dynPcd.getCName();\r
1301 saa[i][1] = dynPcd.getToken().toString();\r
1302 saa[i][2] = dynPcd.getTokenSpaceGuidCName();\r
1303 saa[i][3] = dynPcd.getMaxDatumSize()+"";\r
1304 saa[i][4] = dynPcd.getDatumType().toString();\r
1305 \r
1306 ++i;\r
1307 }\r
1308 }\r
1309 \r
908b1c05 1310 public void addDynamicPcdBuildData(String cName, Object token, String tsGuid, String itemType, String dataType, String defaultVal) \r
82961247 1311 throws PcdValueMalFormed{\r
a13899c5 1312 DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData dynPcdData = getfpdDynPcdBuildDefs().addNewPcdBuildData();\r
1313 dynPcdData.setItemType(PcdItemTypes.Enum.forString(itemType));\r
1314 dynPcdData.setCName(cName);\r
1315 dynPcdData.setToken(token);\r
1316 dynPcdData.setTokenSpaceGuidCName(tsGuid);\r
1317 dynPcdData.setDatumType(PcdDataTypes.Enum.forString(dataType));\r
1318 \r
1319 BigInteger bigInt = new BigInteger("0");\r
1320 DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData.SkuInfo skuInfo = dynPcdData.addNewSkuInfo();\r
1321 skuInfo.setSkuId(bigInt);\r
1322 if (defaultVal != null){\r
1323 skuInfo.setValue(defaultVal);\r
1324 }\r
1325 else {\r
1326 if (dataType.equals("UINT8")){\r
1327 skuInfo.setValue("0");\r
1328 }\r
1329 if (dataType.equals("UINT16")) {\r
1330 skuInfo.setValue("0");\r
1331 }\r
1332 if (dataType.equals("UINT32")) {\r
1333 skuInfo.setValue("0");\r
1334 }\r
1335 if (dataType.equals("UINT64")){\r
1336 skuInfo.setValue("0");\r
1337 }\r
1338 if (dataType.equals("BOOLEAN")){\r
1339 skuInfo.setValue("false");\r
1340 }\r
1341 if (dataType.equals("VOID*")) {\r
1342 skuInfo.setValue("");\r
1343 }\r
1344 }\r
1345 if (dataType.equals("UINT8")){\r
1346 dynPcdData.setMaxDatumSize(1);\r
1347 }\r
1348 if (dataType.equals("UINT16")) {\r
1349 dynPcdData.setMaxDatumSize(2);\r
1350 }\r
1351 if (dataType.equals("UINT32")) {\r
1352 dynPcdData.setMaxDatumSize(4);\r
1353 }\r
1354 if (dataType.equals("UINT64")){\r
1355 dynPcdData.setMaxDatumSize(8);\r
1356 }\r
1357 if (dataType.equals("BOOLEAN")){\r
1358 dynPcdData.setMaxDatumSize(1);\r
1359 }\r
1360 if (dataType.equals("VOID*")) {\r
1361 int maxSize = setMaxSizeForPointer(defaultVal);\r
1362 dynPcdData.setMaxDatumSize(maxSize);\r
1363 }\r
1364 }\r
1365 \r
908b1c05 1366 public void removeDynamicPcdBuildData(String cName, String tsGuid) {\r
e232295e 1367 XmlObject o = fpdRoot.getDynamicPcdBuildDefinitions();\r
1368 if (o == null) {\r
1369 return;\r
1370 }\r
a13899c5 1371 \r
1372 XmlCursor cursor = o.newCursor();\r
1373 if (cursor.toFirstChild()) {\r
af25df16 1374 do {\r
1375 DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData pcdBuildData = \r
1376 (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject();\r
908b1c05 1377 if (pcdBuildData.getCName().equals(cName) && pcdBuildData.getTokenSpaceGuidCName().equals(tsGuid)) {\r
add40ab2 1378 \r
1379 if (getDynamicPcdBuildDataCount() == 1) {\r
af25df16 1380 cursor.toParent();\r
af25df16 1381 }\r
add40ab2 1382 cursor.removeXml();\r
908b1c05 1383 cursor.dispose();\r
1384 return;\r
1385 }\r
a13899c5 1386 }\r
af25df16 1387 while (cursor.toNextSibling());\r
a13899c5 1388 }\r
1389 cursor.dispose();\r
1390 }\r
1391 //\r
1392 // Get the Sku Info count of ith dyn pcd element.\r
1393 //\r
1394 public int getDynamicPcdSkuInfoCount(int i){\r
e232295e 1395 if (fpdRoot.getDynamicPcdBuildDefinitions() == null || fpdRoot.getDynamicPcdBuildDefinitions().getPcdBuildDataList() == null \r
1396 || fpdRoot.getDynamicPcdBuildDefinitions().getPcdBuildDataList().size() == 0) {\r
a13899c5 1397 return 0;\r
1398 }\r
1399 \r
1400 int skuInfoCount = 0;\r
1401 XmlCursor cursor = getfpdDynPcdBuildDefs().newCursor();\r
1402 if (cursor.toFirstChild()) {\r
1403 for (int j = 0; j < i; ++j) {\r
1404 cursor.toNextSibling();\r
1405 }\r
1406 DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData pcdData = (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject();\r
1407 if (pcdData.getSkuInfoList() == null) {\r
1408 skuInfoCount = 0;\r
1409 }\r
1410 else {\r
1411 skuInfoCount = pcdData.getSkuInfoList().size();\r
1412 }\r
1413 }\r
1414 cursor.dispose();\r
1415 return skuInfoCount;\r
1416 }\r
1417 \r
1418 public void getDynamicPcdSkuInfos(int i, String[][] saa){\r
1419 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {\r
e232295e 1420 removeElement(getfpdDynPcdBuildDefs());\r
1421 fpdDynPcdBuildDefs = null;\r
a13899c5 1422 return;\r
1423 }\r
1424 \r
1425 XmlCursor cursor = getfpdDynPcdBuildDefs().newCursor();\r
1426 if (cursor.toFirstChild()) {\r
1427 for (int j = 0; j < i; ++j) {\r
1428 cursor.toNextSibling();\r
1429 }\r
1430 DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData pcdData = (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject();\r
1431 if (pcdData.getSkuInfoList() == null) {\r
1432 cursor.dispose();\r
1433 return;\r
1434 }\r
1435 else {\r
1436 ListIterator<DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData.SkuInfo> li = pcdData.getSkuInfoList().listIterator();\r
1437 int k = 0;\r
1438 while (li.hasNext()) {\r
1439 DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData.SkuInfo skuInfo = li.next();\r
1440 saa[k][0] = skuInfo.getSkuId()+"";\r
1441 saa[k][1] = skuInfo.getVariableName();\r
1442 saa[k][2] = skuInfo.getVariableGuid();\r
1443 saa[k][3] = skuInfo.getVariableOffset();\r
1444 saa[k][4] = skuInfo.getHiiDefaultValue();\r
1445 saa[k][5] = skuInfo.getVpdOffset();\r
1446 saa[k][6] = skuInfo.getValue();\r
1447 ++k;\r
1448 }\r
1449 \r
1450 }\r
1451 }\r
1452 cursor.dispose();\r
1453 \r
1454 }\r
1455 \r
1456 public String getDynamicPcdBuildDataValue(int i){\r
1457 String value = null;\r
1458 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {\r
e232295e 1459 removeElement(getfpdDynPcdBuildDefs());\r
1460 fpdDynPcdBuildDefs = null;\r
a13899c5 1461 return value;\r
1462 }\r
1463 \r
1464 XmlCursor cursor = getfpdDynPcdBuildDefs().newCursor();\r
1465 if (cursor.toFirstChild()) {\r
1466 for (int j = 0; j < i; ++j) {\r
1467 cursor.toNextSibling();\r
1468 }\r
1469 DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData pcdData = (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject();\r
1470 if (pcdData.getSkuInfoList() == null) {\r
1471 value = null;\r
1472 }\r
1473 else {\r
1474 value = pcdData.getSkuInfoArray(0).getValue();\r
1475 }\r
1476 }\r
1477 cursor.dispose();\r
1478 return value;\r
1479 }\r
1480 \r
1481 public String getDynamicPcdBuildDataVpdOffset(int i){\r
1482 String vpdOffset = null;\r
1483 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {\r
e232295e 1484 removeElement(getfpdDynPcdBuildDefs());\r
1485 fpdDynPcdBuildDefs = null;\r
a13899c5 1486 return vpdOffset;\r
1487 }\r
1488 \r
1489 XmlCursor cursor = getfpdDynPcdBuildDefs().newCursor();\r
1490 if (cursor.toFirstChild()) {\r
1491 for (int j = 0; j < i; ++j) {\r
1492 cursor.toNextSibling();\r
1493 }\r
1494 DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData pcdData = (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject();\r
1495 if (pcdData.getSkuInfoList() == null) {\r
1496 vpdOffset = null;\r
1497 }\r
1498 else {\r
1499 vpdOffset = pcdData.getSkuInfoArray(0).getVpdOffset();\r
1500 }\r
1501 }\r
1502 cursor.dispose();\r
1503 return vpdOffset;\r
1504 }\r
1505 \r
1506 public void removeDynamicPcdBuildDataSkuInfo(int i) {\r
1507 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {\r
e232295e 1508 removeElement(getfpdDynPcdBuildDefs());\r
1509 fpdDynPcdBuildDefs = null;\r
a13899c5 1510 return;\r
1511 }\r
1512 \r
1513 XmlCursor cursor = getfpdDynPcdBuildDefs().newCursor();\r
1514 if (cursor.toFirstChild()) {\r
1515 for (int j = 0; j < i; ++j) {\r
1516 cursor.toNextSibling();\r
1517 }\r
1518 DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData pcdData = (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject();\r
1519 if (pcdData.getSkuInfoList() == null) {\r
1520 cursor.dispose();\r
1521 return;\r
1522 }\r
1523 else {\r
1524 QName qSkuInfo = new QName(xmlNs, "SkuInfo");\r
1525 cursor.toChild(qSkuInfo);\r
1526 cursor.removeXml();\r
1527 }\r
1528 }\r
1529 cursor.dispose();\r
1530 }\r
1531 //\r
1532 // generate sku info for ith dyn pcd build data.\r
1533 //\r
1534 public void genDynamicPcdBuildDataSkuInfo(String id, String varName, String varGuid, String varOffset, \r
1535 String hiiDefault, String vpdOffset, String value, int i) {\r
e232295e 1536// if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {\r
1537// return;\r
1538// }\r
a13899c5 1539 \r
1540 XmlCursor cursor = getfpdDynPcdBuildDefs().newCursor();\r
1541 if (cursor.toFirstChild()) {\r
1542 for (int j = 0; j < i; ++j) {\r
1543 cursor.toNextSibling();\r
1544 }\r
1545 DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData pcdData = (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject();\r
1546 DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData.SkuInfo skuInfo = pcdData.addNewSkuInfo();\r
1547 skuInfo.setSkuId(new BigInteger(id));\r
1548 if (varName != null){\r
1549 skuInfo.setVariableName(varName);\r
1550 skuInfo.setVariableGuid(varGuid);\r
1551 skuInfo.setVariableOffset(varOffset);\r
1552 skuInfo.setHiiDefaultValue(hiiDefault);\r
1553 }\r
1554 else if (vpdOffset != null){\r
1555 skuInfo.setVpdOffset(vpdOffset);\r
1556 }\r
1557 else{\r
1558 skuInfo.setValue(value);\r
1559 }\r
1560 }\r
1561 }\r
1562 \r
1563 public void updateDynamicPcdBuildDataSkuInfo(String id, String varName, String varGuid, String varOffset, \r
1564 String hiiDefault, String vpdOffset, String value, int i){\r
e232295e 1565// if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {\r
1566// return;\r
1567// }\r
a13899c5 1568 \r
1569 XmlCursor cursor = getfpdDynPcdBuildDefs().newCursor();\r
1570 if (cursor.toFirstChild()) {\r
1571 for (int j = 0; j < i; ++j) {\r
1572 cursor.toNextSibling();\r
1573 }\r
1574 DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData pcdData = (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject();\r
1575 ListIterator<DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData.SkuInfo> li = pcdData.getSkuInfoList().listIterator();\r
1576 while (li.hasNext()) {\r
1577 DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData.SkuInfo skuInfo = li.next();\r
1578 if (skuInfo.getSkuId().toString().equals(id)){\r
1579 if (varName != null){\r
1580 skuInfo.setVariableName(varName);\r
1581 skuInfo.setVariableGuid(varGuid);\r
1582 skuInfo.setVariableOffset(varOffset);\r
1583 skuInfo.setHiiDefaultValue(hiiDefault);\r
1584 }\r
1585 else if (vpdOffset != null){\r
1586 skuInfo.setVpdOffset(vpdOffset);\r
1587 }\r
1588 else{\r
1589 skuInfo.setValue(value);\r
1590 }\r
1591 break;\r
1592 }\r
1593 }\r
1594 }\r
1595 }\r
1596 \r
a13899c5 1597 public BuildOptionsDocument.BuildOptions getfpdBuildOpts() {\r
1598 if (fpdBuildOpts == null) {\r
1599 fpdBuildOpts = fpdRoot.addNewBuildOptions();\r
1600 }\r
1601 return fpdBuildOpts;\r
1602 }\r
1603 \r
2b70a636 1604 public void genBuildOptionsUserExtensions(String fvName, String outputFileName, Vector<String[]> includeModules) {\r
1bf9fa5a 1605 UserExtensionsDocument.UserExtensions userExts = getfpdBuildOpts().addNewUserExtensions();\r
1606 userExts.setUserID("IMAGES");\r
1607 userExts.setIdentifier(new BigInteger("1"));\r
1608 XmlCursor cursor = userExts.newCursor();\r
1609 cursor.toEndToken();\r
1610 \r
1611 cursor.beginElement("FvName");\r
1612 cursor.insertChars(fvName);\r
1613 cursor.toNextToken();\r
1614 \r
1615 cursor.beginElement("InfFileName");\r
61919f8c 1616 cursor.insertChars(fvName + ".inf");\r
1bf9fa5a 1617 cursor.toNextToken();\r
1618 \r
1619 cursor.beginElement("IncludeModules");\r
2b70a636 1620 for (int i = 0; i < includeModules.size(); ++i) {\r
1bf9fa5a 1621 cursor.beginElement("Module");\r
2b70a636 1622 cursor.insertAttributeWithValue("ModuleGuid", includeModules.get(i)[0]);\r
1623 cursor.insertAttributeWithValue("BaseName", includeModules.get(i)[1]);\r
1bf9fa5a 1624 cursor.toEndToken();\r
1625 cursor.toNextToken();\r
1626 }\r
1627 cursor.dispose();\r
1628 }\r
1629 \r
1630 public int getUserExtsIncModCount (String fvName) {\r
1631 if (getfpdBuildOpts().getUserExtensionsList() == null) {\r
1632 return -1;\r
1633 }\r
1634 ListIterator<UserExtensionsDocument.UserExtensions> li = getfpdBuildOpts().getUserExtensionsList().listIterator();\r
1635 while (li.hasNext()) {\r
1636 UserExtensionsDocument.UserExtensions ues = li.next();\r
1637 if (!ues.getUserID().equals("IMAGES")) {\r
1638 continue;\r
1639 }\r
1640 XmlCursor cursor = ues.newCursor();\r
1641 cursor.toFirstChild();\r
1642 String elementName = cursor.getTextValue();\r
1643 if (elementName.equals(fvName)) {\r
1644 cursor.toNextSibling(new QName("", "IncludeModules"));\r
1645 if (cursor.toFirstChild()) {\r
1646 int i = 1;\r
1647 for (i = 1; cursor.toNextSibling(); ++i);\r
1648 cursor.dispose();\r
1649 return i;\r
1650 }\r
1651 cursor.dispose();\r
1652 return 0;\r
1653 }\r
1654 cursor.dispose();\r
1655 }\r
1656 return -1;\r
1657 }\r
1658 \r
1659 public void getUserExtsIncMods(String fvName, String[][] saa) {\r
1660 if (getfpdBuildOpts().getUserExtensionsList() == null) {\r
1661 return;\r
1662 }\r
1663 ListIterator<UserExtensionsDocument.UserExtensions> li = getfpdBuildOpts().getUserExtensionsList().listIterator();\r
1664 while (li.hasNext()) {\r
1665 UserExtensionsDocument.UserExtensions ues = li.next();\r
1666 if (!ues.getUserID().equals("IMAGES")) {\r
1667 continue;\r
1668 }\r
1669 XmlCursor cursor = ues.newCursor();\r
1670 cursor.toFirstChild();\r
1671 String elementName = cursor.getTextValue();\r
1672 if (elementName.equals(fvName)) {\r
1673 cursor.toNextSibling(new QName("", "IncludeModules"));\r
1674 if (cursor.toFirstChild()) {\r
1675 int i = 0;\r
1676 do {\r
1677 saa[i][0] = cursor.getAttributeText(new QName("ModuleGuid"));\r
1678 saa[i][1] = cursor.getAttributeText(new QName("BaseName"));\r
1679 ++i;\r
1680 }while (cursor.toNextSibling());\r
1681 }\r
1682 cursor.dispose();\r
1683 return;\r
1684 }\r
1685 cursor.dispose();\r
1686 }\r
1687 \r
1688 }\r
1689 \r
61919f8c 1690 public void removeBuildOptionsUserExtensions (String fvName) {\r
1691 if (getfpdBuildOpts().getUserExtensionsList() == null) {\r
1692 return;\r
1693 }\r
1694 \r
1695 ListIterator<UserExtensionsDocument.UserExtensions> li = getfpdBuildOpts().getUserExtensionsList().listIterator();\r
1696 while (li.hasNext()) {\r
1697 UserExtensionsDocument.UserExtensions ues = li.next();\r
1698 if (!ues.getUserID().equals("IMAGES")) {\r
1699 continue;\r
1700 }\r
1701 XmlCursor cursor = ues.newCursor();\r
1702 cursor.toFirstChild();\r
1703 String elementName = cursor.getTextValue();\r
1704 if (elementName.equals(fvName)) {\r
1705 cursor.toParent();\r
1706 cursor.removeXml();\r
1707 cursor.dispose();\r
1708 return;\r
1709 }\r
1710 cursor.dispose();\r
1711 }\r
1712 \r
1713 }\r
1714 \r
1715 \r
a13899c5 1716 public void genBuildOptionsUserDefAntTask (String id, String fileName, String execOrder) {\r
1717 UserDefinedAntTasksDocument.UserDefinedAntTasks udats = getfpdBuildOpts().getUserDefinedAntTasks();\r
1718 if (udats == null) {\r
1719 udats = getfpdBuildOpts().addNewUserDefinedAntTasks();\r
1720 }\r
1721 \r
1722 AntTaskDocument.AntTask at = udats.addNewAntTask();\r
1723 setBuildOptionsUserDefAntTask(id, fileName, execOrder, at);\r
1724 }\r
1725 \r
1726 private void setBuildOptionsUserDefAntTask(String id, String fileName, String execOrder, AntTaskDocument.AntTask at) {\r
1727 at.setId(new Integer(id));\r
bf5abaff 1728 XmlCursor cursor = at.newCursor();\r
a13899c5 1729 if (fileName != null){\r
1730 at.setFilename(fileName);\r
1731 }\r
bf5abaff 1732 else if (cursor.toChild(xmlNs, "Filename")) {\r
1733 cursor.removeXml();\r
1734 }\r
202c4f38 1735 if (execOrder != null) {\r
a13899c5 1736 at.setAntCmdOptions(execOrder);\r
1737 }\r
bf5abaff 1738 else if (cursor.toChild(xmlNs, "AntCmdOptions")) {\r
1739 cursor.removeXml();\r
1740 }\r
1741 cursor.dispose();\r
a13899c5 1742 }\r
1743 \r
1744 public void removeBuildOptionsUserDefAntTask(int i) {\r
1745 XmlObject o = getfpdBuildOpts().getUserDefinedAntTasks();\r
1746 if (o == null) {\r
1747 return;\r
1748 }\r
1749 XmlCursor cursor = o.newCursor();\r
1750 if (cursor.toFirstChild()) {\r
1751 for (int j = 0; j < i; ++j) {\r
1752 cursor.toNextSibling();\r
1753 }\r
1754 cursor.removeXml();\r
af25df16 1755 if (getBuildOptionsUserDefAntTaskCount() == 0) {\r
1756 cursor.toParent();\r
1757 cursor.removeXml();\r
1758 }\r
a13899c5 1759 }\r
1760 cursor.dispose();\r
1761 }\r
1762 \r
1763 public void updateBuildOptionsUserDefAntTask(int i, String id, String fileName, String execOrder){\r
1764 XmlObject o = getfpdBuildOpts().getUserDefinedAntTasks();\r
1765 if (o == null) {\r
1766 return;\r
1767 }\r
1768 XmlCursor cursor = o.newCursor();\r
1769 if (cursor.toFirstChild()) {\r
1770 for (int j = 0; j < i; ++j) {\r
1771 cursor.toNextSibling();\r
1772 }\r
1773 AntTaskDocument.AntTask at = (AntTaskDocument.AntTask)cursor.getObject();\r
1774 setBuildOptionsUserDefAntTask(id, fileName, execOrder, at);\r
1775 }\r
1776 cursor.dispose();\r
1777 }\r
1778 \r
1779 public int getBuildOptionsUserDefAntTaskCount() {\r
1780 UserDefinedAntTasksDocument.UserDefinedAntTasks udats = getfpdBuildOpts().getUserDefinedAntTasks();\r
1781 if (udats == null || udats.getAntTaskList() == null) {\r
1782 return 0;\r
1783 }\r
1784 \r
1785 return udats.getAntTaskList().size();\r
1786 }\r
1787 \r
1788 public void getBuildOptionsUserDefAntTasks(String[][] saa) {\r
1789 UserDefinedAntTasksDocument.UserDefinedAntTasks udats = getfpdBuildOpts().getUserDefinedAntTasks();\r
1790 if (udats == null || udats.getAntTaskList() == null) {\r
1791 return ;\r
1792 }\r
1793 \r
1794 List<AntTaskDocument.AntTask> l = udats.getAntTaskList();\r
1795 ListIterator li = l.listIterator();\r
1796 int i = 0;\r
1797 while (li.hasNext()) {\r
1798 AntTaskDocument.AntTask at = (AntTaskDocument.AntTask)li.next();\r
1799 saa[i][0] = at.getId() + "";\r
1800 saa[i][1] = saa[i][2] = "";\r
1801 if (at.getFilename() != null){\r
1802 saa[i][1] = at.getFilename();\r
1803 }\r
1804 if (at.getAntCmdOptions() != null) {\r
1805 saa[i][2] = at.getAntCmdOptions();\r
1806 }\r
1807 ++i;\r
1808 }\r
1809 }\r
1800d80f 1810 public void genBuildOptionsOpt(Vector<Object> buildTargets, String toolChain, String tagName, String toolCmd, Vector<Object> archList, String contents) {\r
a13899c5 1811 OptionsDocument.Options opts = getfpdBuildOpts().getOptions();\r
1812 if (opts == null) {\r
1813 opts = getfpdBuildOpts().addNewOptions();\r
1814 }\r
1815 OptionDocument.Option opt = opts.addNewOption();\r
1816 setBuildOptionsOpt(buildTargets, toolChain, tagName, toolCmd, archList, contents, opt);\r
1817 }\r
1818 \r
1800d80f 1819 private void setBuildOptionsOpt(Vector<Object> buildTargets, String toolChain, String tagName, String toolCmd, Vector<Object> archList, String contents, OptionDocument.Option opt){\r
a13899c5 1820 opt.setStringValue(contents);\r
1800d80f 1821 \r
1822 opt.setBuildTargets(buildTargets);\r
a13899c5 1823 opt.setToolChainFamily(toolChain);\r
1824 opt.setTagName(tagName);\r
1825 opt.setToolCode(toolCmd);\r
1800d80f 1826 \r
bf5abaff 1827 if (archList != null) {\r
1828 opt.setSupArchList(archList);\r
1829 }\r
1830 else {\r
1831 if (opt.isSetSupArchList()) {\r
1832 opt.unsetSupArchList();\r
1833 }\r
1834 }\r
a13899c5 1835 }\r
1836 \r
1837 public void removeBuildOptionsOpt(int i){\r
1838 \r
1839 XmlObject o = getfpdBuildOpts().getOptions();\r
1840 if (o == null) {\r
1841 return;\r
1842 }\r
1843 \r
1844 XmlCursor cursor = o.newCursor();\r
1845 if (cursor.toFirstChild()) {\r
1846 for (int j = 0; j < i; ++j) {\r
1847 cursor.toNextSibling();\r
1848 }\r
1849 cursor.removeXml();\r
af25df16 1850 if (getBuildOptionsOptCount() == 0) {\r
1851 cursor.toParent();\r
1852 cursor.removeXml();\r
1853 }\r
a13899c5 1854 }\r
1855 cursor.dispose();\r
1856 }\r
1857 \r
1800d80f 1858 public void updateBuildOptionsOpt(int i, Vector<Object> buildTargets, String toolChain, String tagName, String toolCmd, Vector<Object> archList, String contents) {\r
a13899c5 1859 XmlObject o = getfpdBuildOpts().getOptions();\r
1860 if (o == null) {\r
1861 return;\r
1862 }\r
1863 \r
1864 XmlCursor cursor = o.newCursor();\r
1865 if (cursor.toFirstChild()) {\r
1866 for (int j = 0; j < i; ++j) {\r
1867 cursor.toNextSibling();\r
1868 }\r
1869 OptionDocument.Option opt = (OptionDocument.Option)cursor.getObject();\r
1870 setBuildOptionsOpt(buildTargets, toolChain, tagName, toolCmd, archList, contents, opt);\r
1871 }\r
1872 cursor.dispose();\r
1873 }\r
1874 \r
1875 public int getBuildOptionsOptCount(){\r
1876 if (getfpdBuildOpts().getOptions() == null || getfpdBuildOpts().getOptions().getOptionList() == null) {\r
1877 return 0;\r
1878 }\r
1879 return getfpdBuildOpts().getOptions().getOptionList().size();\r
1880 }\r
1881 \r
1882 public void getBuildOptionsOpts(String[][] saa) {\r
1883 if (getfpdBuildOpts().getOptions() == null || getfpdBuildOpts().getOptions().getOptionList() == null) {\r
1884 return ;\r
1885 }\r
1886 \r
1887 List<OptionDocument.Option> lOpt = getfpdBuildOpts().getOptions().getOptionList();\r
1888 ListIterator li = lOpt.listIterator();\r
1889 int i = 0;\r
1890 while(li.hasNext()) {\r
1891 OptionDocument.Option opt = (OptionDocument.Option)li.next();\r
6cba26e8 1892 if (opt.getBuildTargets() != null) {\r
1893 saa[i][0] = listToString(opt.getBuildTargets());\r
1894 }\r
a13899c5 1895 saa[i][1] = opt.getToolChainFamily();\r
1896 if (opt.getSupArchList() != null){\r
6cba26e8 1897 saa[i][2] = listToString(opt.getSupArchList());\r
1898\r
a13899c5 1899 }\r
1900 saa[i][3] = opt.getToolCode();\r
1901 saa[i][4] = opt.getTagName();\r
1902 saa[i][5] = opt.getStringValue();\r
1903 \r
1904 ++i;\r
1905 }\r
1906 }\r
1907 \r
6cba26e8 1908 public void genBuildOptionsFfs(String ffsKey, String type) {\r
1909 BuildOptionsDocument.BuildOptions.Ffs ffs = getfpdBuildOpts().addNewFfs();\r
1910 ffs.setFfsKey(ffsKey);\r
1911 if (type != null) {\r
1912 ffs.addNewSections().setEncapsulationType(type);\r
1913 }\r
1914 }\r
1915 \r
3b405e9b 1916 public void updateBuildOptionsFfsSectionsType(int i, String type) {\r
1917 BuildOptionsDocument.BuildOptions.Ffs ffs = getfpdBuildOpts().addNewFfs();\r
1918 if (type != null) {\r
1919 ffs.addNewSections().setEncapsulationType(type);\r
1920 }\r
1921 }\r
1922 \r
6cba26e8 1923 public void genBuildOptionsFfsAttribute(int i, String name, String value) {\r
1924 BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r
1925 BuildOptionsDocument.BuildOptions.Ffs.Attribute attrib = ffs.addNewAttribute();\r
1926 attrib.setName(name);\r
1927 attrib.setValue(value);\r
1928 }\r
1929 \r
1930 /**update jth attribute of ith ffs.\r
1931 * @param i\r
1932 * @param j\r
1933 */\r
1934 public void updateBuildOptionsFfsAttribute(int i, int j, String name, String value){\r
1935 BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r
1936 XmlCursor cursor = ffs.newCursor();\r
1937 QName qAttrib = new QName(xmlNs, "Attribute");\r
1938 if (cursor.toChild(qAttrib)) {\r
1939 for (int k = 0; k < j; ++k) {\r
1940 cursor.toNextSibling(qAttrib);\r
1941 }\r
1942 BuildOptionsDocument.BuildOptions.Ffs.Attribute attrib = (BuildOptionsDocument.BuildOptions.Ffs.Attribute)cursor.getObject();\r
1943 attrib.setName(name);\r
1944 attrib.setValue(value);\r
1945 }\r
1946 cursor.dispose();\r
1947 }\r
1948 \r
1949 public void removeBuildOptionsFfsAttribute(int i, int j){\r
1950 BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r
1951 XmlCursor cursor = ffs.newCursor();\r
1952 QName qAttrib = new QName(xmlNs, "Attribute");\r
1953 if (cursor.toChild(qAttrib)) {\r
1954 for (int k = 0; k < j; ++k) {\r
1955 cursor.toNextSibling(qAttrib);\r
1956 }\r
1957 cursor.removeXml();\r
1958 }\r
1959 cursor.dispose();\r
1960 }\r
1961 \r
1962 public void genBuildOptionsFfsSectionsSection(int i, String sectionType) {\r
1963 BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r
1964 if (ffs == null) {\r
1965 return;\r
1966 }\r
1967 BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections();\r
1968 \r
1969 if (sections == null){\r
1970 sections = ffs.addNewSections();\r
1971 }\r
1972 sections.addNewSection().setSectionType(EfiSectionType.Enum.forString(sectionType));\r
1973 }\r
1974 \r
3b405e9b 1975 public void removeBuildOptionsFfsSectionsSection(int i, int j) {\r
1976 BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r
1977 BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections();\r
1978 if (sections == null) {\r
1979 return;\r
1980 }\r
1981 XmlCursor cursor = sections.newCursor();\r
1982 QName qSection = new QName(xmlNs, "Section");\r
1983 if (cursor.toChild(qSection)) {\r
1984 for (int k = 0; k < j; ++k) {\r
1985 cursor.toNextSibling(qSection);\r
1986 }\r
1987 cursor.removeXml();\r
1988 }\r
1989 cursor.dispose();\r
1990 }\r
1991 \r
1992 public void updateBuildOptionsFfsSectionsSection(int i, int j, String type){\r
1993 BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r
1994 BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections();\r
1995 if (sections == null) {\r
1996 return;\r
1997 }\r
1998 XmlCursor cursor = sections.newCursor();\r
1999 QName qSection = new QName(xmlNs, "Section");\r
2000 if (cursor.toChild(qSection)) {\r
2001 for (int k = 0; k < j; ++k) {\r
2002 cursor.toNextSibling(qSection);\r
2003 }\r
2004 BuildOptionsDocument.BuildOptions.Ffs.Sections.Section section = (BuildOptionsDocument.BuildOptions.Ffs.Sections.Section)cursor.getObject();\r
2005 section.setSectionType(EfiSectionType.Enum.forString(type));\r
2006 }\r
2007 cursor.dispose();\r
2008 } \r
2009 \r
6cba26e8 2010 public void genBuildOptionsFfsSectionsSections(int i, String encapType) {\r
2011 BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r
2012 if (ffs == null) {\r
2013 return;\r
2014 }\r
2015 BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections();\r
2016 \r
2017 if (sections == null){\r
2018 sections = ffs.addNewSections();\r
2019 }\r
2020 sections.addNewSections().setEncapsulationType(encapType);\r
2021 }\r
2022 \r
3b405e9b 2023 public void removeBuildOptionsFfsSectionsSections(int i, int j) {\r
2024 BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r
2025 BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections();\r
2026 if (sections == null) {\r
2027 return;\r
2028 }\r
2029 XmlCursor cursor = sections.newCursor();\r
2030 QName qSections = new QName(xmlNs, "Sections");\r
2031 if (cursor.toChild(qSections)) {\r
2032 for (int k = 0; k < j; ++k) {\r
2033 cursor.toNextSibling(qSections);\r
2034 }\r
2035 cursor.removeXml();\r
2036 }\r
2037 cursor.dispose();\r
2038 }\r
2039 \r
2040 public void updateBuildOptionsFfsSectionsSections(int i, int j, String type) {\r
2041 BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r
2042 BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections();\r
2043 if (sections == null) {\r
2044 return;\r
2045 }\r
2046 XmlCursor cursor = sections.newCursor();\r
2047 QName qSections = new QName(xmlNs, "Sections");\r
2048 if (cursor.toChild(qSections)) {\r
2049 for (int k = 0; k < j; ++k) {\r
2050 cursor.toNextSibling(qSections);\r
2051 }\r
2052 BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2 sections2 = (BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2)cursor.getObject();\r
2053 sections2.setEncapsulationType(type);\r
2054 }\r
2055 cursor.dispose();\r
2056 }\r
2057 \r
6cba26e8 2058 public void genBuildOptionsFfsSectionsSectionsSection(int i, int j, String type) {\r
2059 BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r
2060 if (ffs == null) {\r
2061 return;\r
2062 }\r
2063 BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections();\r
2064 XmlCursor cursor = sections.newCursor();\r
2065 QName qSections = new QName(xmlNs, "Sections");\r
2066 if (cursor.toChild(qSections)){\r
2067 for (int k = 0; k < j; ++k) {\r
2068 cursor.toNextSibling(qSections);\r
2069 }\r
2070 BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2 sections2 = (BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2)cursor.getObject();\r
2071 sections2.addNewSection().setSectionType(EfiSectionType.Enum.forString(type));\r
2072 }\r
2073 cursor.dispose();\r
2074 }\r
2075 \r
3b405e9b 2076 public void removeBuildOptionsFfsSectionsSectionsSection(int i, int j, int k) {\r
2077 BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r
2078 BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections();\r
2079 if (sections == null) {\r
2080 return;\r
2081 }\r
2082 XmlCursor cursor = sections.newCursor();\r
2083 QName qSections = new QName(xmlNs, "Sections");\r
2084 if (cursor.toChild(qSections)) {\r
2085 for (int l = 0; l < j; ++l) {\r
2086 cursor.toNextSibling(qSections);\r
2087 }\r
2088 if (cursor.toFirstChild()) {\r
af25df16 2089 int m = 0;\r
2090 for (; m < k; ++m) {\r
3b405e9b 2091 cursor.toNextSibling();\r
2092 }\r
2093 cursor.removeXml();\r
af25df16 2094 if (m == 0) {\r
2095 cursor.toParent();\r
2096 cursor.removeXml();\r
2097 }\r
3b405e9b 2098 }\r
2099 }\r
2100 cursor.dispose();\r
2101 }\r
2102 \r
2103 public void updateBuildOptionsFfsSectionsSectionsSection(int i, int j, int k, String type) {\r
2104 BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r
2105 BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections();\r
2106 if (sections == null) {\r
2107 return;\r
2108 }\r
2109 XmlCursor cursor = sections.newCursor();\r
2110 QName qSections = new QName(xmlNs, "Sections");\r
2111 if (cursor.toChild(qSections)) {\r
2112 for (int l = 0; l < j; ++l) {\r
2113 cursor.toNextSibling(qSections);\r
2114 }\r
2115 if (cursor.toFirstChild()) {\r
2116 for (int m = 0; m < k; ++m) {\r
2117 cursor.toNextSibling();\r
2118 }\r
2119 BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2.Section section = (BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2.Section)cursor.getObject();\r
2120 section.setSectionType(EfiSectionType.Enum.forString(type));\r
2121 }\r
2122 }\r
2123 cursor.dispose();\r
2124 }\r
2125 \r
6cba26e8 2126 public void getBuildOptionsFfsSectionsSectionsSection(int i, int j, ArrayList<String> al) {\r
2127 BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r
2128 if (ffs == null) {\r
2129 return;\r
2130 }\r
2131 BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections();\r
2132 XmlCursor cursor = sections.newCursor();\r
2133 QName qSections = new QName(xmlNs, "Sections");\r
2134 if (cursor.toChild(qSections)){\r
2135 for (int k = 0; k < j; ++k) {\r
2136 cursor.toNextSibling(qSections);\r
2137 }\r
2138 BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2 sections2 = (BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2)cursor.getObject();\r
2139 if (sections2.getSectionList() == null){\r
2140 cursor.dispose();\r
2141 return;\r
2142 }\r
2143 ListIterator<BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2.Section> li = sections2.getSectionList().listIterator();\r
2144 while(li.hasNext()) {\r
2145 BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2.Section section = li.next();\r
3b405e9b 2146 if (section.isSetSectionType()) {\r
1800d80f 2147 al.add(section.getSectionType().toString());\r
2148 }\r
3b405e9b 2149 \r
2150 }\r
6cba26e8 2151 }\r
2152 cursor.dispose();\r
2153 \r
2154 }\r
2155 \r
2156 public int getBuildOptionsFfsCount(){\r
2157 if (getfpdBuildOpts().getFfsList() == null) {\r
2158 return 0;\r
2159 }\r
2160 return getfpdBuildOpts().getFfsList().size();\r
2161 }\r
2162 \r
2163 public void getBuildOptionsFfsKey(String[][] saa) {\r
2164 if (getfpdBuildOpts().getFfsList() == null) {\r
2165 return;\r
2166 }\r
2167 ListIterator<BuildOptionsDocument.BuildOptions.Ffs> li = getfpdBuildOpts().getFfsList().listIterator();\r
2168 int i = 0;\r
2169 while(li.hasNext()){\r
2170 BuildOptionsDocument.BuildOptions.Ffs ffs = li.next();\r
2171 saa[i][0] = ffs.getFfsKey();\r
2172 ++i;\r
2173 }\r
2174 }\r
2175 \r
3b405e9b 2176 public void updateBuildOptionsFfsKey(int i, String key) {\r
2177 BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r
2178 ffs.setFfsKey(key);\r
2179 }\r
2180 \r
6cba26e8 2181 /**Get ith FFS key and contents.\r
2182 * @param saa\r
2183 */\r
2184 public void getBuildOptionsFfs(int i, String[] sa, LinkedHashMap<String, String> ffsAttribMap, ArrayList<String> firstLevelSections, ArrayList<String> firstLevelSection) {\r
2185 BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r
2186 \r
2187 if (ffs != null) {\r
2188 \r
2189 sa[0] = ffs.getFfsKey();\r
2190 if (ffs.getSections() != null) {\r
2191 if(ffs.getSections().getEncapsulationType() != null){\r
2192 sa[1] = ffs.getSections().getEncapsulationType();\r
2193 }\r
2194 if (ffs.getSections().getSectionList() != null){\r
2195 ListIterator<BuildOptionsDocument.BuildOptions.Ffs.Sections.Section> li = ffs.getSections().getSectionList().listIterator();\r
2196 while (li.hasNext()) {\r
2197 firstLevelSection.add(li.next().getSectionType().toString());\r
2198 }\r
2199 }\r
2200 if (ffs.getSections().getSectionsList() != null) {\r
2201 ListIterator<BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2> li = ffs.getSections().getSectionsList().listIterator();\r
2202 while(li.hasNext()) {\r
2203 firstLevelSections.add(li.next().getEncapsulationType());\r
2204 }\r
2205 }\r
2206 }\r
2207 if (ffs.getAttributeList() != null) {\r
2208 ListIterator<BuildOptionsDocument.BuildOptions.Ffs.Attribute> li = ffs.getAttributeList().listIterator();\r
2209 while(li.hasNext()) {\r
2210 BuildOptionsDocument.BuildOptions.Ffs.Attribute attrib = li.next();\r
2211 ffsAttribMap.put(attrib.getName(), attrib.getValue());\r
2212 }\r
2213 \r
2214 }\r
2215 }\r
2216\r
2217 \r
2218 }\r
2219 \r
2220 private BuildOptionsDocument.BuildOptions.Ffs getFfs(int i) {\r
2221 XmlObject o = getfpdBuildOpts();\r
2222 BuildOptionsDocument.BuildOptions.Ffs ffs = null;\r
2223 \r
2224 XmlCursor cursor = o.newCursor();\r
2225 QName qFfs = new QName(xmlNs, "Ffs");\r
2226 if (cursor.toChild(qFfs)) {\r
2227 for (int j = 0; j < i; ++j) {\r
2228 cursor.toNextSibling(qFfs);\r
2229 }\r
2230 ffs = (BuildOptionsDocument.BuildOptions.Ffs)cursor.getObject();\r
2231 }\r
2232 cursor.dispose();\r
2233 return ffs;\r
2234 }\r
2235 \r
2236 public void removeBuildOptionsFfs(int i) {\r
2237 BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r
2238 if (ffs == null){\r
2239 return;\r
2240 }\r
2241 \r
2242 XmlCursor cursor = ffs.newCursor();\r
2243 cursor.removeXml();\r
2244 cursor.dispose();\r
2245 }\r
2246 \r
3b405e9b 2247 \r
2248 \r
a13899c5 2249 public PlatformDefinitionsDocument.PlatformDefinitions getfpdPlatformDefs(){\r
2250 if (fpdPlatformDefs == null){\r
2251 fpdPlatformDefs = fpdRoot.addNewPlatformDefinitions();\r
2252 }\r
2253 return fpdPlatformDefs;\r
2254 }\r
2255 \r
6a09eb19 2256 public void getPlatformDefsSupportedArchs(Vector<Object> archs){\r
2257 if (getfpdPlatformDefs().getSupportedArchitectures() == null) {\r
2258 return;\r
2259 }\r
2260 ListIterator li = getfpdPlatformDefs().getSupportedArchitectures().listIterator();\r
2261 while(li.hasNext()) {\r
2262 archs.add(li.next());\r
2263 }\r
2264 }\r
2265 \r
2266 public void setPlatformDefsSupportedArchs(Vector<Object> archs) {\r
bf5abaff 2267 if (archs != null) {\r
2268 getfpdPlatformDefs().setSupportedArchitectures(archs);\r
2269 }\r
2270// else {\r
2271// XmlCursor cursor = getfpdPlatformDefs().newCursor();\r
2272// if (cursor.toChild(xmlNs, "SupportedArchitectures")) {\r
2273// cursor.removeXml();\r
2274// }\r
2275// cursor.dispose();\r
2276// }\r
6a09eb19 2277 }\r
2278 \r
2279 public void getPlatformDefsBuildTargets(Vector<Object> targets) {\r
2280 if (getfpdPlatformDefs().getBuildTargets() == null) {\r
2281 return;\r
2282 }\r
2283 ListIterator li = getfpdPlatformDefs().getBuildTargets().listIterator();\r
2284 while(li.hasNext()) {\r
2285 targets.add(li.next());\r
2286 }\r
2287 }\r
2288 \r
2289 public void setPlatformDefsBuildTargets(Vector<Object> targets) {\r
2290 getfpdPlatformDefs().setBuildTargets(targets);\r
2291 }\r
2292 \r
2293 public void genPlatformDefsSkuInfo(String id, String name) {\r
2294 SkuInfoDocument.SkuInfo skuInfo = null;\r
2295 if (getfpdPlatformDefs().getSkuInfo() == null) {\r
2296 skuInfo = getfpdPlatformDefs().addNewSkuInfo();\r
2297 }\r
2298 skuInfo = getfpdPlatformDefs().getSkuInfo();\r
2299 if (skuInfo.getUiSkuNameList() == null || skuInfo.getUiSkuNameList().size() == 0) {\r
2300 SkuInfoDocument.SkuInfo.UiSkuName skuName = skuInfo.addNewUiSkuName();\r
2301 skuName.setSkuID(new BigInteger("0"));\r
2302 skuName.setStringValue("DEFAULT");\r
2303 }\r
2304 if (id.equals("0")) {\r
2305 return;\r
2306 }\r
2307 SkuInfoDocument.SkuInfo.UiSkuName skuName = skuInfo.addNewUiSkuName();\r
2308 skuName.setSkuID(new BigInteger(id));\r
2309 skuName.setStringValue(name);\r
2310 }\r
2311 \r
2312 public int getPlatformDefsSkuInfoCount(){\r
2313 if (getfpdPlatformDefs().getSkuInfo() == null || getfpdPlatformDefs().getSkuInfo().getUiSkuNameList() == null) {\r
2314 return 0;\r
2315 }\r
2316 return getfpdPlatformDefs().getSkuInfo().getUiSkuNameList().size();\r
2317 }\r
2318 \r
2319 public void getPlatformDefsSkuInfos(String[][] saa){\r
2320 if (getfpdPlatformDefs().getSkuInfo() == null || getfpdPlatformDefs().getSkuInfo().getUiSkuNameList() == null) {\r
5af6b67f 2321 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null) {\r
2322 removeElement(getfpdDynPcdBuildDefs());\r
2323 fpdDynPcdBuildDefs = null;\r
2324 }\r
6a09eb19 2325 return ;\r
2326 }\r
2327 \r
2328 List<SkuInfoDocument.SkuInfo.UiSkuName> l = getfpdPlatformDefs().getSkuInfo().getUiSkuNameList();\r
2329 ListIterator<SkuInfoDocument.SkuInfo.UiSkuName> li = l.listIterator();\r
2330 int i = 0;\r
2331 while(li.hasNext()) {\r
2332 SkuInfoDocument.SkuInfo.UiSkuName sku = li.next();\r
2333 saa[i][0] = sku.getSkuID()+"";\r
2334 saa[i][1] = sku.getStringValue();\r
2335 ++i;\r
2336 }\r
2337 }\r
2338 \r
2339 public void removePlatformDefsSkuInfo(int i) {\r
2340 SkuInfoDocument.SkuInfo skuInfo = getfpdPlatformDefs().getSkuInfo();\r
2341 if (skuInfo == null || i == 0) {\r
2342 return ;\r
2343 }\r
2344 \r
2345 XmlCursor cursor = skuInfo.newCursor();\r
2346 if (cursor.toFirstChild()) {\r
2347 for (int j = 0; j < i; ++j) {\r
2348 cursor.toNextSibling();\r
2349 }\r
2350 cursor.removeXml();\r
2351 }\r
2352 cursor.dispose();\r
2353 }\r
2354 \r
2355 public void updatePlatformDefsSkuInfo(int i, String id, String name) {\r
2356 SkuInfoDocument.SkuInfo skuInfo = getfpdPlatformDefs().getSkuInfo();\r
2357 if (skuInfo == null || i == 0) {\r
2358 return ;\r
2359 }\r
2360 \r
2361 XmlCursor cursor = skuInfo.newCursor();\r
2362 if (cursor.toFirstChild()) {\r
2363 for (int j = 0; j < i; ++j) {\r
2364 cursor.toNextSibling();\r
2365 }\r
2366 SkuInfoDocument.SkuInfo.UiSkuName sku = (SkuInfoDocument.SkuInfo.UiSkuName)cursor.getObject();\r
2367 sku.setSkuID(new BigInteger(id));\r
2368 sku.setStringValue(name);\r
2369 }\r
2370 cursor.dispose();\r
2371 }\r
2372 \r
2373 public String getPlatformDefsInterDir(){\r
2374 if (getfpdPlatformDefs().getIntermediateDirectories() == null) {\r
2375 return null;\r
2376 }\r
2377 return getfpdPlatformDefs().getIntermediateDirectories().toString();\r
2378 }\r
2379 \r
2380 public void setPlatformDefsInterDir(String interDir){\r
2381 getfpdPlatformDefs().setIntermediateDirectories(IntermediateOutputType.Enum.forString(interDir));\r
2382 }\r
2383 \r
2384 public String getPlatformDefsOutputDir() {\r
2385 return getfpdPlatformDefs().getOutputDirectory();\r
2386 }\r
2387 \r
2388 public void setPlatformDefsOutputDir(String outputDir) {\r
af25df16 2389 if (outputDir != null && outputDir.length() > 0) {\r
2390 getfpdPlatformDefs().setOutputDirectory(outputDir);\r
2391 }\r
2392 else{\r
2393 XmlCursor cursor = getfpdPlatformDefs().newCursor();\r
2394 if (cursor.toChild(new QName(xmlNs, "OutputDirectory"))) {\r
2395 cursor.removeXml();\r
2396 }\r
2397 cursor.dispose();\r
2398 }\r
6a09eb19 2399 }\r
2400 \r
a13899c5 2401 public FlashDocument.Flash getfpdFlash() {\r
2402 if (fpdFlash == null) {\r
2403 fpdFlash = fpdRoot.addNewFlash();\r
2404 }\r
2405 return fpdFlash;\r
2406 }\r
2407 \r
2408 public void genFlashDefinitionFile(String file) {\r
2409 FlashDefinitionFileDocument.FlashDefinitionFile fdf = getfpdFlash().getFlashDefinitionFile();\r
2410 if (fdf == null) {\r
2411 fdf = getfpdFlash().addNewFlashDefinitionFile();\r
2412 }\r
2413 \r
2414 fdf.setStringValue(file);\r
2415 }\r
2416 \r
2417 public String getFlashDefinitionFile() {\r
2418 FlashDefinitionFileDocument.FlashDefinitionFile fdf = getfpdFlash().getFlashDefinitionFile();\r
2419 if (fdf == null) {\r
2420 return "";\r
2421 }\r
2422 \r
2423 return fdf.getStringValue();\r
2424 }\r
2425 \r
a13899c5 2426 public void genFvImagesNameValue(String name, String value) {\r
2427 \r
2428 FvImagesDocument.FvImages fi = getfpdFlash().getFvImages();\r
2429 if (fi == null) {\r
2430 fi = getfpdFlash().addNewFvImages();\r
2431 }\r
2432 \r
2433 FvImagesDocument.FvImages.NameValue nv = fi.addNewNameValue();\r
2434 nv.setName(name);\r
2435 nv.setValue(value);\r
2436 }\r
2437 \r
2438 public void removeFvImagesNameValue(int i){\r
2439 \r
2440 XmlObject o = getfpdFlash().getFvImages();\r
2441 if (o == null) {\r
2442 return;\r
2443 }\r
2444 \r
2445 QName qNameValue = new QName(xmlNs, "NameValue");\r
2446 XmlCursor cursor = o.newCursor();\r
2447 if (cursor.toChild(qNameValue)) {\r
2448 for (int j = 0; j < i; ++j) {\r
2449 cursor.toNextSibling(qNameValue);\r
2450 }\r
2451 cursor.removeXml();\r
2452 }\r
2453 cursor.dispose();\r
2454 }\r
2455 \r
2456 public void updateFvImagesNameValue(int i, String name, String value){\r
2457 \r
2458 XmlObject o = getfpdFlash().getFvImages();\r
2459 if (o == null) {\r
2460 return;\r
2461 }\r
2462 \r
2463 QName qNameValue = new QName(xmlNs, "NameValue");\r
2464 XmlCursor cursor = o.newCursor();\r
2465 if (cursor.toChild(qNameValue)) {\r
2466 for (int j = 0; j < i; ++j) {\r
2467 cursor.toNextSibling(qNameValue);\r
2468 }\r
2469 FvImagesDocument.FvImages.NameValue nv = (FvImagesDocument.FvImages.NameValue)cursor.getObject();\r
2470 nv.setName(name);\r
2471 nv.setValue(value);\r
2472 }\r
2473 cursor.dispose();\r
2474 }\r
2475 \r
2476 public int getFvImagesNameValueCount() {\r
2477 \r
2478 FvImagesDocument.FvImages fi = null;\r
2479 if ((fi = getfpdFlash().getFvImages()) == null || fi.getNameValueList() == null) {\r
2480 return 0;\r
2481 }\r
2482 return fi.getNameValueList().size();\r
2483 }\r
2484 \r
2485 public void getFvImagesNameValues(String[][] nv) {\r
2486 \r
2487 FvImagesDocument.FvImages fi = getfpdFlash().getFvImages();\r
2488 if (fi == null){\r
2489 return;\r
2490 }\r
2491 List<FvImagesDocument.FvImages.NameValue> l = fi.getNameValueList();\r
2492 int i = 0;\r
2493 ListIterator li = l.listIterator();\r
2494 while (li.hasNext()) {\r
2495 FvImagesDocument.FvImages.NameValue e = (FvImagesDocument.FvImages.NameValue) li\r
2496 .next();\r
2497 nv[i][0] = e.getName();\r
2498 nv[i][1] = e.getValue();\r
2499 \r
2500 i++;\r
2501 }\r
2502 }\r
2503 \r
2504 public void genFvImagesFvImage(String[] names, String types, Map<String, String> options) {\r
2505 \r
2506 FvImagesDocument.FvImages fis = null;\r
2507 if ((fis = getfpdFlash().getFvImages()) == null) {\r
2508 fis = getfpdFlash().addNewFvImages();\r
2509 }\r
2510 \r
2511 //\r
2512 //gen FvImage with FvImageNames array\r
2513 //\r
2514 FvImagesDocument.FvImages.FvImage fi = fis.addNewFvImage();\r
2515 for (int i = 0; i < names.length; ++i) {\r
2516 fi.addFvImageNames(names[i]);\r
2517 }\r
2518 fi.setType(FvImageTypes.Enum.forString(types));\r
2519 if (options != null){\r
2520 setFvImagesFvImageFvImageOptions(options, fi);\r
2521 }\r
2522 }\r
2523 \r
2524 private void setFvImagesFvImageFvImageOptions(Map<String, String> options, FvImagesDocument.FvImages.FvImage fi){\r
2525 FvImagesDocument.FvImages.FvImage.FvImageOptions fio = fi.getFvImageOptions();\r
2526 if (fio == null){\r
2527 fio = fi.addNewFvImageOptions();\r
2528 }\r
2529 \r
2530 Set<String> key = options.keySet();\r
2531 Iterator<String> i = key.iterator();\r
2532 while (i.hasNext()) {\r
44053733 2533 \r
a13899c5 2534 FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue nv = fio.addNewNameValue();\r
2535 String k = (String)i.next();\r
ae0d4fd2 2536 \r
a13899c5 2537 nv.setName(k);\r
2538 nv.setValue((String)options.get(k));\r
2539 \r
2540 }\r
2541 \r
2542 }\r
2543 \r
44053733 2544 \r
a13899c5 2545 public void removeFvImagesFvImage(int i) {\r
2546 \r
2547 XmlObject o = getfpdFlash().getFvImages();\r
2548 if (o == null) {\r
2549 return;\r
2550 }\r
2551 \r
2552 QName qFvImage = new QName(xmlNs, "FvImage");\r
2553 XmlCursor cursor = o.newCursor();\r
2554 if (cursor.toChild(qFvImage)) {\r
2555 for (int j = 0; j < i; ++j) {\r
2556 cursor.toNextSibling(qFvImage);\r
2557 }\r
2558 cursor.removeXml();\r
2559 }\r
2560 cursor.dispose();\r
2561 }\r
2562 \r
2563 public void updateFvImagesFvImage(int i, String[] names, String types, Map<String, String> options){\r
2564 \r
2565 XmlObject o = getfpdFlash().getFvImages();\r
2566 if (o == null) {\r
2567 return;\r
2568 }\r
2569 XmlCursor cursor = o.newCursor();\r
2570 QName qFvImage = new QName(xmlNs, "FvImage");\r
2571 if (cursor.toChild(qFvImage)) {\r
2572 for (int j = 0; j < i; ++j) {\r
2573 cursor.toNextSibling(qFvImage);\r
2574 }\r
2575 FvImagesDocument.FvImages.FvImage fi = (FvImagesDocument.FvImages.FvImage)cursor.getObject();\r
2576 fi.setType(FvImageTypes.Enum.forString(types));\r
2577 \r
2578 //\r
2579 // remove old FvImageNames before adding new ones\r
2580 //\r
2581 QName qFvImageNames = new QName(xmlNs, "FvImageNames"); \r
2582 cursor.toChild(qFvImageNames);\r
2583 cursor.removeXml();\r
2584 while (cursor.toNextSibling(qFvImageNames)) {\r
2585 cursor.removeXml();\r
2586 }\r
2587 \r
2588 for (int k = 0; k < names.length; ++k) {\r
2589 fi.addFvImageNames(names[k]);\r
2590 }\r
2591 //\r
2592 // remove old FvImageOptions before adding new options\r
2593 //\r
2594 QName qFvImageOptions = new QName(xmlNs, "FvImageOptions");\r
2595 cursor.toNextSibling(qFvImageOptions);\r
2596 cursor.removeXml();\r
2597 \r
2598 setFvImagesFvImageFvImageOptions(options, fi);\r
2599 }\r
2600 cursor.dispose();\r
2601 }\r
2602 \r
2603 public int getFvImagesFvImageCount() {\r
2604 \r