a13899c5 |
1 | /** @file\r |
2 | Java class FpdFileContents is used to parse fpd xml file.\r |
3 | \r |
4 | Copyright (c) 2006, Intel Corporation\r |
5 | All rights reserved. This program and the accompanying materials\r |
6 | are licensed and made available under the terms and conditions of the BSD License\r |
7 | which accompanies this distribution. The full text of the license may be found at\r |
8 | http://opensource.org/licenses/bsd-license.php\r |
9 | \r |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r |
12 | **/\r |
13 | package org.tianocore.frameworkwizard.platform.ui;\r |
14 | \r |
15 | import java.io.File;\r |
16 | import java.io.IOException;\r |
17 | import java.math.BigInteger;\r |
18 | import java.util.ArrayList;\r |
19 | import java.util.HashMap;\r |
20 | import java.util.Iterator;\r |
21 | import java.util.LinkedHashMap;\r |
22 | import java.util.List;\r |
23 | import java.util.ListIterator;\r |
24 | import java.util.Map;\r |
25 | import java.util.Set;\r |
6a09eb19 |
26 | import java.util.Vector;\r |
a13899c5 |
27 | \r |
28 | import javax.xml.namespace.QName;\r |
29 | \r |
30 | import org.apache.xmlbeans.XmlCursor;\r |
31 | import org.apache.xmlbeans.XmlObject;\r |
32 | import org.apache.xmlbeans.XmlOptions;\r |
33 | import org.tianocore.AntTaskDocument;\r |
34 | import org.tianocore.BuildOptionsDocument;\r |
35 | import org.tianocore.DynamicPcdBuildDefinitionsDocument;\r |
6cba26e8 |
36 | import org.tianocore.EfiSectionType;\r |
a13899c5 |
37 | import org.tianocore.FlashDefinitionFileDocument;\r |
a13899c5 |
38 | import org.tianocore.FlashDocument;\r |
39 | import org.tianocore.FrameworkModulesDocument;\r |
6a09eb19 |
40 | import org.tianocore.IntermediateOutputType;\r |
a13899c5 |
41 | import org.tianocore.LibrariesDocument;\r |
42 | import org.tianocore.ModuleSADocument;\r |
43 | import org.tianocore.ModuleSurfaceAreaDocument;\r |
44 | import org.tianocore.OptionDocument;\r |
45 | import org.tianocore.OptionsDocument;\r |
46 | import org.tianocore.PcdBuildDefinitionDocument;\r |
47 | import org.tianocore.PcdCodedDocument;\r |
48 | import org.tianocore.PcdDataTypes;\r |
49 | import org.tianocore.PcdDeclarationsDocument;\r |
50 | import org.tianocore.PcdItemTypes;\r |
51 | import org.tianocore.PlatformDefinitionsDocument;\r |
52 | import org.tianocore.PlatformSurfaceAreaDocument;\r |
53 | import org.tianocore.FvImageTypes;\r |
54 | import org.tianocore.FvImagesDocument;\r |
55 | import org.tianocore.LicenseDocument;\r |
56 | import org.tianocore.PlatformHeaderDocument;\r |
57 | import org.tianocore.SkuInfoDocument;\r |
58 | import org.tianocore.UserDefinedAntTasksDocument;\r |
59 | import org.tianocore.frameworkwizard.platform.ui.global.GlobalData;\r |
60 | import org.tianocore.frameworkwizard.platform.ui.global.SurfaceAreaQuery;\r |
61 | import org.tianocore.frameworkwizard.platform.ui.id.ModuleIdentification;\r |
62 | import org.tianocore.frameworkwizard.platform.ui.id.PackageIdentification;\r |
63 | \r |
64 | /**\r |
65 | This class processes fpd file contents such as add remove xml elements. \r |
66 | @since PackageEditor 1.0\r |
67 | **/\r |
68 | public class FpdFileContents {\r |
69 | \r |
70 | static final String xmlNs = "http://www.TianoCore.org/2006/Edk2.0";\r |
71 | \r |
72 | private PlatformSurfaceAreaDocument fpdd = null;\r |
73 | \r |
74 | private PlatformSurfaceAreaDocument.PlatformSurfaceArea fpdRoot = null;\r |
75 | \r |
76 | private PlatformHeaderDocument.PlatformHeader fpdHdr = null;\r |
77 | \r |
78 | private PlatformDefinitionsDocument.PlatformDefinitions fpdPlatformDefs = null;\r |
79 | \r |
80 | private FlashDocument.Flash fpdFlash = null;\r |
81 | \r |
82 | private BuildOptionsDocument.BuildOptions fpdBuildOpts = null;\r |
83 | \r |
84 | private FrameworkModulesDocument.FrameworkModules fpdFrameworkModules = null;\r |
85 | \r |
86 | private DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions fpdDynPcdBuildDefs = null;\r |
87 | \r |
88 | public static HashMap<String, ArrayList<String>> dynPcdMap = null;\r |
89 | \r |
90 | /**\r |
91 | * look through all pcd data in all ModuleSA, create pcd -> ModuleSA mappings.\r |
92 | */\r |
93 | public void initDynPcdMap() {\r |
94 | if (dynPcdMap == null) {\r |
95 | dynPcdMap = new HashMap<String, ArrayList<String>>();\r |
96 | List<ModuleSADocument.ModuleSA> l = getfpdFrameworkModules().getModuleSAList();\r |
97 | if (l == null) {\r |
98 | return;\r |
99 | }\r |
100 | ListIterator<ModuleSADocument.ModuleSA> li = l.listIterator();\r |
101 | while (li.hasNext()) {\r |
102 | ModuleSADocument.ModuleSA msa = li.next();\r |
103 | if (msa.getPcdBuildDefinition() == null || msa.getPcdBuildDefinition().getPcdDataList() == null) {\r |
104 | continue;\r |
105 | }\r |
106 | String ModuleInfo = msa.getModuleGuid() + " " + msa.getModuleVersion() +\r |
107 | " " + msa.getPackageGuid() + " " + msa.getPackageVersion();\r |
108 | List<PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData> lp = msa.getPcdBuildDefinition().getPcdDataList();\r |
109 | ListIterator<PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData> lpi = lp.listIterator();\r |
110 | while (lpi.hasNext()) {\r |
111 | PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData pcdData = lpi.next();\r |
112 | String pcdKey = pcdData.getCName() + " " + pcdData.getTokenSpaceGuidCName();\r |
113 | if (dynPcdMap.get(pcdKey) == null) {\r |
114 | ArrayList<String> al = new ArrayList<String>();\r |
115 | al.add(ModuleInfo + " " + pcdData.getItemType().toString());\r |
116 | dynPcdMap.put(pcdKey, al);\r |
117 | }\r |
118 | else{\r |
119 | dynPcdMap.get(pcdKey).add(ModuleInfo + " " + pcdData.getItemType().toString());\r |
120 | }\r |
121 | }\r |
122 | }\r |
123 | }\r |
124 | }\r |
125 | /**\r |
126 | Constructor to create a new spd file\r |
127 | **/\r |
128 | public FpdFileContents() {\r |
129 | \r |
130 | fpdd = PlatformSurfaceAreaDocument.Factory.newInstance();\r |
131 | fpdRoot = fpdd.addNewPlatformSurfaceArea();\r |
132 | \r |
133 | }\r |
134 | \r |
135 | /**\r |
136 | Constructor for existing document object\r |
137 | @param psa\r |
138 | **/\r |
139 | public FpdFileContents(PlatformSurfaceAreaDocument.PlatformSurfaceArea fpd) {\r |
140 | fpdRoot = fpd;\r |
141 | fpdHdr = fpdRoot.getPlatformHeader();\r |
142 | fpdPlatformDefs = fpdRoot.getPlatformDefinitions();\r |
143 | fpdBuildOpts = fpdRoot.getBuildOptions();\r |
144 | fpdFrameworkModules = fpdRoot.getFrameworkModules();\r |
145 | fpdDynPcdBuildDefs = fpdRoot.getDynamicPcdBuildDefinitions();\r |
146 | fpdFlash = fpdRoot.getFlash();\r |
147 | }\r |
148 | \r |
149 | /**\r |
150 | Constructor based on an existing spd file\r |
151 | \r |
152 | @param f Existing spd file\r |
153 | **/\r |
154 | public FpdFileContents(File f) {\r |
155 | try {\r |
156 | fpdd = PlatformSurfaceAreaDocument.Factory.parse(f);\r |
157 | fpdRoot = fpdd.getPlatformSurfaceArea();\r |
158 | } catch (Exception e) {\r |
159 | System.out.println(e.toString());\r |
160 | }\r |
161 | }\r |
162 | \r |
163 | public DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions getfpdDynPcdBuildDefs() {\r |
164 | if (fpdDynPcdBuildDefs == null){\r |
165 | fpdDynPcdBuildDefs = fpdRoot.addNewDynamicPcdBuildDefinitions();\r |
166 | }\r |
167 | return fpdDynPcdBuildDefs;\r |
168 | }\r |
169 | \r |
170 | public FrameworkModulesDocument.FrameworkModules getfpdFrameworkModules() {\r |
171 | if (fpdFrameworkModules == null){\r |
172 | fpdFrameworkModules = fpdRoot.addNewFrameworkModules();\r |
173 | }\r |
174 | return fpdFrameworkModules;\r |
175 | }\r |
176 | \r |
a13899c5 |
177 | public int getFrameworkModulesCount() {\r |
178 | if (getfpdFrameworkModules().getModuleSAList() == null){\r |
179 | return 0;\r |
180 | }\r |
181 | return getfpdFrameworkModules().getModuleSAList().size();\r |
182 | }\r |
183 | \r |
184 | public void getFrameworkModulesInfo(String[][] saa) {\r |
185 | if (getFrameworkModulesCount() == 0){\r |
186 | return;\r |
187 | }\r |
188 | \r |
189 | ListIterator li = getfpdFrameworkModules().getModuleSAList().listIterator();\r |
190 | int i = 0;\r |
191 | while(li.hasNext()) {\r |
192 | ModuleSADocument.ModuleSA msa = (ModuleSADocument.ModuleSA)li.next();\r |
193 | saa[i][1] = msa.getModuleGuid();\r |
194 | saa[i][2] = msa.getModuleVersion();\r |
195 | \r |
196 | saa[i][3] = msa.getPackageGuid();\r |
197 | saa[i][4] = msa.getPackageVersion();\r |
198 | // saa[i][4] = listToString(msa.getSupArchList());\r |
199 | ++i;\r |
200 | }\r |
201 | }\r |
202 | \r |
203 | public ModuleSADocument.ModuleSA getModuleSA(String key) {\r |
204 | String[] s = key.split(" ");\r |
205 | if (getfpdFrameworkModules().getModuleSAList() == null) {\r |
206 | return null;\r |
207 | }\r |
208 | ListIterator li = getfpdFrameworkModules().getModuleSAList().listIterator();\r |
209 | while(li.hasNext()) {\r |
210 | ModuleSADocument.ModuleSA msa = (ModuleSADocument.ModuleSA)li.next();\r |
211 | if (msa.getModuleGuid().equals(s[0]) && msa.getModuleVersion().equals(s[1])\r |
212 | && msa.getPackageGuid().equals(s[2]) && msa.getPackageVersion().equals(s[3])) {\r |
213 | \r |
214 | return msa;\r |
215 | }\r |
216 | }\r |
217 | return null;\r |
218 | }\r |
219 | public void removeModuleSA(int i) {\r |
220 | XmlObject o = getfpdFrameworkModules();\r |
221 | if (o == null) {\r |
222 | return;\r |
223 | }\r |
224 | \r |
225 | XmlCursor cursor = o.newCursor();\r |
226 | if (cursor.toFirstChild()) {\r |
227 | for (int j = 0; j < i; ++j) {\r |
228 | cursor.toNextSibling();\r |
229 | }\r |
230 | //\r |
231 | // remove pcd from dynPcdMap, if DynamicPcdBuildData exists, remove them too.\r |
232 | //\r |
233 | ModuleSADocument.ModuleSA moduleSa = (ModuleSADocument.ModuleSA)cursor.getObject();\r |
234 | String moduleInfo = moduleSa.getModuleGuid() + " " + moduleSa.getModuleVersion() + " " +\r |
235 | moduleSa.getPackageGuid()+ " " + moduleSa.getPackageVersion();\r |
236 | PcdBuildDefinitionDocument.PcdBuildDefinition pcdBuildDef = moduleSa.getPcdBuildDefinition();\r |
237 | if (pcdBuildDef != null) {\r |
238 | maintainDynPcdMap(pcdBuildDef, moduleInfo);\r |
239 | }\r |
240 | cursor.removeXml();\r |
241 | }\r |
242 | cursor.dispose();\r |
243 | }\r |
244 | \r |
245 | private void maintainDynPcdMap(PcdBuildDefinitionDocument.PcdBuildDefinition o, String moduleInfo) {\r |
246 | XmlCursor cursor = o.newCursor();\r |
247 | boolean fromLibInstance = false;\r |
248 | if (!cursor.toFirstChild()){\r |
249 | return;\r |
250 | }\r |
251 | //\r |
252 | // deal with first child, same process in the while loop below for siblings.\r |
253 | //\r |
254 | PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData pcdData = (PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData)cursor.getObject();\r |
255 | String pcdKey = pcdData.getCName() + " " + pcdData.getTokenSpaceGuidCName();\r |
256 | ArrayList<String> al = dynPcdMap.get(pcdKey);\r |
257 | for(int i = 0; i < al.size(); ++i){\r |
258 | if (al.get(i).startsWith(moduleInfo)){\r |
259 | fromLibInstance = true;\r |
260 | break;\r |
261 | }\r |
262 | }\r |
263 | al.remove(moduleInfo + " " + pcdData.getItemType().toString());\r |
264 | if (al.size() == 0) {\r |
265 | dynPcdMap.remove(pcdKey);\r |
266 | }\r |
267 | \r |
268 | if (pcdData.getItemType().toString().equals("DYNAMIC")) {\r |
269 | if (dynPcdMap.get(pcdKey) == null) {\r |
270 | removeDynamicPcdBuildData(pcdData.getCName(), pcdData.getTokenSpaceGuidCName());\r |
271 | }\r |
272 | }\r |
273 | if (fromLibInstance){\r |
274 | cursor.removeXml();\r |
275 | }\r |
276 | while(cursor.toNextSibling()) {\r |
277 | fromLibInstance = false;\r |
278 | pcdData = (PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData)cursor.getObject();\r |
279 | //\r |
280 | // remove each pcd record from dynPcdMap\r |
281 | //\r |
282 | pcdKey = pcdData.getCName() + " " + pcdData.getTokenSpaceGuidCName();\r |
283 | al = dynPcdMap.get(pcdKey);\r |
284 | for(int i = 0; i < al.size(); ++i){\r |
285 | if (al.get(i).startsWith(moduleInfo)){\r |
286 | fromLibInstance = true;\r |
287 | break;\r |
288 | }\r |
289 | }\r |
290 | al.remove(moduleInfo + " " + pcdData.getItemType().toString());\r |
291 | if (al.size() == 0) {\r |
292 | dynPcdMap.remove(pcdKey);\r |
293 | }\r |
294 | \r |
295 | if (pcdData.getItemType().toString().equals("DYNAMIC")) {\r |
296 | //\r |
297 | // First check whether this is the only consumer of this dyn pcd.\r |
298 | //\r |
299 | if (dynPcdMap.get(pcdKey) == null) {\r |
300 | //\r |
301 | // delete corresponding entry in DynamicPcdBuildData\r |
302 | //\r |
303 | removeDynamicPcdBuildData(pcdData.getCName(), pcdData.getTokenSpaceGuidCName());\r |
304 | }\r |
305 | }\r |
306 | if (fromLibInstance){\r |
307 | cursor.removeXml();\r |
308 | }\r |
309 | }\r |
310 | }\r |
311 | //\r |
312 | // key for ModuleSA : "ModuleGuid ModuleVer PackageGuid PackageVer"\r |
313 | //\r |
314 | public int getPcdDataCount(String key){\r |
315 | ModuleSADocument.ModuleSA msa = getModuleSA(key);\r |
316 | if (msa == null || msa.getPcdBuildDefinition() == null || msa.getPcdBuildDefinition().getPcdDataList() == null){\r |
317 | return 0;\r |
318 | }\r |
319 | return msa.getPcdBuildDefinition().getPcdDataList().size();\r |
320 | }\r |
321 | \r |
322 | public void getPcdData(String key, String[][] saa) {\r |
323 | ModuleSADocument.ModuleSA msa = getModuleSA(key);\r |
324 | if (msa == null || msa.getPcdBuildDefinition() == null || msa.getPcdBuildDefinition().getPcdDataList() == null){\r |
325 | return;\r |
326 | }\r |
327 | ListIterator<PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData>li = msa.getPcdBuildDefinition().getPcdDataList().listIterator();\r |
328 | for (int i = 0; i < saa.length; ++i) {\r |
329 | PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData pcdData = li.next();\r |
330 | saa[i][0] = pcdData.getCName();\r |
331 | saa[i][1] = pcdData.getTokenSpaceGuidCName();\r |
332 | saa[i][2] = pcdData.getItemType().toString();\r |
333 | saa[i][3] = pcdData.getToken().toString();\r |
334 | saa[i][4] = pcdData.getDatumType().toString();\r |
335 | saa[i][5] = pcdData.getValue();\r |
336 | \r |
337 | }\r |
338 | }\r |
339 | //\r |
340 | // key for ModuleSA : "ModuleGuid ModuleVer PackageGuid PackageVer"\r |
341 | //\r |
342 | public int getLibraryInstancesCount(String key) {\r |
343 | ModuleSADocument.ModuleSA msa = getModuleSA(key);\r |
344 | if (msa == null || msa.getLibraries() == null || msa.getLibraries().getInstanceList() == null){\r |
345 | return 0;\r |
346 | }\r |
347 | return msa.getLibraries().getInstanceList().size();\r |
348 | }\r |
349 | \r |
350 | public void getLibraryInstances(String key, String[][] saa){\r |
351 | ModuleSADocument.ModuleSA msa = getModuleSA(key);\r |
352 | if (msa == null || msa.getLibraries() == null || msa.getLibraries().getInstanceList() == null){\r |
353 | return ;\r |
354 | }\r |
355 | \r |
356 | ListIterator<LibrariesDocument.Libraries.Instance> li = msa.getLibraries().getInstanceList().listIterator();\r |
357 | for (int i = 0; i < saa.length; ++i) {\r |
358 | LibrariesDocument.Libraries.Instance instance = li.next();\r |
359 | saa[i][1] = instance.getModuleGuid();\r |
360 | saa[i][2] = instance.getModuleVersion();\r |
361 | saa[i][3] = instance.getPackageGuid();\r |
362 | saa[i][4] = instance.getPackageVersion();\r |
363 | }\r |
364 | }\r |
365 | \r |
366 | public void removeLibraryInstances(String key) {\r |
367 | ModuleSADocument.ModuleSA msa = getModuleSA(key);\r |
368 | if (msa == null || msa.getLibraries() == null){\r |
369 | return ;\r |
370 | }\r |
371 | \r |
372 | XmlCursor cursor = msa.getLibraries().newCursor();\r |
373 | cursor.removeXml();\r |
374 | cursor.dispose();\r |
375 | }\r |
376 | \r |
377 | public void genLibraryInstance(String mg, String mv, String pg, String pv, String key) {\r |
378 | ModuleSADocument.ModuleSA msa = getModuleSA(key);\r |
379 | if (msa == null){\r |
380 | msa = getfpdFrameworkModules().addNewModuleSA();\r |
381 | }\r |
382 | LibrariesDocument.Libraries libs = msa.getLibraries();\r |
383 | if(libs == null){\r |
384 | libs = msa.addNewLibraries();\r |
385 | }\r |
386 | \r |
387 | LibrariesDocument.Libraries.Instance instance = libs.addNewInstance();\r |
388 | instance.setModuleGuid(mg);\r |
389 | instance.setModuleVersion(mv);\r |
390 | instance.setPackageGuid(pg);\r |
391 | instance.setPackageVersion(pv);\r |
392 | \r |
393 | }\r |
394 | /**add pcd information of module mi to a ModuleSA. \r |
395 | * @param mi\r |
396 | * @param moduleSa if null, generate a new ModuleSA.\r |
397 | */\r |
398 | public void addFrameworkModulesPcdBuildDefs(ModuleIdentification mi, ModuleSADocument.ModuleSA moduleSa){\r |
399 | //ToDo add Arch filter\r |
400 | \r |
401 | try {\r |
402 | ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = (ModuleSurfaceAreaDocument.ModuleSurfaceArea)GlobalData.getModuleXmlObject(mi);\r |
403 | if (msa.getPcdCoded() == null) {\r |
404 | return;\r |
405 | }\r |
406 | if (moduleSa == null) {\r |
407 | moduleSa = genModuleSA(mi);\r |
408 | }\r |
409 | Map<String, XmlObject> m = new HashMap<String, XmlObject>();\r |
410 | m.put("ModuleSurfaceArea", msa);\r |
411 | SurfaceAreaQuery.setDoc(m);\r |
412 | PackageIdentification[] depPkgs = SurfaceAreaQuery.getDependencePkg(null);\r |
413 | //\r |
414 | // Implementing InitializePlatformPcdBuildDefinitions\r |
415 | //\r |
416 | List<PcdCodedDocument.PcdCoded.PcdEntry> l = msa.getPcdCoded().getPcdEntryList();\r |
417 | ListIterator li = l.listIterator();\r |
418 | while(li.hasNext()) {\r |
419 | PcdCodedDocument.PcdCoded.PcdEntry msaPcd = (PcdCodedDocument.PcdCoded.PcdEntry)li.next();\r |
420 | PcdDeclarationsDocument.PcdDeclarations.PcdEntry spdPcd = LookupPcdDeclaration(msaPcd, depPkgs);\r |
421 | if (spdPcd == null) {\r |
422 | //\r |
423 | // ToDo Error \r |
424 | //\r |
425 | break;\r |
426 | }\r |
427 | //\r |
428 | // AddItem to ModuleSA PcdBuildDefinitions\r |
429 | //\r |
430 | String defaultVal = msaPcd.getDefaultValue() == null ? spdPcd.getDefaultValue() : msaPcd.getDefaultValue();\r |
431 | genPcdData(msaPcd.getCName(), spdPcd.getToken(), msaPcd.getTokenSpaceGuidCName(), msaPcd.getPcdItemType().toString(), spdPcd.getDatumType()+"", defaultVal, moduleSa);\r |
432 | }\r |
433 | \r |
434 | }\r |
435 | catch (Exception e){\r |
436 | e.printStackTrace();\r |
437 | }\r |
438 | \r |
439 | }\r |
440 | \r |
441 | private PcdDeclarationsDocument.PcdDeclarations.PcdEntry LookupPcdDeclaration (PcdCodedDocument.PcdCoded.PcdEntry msaPcd, PackageIdentification[] depPkgs) {\r |
442 | \r |
443 | Map<String, XmlObject> m = new HashMap<String, XmlObject>();\r |
444 | PcdDeclarationsDocument.PcdDeclarations.PcdEntry spdPcd = null;\r |
445 | for (int i = 0; i < depPkgs.length; ++i) {\r |
446 | m.put("PackageSurfaceArea", GlobalData.getPackageXmlObject(depPkgs[i]));\r |
447 | SurfaceAreaQuery.setDoc(m);\r |
448 | XmlObject[] xo = SurfaceAreaQuery.getSpdPcdDeclarations();\r |
449 | if (xo == null) {\r |
450 | continue;\r |
451 | }\r |
452 | for (int j = 0; j < xo.length; ++j) {\r |
453 | spdPcd = (PcdDeclarationsDocument.PcdDeclarations.PcdEntry)xo[j];\r |
454 | if (msaPcd.getTokenSpaceGuidCName() == null) {\r |
455 | if (spdPcd.getCName().equals(msaPcd.getCName())) {\r |
456 | return spdPcd;\r |
457 | }\r |
458 | }\r |
459 | else{\r |
460 | if (spdPcd.getCName().equals(msaPcd.getCName()) && spdPcd.getTokenSpaceGuidCName().equals(msaPcd.getTokenSpaceGuidCName())) {\r |
461 | return spdPcd;\r |
462 | }\r |
463 | }\r |
464 | \r |
465 | }\r |
466 | \r |
467 | }\r |
468 | return null;\r |
469 | }\r |
470 | \r |
471 | private ModuleSADocument.ModuleSA genModuleSA (ModuleIdentification mi) {\r |
472 | PackageIdentification pi = GlobalData.getPackageForModule(mi);\r |
473 | ModuleSADocument.ModuleSA msa = getfpdFrameworkModules().addNewModuleSA();\r |
474 | msa.setModuleGuid(mi.getGuid());\r |
475 | msa.setModuleVersion(mi.getVersion());\r |
476 | msa.setPackageGuid(pi.getGuid());\r |
477 | msa.setPackageVersion(pi.getVersion());\r |
478 | \r |
479 | return msa;\r |
480 | }\r |
481 | \r |
482 | private void genPcdData (String cName, Object token, String tsGuid, String itemType, String dataType, String defaultVal, ModuleSADocument.ModuleSA moduleSa) {\r |
483 | if (moduleSa.getPcdBuildDefinition() == null){\r |
484 | moduleSa.addNewPcdBuildDefinition();\r |
485 | }\r |
486 | //\r |
487 | // constructe pcd to modulesa mapping first.\r |
488 | // Attention : for any error condition, remove from map this pcd.\r |
489 | //\r |
490 | ArrayList<String> pcdConsumer = LookupPlatformPcdData(cName + " " + tsGuid);\r |
491 | if (pcdConsumer == null) {\r |
492 | pcdConsumer = new ArrayList<String>();\r |
493 | }\r |
494 | String listValue = moduleSa.getModuleGuid() + " " + moduleSa.getModuleVersion() \r |
495 | + " " + moduleSa.getPackageGuid() + " " + moduleSa.getPackageVersion() \r |
496 | + " " + itemType;\r |
497 | pcdConsumer.add(listValue);\r |
498 | dynPcdMap.put(cName + " " + tsGuid, pcdConsumer);\r |
499 | //\r |
500 | // Special dynamic type, if this pcd already exists in other ModuleSA\r |
501 | //\r |
502 | if (itemType.equals("DYNAMIC")) {\r |
503 | \r |
504 | ListIterator li = pcdConsumer.listIterator();\r |
505 | while(li.hasNext()) {\r |
506 | String value = li.next().toString();\r |
507 | String[] valuePart= value.split(" ");\r |
508 | if (!valuePart[4].equals("DYNAMIC")) {\r |
509 | //ToDo error for same pcd, other type than dynamic\r |
510 | pcdConsumer.remove(listValue);\r |
511 | return;\r |
512 | }\r |
513 | }\r |
514 | }\r |
515 | else {\r |
516 | ListIterator li = pcdConsumer.listIterator();\r |
517 | while(li.hasNext()) {\r |
518 | String value = li.next().toString();\r |
519 | String[] valuePart= value.split(" ");\r |
520 | if (valuePart[4].equals("DYNAMIC")) {\r |
521 | //ToDo error for same pcd, other type than non-dynamic\r |
522 | pcdConsumer.remove(listValue);\r |
523 | return;\r |
524 | }\r |
525 | }\r |
526 | }\r |
527 | \r |
528 | PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData fpdPcd = moduleSa.getPcdBuildDefinition().addNewPcdData();\r |
529 | fpdPcd.setCName(cName);\r |
530 | fpdPcd.setToken(token);\r |
531 | fpdPcd.setTokenSpaceGuidCName(tsGuid);\r |
532 | fpdPcd.setDatumType(PcdDataTypes.Enum.forString(dataType));\r |
533 | fpdPcd.setItemType(PcdItemTypes.Enum.forString(itemType));\r |
534 | \r |
535 | if (itemType.equals("DYNAMIC") || itemType.equals("DYNAMIC_EX")) {\r |
536 | ArrayList<String> al = LookupDynamicPcdBuildDefinition(cName + " " + tsGuid);\r |
537 | //\r |
538 | // if only one module mapped to this pcd, then the one is myself. so no other module mapped.\r |
539 | // so need to add one dyn pcd.\r |
540 | //\r |
541 | if (al.size() == 1) {\r |
542 | addDynamicPcdBuildData(cName, token, tsGuid, itemType, dataType, defaultVal);\r |
543 | }\r |
544 | }\r |
545 | else {\r |
546 | if (defaultVal != null){\r |
547 | fpdPcd.setValue(defaultVal);\r |
548 | }\r |
549 | else {\r |
550 | if (dataType.equals("UINT8") || dataType.equals("UINT16") || dataType.equals("UINT32") || dataType.equals("UINT64")) {\r |
551 | fpdPcd.setValue("0");\r |
552 | }\r |
553 | if (dataType.equals("BOOLEAN")){\r |
554 | fpdPcd.setValue("false");\r |
555 | }\r |
556 | if (dataType.equals("VOID*")) {\r |
557 | fpdPcd.setValue("");\r |
558 | }\r |
559 | }\r |
560 | if (dataType.equals("UINT8")){\r |
561 | fpdPcd.setMaxDatumSize(1);\r |
562 | }\r |
563 | if (dataType.equals("UINT16")) {\r |
564 | fpdPcd.setMaxDatumSize(2);\r |
565 | }\r |
566 | if (dataType.equals("UINT32")) {\r |
567 | fpdPcd.setMaxDatumSize(4);\r |
568 | }\r |
569 | if (dataType.equals("UINT64")){\r |
570 | fpdPcd.setMaxDatumSize(8);\r |
571 | }\r |
572 | if (dataType.equals("BOOLEAN")){\r |
573 | fpdPcd.setMaxDatumSize(1);\r |
574 | }\r |
575 | if (dataType.equals("VOID*")) {\r |
576 | int maxSize = setMaxSizeForPointer(fpdPcd.getValue());\r |
577 | fpdPcd.setMaxDatumSize(maxSize);\r |
578 | }\r |
579 | }\r |
580 | }\r |
581 | \r |
582 | private int setMaxSizeForPointer(String datum) {\r |
583 | if (datum == null) {\r |
584 | return 0;\r |
585 | }\r |
586 | char ch = datum.charAt(0);\r |
587 | int start, end;\r |
588 | String strValue;\r |
589 | //\r |
590 | // For void* type PCD, only three datum is support:\r |
591 | // 1) Unicode: string with start char is "L"\r |
592 | // 2) Ansci: String is ""\r |
593 | // 3) byte array: String start char "{"\r |
594 | // \r |
595 | if (ch == 'L') {\r |
596 | start = datum.indexOf('\"');\r |
597 | end = datum.lastIndexOf('\"');\r |
598 | if ((start > end) || \r |
599 | (end > datum.length())||\r |
600 | ((start == end) && (datum.length() > 0))) {\r |
601 | //ToDo Error handling here\r |
602 | }\r |
603 | \r |
604 | strValue = datum.substring(start + 1, end);\r |
605 | return strValue.length() * 2;\r |
606 | } else if (ch == '\"'){\r |
607 | start = datum.indexOf('\"');\r |
608 | end = datum.lastIndexOf('\"');\r |
609 | if ((start > end) || \r |
610 | (end > datum.length())||\r |
611 | ((start == end) && (datum.length() > 0))) {\r |
612 | \r |
613 | }\r |
614 | strValue = datum.substring(start + 1, end);\r |
615 | return strValue.length();\r |
616 | } else if (ch =='{') {\r |
617 | String[] strValueArray;\r |
618 | \r |
619 | start = datum.indexOf('{');\r |
620 | end = datum.lastIndexOf('}');\r |
621 | strValue = datum.substring(start + 1, end);\r |
622 | strValue = strValue.trim();\r |
623 | if (strValue.length() == 0) {\r |
624 | return 0;\r |
625 | }\r |
626 | strValueArray = strValue.split(",");\r |
627 | for (int index = 0; index < strValueArray.length; index ++) {\r |
628 | Integer value = Integer.decode(strValueArray[index].trim());\r |
629 | \r |
630 | if (value > 0xFF) {\r |
631 | // "[FPD file error] The datum type of PCD %s in %s is VOID*, "+\r |
632 | // "it is byte array in fact. But the element of %s exceed the byte range",\r |
633 | \r |
634 | }\r |
635 | }\r |
636 | return strValueArray.length;\r |
637 | \r |
638 | \r |
639 | } else {\r |
640 | // "[FPD file error] The datum type of PCD %s in %s is VOID*. For VOID* type, you have three format choise:\n "+\r |
641 | // "1) UNICODE string: like L\"xxxx\";\r\n"+\r |
642 | // "2) ANSIC string: like \"xxx\";\r\n"+\r |
643 | // "3) Byte array: like {0x2, 0x45, 0x23}\r\n"+\r |
644 | // "but the datum in seems does not following above format!",\r |
645 | return -1; \r |
646 | \r |
647 | }\r |
648 | }\r |
649 | \r |
650 | private ArrayList<String> LookupDynamicPcdBuildDefinition(String dynPcdKey) {\r |
651 | ArrayList<String> al = dynPcdMap.get(dynPcdKey);\r |
652 | \r |
653 | return al;\r |
654 | }\r |
655 | \r |
656 | private ArrayList<String> LookupPlatformPcdData(String pcdKey) {\r |
657 | \r |
658 | return dynPcdMap.get("pcdKey");\r |
659 | }\r |
660 | \r |
661 | public int getDynamicPcdBuildDataCount() {\r |
662 | if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null) {\r |
663 | return 0;\r |
664 | }\r |
665 | return getfpdDynPcdBuildDefs().getPcdBuildDataList().size();\r |
666 | }\r |
667 | \r |
668 | public void getDynamicPcdBuildData(String[][] saa) {\r |
669 | if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null) {\r |
670 | return ;\r |
671 | }\r |
672 | List<DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData> l = getfpdDynPcdBuildDefs().getPcdBuildDataList();\r |
673 | ListIterator<DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData> li = l.listIterator();\r |
674 | int i = 0;\r |
675 | while(li.hasNext()) {\r |
676 | DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData dynPcd = li.next();\r |
677 | saa[i][0] = dynPcd.getCName();\r |
678 | saa[i][1] = dynPcd.getToken().toString();\r |
679 | saa[i][2] = dynPcd.getTokenSpaceGuidCName();\r |
680 | saa[i][3] = dynPcd.getMaxDatumSize()+"";\r |
681 | saa[i][4] = dynPcd.getDatumType().toString();\r |
682 | \r |
683 | ++i;\r |
684 | }\r |
685 | }\r |
686 | \r |
687 | private void addDynamicPcdBuildData(String cName, Object token, String tsGuid, String itemType, String dataType, String defaultVal) {\r |
688 | DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData dynPcdData = getfpdDynPcdBuildDefs().addNewPcdBuildData();\r |
689 | dynPcdData.setItemType(PcdItemTypes.Enum.forString(itemType));\r |
690 | dynPcdData.setCName(cName);\r |
691 | dynPcdData.setToken(token);\r |
692 | dynPcdData.setTokenSpaceGuidCName(tsGuid);\r |
693 | dynPcdData.setDatumType(PcdDataTypes.Enum.forString(dataType));\r |
694 | \r |
695 | BigInteger bigInt = new BigInteger("0");\r |
696 | DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData.SkuInfo skuInfo = dynPcdData.addNewSkuInfo();\r |
697 | skuInfo.setSkuId(bigInt);\r |
698 | if (defaultVal != null){\r |
699 | skuInfo.setValue(defaultVal);\r |
700 | }\r |
701 | else {\r |
702 | if (dataType.equals("UINT8")){\r |
703 | skuInfo.setValue("0");\r |
704 | }\r |
705 | if (dataType.equals("UINT16")) {\r |
706 | skuInfo.setValue("0");\r |
707 | }\r |
708 | if (dataType.equals("UINT32")) {\r |
709 | skuInfo.setValue("0");\r |
710 | }\r |
711 | if (dataType.equals("UINT64")){\r |
712 | skuInfo.setValue("0");\r |
713 | }\r |
714 | if (dataType.equals("BOOLEAN")){\r |
715 | skuInfo.setValue("false");\r |
716 | }\r |
717 | if (dataType.equals("VOID*")) {\r |
718 | skuInfo.setValue("");\r |
719 | }\r |
720 | }\r |
721 | if (dataType.equals("UINT8")){\r |
722 | dynPcdData.setMaxDatumSize(1);\r |
723 | }\r |
724 | if (dataType.equals("UINT16")) {\r |
725 | dynPcdData.setMaxDatumSize(2);\r |
726 | }\r |
727 | if (dataType.equals("UINT32")) {\r |
728 | dynPcdData.setMaxDatumSize(4);\r |
729 | }\r |
730 | if (dataType.equals("UINT64")){\r |
731 | dynPcdData.setMaxDatumSize(8);\r |
732 | }\r |
733 | if (dataType.equals("BOOLEAN")){\r |
734 | dynPcdData.setMaxDatumSize(1);\r |
735 | }\r |
736 | if (dataType.equals("VOID*")) {\r |
737 | int maxSize = setMaxSizeForPointer(defaultVal);\r |
738 | dynPcdData.setMaxDatumSize(maxSize);\r |
739 | }\r |
740 | }\r |
741 | \r |
742 | private void removeDynamicPcdBuildData(String cName, String tsGuid) {\r |
743 | XmlObject o = getfpdDynPcdBuildDefs();\r |
744 | \r |
745 | XmlCursor cursor = o.newCursor();\r |
746 | if (cursor.toFirstChild()) {\r |
747 | DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData pcdBuildData = \r |
748 | (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject();\r |
749 | while (!(pcdBuildData.getCName().equals(cName) && pcdBuildData.getTokenSpaceGuidCName().equals(tsGuid))) {\r |
750 | cursor.toNextSibling();\r |
751 | pcdBuildData = (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject();\r |
752 | }\r |
753 | \r |
754 | cursor.removeXml();\r |
755 | }\r |
756 | cursor.dispose();\r |
757 | }\r |
758 | //\r |
759 | // Get the Sku Info count of ith dyn pcd element.\r |
760 | //\r |
761 | public int getDynamicPcdSkuInfoCount(int i){\r |
762 | if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {\r |
763 | return 0;\r |
764 | }\r |
765 | \r |
766 | int skuInfoCount = 0;\r |
767 | XmlCursor cursor = getfpdDynPcdBuildDefs().newCursor();\r |
768 | if (cursor.toFirstChild()) {\r |
769 | for (int j = 0; j < i; ++j) {\r |
770 | cursor.toNextSibling();\r |
771 | }\r |
772 | DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData pcdData = (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject();\r |
773 | if (pcdData.getSkuInfoList() == null) {\r |
774 | skuInfoCount = 0;\r |
775 | }\r |
776 | else {\r |
777 | skuInfoCount = pcdData.getSkuInfoList().size();\r |
778 | }\r |
779 | }\r |
780 | cursor.dispose();\r |
781 | return skuInfoCount;\r |
782 | }\r |
783 | \r |
784 | public void getDynamicPcdSkuInfos(int i, String[][] saa){\r |
785 | if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {\r |
786 | return;\r |
787 | }\r |
788 | \r |
789 | XmlCursor cursor = getfpdDynPcdBuildDefs().newCursor();\r |
790 | if (cursor.toFirstChild()) {\r |
791 | for (int j = 0; j < i; ++j) {\r |
792 | cursor.toNextSibling();\r |
793 | }\r |
794 | DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData pcdData = (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject();\r |
795 | if (pcdData.getSkuInfoList() == null) {\r |
796 | cursor.dispose();\r |
797 | return;\r |
798 | }\r |
799 | else {\r |
800 | ListIterator<DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData.SkuInfo> li = pcdData.getSkuInfoList().listIterator();\r |
801 | int k = 0;\r |
802 | while (li.hasNext()) {\r |
803 | DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData.SkuInfo skuInfo = li.next();\r |
804 | saa[k][0] = skuInfo.getSkuId()+"";\r |
805 | saa[k][1] = skuInfo.getVariableName();\r |
806 | saa[k][2] = skuInfo.getVariableGuid();\r |
807 | saa[k][3] = skuInfo.getVariableOffset();\r |
808 | saa[k][4] = skuInfo.getHiiDefaultValue();\r |
809 | saa[k][5] = skuInfo.getVpdOffset();\r |
810 | saa[k][6] = skuInfo.getValue();\r |
811 | ++k;\r |
812 | }\r |
813 | \r |
814 | }\r |
815 | }\r |
816 | cursor.dispose();\r |
817 | \r |
818 | }\r |
819 | \r |
820 | public String getDynamicPcdBuildDataValue(int i){\r |
821 | String value = null;\r |
822 | if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {\r |
823 | return value;\r |
824 | }\r |
825 | \r |
826 | XmlCursor cursor = getfpdDynPcdBuildDefs().newCursor();\r |
827 | if (cursor.toFirstChild()) {\r |
828 | for (int j = 0; j < i; ++j) {\r |
829 | cursor.toNextSibling();\r |
830 | }\r |
831 | DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData pcdData = (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject();\r |
832 | if (pcdData.getSkuInfoList() == null) {\r |
833 | value = null;\r |
834 | }\r |
835 | else {\r |
836 | value = pcdData.getSkuInfoArray(0).getValue();\r |
837 | }\r |
838 | }\r |
839 | cursor.dispose();\r |
840 | return value;\r |
841 | }\r |
842 | \r |
843 | public String getDynamicPcdBuildDataVpdOffset(int i){\r |
844 | String vpdOffset = null;\r |
845 | if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {\r |
846 | return vpdOffset;\r |
847 | }\r |
848 | \r |
849 | XmlCursor cursor = getfpdDynPcdBuildDefs().newCursor();\r |
850 | if (cursor.toFirstChild()) {\r |
851 | for (int j = 0; j < i; ++j) {\r |
852 | cursor.toNextSibling();\r |
853 | }\r |
854 | DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData pcdData = (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject();\r |
855 | if (pcdData.getSkuInfoList() == null) {\r |
856 | vpdOffset = null;\r |
857 | }\r |
858 | else {\r |
859 | vpdOffset = pcdData.getSkuInfoArray(0).getVpdOffset();\r |
860 | }\r |
861 | }\r |
862 | cursor.dispose();\r |
863 | return vpdOffset;\r |
864 | }\r |
865 | \r |
866 | public void removeDynamicPcdBuildDataSkuInfo(int i) {\r |
867 | if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {\r |
868 | return;\r |
869 | }\r |
870 | \r |
871 | XmlCursor cursor = getfpdDynPcdBuildDefs().newCursor();\r |
872 | if (cursor.toFirstChild()) {\r |
873 | for (int j = 0; j < i; ++j) {\r |
874 | cursor.toNextSibling();\r |
875 | }\r |
876 | DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData pcdData = (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject();\r |
877 | if (pcdData.getSkuInfoList() == null) {\r |
878 | cursor.dispose();\r |
879 | return;\r |
880 | }\r |
881 | else {\r |
882 | QName qSkuInfo = new QName(xmlNs, "SkuInfo");\r |
883 | cursor.toChild(qSkuInfo);\r |
884 | cursor.removeXml();\r |
885 | }\r |
886 | }\r |
887 | cursor.dispose();\r |
888 | }\r |
889 | //\r |
890 | // generate sku info for ith dyn pcd build data.\r |
891 | //\r |
892 | public void genDynamicPcdBuildDataSkuInfo(String id, String varName, String varGuid, String varOffset, \r |
893 | String hiiDefault, String vpdOffset, String value, int i) {\r |
894 | if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {\r |
895 | return;\r |
896 | }\r |
897 | \r |
898 | XmlCursor cursor = getfpdDynPcdBuildDefs().newCursor();\r |
899 | if (cursor.toFirstChild()) {\r |
900 | for (int j = 0; j < i; ++j) {\r |
901 | cursor.toNextSibling();\r |
902 | }\r |
903 | DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData pcdData = (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject();\r |
904 | DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData.SkuInfo skuInfo = pcdData.addNewSkuInfo();\r |
905 | skuInfo.setSkuId(new BigInteger(id));\r |
906 | if (varName != null){\r |
907 | skuInfo.setVariableName(varName);\r |
908 | skuInfo.setVariableGuid(varGuid);\r |
909 | skuInfo.setVariableOffset(varOffset);\r |
910 | skuInfo.setHiiDefaultValue(hiiDefault);\r |
911 | }\r |
912 | else if (vpdOffset != null){\r |
913 | skuInfo.setVpdOffset(vpdOffset);\r |
914 | }\r |
915 | else{\r |
916 | skuInfo.setValue(value);\r |
917 | }\r |
918 | }\r |
919 | }\r |
920 | \r |
921 | public void updateDynamicPcdBuildDataSkuInfo(String id, String varName, String varGuid, String varOffset, \r |
922 | String hiiDefault, String vpdOffset, String value, int i){\r |
923 | if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {\r |
924 | return;\r |
925 | }\r |
926 | \r |
927 | XmlCursor cursor = getfpdDynPcdBuildDefs().newCursor();\r |
928 | if (cursor.toFirstChild()) {\r |
929 | for (int j = 0; j < i; ++j) {\r |
930 | cursor.toNextSibling();\r |
931 | }\r |
932 | DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData pcdData = (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject();\r |
933 | ListIterator<DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData.SkuInfo> li = pcdData.getSkuInfoList().listIterator();\r |
934 | while (li.hasNext()) {\r |
935 | DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData.SkuInfo skuInfo = li.next();\r |
936 | if (skuInfo.getSkuId().toString().equals(id)){\r |
937 | if (varName != null){\r |
938 | skuInfo.setVariableName(varName);\r |
939 | skuInfo.setVariableGuid(varGuid);\r |
940 | skuInfo.setVariableOffset(varOffset);\r |
941 | skuInfo.setHiiDefaultValue(hiiDefault);\r |
942 | }\r |
943 | else if (vpdOffset != null){\r |
944 | skuInfo.setVpdOffset(vpdOffset);\r |
945 | }\r |
946 | else{\r |
947 | skuInfo.setValue(value);\r |
948 | }\r |
949 | break;\r |
950 | }\r |
951 | }\r |
952 | }\r |
953 | }\r |
954 | \r |
955 | public void removePcdDataFromLibraryInstance(String moduleKey, String libInstanceKey){\r |
956 | ModuleSADocument.ModuleSA moduleSa = getModuleSA(moduleKey);\r |
957 | //\r |
958 | // should better maintain pcd from lib instance only, but maintain all is acceptable now. \r |
959 | //\r |
960 | maintainDynPcdMap(moduleSa.getPcdBuildDefinition(), libInstanceKey);\r |
961 | \r |
962 | }\r |
963 | \r |
964 | public BuildOptionsDocument.BuildOptions getfpdBuildOpts() {\r |
965 | if (fpdBuildOpts == null) {\r |
966 | fpdBuildOpts = fpdRoot.addNewBuildOptions();\r |
967 | }\r |
968 | return fpdBuildOpts;\r |
969 | }\r |
970 | \r |
971 | public void genBuildOptionsUserDefAntTask (String id, String fileName, String execOrder) {\r |
972 | UserDefinedAntTasksDocument.UserDefinedAntTasks udats = getfpdBuildOpts().getUserDefinedAntTasks();\r |
973 | if (udats == null) {\r |
974 | udats = getfpdBuildOpts().addNewUserDefinedAntTasks();\r |
975 | }\r |
976 | \r |
977 | AntTaskDocument.AntTask at = udats.addNewAntTask();\r |
978 | setBuildOptionsUserDefAntTask(id, fileName, execOrder, at);\r |
979 | }\r |
980 | \r |
981 | private void setBuildOptionsUserDefAntTask(String id, String fileName, String execOrder, AntTaskDocument.AntTask at) {\r |
982 | at.setId(new Integer(id));\r |
983 | if (fileName != null){\r |
984 | at.setFilename(fileName);\r |
985 | }\r |
202c4f38 |
986 | if (execOrder != null) {\r |
a13899c5 |
987 | at.setAntCmdOptions(execOrder);\r |
988 | }\r |
989 | }\r |
990 | \r |
991 | public void removeBuildOptionsUserDefAntTask(int i) {\r |
992 | XmlObject o = getfpdBuildOpts().getUserDefinedAntTasks();\r |
993 | if (o == null) {\r |
994 | return;\r |
995 | }\r |
996 | XmlCursor cursor = o.newCursor();\r |
997 | if (cursor.toFirstChild()) {\r |
998 | for (int j = 0; j < i; ++j) {\r |
999 | cursor.toNextSibling();\r |
1000 | }\r |
1001 | cursor.removeXml();\r |
1002 | }\r |
1003 | cursor.dispose();\r |
1004 | }\r |
1005 | \r |
1006 | public void updateBuildOptionsUserDefAntTask(int i, String id, String fileName, String execOrder){\r |
1007 | XmlObject o = getfpdBuildOpts().getUserDefinedAntTasks();\r |
1008 | if (o == null) {\r |
1009 | return;\r |
1010 | }\r |
1011 | XmlCursor cursor = o.newCursor();\r |
1012 | if (cursor.toFirstChild()) {\r |
1013 | for (int j = 0; j < i; ++j) {\r |
1014 | cursor.toNextSibling();\r |
1015 | }\r |
1016 | AntTaskDocument.AntTask at = (AntTaskDocument.AntTask)cursor.getObject();\r |
1017 | setBuildOptionsUserDefAntTask(id, fileName, execOrder, at);\r |
1018 | }\r |
1019 | cursor.dispose();\r |
1020 | }\r |
1021 | \r |
1022 | public int getBuildOptionsUserDefAntTaskCount() {\r |
1023 | UserDefinedAntTasksDocument.UserDefinedAntTasks udats = getfpdBuildOpts().getUserDefinedAntTasks();\r |
1024 | if (udats == null || udats.getAntTaskList() == null) {\r |
1025 | return 0;\r |
1026 | }\r |
1027 | \r |
1028 | return udats.getAntTaskList().size();\r |
1029 | }\r |
1030 | \r |
1031 | public void getBuildOptionsUserDefAntTasks(String[][] saa) {\r |
1032 | UserDefinedAntTasksDocument.UserDefinedAntTasks udats = getfpdBuildOpts().getUserDefinedAntTasks();\r |
1033 | if (udats == null || udats.getAntTaskList() == null) {\r |
1034 | return ;\r |
1035 | }\r |
1036 | \r |
1037 | List<AntTaskDocument.AntTask> l = udats.getAntTaskList();\r |
1038 | ListIterator li = l.listIterator();\r |
1039 | int i = 0;\r |
1040 | while (li.hasNext()) {\r |
1041 | AntTaskDocument.AntTask at = (AntTaskDocument.AntTask)li.next();\r |
1042 | saa[i][0] = at.getId() + "";\r |
1043 | saa[i][1] = saa[i][2] = "";\r |
1044 | if (at.getFilename() != null){\r |
1045 | saa[i][1] = at.getFilename();\r |
1046 | }\r |
1047 | if (at.getAntCmdOptions() != null) {\r |
1048 | saa[i][2] = at.getAntCmdOptions();\r |
1049 | }\r |
1050 | ++i;\r |
1051 | }\r |
1052 | }\r |
1053 | public void genBuildOptionsOpt(String buildTargets, String toolChain, String tagName, String toolCmd, String archList, String contents) {\r |
1054 | OptionsDocument.Options opts = getfpdBuildOpts().getOptions();\r |
1055 | if (opts == null) {\r |
1056 | opts = getfpdBuildOpts().addNewOptions();\r |
1057 | }\r |
1058 | OptionDocument.Option opt = opts.addNewOption();\r |
1059 | setBuildOptionsOpt(buildTargets, toolChain, tagName, toolCmd, archList, contents, opt);\r |
1060 | }\r |
1061 | \r |
1062 | private void setBuildOptionsOpt(String buildTargets, String toolChain, String tagName, String toolCmd, String archList, String contents, OptionDocument.Option opt){\r |
1063 | opt.setStringValue(contents);\r |
1064 | // opt.setBuildTargets(buildTargets);\r |
1065 | opt.setToolChainFamily(toolChain);\r |
1066 | opt.setTagName(tagName);\r |
1067 | opt.setToolCode(toolCmd);\r |
1068 | String[] s = archList.split(" ");\r |
1069 | ArrayList<String> al = new ArrayList<String>();\r |
1070 | for (int i = 0; i < s.length; ++i) {\r |
1071 | al.add(s[i]);\r |
1072 | }\r |
1073 | opt.setSupArchList(al);\r |
1074 | }\r |
1075 | \r |
1076 | public void removeBuildOptionsOpt(int i){\r |
1077 | \r |
1078 | XmlObject o = getfpdBuildOpts().getOptions();\r |
1079 | if (o == null) {\r |
1080 | return;\r |
1081 | }\r |
1082 | \r |
1083 | XmlCursor cursor = o.newCursor();\r |
1084 | if (cursor.toFirstChild()) {\r |
1085 | for (int j = 0; j < i; ++j) {\r |
1086 | cursor.toNextSibling();\r |
1087 | }\r |
1088 | cursor.removeXml();\r |
1089 | }\r |
1090 | cursor.dispose();\r |
1091 | }\r |
1092 | \r |
1093 | public void updateBuildOptionsOpt(int i, String buildTargets, String toolChain, String tagName, String toolCmd, String archList, String contents) {\r |
1094 | XmlObject o = getfpdBuildOpts().getOptions();\r |
1095 | if (o == null) {\r |
1096 | return;\r |
1097 | }\r |
1098 | \r |
1099 | XmlCursor cursor = o.newCursor();\r |
1100 | if (cursor.toFirstChild()) {\r |
1101 | for (int j = 0; j < i; ++j) {\r |
1102 | cursor.toNextSibling();\r |
1103 | }\r |
1104 | OptionDocument.Option opt = (OptionDocument.Option)cursor.getObject();\r |
1105 | setBuildOptionsOpt(buildTargets, toolChain, tagName, toolCmd, archList, contents, opt);\r |
1106 | }\r |
1107 | cursor.dispose();\r |
1108 | }\r |
1109 | \r |
1110 | public int getBuildOptionsOptCount(){\r |
1111 | if (getfpdBuildOpts().getOptions() == null || getfpdBuildOpts().getOptions().getOptionList() == null) {\r |
1112 | return 0;\r |
1113 | }\r |
1114 | return getfpdBuildOpts().getOptions().getOptionList().size();\r |
1115 | }\r |
1116 | \r |
1117 | public void getBuildOptionsOpts(String[][] saa) {\r |
1118 | if (getfpdBuildOpts().getOptions() == null || getfpdBuildOpts().getOptions().getOptionList() == null) {\r |
1119 | return ;\r |
1120 | }\r |
1121 | \r |
1122 | List<OptionDocument.Option> lOpt = getfpdBuildOpts().getOptions().getOptionList();\r |
1123 | ListIterator li = lOpt.listIterator();\r |
1124 | int i = 0;\r |
1125 | while(li.hasNext()) {\r |
1126 | OptionDocument.Option opt = (OptionDocument.Option)li.next();\r |
6cba26e8 |
1127 | if (opt.getBuildTargets() != null) {\r |
1128 | saa[i][0] = listToString(opt.getBuildTargets());\r |
1129 | }\r |
a13899c5 |
1130 | saa[i][1] = opt.getToolChainFamily();\r |
1131 | if (opt.getSupArchList() != null){\r |
6cba26e8 |
1132 | saa[i][2] = listToString(opt.getSupArchList());\r |
1133 | \r |
a13899c5 |
1134 | }\r |
1135 | saa[i][3] = opt.getToolCode();\r |
1136 | saa[i][4] = opt.getTagName();\r |
1137 | saa[i][5] = opt.getStringValue();\r |
1138 | \r |
1139 | ++i;\r |
1140 | }\r |
1141 | }\r |
1142 | \r |
6cba26e8 |
1143 | public void genBuildOptionsFfs(String ffsKey, String type) {\r |
1144 | BuildOptionsDocument.BuildOptions.Ffs ffs = getfpdBuildOpts().addNewFfs();\r |
1145 | ffs.setFfsKey(ffsKey);\r |
1146 | if (type != null) {\r |
1147 | ffs.addNewSections().setEncapsulationType(type);\r |
1148 | }\r |
1149 | }\r |
1150 | \r |
3b405e9b |
1151 | public void updateBuildOptionsFfsSectionsType(int i, String type) {\r |
1152 | BuildOptionsDocument.BuildOptions.Ffs ffs = getfpdBuildOpts().addNewFfs();\r |
1153 | if (type != null) {\r |
1154 | ffs.addNewSections().setEncapsulationType(type);\r |
1155 | }\r |
1156 | }\r |
1157 | \r |
6cba26e8 |
1158 | public void genBuildOptionsFfsAttribute(int i, String name, String value) {\r |
1159 | BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r |
1160 | BuildOptionsDocument.BuildOptions.Ffs.Attribute attrib = ffs.addNewAttribute();\r |
1161 | attrib.setName(name);\r |
1162 | attrib.setValue(value);\r |
1163 | }\r |
1164 | \r |
1165 | /**update jth attribute of ith ffs.\r |
1166 | * @param i\r |
1167 | * @param j\r |
1168 | */\r |
1169 | public void updateBuildOptionsFfsAttribute(int i, int j, String name, String value){\r |
1170 | BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r |
1171 | XmlCursor cursor = ffs.newCursor();\r |
1172 | QName qAttrib = new QName(xmlNs, "Attribute");\r |
1173 | if (cursor.toChild(qAttrib)) {\r |
1174 | for (int k = 0; k < j; ++k) {\r |
1175 | cursor.toNextSibling(qAttrib);\r |
1176 | }\r |
1177 | BuildOptionsDocument.BuildOptions.Ffs.Attribute attrib = (BuildOptionsDocument.BuildOptions.Ffs.Attribute)cursor.getObject();\r |
1178 | attrib.setName(name);\r |
1179 | attrib.setValue(value);\r |
1180 | }\r |
1181 | cursor.dispose();\r |
1182 | }\r |
1183 | \r |
1184 | public void removeBuildOptionsFfsAttribute(int i, int j){\r |
1185 | BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r |
1186 | XmlCursor cursor = ffs.newCursor();\r |
1187 | QName qAttrib = new QName(xmlNs, "Attribute");\r |
1188 | if (cursor.toChild(qAttrib)) {\r |
1189 | for (int k = 0; k < j; ++k) {\r |
1190 | cursor.toNextSibling(qAttrib);\r |
1191 | }\r |
1192 | cursor.removeXml();\r |
1193 | }\r |
1194 | cursor.dispose();\r |
1195 | }\r |
1196 | \r |
1197 | public void genBuildOptionsFfsSectionsSection(int i, String sectionType) {\r |
1198 | BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r |
1199 | if (ffs == null) {\r |
1200 | return;\r |
1201 | }\r |
1202 | BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections();\r |
1203 | \r |
1204 | if (sections == null){\r |
1205 | sections = ffs.addNewSections();\r |
1206 | }\r |
1207 | sections.addNewSection().setSectionType(EfiSectionType.Enum.forString(sectionType));\r |
1208 | }\r |
1209 | \r |
3b405e9b |
1210 | public void removeBuildOptionsFfsSectionsSection(int i, int j) {\r |
1211 | BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r |
1212 | BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections();\r |
1213 | if (sections == null) {\r |
1214 | return;\r |
1215 | }\r |
1216 | XmlCursor cursor = sections.newCursor();\r |
1217 | QName qSection = new QName(xmlNs, "Section");\r |
1218 | if (cursor.toChild(qSection)) {\r |
1219 | for (int k = 0; k < j; ++k) {\r |
1220 | cursor.toNextSibling(qSection);\r |
1221 | }\r |
1222 | cursor.removeXml();\r |
1223 | }\r |
1224 | cursor.dispose();\r |
1225 | }\r |
1226 | \r |
1227 | public void updateBuildOptionsFfsSectionsSection(int i, int j, String type){\r |
1228 | BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r |
1229 | BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections();\r |
1230 | if (sections == null) {\r |
1231 | return;\r |
1232 | }\r |
1233 | XmlCursor cursor = sections.newCursor();\r |
1234 | QName qSection = new QName(xmlNs, "Section");\r |
1235 | if (cursor.toChild(qSection)) {\r |
1236 | for (int k = 0; k < j; ++k) {\r |
1237 | cursor.toNextSibling(qSection);\r |
1238 | }\r |
1239 | BuildOptionsDocument.BuildOptions.Ffs.Sections.Section section = (BuildOptionsDocument.BuildOptions.Ffs.Sections.Section)cursor.getObject();\r |
1240 | section.setSectionType(EfiSectionType.Enum.forString(type));\r |
1241 | }\r |
1242 | cursor.dispose();\r |
1243 | } \r |
1244 | \r |
6cba26e8 |
1245 | public void genBuildOptionsFfsSectionsSections(int i, String encapType) {\r |
1246 | BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r |
1247 | if (ffs == null) {\r |
1248 | return;\r |
1249 | }\r |
1250 | BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections();\r |
1251 | \r |
1252 | if (sections == null){\r |
1253 | sections = ffs.addNewSections();\r |
1254 | }\r |
1255 | sections.addNewSections().setEncapsulationType(encapType);\r |
1256 | }\r |
1257 | \r |
3b405e9b |
1258 | public void removeBuildOptionsFfsSectionsSections(int i, int j) {\r |
1259 | BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r |
1260 | BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections();\r |
1261 | if (sections == null) {\r |
1262 | return;\r |
1263 | }\r |
1264 | XmlCursor cursor = sections.newCursor();\r |
1265 | QName qSections = new QName(xmlNs, "Sections");\r |
1266 | if (cursor.toChild(qSections)) {\r |
1267 | for (int k = 0; k < j; ++k) {\r |
1268 | cursor.toNextSibling(qSections);\r |
1269 | }\r |
1270 | cursor.removeXml();\r |
1271 | }\r |
1272 | cursor.dispose();\r |
1273 | }\r |
1274 | \r |
1275 | public void updateBuildOptionsFfsSectionsSections(int i, int j, String type) {\r |
1276 | BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r |
1277 | BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections();\r |
1278 | if (sections == null) {\r |
1279 | return;\r |
1280 | }\r |
1281 | XmlCursor cursor = sections.newCursor();\r |
1282 | QName qSections = new QName(xmlNs, "Sections");\r |
1283 | if (cursor.toChild(qSections)) {\r |
1284 | for (int k = 0; k < j; ++k) {\r |
1285 | cursor.toNextSibling(qSections);\r |
1286 | }\r |
1287 | BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2 sections2 = (BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2)cursor.getObject();\r |
1288 | sections2.setEncapsulationType(type);\r |
1289 | }\r |
1290 | cursor.dispose();\r |
1291 | }\r |
1292 | \r |
6cba26e8 |
1293 | public void genBuildOptionsFfsSectionsSectionsSection(int i, int j, String type) {\r |
1294 | BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r |
1295 | if (ffs == null) {\r |
1296 | return;\r |
1297 | }\r |
1298 | BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections();\r |
1299 | XmlCursor cursor = sections.newCursor();\r |
1300 | QName qSections = new QName(xmlNs, "Sections");\r |
1301 | if (cursor.toChild(qSections)){\r |
1302 | for (int k = 0; k < j; ++k) {\r |
1303 | cursor.toNextSibling(qSections);\r |
1304 | }\r |
1305 | BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2 sections2 = (BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2)cursor.getObject();\r |
1306 | sections2.addNewSection().setSectionType(EfiSectionType.Enum.forString(type));\r |
1307 | }\r |
1308 | cursor.dispose();\r |
1309 | }\r |
1310 | \r |
3b405e9b |
1311 | public void removeBuildOptionsFfsSectionsSectionsSection(int i, int j, int k) {\r |
1312 | BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r |
1313 | BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections();\r |
1314 | if (sections == null) {\r |
1315 | return;\r |
1316 | }\r |
1317 | XmlCursor cursor = sections.newCursor();\r |
1318 | QName qSections = new QName(xmlNs, "Sections");\r |
1319 | if (cursor.toChild(qSections)) {\r |
1320 | for (int l = 0; l < j; ++l) {\r |
1321 | cursor.toNextSibling(qSections);\r |
1322 | }\r |
1323 | if (cursor.toFirstChild()) {\r |
1324 | for (int m = 0; m < k; ++m) {\r |
1325 | cursor.toNextSibling();\r |
1326 | }\r |
1327 | cursor.removeXml();\r |
1328 | }\r |
1329 | }\r |
1330 | cursor.dispose();\r |
1331 | }\r |
1332 | \r |
1333 | public void updateBuildOptionsFfsSectionsSectionsSection(int i, int j, int k, String type) {\r |
1334 | BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r |
1335 | BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections();\r |
1336 | if (sections == null) {\r |
1337 | return;\r |
1338 | }\r |
1339 | XmlCursor cursor = sections.newCursor();\r |
1340 | QName qSections = new QName(xmlNs, "Sections");\r |
1341 | if (cursor.toChild(qSections)) {\r |
1342 | for (int l = 0; l < j; ++l) {\r |
1343 | cursor.toNextSibling(qSections);\r |
1344 | }\r |
1345 | if (cursor.toFirstChild()) {\r |
1346 | for (int m = 0; m < k; ++m) {\r |
1347 | cursor.toNextSibling();\r |
1348 | }\r |
1349 | BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2.Section section = (BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2.Section)cursor.getObject();\r |
1350 | section.setSectionType(EfiSectionType.Enum.forString(type));\r |
1351 | }\r |
1352 | }\r |
1353 | cursor.dispose();\r |
1354 | }\r |
1355 | \r |
6cba26e8 |
1356 | public void getBuildOptionsFfsSectionsSectionsSection(int i, int j, ArrayList<String> al) {\r |
1357 | BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r |
1358 | if (ffs == null) {\r |
1359 | return;\r |
1360 | }\r |
1361 | BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections();\r |
1362 | XmlCursor cursor = sections.newCursor();\r |
1363 | QName qSections = new QName(xmlNs, "Sections");\r |
1364 | if (cursor.toChild(qSections)){\r |
1365 | for (int k = 0; k < j; ++k) {\r |
1366 | cursor.toNextSibling(qSections);\r |
1367 | }\r |
1368 | BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2 sections2 = (BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2)cursor.getObject();\r |
1369 | if (sections2.getSectionList() == null){\r |
1370 | cursor.dispose();\r |
1371 | return;\r |
1372 | }\r |
1373 | ListIterator<BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2.Section> li = sections2.getSectionList().listIterator();\r |
1374 | while(li.hasNext()) {\r |
1375 | BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2.Section section = li.next();\r |
3b405e9b |
1376 | if (section.isSetSectionType()) {\r |
6cba26e8 |
1377 | al.add(section.getSectionType().toString());\r |
1378 | }\r |
3b405e9b |
1379 | \r |
1380 | }\r |
6cba26e8 |
1381 | }\r |
1382 | cursor.dispose();\r |
1383 | \r |
1384 | }\r |
1385 | \r |
1386 | public int getBuildOptionsFfsCount(){\r |
1387 | if (getfpdBuildOpts().getFfsList() == null) {\r |
1388 | return 0;\r |
1389 | }\r |
1390 | return getfpdBuildOpts().getFfsList().size();\r |
1391 | }\r |
1392 | \r |
1393 | public void getBuildOptionsFfsKey(String[][] saa) {\r |
1394 | if (getfpdBuildOpts().getFfsList() == null) {\r |
1395 | return;\r |
1396 | }\r |
1397 | ListIterator<BuildOptionsDocument.BuildOptions.Ffs> li = getfpdBuildOpts().getFfsList().listIterator();\r |
1398 | int i = 0;\r |
1399 | while(li.hasNext()){\r |
1400 | BuildOptionsDocument.BuildOptions.Ffs ffs = li.next();\r |
1401 | saa[i][0] = ffs.getFfsKey();\r |
1402 | ++i;\r |
1403 | }\r |
1404 | }\r |
1405 | \r |
3b405e9b |
1406 | public void updateBuildOptionsFfsKey(int i, String key) {\r |
1407 | BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r |
1408 | ffs.setFfsKey(key);\r |
1409 | }\r |
1410 | \r |
6cba26e8 |
1411 | /**Get ith FFS key and contents.\r |
1412 | * @param saa\r |
1413 | */\r |
1414 | public void getBuildOptionsFfs(int i, String[] sa, LinkedHashMap<String, String> ffsAttribMap, ArrayList<String> firstLevelSections, ArrayList<String> firstLevelSection) {\r |
1415 | BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r |
1416 | \r |
1417 | if (ffs != null) {\r |
1418 | \r |
1419 | sa[0] = ffs.getFfsKey();\r |
1420 | if (ffs.getSections() != null) {\r |
1421 | if(ffs.getSections().getEncapsulationType() != null){\r |
1422 | sa[1] = ffs.getSections().getEncapsulationType();\r |
1423 | }\r |
1424 | if (ffs.getSections().getSectionList() != null){\r |
1425 | ListIterator<BuildOptionsDocument.BuildOptions.Ffs.Sections.Section> li = ffs.getSections().getSectionList().listIterator();\r |
1426 | while (li.hasNext()) {\r |
1427 | firstLevelSection.add(li.next().getSectionType().toString());\r |
1428 | }\r |
1429 | }\r |
1430 | if (ffs.getSections().getSectionsList() != null) {\r |
1431 | ListIterator<BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2> li = ffs.getSections().getSectionsList().listIterator();\r |
1432 | while(li.hasNext()) {\r |
1433 | firstLevelSections.add(li.next().getEncapsulationType());\r |
1434 | }\r |
1435 | }\r |
1436 | }\r |
1437 | if (ffs.getAttributeList() != null) {\r |
1438 | ListIterator<BuildOptionsDocument.BuildOptions.Ffs.Attribute> li = ffs.getAttributeList().listIterator();\r |
1439 | while(li.hasNext()) {\r |
1440 | BuildOptionsDocument.BuildOptions.Ffs.Attribute attrib = li.next();\r |
1441 | ffsAttribMap.put(attrib.getName(), attrib.getValue());\r |
1442 | }\r |
1443 | \r |
1444 | }\r |
1445 | }\r |
1446 | \r |
1447 | \r |
1448 | }\r |
1449 | \r |
1450 | private BuildOptionsDocument.BuildOptions.Ffs getFfs(int i) {\r |
1451 | XmlObject o = getfpdBuildOpts();\r |
1452 | BuildOptionsDocument.BuildOptions.Ffs ffs = null;\r |
1453 | \r |
1454 | XmlCursor cursor = o.newCursor();\r |
1455 | QName qFfs = new QName(xmlNs, "Ffs");\r |
1456 | if (cursor.toChild(qFfs)) {\r |
1457 | for (int j = 0; j < i; ++j) {\r |
1458 | cursor.toNextSibling(qFfs);\r |
1459 | }\r |
1460 | ffs = (BuildOptionsDocument.BuildOptions.Ffs)cursor.getObject();\r |
1461 | }\r |
1462 | cursor.dispose();\r |
1463 | return ffs;\r |
1464 | }\r |
1465 | \r |
1466 | public void removeBuildOptionsFfs(int i) {\r |
1467 | BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r |
1468 | if (ffs == null){\r |
1469 | return;\r |
1470 | }\r |
1471 | \r |
1472 | XmlCursor cursor = ffs.newCursor();\r |
1473 | cursor.removeXml();\r |
1474 | cursor.dispose();\r |
1475 | }\r |
1476 | \r |
3b405e9b |
1477 | \r |
1478 | \r |
a13899c5 |
1479 | public PlatformDefinitionsDocument.PlatformDefinitions getfpdPlatformDefs(){\r |
1480 | if (fpdPlatformDefs == null){\r |
1481 | fpdPlatformDefs = fpdRoot.addNewPlatformDefinitions();\r |
1482 | }\r |
1483 | return fpdPlatformDefs;\r |
1484 | }\r |
1485 | \r |
6a09eb19 |
1486 | public void getPlatformDefsSupportedArchs(Vector<Object> archs){\r |
1487 | if (getfpdPlatformDefs().getSupportedArchitectures() == null) {\r |
1488 | return;\r |
1489 | }\r |
1490 | ListIterator li = getfpdPlatformDefs().getSupportedArchitectures().listIterator();\r |
1491 | while(li.hasNext()) {\r |
1492 | archs.add(li.next());\r |
1493 | }\r |
1494 | }\r |
1495 | \r |
1496 | public void setPlatformDefsSupportedArchs(Vector<Object> archs) {\r |
1497 | getfpdPlatformDefs().setSupportedArchitectures(archs);\r |
1498 | }\r |
1499 | \r |
1500 | public void getPlatformDefsBuildTargets(Vector<Object> targets) {\r |
1501 | if (getfpdPlatformDefs().getBuildTargets() == null) {\r |
1502 | return;\r |
1503 | }\r |
1504 | ListIterator li = getfpdPlatformDefs().getBuildTargets().listIterator();\r |
1505 | while(li.hasNext()) {\r |
1506 | targets.add(li.next());\r |
1507 | }\r |
1508 | }\r |
1509 | \r |
1510 | public void setPlatformDefsBuildTargets(Vector<Object> targets) {\r |
1511 | getfpdPlatformDefs().setBuildTargets(targets);\r |
1512 | }\r |
1513 | \r |
1514 | public void genPlatformDefsSkuInfo(String id, String name) {\r |
1515 | SkuInfoDocument.SkuInfo skuInfo = null;\r |
1516 | if (getfpdPlatformDefs().getSkuInfo() == null) {\r |
1517 | skuInfo = getfpdPlatformDefs().addNewSkuInfo();\r |
1518 | }\r |
1519 | skuInfo = getfpdPlatformDefs().getSkuInfo();\r |
1520 | if (skuInfo.getUiSkuNameList() == null || skuInfo.getUiSkuNameList().size() == 0) {\r |
1521 | SkuInfoDocument.SkuInfo.UiSkuName skuName = skuInfo.addNewUiSkuName();\r |
1522 | skuName.setSkuID(new BigInteger("0"));\r |
1523 | skuName.setStringValue("DEFAULT");\r |
1524 | }\r |
1525 | if (id.equals("0")) {\r |
1526 | return;\r |
1527 | }\r |
1528 | SkuInfoDocument.SkuInfo.UiSkuName skuName = skuInfo.addNewUiSkuName();\r |
1529 | skuName.setSkuID(new BigInteger(id));\r |
1530 | skuName.setStringValue(name);\r |
1531 | }\r |
1532 | \r |
1533 | public int getPlatformDefsSkuInfoCount(){\r |
1534 | if (getfpdPlatformDefs().getSkuInfo() == null || getfpdPlatformDefs().getSkuInfo().getUiSkuNameList() == null) {\r |
1535 | return 0;\r |
1536 | }\r |
1537 | return getfpdPlatformDefs().getSkuInfo().getUiSkuNameList().size();\r |
1538 | }\r |
1539 | \r |
1540 | public void getPlatformDefsSkuInfos(String[][] saa){\r |
1541 | if (getfpdPlatformDefs().getSkuInfo() == null || getfpdPlatformDefs().getSkuInfo().getUiSkuNameList() == null) {\r |
1542 | return ;\r |
1543 | }\r |
1544 | \r |
1545 | List<SkuInfoDocument.SkuInfo.UiSkuName> l = getfpdPlatformDefs().getSkuInfo().getUiSkuNameList();\r |
1546 | ListIterator<SkuInfoDocument.SkuInfo.UiSkuName> li = l.listIterator();\r |
1547 | int i = 0;\r |
1548 | while(li.hasNext()) {\r |
1549 | SkuInfoDocument.SkuInfo.UiSkuName sku = li.next();\r |
1550 | saa[i][0] = sku.getSkuID()+"";\r |
1551 | saa[i][1] = sku.getStringValue();\r |
1552 | ++i;\r |
1553 | }\r |
1554 | }\r |
1555 | \r |
1556 | public void removePlatformDefsSkuInfo(int i) {\r |
1557 | SkuInfoDocument.SkuInfo skuInfo = getfpdPlatformDefs().getSkuInfo();\r |
1558 | if (skuInfo == null || i == 0) {\r |
1559 | return ;\r |
1560 | }\r |
1561 | \r |
1562 | XmlCursor cursor = skuInfo.newCursor();\r |
1563 | if (cursor.toFirstChild()) {\r |
1564 | for (int j = 0; j < i; ++j) {\r |
1565 | cursor.toNextSibling();\r |
1566 | }\r |
1567 | cursor.removeXml();\r |
1568 | }\r |
1569 | cursor.dispose();\r |
1570 | }\r |
1571 | \r |
1572 | public void updatePlatformDefsSkuInfo(int i, String id, String name) {\r |
1573 | SkuInfoDocument.SkuInfo skuInfo = getfpdPlatformDefs().getSkuInfo();\r |
1574 | if (skuInfo == null || i == 0) {\r |
1575 | return ;\r |
1576 | }\r |
1577 | \r |
1578 | XmlCursor cursor = skuInfo.newCursor();\r |
1579 | if (cursor.toFirstChild()) {\r |
1580 | for (int j = 0; j < i; ++j) {\r |
1581 | cursor.toNextSibling();\r |
1582 | }\r |
1583 | SkuInfoDocument.SkuInfo.UiSkuName sku = (SkuInfoDocument.SkuInfo.UiSkuName)cursor.getObject();\r |
1584 | sku.setSkuID(new BigInteger(id));\r |
1585 | sku.setStringValue(name);\r |
1586 | }\r |
1587 | cursor.dispose();\r |
1588 | }\r |
1589 | \r |
1590 | public String getPlatformDefsInterDir(){\r |
1591 | if (getfpdPlatformDefs().getIntermediateDirectories() == null) {\r |
1592 | return null;\r |
1593 | }\r |
1594 | return getfpdPlatformDefs().getIntermediateDirectories().toString();\r |
1595 | }\r |
1596 | \r |
1597 | public void setPlatformDefsInterDir(String interDir){\r |
1598 | getfpdPlatformDefs().setIntermediateDirectories(IntermediateOutputType.Enum.forString(interDir));\r |
1599 | }\r |
1600 | \r |
1601 | public String getPlatformDefsOutputDir() {\r |
1602 | return getfpdPlatformDefs().getOutputDirectory();\r |
1603 | }\r |
1604 | \r |
1605 | public void setPlatformDefsOutputDir(String outputDir) {\r |
1606 | getfpdPlatformDefs().setOutputDirectory(outputDir);\r |
1607 | }\r |
1608 | \r |
a13899c5 |
1609 | public FlashDocument.Flash getfpdFlash() {\r |
1610 | if (fpdFlash == null) {\r |
1611 | fpdFlash = fpdRoot.addNewFlash();\r |
1612 | }\r |
1613 | return fpdFlash;\r |
1614 | }\r |
1615 | \r |
1616 | public void genFlashDefinitionFile(String file) {\r |
1617 | FlashDefinitionFileDocument.FlashDefinitionFile fdf = getfpdFlash().getFlashDefinitionFile();\r |
1618 | if (fdf == null) {\r |
1619 | fdf = getfpdFlash().addNewFlashDefinitionFile();\r |
1620 | }\r |
1621 | \r |
1622 | fdf.setStringValue(file);\r |
1623 | }\r |
1624 | \r |
1625 | public String getFlashDefinitionFile() {\r |
1626 | FlashDefinitionFileDocument.FlashDefinitionFile fdf = getfpdFlash().getFlashDefinitionFile();\r |
1627 | if (fdf == null) {\r |
1628 | return "";\r |
1629 | }\r |
1630 | \r |
1631 | return fdf.getStringValue();\r |
1632 | }\r |
1633 | \r |
1634 | \r |
1635 | \r |
1636 | public void genFvImagesNameValue(String name, String value) {\r |
1637 | \r |
1638 | FvImagesDocument.FvImages fi = getfpdFlash().getFvImages();\r |
1639 | if (fi == null) {\r |
1640 | fi = getfpdFlash().addNewFvImages();\r |
1641 | }\r |
1642 | \r |
1643 | FvImagesDocument.FvImages.NameValue nv = fi.addNewNameValue();\r |
1644 | nv.setName(name);\r |
1645 | nv.setValue(value);\r |
1646 | }\r |
1647 | \r |
1648 | public void removeFvImagesNameValue(int i){\r |
1649 | \r |
1650 | XmlObject o = getfpdFlash().getFvImages();\r |
1651 | if (o == null) {\r |
1652 | return;\r |
1653 | }\r |
1654 | \r |
1655 | QName qNameValue = new QName(xmlNs, "NameValue");\r |
1656 | XmlCursor cursor = o.newCursor();\r |
1657 | if (cursor.toChild(qNameValue)) {\r |
1658 | for (int j = 0; j < i; ++j) {\r |
1659 | cursor.toNextSibling(qNameValue);\r |
1660 | }\r |
1661 | cursor.removeXml();\r |
1662 | }\r |
1663 | cursor.dispose();\r |
1664 | }\r |
1665 | \r |
1666 | public void updateFvImagesNameValue(int i, String name, String value){\r |
1667 | \r |
1668 | XmlObject o = getfpdFlash().getFvImages();\r |
1669 | if (o == null) {\r |
1670 | return;\r |
1671 | }\r |
1672 | \r |
1673 | QName qNameValue = new QName(xmlNs, "NameValue");\r |
1674 | XmlCursor cursor = o.newCursor();\r |
1675 | if (cursor.toChild(qNameValue)) {\r |
1676 | for (int j = 0; j < i; ++j) {\r |
1677 | cursor.toNextSibling(qNameValue);\r |
1678 | }\r |
1679 | FvImagesDocument.FvImages.NameValue nv = (FvImagesDocument.FvImages.NameValue)cursor.getObject();\r |
1680 | nv.setName(name);\r |
1681 | nv.setValue(value);\r |
1682 | }\r |
1683 | cursor.dispose();\r |
1684 | }\r |
1685 | \r |
1686 | public int getFvImagesNameValueCount() {\r |
1687 | \r |
1688 | FvImagesDocument.FvImages fi = null;\r |
1689 | if ((fi = getfpdFlash().getFvImages()) == null || fi.getNameValueList() == null) {\r |
1690 | return 0;\r |
1691 | }\r |
1692 | return fi.getNameValueList().size();\r |
1693 | }\r |
1694 | \r |
1695 | public void getFvImagesNameValues(String[][] nv) {\r |
1696 | \r |
1697 | FvImagesDocument.FvImages fi = getfpdFlash().getFvImages();\r |
1698 | if (fi == null){\r |
1699 | return;\r |
1700 | }\r |
1701 | List<FvImagesDocument.FvImages.NameValue> l = fi.getNameValueList();\r |
1702 | int i = 0;\r |
1703 | ListIterator li = l.listIterator();\r |
1704 | while (li.hasNext()) {\r |
1705 | FvImagesDocument.FvImages.NameValue e = (FvImagesDocument.FvImages.NameValue) li\r |
1706 | .next();\r |
1707 | nv[i][0] = e.getName();\r |
1708 | nv[i][1] = e.getValue();\r |
1709 | \r |
1710 | i++;\r |
1711 | }\r |
1712 | }\r |
1713 | \r |
1714 | public void genFvImagesFvImage(String[] names, String types, Map<String, String> options) {\r |
1715 | \r |
1716 | FvImagesDocument.FvImages fis = null;\r |
1717 | if ((fis = getfpdFlash().getFvImages()) == null) {\r |
1718 | fis = getfpdFlash().addNewFvImages();\r |
1719 | }\r |
1720 | \r |
1721 | //\r |
1722 | //gen FvImage with FvImageNames array\r |
1723 | //\r |
1724 | FvImagesDocument.FvImages.FvImage fi = fis.addNewFvImage();\r |
1725 | for (int i = 0; i < names.length; ++i) {\r |
1726 | fi.addFvImageNames(names[i]);\r |
1727 | }\r |
1728 | fi.setType(FvImageTypes.Enum.forString(types));\r |
1729 | if (options != null){\r |
1730 | setFvImagesFvImageFvImageOptions(options, fi);\r |
1731 | }\r |
1732 | }\r |
1733 | \r |
1734 | private void setFvImagesFvImageFvImageOptions(Map<String, String> options, FvImagesDocument.FvImages.FvImage fi){\r |
1735 | FvImagesDocument.FvImages.FvImage.FvImageOptions fio = fi.getFvImageOptions();\r |
1736 | if (fio == null){\r |
1737 | fio = fi.addNewFvImageOptions();\r |
1738 | }\r |
1739 | \r |
1740 | Set<String> key = options.keySet();\r |
1741 | Iterator<String> i = key.iterator();\r |
1742 | while (i.hasNext()) {\r |
44053733 |
1743 | \r |
a13899c5 |
1744 | FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue nv = fio.addNewNameValue();\r |
1745 | String k = (String)i.next();\r |
ae0d4fd2 |
1746 | \r |
a13899c5 |
1747 | nv.setName(k);\r |
1748 | nv.setValue((String)options.get(k));\r |
1749 | \r |
1750 | }\r |
1751 | \r |
1752 | }\r |
1753 | \r |
44053733 |
1754 | \r |
a13899c5 |
1755 | public void removeFvImagesFvImage(int i) {\r |
1756 | \r |
1757 | XmlObject o = getfpdFlash().getFvImages();\r |
1758 | if (o == null) {\r |
1759 | return;\r |
1760 | }\r |
1761 | \r |
1762 | QName qFvImage = new QName(xmlNs, "FvImage");\r |
1763 | XmlCursor cursor = o.newCursor();\r |
1764 | if (cursor.toChild(qFvImage)) {\r |
1765 | for (int j = 0; j < i; ++j) {\r |
1766 | cursor.toNextSibling(qFvImage);\r |
1767 | }\r |
1768 | cursor.removeXml();\r |
1769 | }\r |
1770 | cursor.dispose();\r |
1771 | }\r |
1772 | \r |
1773 | public void updateFvImagesFvImage(int i, String[] names, String types, Map<String, String> options){\r |
1774 | \r |
1775 | XmlObject o = getfpdFlash().getFvImages();\r |
1776 | if (o == null) {\r |
1777 | return;\r |
1778 | }\r |
1779 | XmlCursor cursor = o.newCursor();\r |
1780 | QName qFvImage = new QName(xmlNs, "FvImage");\r |
1781 | if (cursor.toChild(qFvImage)) {\r |
1782 | for (int j = 0; j < i; ++j) {\r |
1783 | cursor.toNextSibling(qFvImage);\r |
1784 | }\r |
1785 | FvImagesDocument.FvImages.FvImage fi = (FvImagesDocument.FvImages.FvImage)cursor.getObject();\r |
1786 | fi.setType(FvImageTypes.Enum.forString(types));\r |
1787 | \r |
1788 | //\r |
1789 | // remove old FvImageNames before adding new ones\r |
1790 | //\r |
1791 | QName qFvImageNames = new QName(xmlNs, "FvImageNames"); \r |
1792 | cursor.toChild(qFvImageNames);\r |
1793 | cursor.removeXml();\r |
1794 | while (cursor.toNextSibling(qFvImageNames)) {\r |
1795 | cursor.removeXml();\r |
1796 | }\r |
1797 | \r |
1798 | for (int k = 0; k < names.length; ++k) {\r |
1799 | fi.addFvImageNames(names[k]);\r |
1800 | }\r |
1801 | //\r |
1802 | // remove old FvImageOptions before adding new options\r |
1803 | //\r |
1804 | QName qFvImageOptions = new QName(xmlNs, "FvImageOptions");\r |
1805 | cursor.toNextSibling(qFvImageOptions);\r |
1806 | cursor.removeXml();\r |
1807 | \r |
1808 | setFvImagesFvImageFvImageOptions(options, fi);\r |
1809 | }\r |
1810 | cursor.dispose();\r |
1811 | }\r |
1812 | \r |
1813 | public int getFvImagesFvImageCount() {\r |
1814 | \r |
1815 | if (getfpdFlash().getFvImages() == null || getfpdFlash().getFvImages().getFvImageList() == null) {\r |
1816 | return 0;\r |
1817 | }\r |
1818 | return getfpdFlash().getFvImages().getFvImageList().size();\r |
1819 | }\r |
1820 | \r |
ae0d4fd2 |
1821 | /**Only Get Fv image setting - name and type.\r |
1822 | * @param saa\r |
1823 | */\r |
1824 | public void getFvImagesFvImages(String[][] saa) {\r |
a13899c5 |
1825 | \r |
1826 | if (getfpdFlash().getFvImages() == null) {\r |
1827 | return;\r |
1828 | }\r |
1829 | List<FvImagesDocument.FvImages.FvImage> l = getfpdFlash().getFvImages().getFvImageList();\r |
1830 | if (l == null) {\r |
1831 | return;\r |
1832 | }\r |
1833 | ListIterator li = l.listIterator();\r |
1834 | int i = 0;\r |
1835 | while(li.hasNext()) {\r |
1836 | FvImagesDocument.FvImages.FvImage fi = (FvImagesDocument.FvImages.FvImage)li.next();\r |
1837 | //\r |
1838 | // get FvImageNames array, space separated\r |
1839 | //\r |
1840 | List<String> lfn = fi.getFvImageNamesList();\r |
1841 | ListIterator lfni = lfn.listIterator();\r |
1842 | saa[i][0] = " ";\r |
1843 | while (lfni.hasNext()) {\r |
1844 | saa[i][0] += (String)lfni.next();\r |
1845 | saa[i][0] += " ";\r |
1846 | }\r |
1847 | saa[i][0] = saa[i][0].trim();\r |
1848 | \r |
1849 | saa[i][1] = fi.getType()+"";\r |
1850 | \r |
ae0d4fd2 |
1851 | ++i;\r |
1852 | }\r |
1853 | }\r |
1854 | \r |
1855 | /**Get FvImage Options for FvImage i\r |
1856 | * @param i the ith FvImage\r |
1857 | */\r |
1858 | public void getFvImagesFvImageOptions(int i, Map<String, String> m) {\r |
1859 | XmlObject o = getfpdFlash().getFvImages();\r |
1860 | if (o == null) {\r |
1861 | return;\r |
1862 | }\r |
1863 | XmlCursor cursor = o.newCursor();\r |
1864 | QName qFvImage = new QName(xmlNs, "FvImage");\r |
1865 | if (cursor.toChild(qFvImage)) {\r |
1866 | for (int j = 0; j < i; ++j) {\r |
1867 | cursor.toNextSibling(qFvImage);\r |
a13899c5 |
1868 | }\r |
ae0d4fd2 |
1869 | FvImagesDocument.FvImages.FvImage fi = (FvImagesDocument.FvImages.FvImage)cursor.getObject();\r |
1870 | if (fi.getFvImageOptions() == null || fi.getFvImageOptions().getNameValueList() == null){\r |
1871 | return;\r |
a13899c5 |
1872 | }\r |
ae0d4fd2 |
1873 | ListIterator<FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue> li = fi.getFvImageOptions().getNameValueList().listIterator();\r |
1874 | while(li.hasNext()){\r |
1875 | FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue nv = li.next();\r |
a13899c5 |
1876 | m.put(nv.getName(), nv.getValue());\r |
1877 | }\r |
a13899c5 |
1878 | }\r |
1879 | }\r |
1880 | \r |
1881 | /**\r |
1882 | Get platform header element\r |
1883 | @return PlatformHeaderDocument.PlatformHeader\r |
1884 | **/\r |
1885 | public PlatformHeaderDocument.PlatformHeader getFpdHdr() {\r |
1886 | if (fpdHdr == null) {\r |
1887 | fpdHdr = fpdRoot.addNewPlatformHeader();\r |
1888 | }\r |
1889 | genPlatformDefsSkuInfo("0", "DEFAULT");\r |
1890 | return fpdHdr;\r |
1891 | }\r |
1892 | \r |
a13899c5 |
1893 | public String getFpdHdrPlatformName() {\r |
1894 | return getFpdHdr().getPlatformName();\r |
1895 | }\r |
1896 | \r |
1897 | public String getFpdHdrGuidValue() {\r |
1898 | return getFpdHdr().getGuidValue();\r |
1899 | }\r |
1900 | \r |
1901 | public String getFpdHdrVer() {\r |
1902 | return getFpdHdr().getVersion();\r |
1903 | }\r |
1904 | \r |
1905 | public String getFpdHdrAbs() {\r |
1906 | return getFpdHdr().getAbstract();\r |
1907 | }\r |
1908 | \r |
1909 | public String getFpdHdrDescription() {\r |
1910 | return getFpdHdr().getDescription();\r |
1911 | }\r |
1912 | \r |
1913 | public String getFpdHdrCopyright() {\r |
1914 | return getFpdHdr().getCopyright();\r |
1915 | }\r |
1916 | \r |
1917 | public String getFpdHdrLicense() {\r |
1918 | LicenseDocument.License l = getFpdHdr().getLicense();\r |
1919 | if (l == null) {\r |
1920 | return null;\r |
1921 | }\r |
1922 | return l.getStringValue();\r |
1923 | }\r |
1924 | \r |
1925 | public String getFpdHdrUrl() {\r |
1926 | LicenseDocument.License l = getFpdHdr().getLicense();\r |
1927 | if (l == null) {\r |
1928 | return null;\r |
1929 | }\r |
1930 | return l.getURL();\r |
1931 | }\r |
1932 | \r |
1933 | public String getFpdHdrSpec() {\r |
1934 | \r |
1935 | return "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052";\r |
1936 | // return getFpdHdr().getSpecification();\r |
1937 | }\r |
1938 | \r |
1939 | public void setFpdHdrPlatformName(String name){\r |
1940 | getFpdHdr().setPlatformName(name);\r |
1941 | }\r |
1942 | \r |
1943 | public void setFpdHdrGuidValue(String guid){\r |
1944 | getFpdHdr().setGuidValue(guid);\r |
1945 | }\r |
1946 | \r |
1947 | public void setFpdHdrVer(String v){\r |
1948 | getFpdHdr().setVersion(v);\r |
1949 | }\r |
1950 | \r |
1951 | public void setFpdHdrAbs(String abs) {\r |
1952 | getFpdHdr().setAbstract(abs);\r |
1953 | }\r |
1954 | \r |
1955 | public void setFpdHdrDescription(String desc){\r |
1956 | getFpdHdr().setDescription(desc);\r |
1957 | }\r |
1958 | \r |
1959 | public void setFpdHdrCopyright(String cr) {\r |
1960 | getFpdHdr().setCopyright(cr);\r |
1961 | }\r |
1962 | \r |
1963 | public void setFpdHdrLicense(String license){\r |
1964 | LicenseDocument.License l = getFpdHdr().getLicense();\r |
1965 | if (l == null) {\r |
1966 | getFpdHdr().addNewLicense().setStringValue(license);\r |
1967 | }\r |
1968 | else {\r |
1969 | l.setStringValue(license);\r |
1970 | }\r |
1971 | }\r |
1972 | \r |
1973 | public void setFpdHdrUrl(String url){\r |
1974 | LicenseDocument.License l = getFpdHdr().getLicense();\r |
1975 | \r |
1976 | l.setURL(url);\r |
1977 | \r |
1978 | }\r |
1979 | \r |
1980 | public void setFpdHdrSpec(String s){\r |
1981 | s = "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052";\r |
1982 | getFpdHdr().setSpecification(s);\r |
1983 | }\r |
1984 | /**\r |
1985 | Save the processed xml contents to file\r |
1986 | \r |
1987 | @param fpdFile The file to save xml contents\r |
1988 | @throws IOException Exceptions during file operation\r |
1989 | **/\r |
1990 | public void saveAs(File fpdFile) throws IOException {\r |
1991 | \r |
1992 | XmlOptions options = new XmlOptions();\r |
1993 | \r |
1994 | options.setCharacterEncoding("UTF-8");\r |
1995 | options.setSavePrettyPrint();\r |
1996 | options.setSavePrettyPrintIndent(2);\r |
1997 | try {\r |
1998 | fpdd.save(fpdFile, options);\r |
1999 | } catch (IOException e) {\r |
2000 | e.printStackTrace();\r |
2001 | }\r |
2002 | \r |
2003 | }\r |
2004 | \r |
2005 | private String listToString(List<String> l) {\r |
2006 | if (l == null) {\r |
2007 | return null;\r |
2008 | }\r |
2009 | String s = " ";\r |
2010 | ListIterator li = l.listIterator();\r |
2011 | while(li.hasNext()) {\r |
2012 | s += li.next();\r |
2013 | s += " ";\r |
2014 | }\r |
2015 | return s.trim();\r |
2016 | }\r |
2017 | }\r |