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