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