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