]>
Commit | Line | Data |
---|---|---|
a13899c5 | 1 | /** @file\r |
2 | Java class FpdFileContents is used to parse fpd xml file.\r | |
3 | \r | |
4 | Copyright (c) 2006, Intel Corporation\r | |
5 | All rights reserved. This program and the accompanying materials\r | |
6 | are licensed and made available under the terms and conditions of the BSD License\r | |
7 | which accompanies this distribution. The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license.php\r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
12 | **/\r | |
13 | package org.tianocore.frameworkwizard.platform.ui;\r | |
14 | \r | |
15 | import java.io.File;\r | |
16 | import java.io.IOException;\r | |
17 | import java.math.BigInteger;\r | |
18 | import java.util.ArrayList;\r | |
19 | import java.util.HashMap;\r | |
20 | import java.util.Iterator;\r | |
21 | import java.util.LinkedHashMap;\r | |
22 | import java.util.List;\r | |
23 | import java.util.ListIterator;\r | |
24 | import java.util.Map;\r | |
25 | import java.util.Set;\r | |
6a09eb19 | 26 | import java.util.Vector;\r |
a13899c5 | 27 | \r |
28 | import javax.xml.namespace.QName;\r | |
29 | \r | |
30 | import org.apache.xmlbeans.XmlCursor;\r | |
31 | import org.apache.xmlbeans.XmlObject;\r | |
32 | import org.apache.xmlbeans.XmlOptions;\r | |
33 | import org.tianocore.AntTaskDocument;\r | |
34 | import org.tianocore.BuildOptionsDocument;\r | |
35 | import org.tianocore.DynamicPcdBuildDefinitionsDocument;\r | |
6cba26e8 | 36 | import org.tianocore.EfiSectionType;\r |
a13899c5 | 37 | import org.tianocore.FlashDefinitionFileDocument;\r |
a13899c5 | 38 | import org.tianocore.FlashDocument;\r |
39 | import org.tianocore.FrameworkModulesDocument;\r | |
6a09eb19 | 40 | import org.tianocore.IntermediateOutputType;\r |
a13899c5 | 41 | import org.tianocore.LibrariesDocument;\r |
42 | import org.tianocore.ModuleSADocument;\r | |
8f55ea73 | 43 | import org.tianocore.ModuleSaBuildOptionsDocument;\r |
a13899c5 | 44 | import org.tianocore.ModuleSurfaceAreaDocument;\r |
45 | import org.tianocore.OptionDocument;\r | |
46 | import org.tianocore.OptionsDocument;\r | |
47 | import org.tianocore.PcdBuildDefinitionDocument;\r | |
48 | import org.tianocore.PcdCodedDocument;\r | |
49 | import org.tianocore.PcdDataTypes;\r | |
50 | import org.tianocore.PcdDeclarationsDocument;\r | |
51 | import org.tianocore.PcdItemTypes;\r | |
52 | import org.tianocore.PlatformDefinitionsDocument;\r | |
53 | import org.tianocore.PlatformSurfaceAreaDocument;\r | |
54 | import org.tianocore.FvImageTypes;\r | |
55 | import org.tianocore.FvImagesDocument;\r | |
56 | import org.tianocore.LicenseDocument;\r | |
57 | import org.tianocore.PlatformHeaderDocument;\r | |
58 | import org.tianocore.SkuInfoDocument;\r | |
59 | import org.tianocore.UserDefinedAntTasksDocument;\r | |
1bf9fa5a | 60 | import org.tianocore.UserExtensionsDocument;\r |
61 | import org.tianocore.frameworkwizard.platform.ui.global.WorkspaceProfile;\r | |
a13899c5 | 62 | import org.tianocore.frameworkwizard.platform.ui.global.SurfaceAreaQuery;\r |
3658f95e | 63 | import org.tianocore.frameworkwizard.module.Identifications.ModuleIdentification;\r |
64 | import org.tianocore.frameworkwizard.packaging.PackageIdentification;\r | |
a13899c5 | 65 | \r |
66 | /**\r | |
67 | This class processes fpd file contents such as add remove xml elements. \r | |
68 | @since PackageEditor 1.0\r | |
69 | **/\r | |
70 | public class FpdFileContents {\r | |
71 | \r | |
72 | static final String xmlNs = "http://www.TianoCore.org/2006/Edk2.0";\r | |
73 | \r | |
74 | private PlatformSurfaceAreaDocument fpdd = null;\r | |
75 | \r | |
76 | private PlatformSurfaceAreaDocument.PlatformSurfaceArea fpdRoot = null;\r | |
77 | \r | |
78 | private PlatformHeaderDocument.PlatformHeader fpdHdr = null;\r | |
79 | \r | |
80 | private PlatformDefinitionsDocument.PlatformDefinitions fpdPlatformDefs = null;\r | |
81 | \r | |
82 | private FlashDocument.Flash fpdFlash = null;\r | |
83 | \r | |
84 | private BuildOptionsDocument.BuildOptions fpdBuildOpts = null;\r | |
85 | \r | |
86 | private FrameworkModulesDocument.FrameworkModules fpdFrameworkModules = null;\r | |
87 | \r | |
88 | private DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions fpdDynPcdBuildDefs = null;\r | |
89 | \r | |
908b1c05 | 90 | private HashMap<String, ArrayList<String>> dynPcdMap = null;\r |
a13899c5 | 91 | \r |
1bf9fa5a | 92 | private HashMap<String, String> defaultPcdValue = new HashMap<String, String>();\r |
93 | \r | |
a13899c5 | 94 | /**\r |
95 | * look through all pcd data in all ModuleSA, create pcd -> ModuleSA mappings.\r | |
96 | */\r | |
97 | public void initDynPcdMap() {\r | |
98 | if (dynPcdMap == null) {\r | |
99 | dynPcdMap = new HashMap<String, ArrayList<String>>();\r | |
100 | List<ModuleSADocument.ModuleSA> l = getfpdFrameworkModules().getModuleSAList();\r | |
101 | if (l == null) {\r | |
e232295e | 102 | removeElement(getfpdFrameworkModules());\r |
103 | fpdFrameworkModules = null;\r | |
a13899c5 | 104 | return;\r |
105 | }\r | |
106 | ListIterator<ModuleSADocument.ModuleSA> li = l.listIterator();\r | |
107 | while (li.hasNext()) {\r | |
1dac04ab | 108 | ModuleSADocument.ModuleSA moduleSa = li.next();\r |
109 | if (moduleSa.getPcdBuildDefinition() == null || moduleSa.getPcdBuildDefinition().getPcdDataList() == null) {\r | |
a13899c5 | 110 | continue;\r |
111 | }\r | |
1dac04ab | 112 | String ModuleInfo = moduleSa.getModuleGuid() + " " + moduleSa.getModuleVersion() +\r |
113 | " " + moduleSa.getPackageGuid() + " " + moduleSa.getPackageVersion() + " " + listToString(moduleSa.getSupArchList());\r | |
114 | List<PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData> lp = moduleSa.getPcdBuildDefinition().getPcdDataList();\r | |
a13899c5 | 115 | ListIterator<PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData> lpi = lp.listIterator();\r |
116 | while (lpi.hasNext()) {\r | |
117 | PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData pcdData = lpi.next();\r | |
118 | String pcdKey = pcdData.getCName() + " " + pcdData.getTokenSpaceGuidCName();\r | |
119 | if (dynPcdMap.get(pcdKey) == null) {\r | |
120 | ArrayList<String> al = new ArrayList<String>();\r | |
121 | al.add(ModuleInfo + " " + pcdData.getItemType().toString());\r | |
122 | dynPcdMap.put(pcdKey, al);\r | |
123 | }\r | |
124 | else{\r | |
125 | dynPcdMap.get(pcdKey).add(ModuleInfo + " " + pcdData.getItemType().toString());\r | |
126 | }\r | |
127 | }\r | |
128 | }\r | |
129 | }\r | |
130 | }\r | |
908b1c05 | 131 | \r |
132 | public ArrayList<String> getDynPcdMapValue(String key) {\r | |
133 | return dynPcdMap.get(key);\r | |
134 | }\r | |
a13899c5 | 135 | /**\r |
136 | Constructor to create a new spd file\r | |
137 | **/\r | |
138 | public FpdFileContents() {\r | |
139 | \r | |
140 | fpdd = PlatformSurfaceAreaDocument.Factory.newInstance();\r | |
141 | fpdRoot = fpdd.addNewPlatformSurfaceArea();\r | |
142 | \r | |
143 | }\r | |
144 | \r | |
145 | /**\r | |
146 | Constructor for existing document object\r | |
147 | @param psa\r | |
148 | **/\r | |
149 | public FpdFileContents(PlatformSurfaceAreaDocument.PlatformSurfaceArea fpd) {\r | |
150 | fpdRoot = fpd;\r | |
151 | fpdHdr = fpdRoot.getPlatformHeader();\r | |
152 | fpdPlatformDefs = fpdRoot.getPlatformDefinitions();\r | |
153 | fpdBuildOpts = fpdRoot.getBuildOptions();\r | |
154 | fpdFrameworkModules = fpdRoot.getFrameworkModules();\r | |
155 | fpdDynPcdBuildDefs = fpdRoot.getDynamicPcdBuildDefinitions();\r | |
156 | fpdFlash = fpdRoot.getFlash();\r | |
157 | }\r | |
158 | \r | |
159 | /**\r | |
160 | Constructor based on an existing spd file\r | |
161 | \r | |
162 | @param f Existing spd file\r | |
163 | **/\r | |
164 | public FpdFileContents(File f) {\r | |
165 | try {\r | |
166 | fpdd = PlatformSurfaceAreaDocument.Factory.parse(f);\r | |
167 | fpdRoot = fpdd.getPlatformSurfaceArea();\r | |
168 | } catch (Exception e) {\r | |
169 | System.out.println(e.toString());\r | |
170 | }\r | |
171 | }\r | |
172 | \r | |
173 | public DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions getfpdDynPcdBuildDefs() {\r | |
174 | if (fpdDynPcdBuildDefs == null){\r | |
175 | fpdDynPcdBuildDefs = fpdRoot.addNewDynamicPcdBuildDefinitions();\r | |
176 | }\r | |
177 | return fpdDynPcdBuildDefs;\r | |
178 | }\r | |
179 | \r | |
180 | public FrameworkModulesDocument.FrameworkModules getfpdFrameworkModules() {\r | |
181 | if (fpdFrameworkModules == null){\r | |
182 | fpdFrameworkModules = fpdRoot.addNewFrameworkModules();\r | |
183 | }\r | |
184 | return fpdFrameworkModules;\r | |
185 | }\r | |
186 | \r | |
61919f8c | 187 | public void getFrameworkModuleGuid (String fvName, Vector<String> vGuid) {\r |
188 | if (getFrameworkModulesCount() == 0){\r | |
189 | return;\r | |
190 | }\r | |
191 | \r | |
192 | ListIterator li = getfpdFrameworkModules().getModuleSAList().listIterator();\r | |
193 | while(li.hasNext()) {\r | |
194 | ModuleSADocument.ModuleSA moduleSa = (ModuleSADocument.ModuleSA)li.next();\r | |
195 | if (moduleSa.getModuleSaBuildOptions() == null) {\r | |
196 | continue;\r | |
197 | }\r | |
198 | String fvBinding = moduleSa.getModuleSaBuildOptions().getFvBinding();\r | |
199 | if (fvBinding == null) {\r | |
200 | continue;\r | |
201 | }\r | |
202 | \r | |
203 | String[] fvNames = fvBinding.split(" ");\r | |
204 | for (int i = 0; i < fvNames.length; ++i) {\r | |
205 | if (fvNames[i].equals(fvName) || fvNames[i].replaceAll("_", "").equals(fvName)) {\r | |
206 | vGuid.add(moduleSa.getModuleGuid());\r | |
207 | break;\r | |
208 | }\r | |
209 | }\r | |
210 | }\r | |
211 | }\r | |
212 | \r | |
a13899c5 | 213 | public int getFrameworkModulesCount() {\r |
5af6b67f | 214 | if (getfpdFrameworkModules().getModuleSAList() == null || getfpdFrameworkModules().getModuleSAList().size() == 0){\r |
e232295e | 215 | removeElement(getfpdFrameworkModules());\r |
216 | fpdFrameworkModules = null;\r | |
a13899c5 | 217 | return 0;\r |
218 | }\r | |
219 | return getfpdFrameworkModules().getModuleSAList().size();\r | |
220 | }\r | |
221 | \r | |
222 | public void getFrameworkModulesInfo(String[][] saa) {\r | |
223 | if (getFrameworkModulesCount() == 0){\r | |
224 | return;\r | |
225 | }\r | |
226 | \r | |
227 | ListIterator li = getfpdFrameworkModules().getModuleSAList().listIterator();\r | |
228 | int i = 0;\r | |
229 | while(li.hasNext()) {\r | |
61919f8c | 230 | ModuleSADocument.ModuleSA moduleSa = (ModuleSADocument.ModuleSA)li.next();\r |
231 | saa[i][0] = moduleSa.getModuleGuid();\r | |
232 | saa[i][1] = moduleSa.getModuleVersion();\r | |
a13899c5 | 233 | \r |
61919f8c | 234 | saa[i][2] = moduleSa.getPackageGuid();\r |
235 | saa[i][3] = moduleSa.getPackageVersion();\r | |
236 | saa[i][4] = listToString(moduleSa.getSupArchList());\r | |
a13899c5 | 237 | ++i;\r |
238 | }\r | |
239 | }\r | |
240 | \r | |
bf5abaff | 241 | public void getFrameworkModuleInfo(int i, String[] sa) {\r |
242 | ModuleSADocument.ModuleSA msa = getModuleSA(i);\r | |
243 | if (msa == null) {\r | |
244 | return;\r | |
245 | }\r | |
246 | sa[0] = msa.getModuleGuid();\r | |
247 | sa[1] = msa.getModuleVersion();\r | |
248 | sa[2] = msa.getPackageGuid();\r | |
249 | sa[3] = msa.getPackageVersion();\r | |
250 | sa[4] = listToString(msa.getSupArchList());\r | |
251 | }\r | |
252 | \r | |
a13899c5 | 253 | public ModuleSADocument.ModuleSA getModuleSA(String key) {\r |
254 | String[] s = key.split(" ");\r | |
5af6b67f | 255 | if (getfpdFrameworkModules().getModuleSAList() == null || getfpdFrameworkModules().getModuleSAList().size() == 0) {\r |
e232295e | 256 | removeElement(getfpdFrameworkModules());\r |
257 | fpdFrameworkModules = null;\r | |
a13899c5 | 258 | return null;\r |
259 | }\r | |
260 | ListIterator li = getfpdFrameworkModules().getModuleSAList().listIterator();\r | |
261 | while(li.hasNext()) {\r | |
1dac04ab | 262 | ModuleSADocument.ModuleSA moduleSa = (ModuleSADocument.ModuleSA)li.next();\r |
263 | if (moduleSa.getModuleGuid().equalsIgnoreCase(s[0]) && moduleSa.getPackageGuid().equalsIgnoreCase(s[2])) {\r | |
264 | if (moduleSa.getModuleVersion() != null) {\r | |
265 | if (!moduleSa.getModuleVersion().equals(s[1])) {\r | |
12e17a0a | 266 | continue;\r |
267 | }\r | |
268 | }\r | |
1dac04ab | 269 | if (moduleSa.getPackageVersion() != null) {\r |
270 | if (!moduleSa.getPackageVersion().equals(s[3])) {\r | |
12e17a0a | 271 | continue;\r |
272 | }\r | |
273 | }\r | |
bf5abaff | 274 | //ToDo add arch check for s[4]\r |
1dac04ab | 275 | if (moduleSa.getSupArchList() != null) {\r |
276 | if (!listToString(moduleSa.getSupArchList()).equals(s[4])) {\r | |
bf5abaff | 277 | continue;\r |
278 | }\r | |
279 | }\r | |
1dac04ab | 280 | return moduleSa;\r |
a13899c5 | 281 | }\r |
282 | }\r | |
283 | return null;\r | |
284 | }\r | |
bf5abaff | 285 | \r |
286 | private ModuleSADocument.ModuleSA getModuleSA(int i) {\r | |
1dac04ab | 287 | ModuleSADocument.ModuleSA moduleSa = null;\r |
e232295e | 288 | if (fpdRoot.getFrameworkModules() == null) {\r |
289 | return null;\r | |
290 | }\r | |
291 | XmlCursor cursor = fpdRoot.getFrameworkModules().newCursor();\r | |
bf5abaff | 292 | if (cursor.toFirstChild()) {\r |
293 | for (int j = 0; j < i; ++j) {\r | |
294 | cursor.toNextSibling();\r | |
295 | }\r | |
1dac04ab | 296 | moduleSa = (ModuleSADocument.ModuleSA)cursor.getObject();\r |
bf5abaff | 297 | }\r |
298 | cursor.dispose();\r | |
1dac04ab | 299 | return moduleSa;\r |
bf5abaff | 300 | }\r |
301 | \r | |
a13899c5 | 302 | public void removeModuleSA(int i) {\r |
e232295e | 303 | XmlObject o = fpdRoot.getFrameworkModules();\r |
a13899c5 | 304 | if (o == null) {\r |
305 | return;\r | |
306 | }\r | |
307 | \r | |
308 | XmlCursor cursor = o.newCursor();\r | |
309 | if (cursor.toFirstChild()) {\r | |
310 | for (int j = 0; j < i; ++j) {\r | |
311 | cursor.toNextSibling();\r | |
312 | }\r | |
313 | //\r | |
314 | // remove pcd from dynPcdMap, if DynamicPcdBuildData exists, remove them too.\r | |
315 | //\r | |
316 | ModuleSADocument.ModuleSA moduleSa = (ModuleSADocument.ModuleSA)cursor.getObject();\r | |
317 | String moduleInfo = moduleSa.getModuleGuid() + " " + moduleSa.getModuleVersion() + " " +\r | |
bf5abaff | 318 | moduleSa.getPackageGuid()+ " " + moduleSa.getPackageVersion() + " " + listToString(moduleSa.getSupArchList());\r |
a13899c5 | 319 | PcdBuildDefinitionDocument.PcdBuildDefinition pcdBuildDef = moduleSa.getPcdBuildDefinition();\r |
908b1c05 | 320 | if (pcdBuildDef != null && pcdBuildDef.getPcdDataList() != null) {\r |
321 | ListIterator<PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData> li = pcdBuildDef.getPcdDataList().listIterator();\r | |
322 | while(li.hasNext()) {\r | |
323 | PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData pcdData = li.next();\r | |
324 | maintainDynPcdMap(pcdData.getCName() + " " + pcdData.getTokenSpaceGuidCName(), moduleInfo);\r | |
325 | }\r | |
a13899c5 | 326 | }\r |
82dcbb45 | 327 | \r |
328 | cursor.push();\r | |
329 | cursor.toPrevToken();\r | |
330 | if (cursor.isComment()) {\r | |
331 | cursor.removeXml();\r | |
332 | }\r | |
333 | cursor.pop();\r | |
a13899c5 | 334 | cursor.removeXml();\r |
af25df16 | 335 | if (getFrameworkModulesCount() == 0) {\r |
336 | cursor.toParent();\r | |
337 | cursor.removeXml();\r | |
338 | }\r | |
a13899c5 | 339 | }\r |
340 | cursor.dispose();\r | |
341 | }\r | |
342 | \r | |
1dac04ab | 343 | public boolean adjustPcd (int seqModuleSa) throws Exception {\r |
344 | boolean dataModified = false;\r | |
345 | ModuleSADocument.ModuleSA moduleSa = getModuleSA(seqModuleSa);\r | |
346 | int pcdCount = getPcdDataCount(seqModuleSa);\r | |
347 | String[][] saaModuleSaPcd = new String[pcdCount][7];\r | |
348 | getPcdData(seqModuleSa, saaModuleSaPcd);\r | |
349 | String mg = moduleSa.getModuleGuid();\r | |
350 | String mv = moduleSa.getModuleVersion();\r | |
351 | String pg = moduleSa.getPackageGuid();\r | |
352 | String pv = moduleSa.getPackageVersion();\r | |
353 | String arch = listToString(moduleSa.getSupArchList());\r | |
354 | //\r | |
355 | // delete pcd in ModuleSA but not in MSA files any longer.\r | |
356 | //\r | |
357 | String moduleKey = mg + " " + mv + " " + pg + " " + pv + " " + arch;\r | |
358 | int libCount = getLibraryInstancesCount(moduleKey);\r | |
359 | String[][] saaLib = new String[libCount][5];\r | |
360 | getLibraryInstances(moduleKey, saaLib);\r | |
1bf9fa5a | 361 | ModuleIdentification mi = WorkspaceProfile.getModuleId(moduleKey);\r |
1dac04ab | 362 | Vector<ModuleIdentification> vMi = new Vector<ModuleIdentification>();\r |
607ef994 | 363 | //\r |
364 | // create vector for module & library instance MIs.\r | |
365 | //\r | |
1dac04ab | 366 | vMi.add(mi);\r |
607ef994 | 367 | for (int j = 0; j < saaLib.length; ++j) {\r |
368 | String libKey = saaLib[j][1] + " " + saaLib[j][2] + " " + saaLib[j][3] + " " + saaLib[j][4];\r | |
369 | ModuleIdentification libMi = WorkspaceProfile.getModuleId(libKey);\r | |
370 | vMi.add(libMi);\r | |
371 | }\r | |
372 | \r | |
1dac04ab | 373 | try {\r |
374 | nextPcd:for (int i = 0; i < saaModuleSaPcd.length; ++i) {\r | |
607ef994 | 375 | \r |
376 | for (int j = 0; j < vMi.size(); ++j) {\r | |
377 | ModuleIdentification nextMi = vMi.get(j);\r | |
378 | if (WorkspaceProfile.pcdInMsa(saaModuleSaPcd[i][0], saaModuleSaPcd[i][1], nextMi)) {\r | |
1dac04ab | 379 | continue nextPcd;\r |
380 | }\r | |
381 | }\r | |
382 | removePcdData(seqModuleSa, saaModuleSaPcd[i][0], saaModuleSaPcd[i][1]);\r | |
383 | dataModified = true;\r | |
384 | }\r | |
385 | }\r | |
386 | catch (Exception e) {\r | |
607ef994 | 387 | throw e;\r |
1dac04ab | 388 | }\r |
389 | //\r | |
390 | // add new Pcd from MSA file to ModuleSA.\r | |
391 | //\r | |
392 | try {\r | |
393 | \r | |
394 | for (int i = 0; i < vMi.size(); ++i) {\r | |
1bf9fa5a | 395 | ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = (ModuleSurfaceAreaDocument.ModuleSurfaceArea) WorkspaceProfile\r |
1dac04ab | 396 | .getModuleXmlObject(vMi\r |
397 | .get(i));\r | |
398 | if (msa.getPcdCoded() == null || msa.getPcdCoded().getPcdEntryList() == null) {\r | |
399 | continue;\r | |
400 | }\r | |
401 | ListIterator li = msa.getPcdCoded().getPcdEntryList().listIterator();\r | |
402 | msaPcdIter:while (li.hasNext()) {\r | |
403 | PcdCodedDocument.PcdCoded.PcdEntry msaPcd = (PcdCodedDocument.PcdCoded.PcdEntry) li.next();\r | |
404 | ArrayList<String> al = getDynPcdMapValue(msaPcd.getCName() + " " + msaPcd.getTokenSpaceGuidCName());\r | |
405 | if (al != null) {\r | |
406 | for (int j = 0; j < al.size(); ++j) {\r | |
407 | if (al.get(j).contains(moduleKey)) {\r | |
408 | continue msaPcdIter;\r | |
409 | }\r | |
410 | }\r | |
411 | }\r | |
412 | \r | |
daa4663b | 413 | PackageIdentification[] depPkgs = SurfaceAreaQuery.getDependencePkg(null, vMi.get(i));\r |
1dac04ab | 414 | PcdDeclarationsDocument.PcdDeclarations.PcdEntry spdPcd = LookupPcdDeclaration(msaPcd, depPkgs);\r |
415 | if (spdPcd == null) {\r | |
416 | //\r | |
417 | // ToDo Error \r | |
418 | //\r | |
419 | throw new PcdDeclNotFound("No Declaration for PCD Entry " + msaPcd.getCName() + " in Module "\r | |
420 | + mi.getName());\r | |
421 | }\r | |
422 | //\r | |
423 | // AddItem to ModuleSA PcdBuildDefinitions\r | |
424 | //\r | |
425 | String defaultVal = msaPcd.getDefaultValue() == null ? spdPcd.getDefaultValue()\r | |
426 | : msaPcd.getDefaultValue();\r | |
427 | \r | |
428 | genPcdData(msaPcd.getCName(), spdPcd.getToken(), msaPcd.getTokenSpaceGuidCName(),\r | |
429 | msaPcd.getPcdItemType().toString(), spdPcd.getDatumType() + "", defaultVal, moduleSa);\r | |
430 | dataModified = true;\r | |
431 | }\r | |
432 | \r | |
433 | }\r | |
434 | }\r | |
435 | catch (Exception e){\r | |
436 | throw e;\r | |
437 | }\r | |
438 | \r | |
439 | return dataModified;\r | |
440 | }\r | |
441 | \r | |
908b1c05 | 442 | private void maintainDynPcdMap(String pcdKey, String moduleInfo) {\r |
443 | \r | |
444 | ArrayList<String> al = dynPcdMap.get(pcdKey);\r | |
445 | if (al == null) {\r | |
a13899c5 | 446 | return;\r |
447 | }\r | |
908b1c05 | 448 | String[] s = moduleInfo.split(" ");\r |
a13899c5 | 449 | for(int i = 0; i < al.size(); ++i){\r |
908b1c05 | 450 | String consumer = al.get(i);\r |
451 | if (consumer.contains(s[0]) && consumer.contains(s[2])){\r | |
bf5abaff | 452 | String[] consumerPart = consumer.split(" ");\r |
453 | if (!consumerPart[4].equals(s[4])) {\r | |
454 | continue;\r | |
455 | }\r | |
908b1c05 | 456 | al.remove(consumer);\r |
a13899c5 | 457 | break;\r |
458 | }\r | |
459 | }\r | |
908b1c05 | 460 | \r |
a13899c5 | 461 | if (al.size() == 0) {\r |
1bf9fa5a | 462 | defaultPcdValue.remove(pcdKey);\r |
a13899c5 | 463 | dynPcdMap.remove(pcdKey);\r |
908b1c05 | 464 | String[] s1 = pcdKey.split(" ");\r |
465 | removeDynamicPcdBuildData(s1[0], s1[1]);\r | |
a13899c5 | 466 | }\r |
467 | \r | |
a13899c5 | 468 | }\r |
469 | //\r | |
bf5abaff | 470 | // key for ModuleSA : "ModuleGuid ModuleVer PackageGuid PackageVer Arch"\r |
a13899c5 | 471 | //\r |
1dac04ab | 472 | public int getPcdDataCount (int i){\r |
bf5abaff | 473 | ModuleSADocument.ModuleSA msa = getModuleSA(i);\r |
055e7ae6 | 474 | \r |
a13899c5 | 475 | if (msa == null || msa.getPcdBuildDefinition() == null || msa.getPcdBuildDefinition().getPcdDataList() == null){\r |
476 | return 0;\r | |
477 | }\r | |
478 | return msa.getPcdBuildDefinition().getPcdDataList().size();\r | |
055e7ae6 | 479 | \r |
a13899c5 | 480 | }\r |
481 | \r | |
1dac04ab | 482 | public void getPcdData (int i, String[][] saa) {\r |
bf5abaff | 483 | ModuleSADocument.ModuleSA msa = getModuleSA(i);\r |
055e7ae6 | 484 | \r |
a13899c5 | 485 | if (msa == null || msa.getPcdBuildDefinition() == null || msa.getPcdBuildDefinition().getPcdDataList() == null){\r |
486 | return;\r | |
487 | }\r | |
488 | ListIterator<PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData>li = msa.getPcdBuildDefinition().getPcdDataList().listIterator();\r | |
055e7ae6 | 489 | for (int k = 0; k < saa.length; ++k) {\r |
a13899c5 | 490 | PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData pcdData = li.next();\r |
055e7ae6 | 491 | saa[k][0] = pcdData.getCName();\r |
492 | saa[k][1] = pcdData.getTokenSpaceGuidCName();\r | |
493 | saa[k][2] = pcdData.getItemType()+"";\r | |
494 | saa[k][3] = pcdData.getToken().toString();\r | |
495 | saa[k][4] = pcdData.getMaxDatumSize()+"";\r | |
496 | saa[k][5] = pcdData.getDatumType()+"";\r | |
497 | saa[k][6] = pcdData.getValue();\r | |
a13899c5 | 498 | \r |
499 | }\r | |
500 | }\r | |
908b1c05 | 501 | \r |
1dac04ab | 502 | public void removePcdData (int seqModuleSa, String cName, String tsGuid) {\r |
503 | ModuleSADocument.ModuleSA moduleSa = getModuleSA(seqModuleSa);\r | |
504 | if (moduleSa == null || moduleSa.getPcdBuildDefinition() == null){\r | |
908b1c05 | 505 | return;\r |
506 | }\r | |
507 | \r | |
1dac04ab | 508 | String mg = moduleSa.getModuleGuid();\r |
509 | String mv = moduleSa.getModuleVersion();\r | |
510 | String pg = moduleSa.getPackageGuid();\r | |
511 | String pv = moduleSa.getPackageVersion();\r | |
512 | String arch = listToString(moduleSa.getSupArchList());\r | |
513 | String moduleKey = mg + " " + mv + " " + pg + " " + pv + " " + arch;\r | |
514 | \r | |
515 | XmlCursor cursor = moduleSa.getPcdBuildDefinition().newCursor();\r | |
516 | if (cursor.toFirstChild()){\r | |
517 | \r | |
518 | do {\r | |
519 | PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData pcdData = (PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData)cursor.getObject();\r | |
520 | if (pcdData.getCName().equals(cName) && pcdData.getTokenSpaceGuidCName().equals(tsGuid)) {\r | |
521 | maintainDynPcdMap(cName + " " + tsGuid, moduleKey);\r | |
522 | if (getPcdDataCount(seqModuleSa) == 1) {\r | |
523 | cursor.toParent();\r | |
524 | }\r | |
525 | cursor.removeXml();\r | |
526 | break;\r | |
527 | }\r | |
528 | }\r | |
529 | while(cursor.toNextSibling());\r | |
530 | \r | |
531 | }\r | |
532 | cursor.dispose();\r | |
533 | }\r | |
534 | \r | |
535 | public void updatePcdData (String key, String cName, String tsGuid, String itemType, String maxSize, String value){\r | |
536 | ModuleSADocument.ModuleSA moduleSa = getModuleSA(key);\r | |
537 | if (moduleSa == null || moduleSa.getPcdBuildDefinition() == null){\r | |
538 | return;\r | |
539 | }\r | |
540 | \r | |
541 | XmlCursor cursor = moduleSa.getPcdBuildDefinition().newCursor();\r | |
908b1c05 | 542 | if (cursor.toFirstChild()){\r |
543 | do {\r | |
544 | PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData pcdData = (PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData)cursor.getObject();\r | |
545 | if (pcdData.getCName().equals(cName) && pcdData.getTokenSpaceGuidCName().equals(tsGuid)) {\r | |
546 | pcdData.setItemType(PcdItemTypes.Enum.forString(itemType));\r | |
547 | if(pcdData.getDatumType().equals("VOID*")) {\r | |
548 | pcdData.setMaxDatumSize(new Integer(maxSize));\r | |
549 | }\r | |
550 | pcdData.setValue(value);\r | |
1bf9fa5a | 551 | defaultPcdValue.put(cName + " " + tsGuid, value);\r |
908b1c05 | 552 | break;\r |
553 | }\r | |
554 | }\r | |
555 | while(cursor.toNextSibling());\r | |
556 | }\r | |
557 | cursor.dispose();\r | |
558 | }\r | |
559 | \r | |
560 | /**Get original Pcd info from MSA & SPD files.\r | |
561 | * @param mi ModuleIdentification from which MSA & SPD come\r | |
562 | * @param cName PCD cName\r | |
563 | * @param sa Results: HelpText, Original item type.\r | |
564 | * @return\r | |
565 | */\r | |
1dac04ab | 566 | public boolean getPcdBuildDataInfo(ModuleIdentification mi, String cName, String tsGuid, String[] sa) throws Exception{\r |
908b1c05 | 567 | try {\r |
568 | \r | |
1bf9fa5a | 569 | ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = (ModuleSurfaceAreaDocument.ModuleSurfaceArea)WorkspaceProfile.getModuleXmlObject(mi);\r |
908b1c05 | 570 | if (msa.getPcdCoded() == null) {\r |
571 | return false;\r | |
572 | }\r | |
573 | \r | |
574 | Map<String, XmlObject> m = new HashMap<String, XmlObject>();\r | |
575 | m.put("ModuleSurfaceArea", msa);\r | |
576 | SurfaceAreaQuery.setDoc(m);\r | |
daa4663b | 577 | PackageIdentification[] depPkgs = SurfaceAreaQuery.getDependencePkg(null, mi);\r |
908b1c05 | 578 | //\r |
579 | // First look through MSA pcd entries.\r | |
580 | //\r | |
581 | List<PcdCodedDocument.PcdCoded.PcdEntry> l = msa.getPcdCoded().getPcdEntryList();\r | |
582 | ListIterator li = l.listIterator();\r | |
583 | while(li.hasNext()) {\r | |
584 | PcdCodedDocument.PcdCoded.PcdEntry msaPcd = (PcdCodedDocument.PcdCoded.PcdEntry)li.next();\r | |
585 | if (!msaPcd.getCName().equals(cName)) {\r | |
586 | continue;\r | |
587 | }\r | |
1dac04ab | 588 | if (!msaPcd.getTokenSpaceGuidCName().equals(tsGuid)) {\r |
589 | continue;\r | |
590 | }\r | |
908b1c05 | 591 | PcdDeclarationsDocument.PcdDeclarations.PcdEntry spdPcd = LookupPcdDeclaration(msaPcd, depPkgs);\r |
592 | if (spdPcd == null) {\r | |
593 | //\r | |
594 | // ToDo Error \r | |
595 | //\r | |
596 | throw new PcdDeclNotFound(mi.getName() + " " + msaPcd.getCName());\r | |
597 | }\r | |
598 | //\r | |
599 | // Get Pcd help text and original item type.\r | |
600 | //\r | |
601 | sa[0] = spdPcd.getHelpText() + msaPcd.getHelpText();\r | |
602 | sa[1] = msaPcd.getPcdItemType()+"";\r | |
603 | return true;\r | |
604 | }\r | |
605 | \r | |
606 | \r | |
607 | }\r | |
608 | catch (Exception e){\r | |
e232295e | 609 | e.printStackTrace();\r |
908b1c05 | 610 | throw e;\r |
611 | }\r | |
612 | \r | |
613 | return false;\r | |
614 | }\r | |
615 | \r | |
616 | /**Remove PCDBuildDefinition entries from ModuleSA\r | |
617 | * @param moduleKey identifier of ModuleSA.\r | |
618 | * @param consumer where these entries come from.\r | |
619 | */\r | |
620 | public void removePcdData(String moduleKey, ModuleIdentification consumer) {\r | |
621 | try {\r | |
1bf9fa5a | 622 | ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = (ModuleSurfaceAreaDocument.ModuleSurfaceArea)WorkspaceProfile.getModuleXmlObject(consumer);\r |
908b1c05 | 623 | if (msa.getPcdCoded() == null) {\r |
624 | return;\r | |
625 | }\r | |
626 | \r | |
627 | List<PcdCodedDocument.PcdCoded.PcdEntry> l = msa.getPcdCoded().getPcdEntryList();\r | |
628 | ListIterator li = l.listIterator();\r | |
629 | \r | |
630 | while(li.hasNext()) {\r | |
631 | PcdCodedDocument.PcdCoded.PcdEntry msaPcd = (PcdCodedDocument.PcdCoded.PcdEntry)li.next();\r | |
632 | ModuleSADocument.ModuleSA moduleSA = getModuleSA(moduleKey);\r | |
82dcbb45 | 633 | if (moduleSA.getPcdBuildDefinition() != null) {\r |
634 | XmlCursor cursor = moduleSA.getPcdBuildDefinition().newCursor();\r | |
635 | if (cursor.toFirstChild()) {\r | |
a094728f | 636 | do {\r |
637 | PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData pcdData = (PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData) cursor\r | |
638 | .getObject();\r | |
82dcbb45 | 639 | if (msaPcd.getCName().equals(pcdData.getCName())\r |
640 | && msaPcd.getTokenSpaceGuidCName().equals(pcdData.getTokenSpaceGuidCName())) {\r | |
a094728f | 641 | \r |
82dcbb45 | 642 | maintainDynPcdMap(pcdData.getCName() + " " + pcdData.getTokenSpaceGuidCName(),\r |
643 | moduleKey);\r | |
644 | cursor.removeXml();\r | |
645 | break;\r | |
646 | }\r | |
a094728f | 647 | } while (cursor.toNextSibling());\r |
908b1c05 | 648 | }\r |
82dcbb45 | 649 | cursor.dispose();\r |
908b1c05 | 650 | }\r |
908b1c05 | 651 | }\r |
652 | \r | |
653 | }\r | |
654 | catch (Exception e){\r | |
655 | e.printStackTrace();\r | |
656 | \r | |
657 | }\r | |
658 | }\r | |
a13899c5 | 659 | //\r |
bf5abaff | 660 | // key for ModuleSA : "ModuleGuid ModuleVer PackageGuid PackageVer Arch"\r |
a13899c5 | 661 | //\r |
662 | public int getLibraryInstancesCount(String key) {\r | |
663 | ModuleSADocument.ModuleSA msa = getModuleSA(key);\r | |
664 | if (msa == null || msa.getLibraries() == null || msa.getLibraries().getInstanceList() == null){\r | |
665 | return 0;\r | |
666 | }\r | |
667 | return msa.getLibraries().getInstanceList().size();\r | |
668 | }\r | |
669 | \r | |
670 | public void getLibraryInstances(String key, String[][] saa){\r | |
671 | ModuleSADocument.ModuleSA msa = getModuleSA(key);\r | |
672 | if (msa == null || msa.getLibraries() == null || msa.getLibraries().getInstanceList() == null){\r | |
673 | return ;\r | |
674 | }\r | |
675 | \r | |
676 | ListIterator<LibrariesDocument.Libraries.Instance> li = msa.getLibraries().getInstanceList().listIterator();\r | |
677 | for (int i = 0; i < saa.length; ++i) {\r | |
678 | LibrariesDocument.Libraries.Instance instance = li.next();\r | |
679 | saa[i][1] = instance.getModuleGuid();\r | |
680 | saa[i][2] = instance.getModuleVersion();\r | |
681 | saa[i][3] = instance.getPackageGuid();\r | |
682 | saa[i][4] = instance.getPackageVersion();\r | |
683 | }\r | |
684 | }\r | |
685 | \r | |
908b1c05 | 686 | public void removeLibraryInstance(String key, int i) {\r |
a13899c5 | 687 | ModuleSADocument.ModuleSA msa = getModuleSA(key);\r |
688 | if (msa == null || msa.getLibraries() == null){\r | |
689 | return ;\r | |
690 | }\r | |
691 | \r | |
692 | XmlCursor cursor = msa.getLibraries().newCursor();\r | |
908b1c05 | 693 | if (cursor.toFirstChild()) {\r |
694 | for (int j = 0; j < i; ++j) {\r | |
695 | cursor.toNextSibling();\r | |
696 | }\r | |
82dcbb45 | 697 | cursor.push();\r |
698 | cursor.toPrevToken();\r | |
699 | if (cursor.isComment()) {\r | |
700 | cursor.removeXml();\r | |
701 | }\r | |
702 | cursor.pop();\r | |
908b1c05 | 703 | cursor.removeXml();\r |
82dcbb45 | 704 | if (getLibraryInstancesCount(key) == 0) {\r |
705 | cursor.toParent();\r | |
706 | cursor.removeXml();\r | |
707 | }\r | |
908b1c05 | 708 | }\r |
709 | \r | |
a13899c5 | 710 | cursor.dispose();\r |
711 | }\r | |
712 | \r | |
82dcbb45 | 713 | public void genLibraryInstance(ModuleIdentification libMi, String key) {\r |
a13899c5 | 714 | ModuleSADocument.ModuleSA msa = getModuleSA(key);\r |
715 | if (msa == null){\r | |
716 | msa = getfpdFrameworkModules().addNewModuleSA();\r | |
717 | }\r | |
718 | LibrariesDocument.Libraries libs = msa.getLibraries();\r | |
719 | if(libs == null){\r | |
720 | libs = msa.addNewLibraries();\r | |
721 | }\r | |
722 | \r | |
82dcbb45 | 723 | String mn = libMi.getName();\r |
724 | String mg = libMi.getGuid();\r | |
725 | String mv = libMi.getVersion();\r | |
3658f95e | 726 | String pn = libMi.getPackageId().getName();\r |
727 | String pg = libMi.getPackageId().getGuid();\r | |
728 | String pv = libMi.getPackageId().getVersion();\r | |
a13899c5 | 729 | LibrariesDocument.Libraries.Instance instance = libs.addNewInstance();\r |
82dcbb45 | 730 | XmlCursor cursor = instance.newCursor();\r |
731 | try{\r | |
732 | String comment = "Pkg: " + pn + " Mod: " + mn \r | |
3658f95e | 733 | + " Path: " + libMi.getPath().substring(System.getenv("WORKSPACE").length() + 1);\r |
82dcbb45 | 734 | cursor.insertComment(comment);\r |
735 | }\r | |
736 | catch (Exception e){\r | |
737 | e.printStackTrace();\r | |
738 | }\r | |
739 | finally {\r | |
740 | cursor.dispose();\r | |
741 | }\r | |
742 | \r | |
a13899c5 | 743 | instance.setModuleGuid(mg);\r |
744 | instance.setModuleVersion(mv);\r | |
745 | instance.setPackageGuid(pg);\r | |
746 | instance.setPackageVersion(pv);\r | |
747 | \r | |
748 | }\r | |
1800d80f | 749 | \r |
750 | public String getFvBinding(String moduleKey){\r | |
eb8ea829 | 751 | ModuleSADocument.ModuleSA moduleSa = getModuleSA(moduleKey);\r |
752 | return getFvBinding (moduleSa);\r | |
753 | }\r | |
754 | \r | |
755 | public String getFvBinding (ModuleSADocument.ModuleSA moduleSa) {\r | |
756 | if (moduleSa == null || moduleSa.getModuleSaBuildOptions() == null) {\r | |
1800d80f | 757 | return null;\r |
758 | }\r | |
eb8ea829 | 759 | return moduleSa.getModuleSaBuildOptions().getFvBinding();\r |
1800d80f | 760 | }\r |
761 | \r | |
2b70a636 | 762 | public void setFvBinding(ModuleSADocument.ModuleSA moduleSa, String fvBinding) {\r |
763 | if (moduleSa == null ) {\r | |
1800d80f | 764 | return;\r |
765 | }\r | |
61919f8c | 766 | if (fvBinding == null || fvBinding.length() == 0) {\r |
2b70a636 | 767 | if(moduleSa.getModuleSaBuildOptions() != null){\r |
768 | moduleSa.getModuleSaBuildOptions().unsetFvBinding();\r | |
61919f8c | 769 | }\r |
770 | }\r | |
771 | else {\r | |
2b70a636 | 772 | if(moduleSa.getModuleSaBuildOptions() == null){\r |
773 | moduleSa.addNewModuleSaBuildOptions().setFvBinding(fvBinding);\r | |
61919f8c | 774 | return;\r |
775 | }\r | |
2b70a636 | 776 | moduleSa.getModuleSaBuildOptions().setFvBinding(fvBinding);\r |
777 | }\r | |
778 | }\r | |
779 | \r | |
780 | public void setFvBinding(String moduleKey, String fvBinding){\r | |
781 | ModuleSADocument.ModuleSA moduleSa = getModuleSA(moduleKey);\r | |
782 | setFvBinding (moduleSa, fvBinding);\r | |
783 | }\r | |
784 | \r | |
eb8ea829 | 785 | private int fvBindingForModuleSA (ModuleSADocument.ModuleSA moduleSa, String fvName) {\r |
786 | if (moduleSa == null || moduleSa.getModuleSaBuildOptions() == null || moduleSa.getModuleSaBuildOptions().getFvBinding() == null) {\r | |
787 | return -1;\r | |
788 | }\r | |
789 | \r | |
790 | String fvNameList = moduleSa.getModuleSaBuildOptions().getFvBinding();\r | |
791 | String[] fvNamesArray = fvNameList.split(" ");\r | |
792 | int occursAt = -1;\r | |
793 | for (int i = 0; i < fvNamesArray.length; ++i) {\r | |
794 | if (fvNamesArray[i].equals(fvName)) {\r | |
795 | occursAt = i;\r | |
796 | break;\r | |
797 | }\r | |
798 | }\r | |
799 | return occursAt;\r | |
800 | }\r | |
801 | \r | |
2b70a636 | 802 | public void removeFvBinding (ModuleSADocument.ModuleSA moduleSa, String fvName) {\r |
803 | if (moduleSa == null || moduleSa.getModuleSaBuildOptions() == null || moduleSa.getModuleSaBuildOptions().getFvBinding() == null) {\r | |
804 | return;\r | |
805 | }\r | |
806 | \r | |
807 | String fvNameList = moduleSa.getModuleSaBuildOptions().getFvBinding();\r | |
808 | String[] fvNamesArray = fvNameList.split(" ");\r | |
809 | int occursAt = -1;\r | |
810 | for (int i = 0; i < fvNamesArray.length; ++i) {\r | |
811 | if (fvNamesArray[i].equals(fvName)) {\r | |
812 | occursAt = i;\r | |
813 | break;\r | |
814 | }\r | |
815 | }\r | |
816 | // jump over where the input fvName occurs in the original Fv list.\r | |
817 | if (occursAt != -1) {\r | |
818 | String newFvNameList = " ";\r | |
819 | for (int i = 0; i < fvNamesArray.length; ++i) {\r | |
820 | if (i == occursAt) {\r | |
821 | continue;\r | |
822 | }\r | |
823 | newFvNameList += fvNamesArray[i];\r | |
824 | }\r | |
825 | setFvBinding (moduleSa, newFvNameList.trim());\r | |
826 | }\r | |
827 | \r | |
828 | }\r | |
829 | \r | |
830 | /**\r | |
831 | * @param fvName The FV name that to be removed from FvBinding List.\r | |
832 | */\r | |
833 | public void removeFvBindingAll (String fvName) {\r | |
834 | if (getfpdFrameworkModules().getModuleSAList() == null || getfpdFrameworkModules().getModuleSAList().size() == 0){\r | |
835 | removeElement(getfpdFrameworkModules());\r | |
836 | fpdFrameworkModules = null;\r | |
837 | return;\r | |
838 | }\r | |
839 | \r | |
840 | Iterator<ModuleSADocument.ModuleSA> li = getfpdFrameworkModules().getModuleSAList().iterator();\r | |
841 | while (li.hasNext()) {\r | |
842 | ModuleSADocument.ModuleSA moduleSa = li.next();\r | |
843 | removeFvBinding (moduleSa, fvName); \r | |
844 | }\r | |
845 | }\r | |
846 | \r | |
eb8ea829 | 847 | public void appendFvBindingAll (String fvName) {\r |
848 | if (getfpdFrameworkModules().getModuleSAList() == null || getfpdFrameworkModules().getModuleSAList().size() == 0){\r | |
849 | removeElement(getfpdFrameworkModules());\r | |
850 | fpdFrameworkModules = null;\r | |
851 | return;\r | |
852 | }\r | |
853 | \r | |
854 | Iterator<ModuleSADocument.ModuleSA> li = getfpdFrameworkModules().getModuleSAList().iterator();\r | |
855 | while (li.hasNext()) {\r | |
856 | ModuleSADocument.ModuleSA moduleSa = li.next();\r | |
857 | appendFvBinding (moduleSa, fvName); \r | |
858 | }\r | |
859 | }\r | |
860 | \r | |
861 | public void appendFvBindingFor (String oldFvName, String newFvName) {\r | |
862 | if (getfpdFrameworkModules().getModuleSAList() == null || getfpdFrameworkModules().getModuleSAList().size() == 0){\r | |
863 | removeElement(getfpdFrameworkModules());\r | |
864 | fpdFrameworkModules = null;\r | |
865 | return;\r | |
866 | }\r | |
867 | \r | |
868 | Iterator<ModuleSADocument.ModuleSA> li = getfpdFrameworkModules().getModuleSAList().iterator();\r | |
869 | while (li.hasNext()) {\r | |
870 | ModuleSADocument.ModuleSA moduleSa = li.next();\r | |
871 | String fvBinding = getFvBinding (moduleSa);\r | |
872 | if (fvBinding != null && fvBindingForModuleSA (moduleSa, oldFvName) >= 0) {\r | |
873 | appendFvBinding (moduleSa, newFvName); \r | |
874 | }\r | |
875 | }\r | |
876 | }\r | |
877 | \r | |
2b70a636 | 878 | public void appendFvBinding (String moduleKey, String fvName) {\r |
879 | ModuleSADocument.ModuleSA moduleSa = getModuleSA(moduleKey);\r | |
880 | appendFvBinding (moduleSa, fvName);\r | |
881 | }\r | |
882 | \r | |
883 | public void appendFvBinding (ModuleSADocument.ModuleSA moduleSa, String fvName) {\r | |
884 | if (moduleSa == null) {\r | |
885 | return;\r | |
886 | }\r | |
887 | \r | |
888 | if (moduleSa.getModuleSaBuildOptions() == null || moduleSa.getModuleSaBuildOptions().getFvBinding() == null) {\r | |
889 | setFvBinding(moduleSa, fvName);\r | |
890 | return;\r | |
891 | }\r | |
892 | \r | |
893 | String fvNameList = moduleSa.getModuleSaBuildOptions().getFvBinding();\r | |
894 | String newFvNameList = fvNameList + " " + fvName;\r | |
895 | setFvBinding (moduleSa, newFvNameList.trim());\r | |
896 | }\r | |
897 | \r | |
898 | public void updateFvBindingInModuleSA (ModuleIdentification mi, String fvName) {\r | |
899 | Vector<Object> vSupArchs = new Vector<Object>();\r | |
900 | getPlatformDefsSupportedArchs(vSupArchs);\r | |
901 | String moduleInfo = mi.getGuid() + " " + mi.getVersion() + " " + mi.getPackageId().getGuid() + " " + mi.getPackageId().getVersion();\r | |
902 | for (int i = 0; i < vSupArchs.size(); ++i) {\r | |
903 | String moduleKey = moduleInfo + " " + vSupArchs.get(i);\r | |
904 | appendFvBinding (moduleKey, fvName);\r | |
1800d80f | 905 | }\r |
1800d80f | 906 | }\r |
907 | \r | |
908 | public String getFfsFileNameGuid(String moduleKey){\r | |
2b70a636 | 909 | ModuleSADocument.ModuleSA moduleSa = getModuleSA(moduleKey);\r |
910 | if (moduleSa == null || moduleSa.getModuleSaBuildOptions() == null) {\r | |
1800d80f | 911 | return null;\r |
912 | }\r | |
2b70a636 | 913 | return moduleSa.getModuleSaBuildOptions().getFfsFileNameGuid();\r |
1800d80f | 914 | }\r |
915 | \r | |
916 | public void setFfsFileNameGuid(String moduleKey, String fileGuid){\r | |
917 | ModuleSADocument.ModuleSA msa = getModuleSA(moduleKey);\r | |
918 | if (msa == null ) {\r | |
919 | return;\r | |
920 | }\r | |
921 | if(msa.getModuleSaBuildOptions() == null){\r | |
8f55ea73 | 922 | msa.addNewModuleSaBuildOptions();\r |
923 | \r | |
1800d80f | 924 | }\r |
8f55ea73 | 925 | ModuleSaBuildOptionsDocument.ModuleSaBuildOptions msaBuildOpts= msa.getModuleSaBuildOptions();\r |
926 | if (fileGuid != null) {\r | |
927 | msaBuildOpts.setFfsFileNameGuid(fileGuid);\r | |
928 | }\r | |
929 | else{\r | |
930 | XmlCursor cursor = msaBuildOpts.newCursor();\r | |
931 | if (cursor.toChild(xmlNs, "FfsFileNameGuid")) {\r | |
932 | cursor.removeXml();\r | |
933 | }\r | |
934 | cursor.dispose();\r | |
935 | }\r | |
936 | \r | |
1800d80f | 937 | }\r |
938 | \r | |
939 | public String getFfsFormatKey(String moduleKey){\r | |
940 | ModuleSADocument.ModuleSA msa = getModuleSA(moduleKey);\r | |
941 | if (msa == null || msa.getModuleSaBuildOptions() == null) {\r | |
942 | return null;\r | |
943 | }\r | |
944 | return msa.getModuleSaBuildOptions().getFfsFormatKey();\r | |
945 | }\r | |
946 | \r | |
947 | public void setFfsFormatKey(String moduleKey, String ffsKey){\r | |
948 | ModuleSADocument.ModuleSA msa = getModuleSA(moduleKey);\r | |
949 | if (msa == null ) {\r | |
950 | return;\r | |
951 | }\r | |
952 | if(msa.getModuleSaBuildOptions() == null){\r | |
953 | msa.addNewModuleSaBuildOptions().setFfsFormatKey(ffsKey);\r | |
954 | return;\r | |
955 | }\r | |
bf5abaff | 956 | msa.getModuleSaBuildOptions().setFfsFormatKey(ffsKey);\r |
1800d80f | 957 | }\r |
958 | \r | |
e7cc0547 | 959 | public void setModuleSAForceDebug(int i, boolean dbgEnable) {\r |
960 | ModuleSADocument.ModuleSA moduleSa = getModuleSA(i);\r | |
961 | moduleSa.setForceDebug(dbgEnable);\r | |
962 | }\r | |
963 | \r | |
964 | public boolean getModuleSAForceDebug (int i) {\r | |
965 | ModuleSADocument.ModuleSA moduleSa = getModuleSA(i);\r | |
966 | if (moduleSa.getForceDebug() == true) {\r | |
967 | return true;\r | |
968 | }\r | |
969 | return false;\r | |
970 | }\r | |
971 | \r | |
1800d80f | 972 | public void getModuleSAOptions(String moduleKey, String[][] saa) {\r |
973 | ModuleSADocument.ModuleSA msa = getModuleSA(moduleKey);\r | |
e232295e | 974 | if (msa == null || msa.getModuleSaBuildOptions() == null || msa.getModuleSaBuildOptions().getOptions() == null\r |
1800d80f | 975 | || msa.getModuleSaBuildOptions().getOptions().getOptionList() == null) {\r |
976 | return ;\r | |
977 | }\r | |
978 | \r | |
979 | List<OptionDocument.Option> lOpt = msa.getModuleSaBuildOptions().getOptions().getOptionList();\r | |
980 | ListIterator li = lOpt.listIterator();\r | |
981 | int i = 0;\r | |
982 | while(li.hasNext()) {\r | |
983 | OptionDocument.Option opt = (OptionDocument.Option)li.next();\r | |
984 | if (opt.getBuildTargets() != null) {\r | |
985 | saa[i][0] = listToString(opt.getBuildTargets());\r | |
986 | }\r | |
987 | saa[i][1] = opt.getToolChainFamily();\r | |
bf5abaff | 988 | saa[i][2] = opt.getTagName();\r |
989 | saa[i][3] = opt.getToolCode();\r | |
990 | \r | |
1800d80f | 991 | if (opt.getSupArchList() != null){\r |
bf5abaff | 992 | saa[i][4] = listToString(opt.getSupArchList());\r |
98c20797 | 993 | }\r |
994 | else {\r | |
995 | saa[i][4] = "";\r | |
1800d80f | 996 | }\r |
bf5abaff | 997 | \r |
1800d80f | 998 | saa[i][5] = opt.getStringValue();\r |
999 | \r | |
1000 | ++i;\r | |
1001 | }\r | |
1002 | }\r | |
1003 | \r | |
1004 | public int getModuleSAOptionsCount(String moduleKey){\r | |
1005 | ModuleSADocument.ModuleSA msa = getModuleSA(moduleKey);\r | |
e232295e | 1006 | if (msa == null || msa.getModuleSaBuildOptions() == null || msa.getModuleSaBuildOptions().getOptions() == null\r |
1800d80f | 1007 | || msa.getModuleSaBuildOptions().getOptions().getOptionList() == null) {\r |
1008 | return 0;\r | |
1009 | }\r | |
1010 | return msa.getModuleSaBuildOptions().getOptions().getOptionList().size();\r | |
1011 | }\r | |
1012 | \r | |
1013 | public void genModuleSAOptionsOpt(String moduleKey, Vector<Object> buildTargets, String toolChain, String tagName, String toolCmd, Vector<Object> archList, String contents) {\r | |
1014 | ModuleSADocument.ModuleSA msa = getModuleSA(moduleKey);\r | |
1015 | if (msa.getModuleSaBuildOptions() == null) {\r | |
1016 | msa.addNewModuleSaBuildOptions();\r | |
1017 | }\r | |
1018 | if (msa.getModuleSaBuildOptions().getOptions() == null){\r | |
1019 | msa.getModuleSaBuildOptions().addNewOptions();\r | |
1020 | }\r | |
1021 | OptionDocument.Option opt = msa.getModuleSaBuildOptions().getOptions().addNewOption();\r | |
1022 | setBuildOptionsOpt(buildTargets, toolChain, tagName, toolCmd, archList, contents, opt);\r | |
1023 | }\r | |
1024 | \r | |
1025 | public void removeModuleSAOptionsOpt(String moduleKey, int i) {\r | |
1026 | ModuleSADocument.ModuleSA msa = getModuleSA(moduleKey);\r | |
1027 | if (msa.getModuleSaBuildOptions() == null || msa.getModuleSaBuildOptions().getOptions() == null) {\r | |
1028 | return ;\r | |
1029 | }\r | |
1030 | OptionsDocument.Options opts = msa.getModuleSaBuildOptions().getOptions();\r | |
1031 | XmlCursor cursor = opts.newCursor();\r | |
1032 | if (cursor.toFirstChild()) {\r | |
1033 | for (int j = 0; j < i; ++j){\r | |
1034 | cursor.toNextSibling();\r | |
1035 | }\r | |
1036 | cursor.removeXml();\r | |
1037 | }\r | |
1038 | cursor.dispose();\r | |
1039 | }\r | |
1040 | \r | |
1041 | public void updateModuleSAOptionsOpt(String moduleKey, int i, Vector<Object> buildTargets, String toolChain, String tagName, String toolCmd, Vector<Object> archList, String contents) {\r | |
1042 | ModuleSADocument.ModuleSA msa = getModuleSA(moduleKey);\r | |
1043 | if (msa.getModuleSaBuildOptions() == null || msa.getModuleSaBuildOptions().getOptions() == null) {\r | |
1044 | return ;\r | |
1045 | }\r | |
1046 | OptionsDocument.Options opts = msa.getModuleSaBuildOptions().getOptions();\r | |
1047 | XmlCursor cursor = opts.newCursor();\r | |
1048 | if (cursor.toFirstChild()) {\r | |
1049 | for (int j = 0; j < i; ++j){\r | |
1050 | cursor.toNextSibling();\r | |
1051 | }\r | |
1052 | OptionDocument.Option opt = (OptionDocument.Option)cursor.getObject();\r | |
1053 | setBuildOptionsOpt(buildTargets, toolChain, tagName, toolCmd, archList, contents, opt);\r | |
1054 | }\r | |
1055 | cursor.dispose();\r | |
1056 | }\r | |
1057 | \r | |
a13899c5 | 1058 | /**add pcd information of module mi to a ModuleSA. \r |
1059 | * @param mi\r | |
1060 | * @param moduleSa if null, generate a new ModuleSA.\r | |
1061 | */\r | |
bf5abaff | 1062 | public void addFrameworkModulesPcdBuildDefs(ModuleIdentification mi, String arch, ModuleSADocument.ModuleSA moduleSa) throws Exception {\r |
a13899c5 | 1063 | //ToDo add Arch filter\r |
1064 | \r | |
1065 | try {\r | |
af25df16 | 1066 | if (moduleSa == null) {\r |
bf5abaff | 1067 | moduleSa = genModuleSA(mi, arch);\r |
af25df16 | 1068 | }\r |
1069 | \r | |
1bf9fa5a | 1070 | ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = (ModuleSurfaceAreaDocument.ModuleSurfaceArea)WorkspaceProfile.getModuleXmlObject(mi);\r |
a13899c5 | 1071 | if (msa.getPcdCoded() == null) {\r |
1072 | return;\r | |
1073 | }\r | |
af25df16 | 1074 | \r |
a13899c5 | 1075 | Map<String, XmlObject> m = new HashMap<String, XmlObject>();\r |
1076 | m.put("ModuleSurfaceArea", msa);\r | |
1077 | SurfaceAreaQuery.setDoc(m);\r | |
daa4663b | 1078 | PackageIdentification[] depPkgs = SurfaceAreaQuery.getDependencePkg(null, mi);\r |
a13899c5 | 1079 | //\r |
1080 | // Implementing InitializePlatformPcdBuildDefinitions\r | |
1081 | //\r | |
1082 | List<PcdCodedDocument.PcdCoded.PcdEntry> l = msa.getPcdCoded().getPcdEntryList();\r | |
1083 | ListIterator li = l.listIterator();\r | |
1084 | while(li.hasNext()) {\r | |
1085 | PcdCodedDocument.PcdCoded.PcdEntry msaPcd = (PcdCodedDocument.PcdCoded.PcdEntry)li.next();\r | |
1086 | PcdDeclarationsDocument.PcdDeclarations.PcdEntry spdPcd = LookupPcdDeclaration(msaPcd, depPkgs);\r | |
1087 | if (spdPcd == null) {\r | |
1088 | //\r | |
1089 | // ToDo Error \r | |
1090 | //\r | |
34c614e1 | 1091 | throw new PcdDeclNotFound("No Declaration for PCD Entry " + msaPcd.getCName() + " in Module " + mi.getName());\r |
a13899c5 | 1092 | }\r |
1093 | //\r | |
1094 | // AddItem to ModuleSA PcdBuildDefinitions\r | |
1095 | //\r | |
1096 | String defaultVal = msaPcd.getDefaultValue() == null ? spdPcd.getDefaultValue() : msaPcd.getDefaultValue();\r | |
908b1c05 | 1097 | \r |
a13899c5 | 1098 | genPcdData(msaPcd.getCName(), spdPcd.getToken(), msaPcd.getTokenSpaceGuidCName(), msaPcd.getPcdItemType().toString(), spdPcd.getDatumType()+"", defaultVal, moduleSa);\r |
1099 | }\r | |
1100 | \r | |
1101 | }\r | |
1102 | catch (Exception e){\r | |
34c614e1 | 1103 | \r |
82961247 | 1104 | throw e; \r |
a13899c5 | 1105 | }\r |
1106 | \r | |
1107 | }\r | |
1108 | \r | |
1109 | private PcdDeclarationsDocument.PcdDeclarations.PcdEntry LookupPcdDeclaration (PcdCodedDocument.PcdCoded.PcdEntry msaPcd, PackageIdentification[] depPkgs) {\r | |
1110 | \r | |
a13899c5 | 1111 | PcdDeclarationsDocument.PcdDeclarations.PcdEntry spdPcd = null;\r |
1112 | for (int i = 0; i < depPkgs.length; ++i) {\r | |
3658f95e | 1113 | \r |
1114 | XmlObject[] xo = SurfaceAreaQuery.getSpdPcdDeclarations(depPkgs[i]);\r | |
a13899c5 | 1115 | if (xo == null) {\r |
1116 | continue;\r | |
1117 | }\r | |
1118 | for (int j = 0; j < xo.length; ++j) {\r | |
1119 | spdPcd = (PcdDeclarationsDocument.PcdDeclarations.PcdEntry)xo[j];\r | |
1120 | if (msaPcd.getTokenSpaceGuidCName() == null) {\r | |
1121 | if (spdPcd.getCName().equals(msaPcd.getCName())) {\r | |
1122 | return spdPcd;\r | |
1123 | }\r | |
1124 | }\r | |
1125 | else{\r | |
1126 | if (spdPcd.getCName().equals(msaPcd.getCName()) && spdPcd.getTokenSpaceGuidCName().equals(msaPcd.getTokenSpaceGuidCName())) {\r | |
1127 | return spdPcd;\r | |
1128 | }\r | |
1129 | }\r | |
1130 | \r | |
1131 | }\r | |
1132 | \r | |
1133 | }\r | |
1134 | return null;\r | |
1135 | }\r | |
1136 | \r | |
bf5abaff | 1137 | private ModuleSADocument.ModuleSA genModuleSA (ModuleIdentification mi, String arch) {\r |
1bf9fa5a | 1138 | PackageIdentification pi = WorkspaceProfile.getPackageForModule(mi);\r |
a13899c5 | 1139 | ModuleSADocument.ModuleSA msa = getfpdFrameworkModules().addNewModuleSA();\r |
82dcbb45 | 1140 | XmlCursor cursor = msa.newCursor();\r |
1141 | try{\r | |
3658f95e | 1142 | String comment = "Mod: " + mi.getName() + " Type: " + SurfaceAreaQuery.getModuleType(mi) + " Path: "\r |
1143 | + mi.getPath().substring(System.getenv("WORKSPACE").length() + 1);\r | |
82dcbb45 | 1144 | cursor.insertComment(comment);\r |
1145 | }\r | |
1146 | catch(Exception e){\r | |
1147 | e.printStackTrace();\r | |
1148 | }\r | |
1149 | finally { \r | |
1150 | cursor.dispose();\r | |
1151 | }\r | |
a13899c5 | 1152 | msa.setModuleGuid(mi.getGuid());\r |
1153 | msa.setModuleVersion(mi.getVersion());\r | |
1154 | msa.setPackageGuid(pi.getGuid());\r | |
1155 | msa.setPackageVersion(pi.getVersion());\r | |
bf5abaff | 1156 | if (arch != null) {\r |
1157 | Vector<String> v = new Vector<String>();\r | |
1158 | v.add(arch);\r | |
1159 | msa.setSupArchList(v); \r | |
1160 | }\r | |
a13899c5 | 1161 | \r |
1162 | return msa;\r | |
1163 | }\r | |
1164 | \r | |
82961247 | 1165 | private void genPcdData (String cName, Object token, String tsGuid, String itemType, String dataType, String defaultVal, ModuleSADocument.ModuleSA moduleSa) \r |
1166 | throws PcdItemTypeConflictException, PcdValueMalFormed{\r | |
a13899c5 | 1167 | if (moduleSa.getPcdBuildDefinition() == null){\r |
1168 | moduleSa.addNewPcdBuildDefinition();\r | |
1169 | }\r | |
1170 | //\r | |
1171 | // constructe pcd to modulesa mapping first.\r | |
1172 | // Attention : for any error condition, remove from map this pcd.\r | |
1173 | //\r | |
1174 | ArrayList<String> pcdConsumer = LookupPlatformPcdData(cName + " " + tsGuid);\r | |
1175 | if (pcdConsumer == null) {\r | |
1176 | pcdConsumer = new ArrayList<String>();\r | |
1177 | }\r | |
1bf9fa5a | 1178 | //\r |
1179 | // Using existing Pcd type, if this pcd already exists in other ModuleSA\r | |
1180 | //\r | |
1181 | if (pcdConsumer.size() > 0) {\r | |
1182 | String[] valPart = pcdConsumer.get(0).split(" ");\r | |
1183 | itemType = valPart[5];\r | |
1184 | }\r | |
a13899c5 | 1185 | String listValue = moduleSa.getModuleGuid() + " " + moduleSa.getModuleVersion() \r |
bf5abaff | 1186 | + " " + moduleSa.getPackageGuid() + " " + moduleSa.getPackageVersion() + " " + listToString(moduleSa.getSupArchList())\r |
a13899c5 | 1187 | + " " + itemType;\r |
1188 | pcdConsumer.add(listValue);\r | |
1189 | dynPcdMap.put(cName + " " + tsGuid, pcdConsumer);\r | |
1bf9fa5a | 1190 | \r |
a13899c5 | 1191 | PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData fpdPcd = moduleSa.getPcdBuildDefinition().addNewPcdData();\r |
1192 | fpdPcd.setCName(cName);\r | |
1193 | fpdPcd.setToken(token);\r | |
1194 | fpdPcd.setTokenSpaceGuidCName(tsGuid);\r | |
1195 | fpdPcd.setDatumType(PcdDataTypes.Enum.forString(dataType));\r | |
1196 | fpdPcd.setItemType(PcdItemTypes.Enum.forString(itemType));\r | |
a390c35d | 1197 | \r |
1198 | if (defaultVal != null){\r | |
1199 | fpdPcd.setValue(defaultVal);\r | |
1200 | }\r | |
1201 | else {\r | |
1202 | if (dataType.equals("UINT8") || dataType.equals("UINT16") || dataType.equals("UINT32") || dataType.equals("UINT64")) {\r | |
1203 | fpdPcd.setValue("0");\r | |
1204 | }\r | |
1205 | if (dataType.equals("BOOLEAN")){\r | |
b3151273 | 1206 | fpdPcd.setValue("FALSE");\r |
a390c35d | 1207 | }\r |
1208 | if (dataType.equals("VOID*")) {\r | |
1209 | fpdPcd.setValue("");\r | |
1210 | }\r | |
1211 | }\r | |
1bf9fa5a | 1212 | //\r |
1213 | // Using existing pcd value, if this pcd already exists in other moduleSa.\r | |
1214 | //\r | |
1215 | if (defaultPcdValue.get(cName + " " + tsGuid) == null) {\r | |
1216 | defaultPcdValue.put(cName + " " + tsGuid, fpdPcd.getValue());\r | |
1217 | }\r | |
1218 | else {\r | |
1219 | fpdPcd.setValue(defaultPcdValue.get(cName + " " + tsGuid));\r | |
1220 | }\r | |
1221 | \r | |
802e0055 | 1222 | if (dataType.equals("UINT8")){\r |
1223 | fpdPcd.setMaxDatumSize(1);\r | |
1224 | }\r | |
1225 | if (dataType.equals("UINT16")) {\r | |
1226 | fpdPcd.setMaxDatumSize(2);\r | |
1227 | }\r | |
1228 | if (dataType.equals("UINT32")) {\r | |
1229 | fpdPcd.setMaxDatumSize(4);\r | |
1230 | }\r | |
1231 | if (dataType.equals("UINT64")){\r | |
1232 | fpdPcd.setMaxDatumSize(8);\r | |
1233 | }\r | |
1234 | if (dataType.equals("BOOLEAN")){\r | |
1235 | fpdPcd.setMaxDatumSize(1);\r | |
1236 | }\r | |
1237 | if (dataType.equals("VOID*")) {\r | |
1238 | int maxSize = setMaxSizeForPointer(fpdPcd.getValue());\r | |
1239 | fpdPcd.setMaxDatumSize(maxSize);\r | |
1240 | }\r | |
a13899c5 | 1241 | \r |
a390c35d | 1242 | \r |
a13899c5 | 1243 | if (itemType.equals("DYNAMIC") || itemType.equals("DYNAMIC_EX")) {\r |
1244 | ArrayList<String> al = LookupDynamicPcdBuildDefinition(cName + " " + tsGuid);\r | |
1245 | //\r | |
1246 | // if only one module mapped to this pcd, then the one is myself. so no other module mapped.\r | |
1247 | // so need to add one dyn pcd.\r | |
1248 | //\r | |
1249 | if (al.size() == 1) {\r | |
1250 | addDynamicPcdBuildData(cName, token, tsGuid, itemType, dataType, defaultVal);\r | |
1251 | }\r | |
1252 | }\r | |
1bf9fa5a | 1253 | \r |
a13899c5 | 1254 | }\r |
1255 | \r | |
908b1c05 | 1256 | public int setMaxSizeForPointer(String datum) throws PcdValueMalFormed{\r |
a13899c5 | 1257 | if (datum == null) {\r |
1258 | return 0;\r | |
1259 | }\r | |
1260 | char ch = datum.charAt(0);\r | |
1261 | int start, end;\r | |
1262 | String strValue;\r | |
1263 | //\r | |
1264 | // For void* type PCD, only three datum is support:\r | |
1265 | // 1) Unicode: string with start char is "L"\r | |
1266 | // 2) Ansci: String is ""\r | |
1267 | // 3) byte array: String start char "{"\r | |
1268 | // \r | |
1269 | if (ch == 'L') {\r | |
1270 | start = datum.indexOf('\"');\r | |
1271 | end = datum.lastIndexOf('\"');\r | |
1272 | if ((start > end) || \r | |
1273 | (end > datum.length())||\r | |
1274 | ((start == end) && (datum.length() > 0))) {\r | |
1275 | //ToDo Error handling here\r | |
82961247 | 1276 | throw new PcdValueMalFormed (datum);\r |
a13899c5 | 1277 | }\r |
1278 | \r | |
1279 | strValue = datum.substring(start + 1, end);\r | |
1280 | return strValue.length() * 2;\r | |
1281 | } else if (ch == '\"'){\r | |
1282 | start = datum.indexOf('\"');\r | |
1283 | end = datum.lastIndexOf('\"');\r | |
1284 | if ((start > end) || \r | |
1285 | (end > datum.length())||\r | |
1286 | ((start == end) && (datum.length() > 0))) {\r | |
82961247 | 1287 | throw new PcdValueMalFormed (datum);\r |
a13899c5 | 1288 | }\r |
1289 | strValue = datum.substring(start + 1, end);\r | |
1290 | return strValue.length();\r | |
1291 | } else if (ch =='{') {\r | |
1292 | String[] strValueArray;\r | |
1293 | \r | |
1294 | start = datum.indexOf('{');\r | |
1295 | end = datum.lastIndexOf('}');\r | |
1296 | strValue = datum.substring(start + 1, end);\r | |
1297 | strValue = strValue.trim();\r | |
1298 | if (strValue.length() == 0) {\r | |
1299 | return 0;\r | |
1300 | }\r | |
1301 | strValueArray = strValue.split(",");\r | |
1302 | for (int index = 0; index < strValueArray.length; index ++) {\r | |
1303 | Integer value = Integer.decode(strValueArray[index].trim());\r | |
1304 | \r | |
1305 | if (value > 0xFF) {\r | |
1306 | // "[FPD file error] The datum type of PCD %s in %s is VOID*, "+\r | |
a70d444e | 1307 | // "it must be a byte array. But the element of %s exceed the byte range",\r |
82961247 | 1308 | throw new PcdValueMalFormed (datum); \r |
a13899c5 | 1309 | }\r |
1310 | }\r | |
1311 | return strValueArray.length;\r | |
1312 | \r | |
1313 | \r | |
1314 | } else {\r | |
1315 | // "[FPD file error] The datum type of PCD %s in %s is VOID*. For VOID* type, you have three format choise:\n "+\r | |
1316 | // "1) UNICODE string: like L\"xxxx\";\r\n"+\r | |
1317 | // "2) ANSIC string: like \"xxx\";\r\n"+\r | |
1318 | // "3) Byte array: like {0x2, 0x45, 0x23}\r\n"+\r | |
1319 | // "but the datum in seems does not following above format!",\r | |
82961247 | 1320 | throw new PcdValueMalFormed (datum);\r |
a13899c5 | 1321 | \r |
1322 | }\r | |
1323 | }\r | |
1324 | \r | |
1325 | private ArrayList<String> LookupDynamicPcdBuildDefinition(String dynPcdKey) {\r | |
1326 | ArrayList<String> al = dynPcdMap.get(dynPcdKey);\r | |
1327 | \r | |
1328 | return al;\r | |
1329 | }\r | |
1330 | \r | |
1331 | private ArrayList<String> LookupPlatformPcdData(String pcdKey) {\r | |
1332 | \r | |
34c614e1 | 1333 | return dynPcdMap.get(pcdKey);\r |
a13899c5 | 1334 | }\r |
1335 | \r | |
1336 | public int getDynamicPcdBuildDataCount() {\r | |
5af6b67f | 1337 | if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {\r |
e232295e | 1338 | removeElement(getfpdDynPcdBuildDefs());\r |
1339 | fpdDynPcdBuildDefs = null;\r | |
a13899c5 | 1340 | return 0;\r |
1341 | }\r | |
1342 | return getfpdDynPcdBuildDefs().getPcdBuildDataList().size();\r | |
1343 | }\r | |
1344 | \r | |
1345 | public void getDynamicPcdBuildData(String[][] saa) {\r | |
5af6b67f | 1346 | if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {\r |
e232295e | 1347 | removeElement(getfpdDynPcdBuildDefs());\r |
1348 | fpdDynPcdBuildDefs = null;\r | |
a13899c5 | 1349 | return ;\r |
1350 | }\r | |
1351 | List<DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData> l = getfpdDynPcdBuildDefs().getPcdBuildDataList();\r | |
1352 | ListIterator<DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData> li = l.listIterator();\r | |
1353 | int i = 0;\r | |
1354 | while(li.hasNext()) {\r | |
1355 | DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData dynPcd = li.next();\r | |
1356 | saa[i][0] = dynPcd.getCName();\r | |
1357 | saa[i][1] = dynPcd.getToken().toString();\r | |
1358 | saa[i][2] = dynPcd.getTokenSpaceGuidCName();\r | |
1359 | saa[i][3] = dynPcd.getMaxDatumSize()+"";\r | |
1360 | saa[i][4] = dynPcd.getDatumType().toString();\r | |
1361 | \r | |
1362 | ++i;\r | |
1363 | }\r | |
1364 | }\r | |
1365 | \r | |
908b1c05 | 1366 | public void addDynamicPcdBuildData(String cName, Object token, String tsGuid, String itemType, String dataType, String defaultVal) \r |
82961247 | 1367 | throws PcdValueMalFormed{\r |
a13899c5 | 1368 | DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData dynPcdData = getfpdDynPcdBuildDefs().addNewPcdBuildData();\r |
1369 | dynPcdData.setItemType(PcdItemTypes.Enum.forString(itemType));\r | |
1370 | dynPcdData.setCName(cName);\r | |
1371 | dynPcdData.setToken(token);\r | |
1372 | dynPcdData.setTokenSpaceGuidCName(tsGuid);\r | |
1373 | dynPcdData.setDatumType(PcdDataTypes.Enum.forString(dataType));\r | |
1374 | \r | |
1375 | BigInteger bigInt = new BigInteger("0");\r | |
1376 | DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData.SkuInfo skuInfo = dynPcdData.addNewSkuInfo();\r | |
1377 | skuInfo.setSkuId(bigInt);\r | |
1378 | if (defaultVal != null){\r | |
1379 | skuInfo.setValue(defaultVal);\r | |
1380 | }\r | |
1381 | else {\r | |
1382 | if (dataType.equals("UINT8")){\r | |
1383 | skuInfo.setValue("0");\r | |
1384 | }\r | |
1385 | if (dataType.equals("UINT16")) {\r | |
1386 | skuInfo.setValue("0");\r | |
1387 | }\r | |
1388 | if (dataType.equals("UINT32")) {\r | |
1389 | skuInfo.setValue("0");\r | |
1390 | }\r | |
1391 | if (dataType.equals("UINT64")){\r | |
1392 | skuInfo.setValue("0");\r | |
1393 | }\r | |
1394 | if (dataType.equals("BOOLEAN")){\r | |
1395 | skuInfo.setValue("false");\r | |
1396 | }\r | |
1397 | if (dataType.equals("VOID*")) {\r | |
1398 | skuInfo.setValue("");\r | |
1399 | }\r | |
1400 | }\r | |
1401 | if (dataType.equals("UINT8")){\r | |
1402 | dynPcdData.setMaxDatumSize(1);\r | |
1403 | }\r | |
1404 | if (dataType.equals("UINT16")) {\r | |
1405 | dynPcdData.setMaxDatumSize(2);\r | |
1406 | }\r | |
1407 | if (dataType.equals("UINT32")) {\r | |
1408 | dynPcdData.setMaxDatumSize(4);\r | |
1409 | }\r | |
1410 | if (dataType.equals("UINT64")){\r | |
1411 | dynPcdData.setMaxDatumSize(8);\r | |
1412 | }\r | |
1413 | if (dataType.equals("BOOLEAN")){\r | |
1414 | dynPcdData.setMaxDatumSize(1);\r | |
1415 | }\r | |
1416 | if (dataType.equals("VOID*")) {\r | |
1417 | int maxSize = setMaxSizeForPointer(defaultVal);\r | |
1418 | dynPcdData.setMaxDatumSize(maxSize);\r | |
1419 | }\r | |
1420 | }\r | |
1421 | \r | |
908b1c05 | 1422 | public void removeDynamicPcdBuildData(String cName, String tsGuid) {\r |
e232295e | 1423 | XmlObject o = fpdRoot.getDynamicPcdBuildDefinitions();\r |
1424 | if (o == null) {\r | |
1425 | return;\r | |
1426 | }\r | |
a13899c5 | 1427 | \r |
1428 | XmlCursor cursor = o.newCursor();\r | |
1429 | if (cursor.toFirstChild()) {\r | |
af25df16 | 1430 | do {\r |
1431 | DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData pcdBuildData = \r | |
1432 | (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject();\r | |
908b1c05 | 1433 | if (pcdBuildData.getCName().equals(cName) && pcdBuildData.getTokenSpaceGuidCName().equals(tsGuid)) {\r |
add40ab2 | 1434 | \r |
1435 | if (getDynamicPcdBuildDataCount() == 1) {\r | |
af25df16 | 1436 | cursor.toParent();\r |
af25df16 | 1437 | }\r |
add40ab2 | 1438 | cursor.removeXml();\r |
908b1c05 | 1439 | cursor.dispose();\r |
1440 | return;\r | |
1441 | }\r | |
a13899c5 | 1442 | }\r |
af25df16 | 1443 | while (cursor.toNextSibling());\r |
a13899c5 | 1444 | }\r |
1445 | cursor.dispose();\r | |
1446 | }\r | |
1447 | //\r | |
1448 | // Get the Sku Info count of ith dyn pcd element.\r | |
1449 | //\r | |
1450 | public int getDynamicPcdSkuInfoCount(int i){\r | |
e232295e | 1451 | if (fpdRoot.getDynamicPcdBuildDefinitions() == null || fpdRoot.getDynamicPcdBuildDefinitions().getPcdBuildDataList() == null \r |
1452 | || fpdRoot.getDynamicPcdBuildDefinitions().getPcdBuildDataList().size() == 0) {\r | |
a13899c5 | 1453 | return 0;\r |
1454 | }\r | |
1455 | \r | |
1456 | int skuInfoCount = 0;\r | |
1457 | XmlCursor cursor = getfpdDynPcdBuildDefs().newCursor();\r | |
1458 | if (cursor.toFirstChild()) {\r | |
1459 | for (int j = 0; j < i; ++j) {\r | |
1460 | cursor.toNextSibling();\r | |
1461 | }\r | |
1462 | DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData pcdData = (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject();\r | |
1463 | if (pcdData.getSkuInfoList() == null) {\r | |
1464 | skuInfoCount = 0;\r | |
1465 | }\r | |
1466 | else {\r | |
1467 | skuInfoCount = pcdData.getSkuInfoList().size();\r | |
1468 | }\r | |
1469 | }\r | |
1470 | cursor.dispose();\r | |
1471 | return skuInfoCount;\r | |
1472 | }\r | |
1473 | \r | |
1474 | public void getDynamicPcdSkuInfos(int i, String[][] saa){\r | |
1475 | if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {\r | |
e232295e | 1476 | removeElement(getfpdDynPcdBuildDefs());\r |
1477 | fpdDynPcdBuildDefs = null;\r | |
a13899c5 | 1478 | return;\r |
1479 | }\r | |
1480 | \r | |
1481 | XmlCursor cursor = getfpdDynPcdBuildDefs().newCursor();\r | |
1482 | if (cursor.toFirstChild()) {\r | |
1483 | for (int j = 0; j < i; ++j) {\r | |
1484 | cursor.toNextSibling();\r | |
1485 | }\r | |
1486 | DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData pcdData = (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject();\r | |
1487 | if (pcdData.getSkuInfoList() == null) {\r | |
1488 | cursor.dispose();\r | |
1489 | return;\r | |
1490 | }\r | |
1491 | else {\r | |
1492 | ListIterator<DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData.SkuInfo> li = pcdData.getSkuInfoList().listIterator();\r | |
1493 | int k = 0;\r | |
1494 | while (li.hasNext()) {\r | |
1495 | DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData.SkuInfo skuInfo = li.next();\r | |
1496 | saa[k][0] = skuInfo.getSkuId()+"";\r | |
1497 | saa[k][1] = skuInfo.getVariableName();\r | |
1498 | saa[k][2] = skuInfo.getVariableGuid();\r | |
1499 | saa[k][3] = skuInfo.getVariableOffset();\r | |
1500 | saa[k][4] = skuInfo.getHiiDefaultValue();\r | |
1501 | saa[k][5] = skuInfo.getVpdOffset();\r | |
1502 | saa[k][6] = skuInfo.getValue();\r | |
1503 | ++k;\r | |
1504 | }\r | |
1505 | \r | |
1506 | }\r | |
1507 | }\r | |
1508 | cursor.dispose();\r | |
1509 | \r | |
1510 | }\r | |
1511 | \r | |
1512 | public String getDynamicPcdBuildDataValue(int i){\r | |
1513 | String value = null;\r | |
1514 | if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {\r | |
e232295e | 1515 | removeElement(getfpdDynPcdBuildDefs());\r |
1516 | fpdDynPcdBuildDefs = null;\r | |
a13899c5 | 1517 | return value;\r |
1518 | }\r | |
1519 | \r | |
1520 | XmlCursor cursor = getfpdDynPcdBuildDefs().newCursor();\r | |
1521 | if (cursor.toFirstChild()) {\r | |
1522 | for (int j = 0; j < i; ++j) {\r | |
1523 | cursor.toNextSibling();\r | |
1524 | }\r | |
1525 | DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData pcdData = (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject();\r | |
1526 | if (pcdData.getSkuInfoList() == null) {\r | |
1527 | value = null;\r | |
1528 | }\r | |
1529 | else {\r | |
1530 | value = pcdData.getSkuInfoArray(0).getValue();\r | |
1531 | }\r | |
1532 | }\r | |
1533 | cursor.dispose();\r | |
1534 | return value;\r | |
1535 | }\r | |
1536 | \r | |
1537 | public String getDynamicPcdBuildDataVpdOffset(int i){\r | |
1538 | String vpdOffset = null;\r | |
1539 | if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {\r | |
e232295e | 1540 | removeElement(getfpdDynPcdBuildDefs());\r |
1541 | fpdDynPcdBuildDefs = null;\r | |
a13899c5 | 1542 | return vpdOffset;\r |
1543 | }\r | |
1544 | \r | |
1545 | XmlCursor cursor = getfpdDynPcdBuildDefs().newCursor();\r | |
1546 | if (cursor.toFirstChild()) {\r | |
1547 | for (int j = 0; j < i; ++j) {\r | |
1548 | cursor.toNextSibling();\r | |
1549 | }\r | |
1550 | DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData pcdData = (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject();\r | |
1551 | if (pcdData.getSkuInfoList() == null) {\r | |
1552 | vpdOffset = null;\r | |
1553 | }\r | |
1554 | else {\r | |
1555 | vpdOffset = pcdData.getSkuInfoArray(0).getVpdOffset();\r | |
1556 | }\r | |
1557 | }\r | |
1558 | cursor.dispose();\r | |
1559 | return vpdOffset;\r | |
1560 | }\r | |
1561 | \r | |
1562 | public void removeDynamicPcdBuildDataSkuInfo(int i) {\r | |
1563 | if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {\r | |
e232295e | 1564 | removeElement(getfpdDynPcdBuildDefs());\r |
1565 | fpdDynPcdBuildDefs = null;\r | |
a13899c5 | 1566 | return;\r |
1567 | }\r | |
1568 | \r | |
1569 | XmlCursor cursor = getfpdDynPcdBuildDefs().newCursor();\r | |
1570 | if (cursor.toFirstChild()) {\r | |
1571 | for (int j = 0; j < i; ++j) {\r | |
1572 | cursor.toNextSibling();\r | |
1573 | }\r | |
1574 | DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData pcdData = (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject();\r | |
1575 | if (pcdData.getSkuInfoList() == null) {\r | |
1576 | cursor.dispose();\r | |
1577 | return;\r | |
1578 | }\r | |
1579 | else {\r | |
1580 | QName qSkuInfo = new QName(xmlNs, "SkuInfo");\r | |
1581 | cursor.toChild(qSkuInfo);\r | |
1582 | cursor.removeXml();\r | |
1583 | }\r | |
1584 | }\r | |
1585 | cursor.dispose();\r | |
1586 | }\r | |
1587 | //\r | |
1588 | // generate sku info for ith dyn pcd build data.\r | |
1589 | //\r | |
1590 | public void genDynamicPcdBuildDataSkuInfo(String id, String varName, String varGuid, String varOffset, \r | |
1591 | String hiiDefault, String vpdOffset, String value, int i) {\r | |
e232295e | 1592 | // if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {\r |
1593 | // return;\r | |
1594 | // }\r | |
a13899c5 | 1595 | \r |
1596 | XmlCursor cursor = getfpdDynPcdBuildDefs().newCursor();\r | |
1597 | if (cursor.toFirstChild()) {\r | |
1598 | for (int j = 0; j < i; ++j) {\r | |
1599 | cursor.toNextSibling();\r | |
1600 | }\r | |
1601 | DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData pcdData = (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject();\r | |
1602 | DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData.SkuInfo skuInfo = pcdData.addNewSkuInfo();\r | |
1603 | skuInfo.setSkuId(new BigInteger(id));\r | |
1604 | if (varName != null){\r | |
1605 | skuInfo.setVariableName(varName);\r | |
1606 | skuInfo.setVariableGuid(varGuid);\r | |
1607 | skuInfo.setVariableOffset(varOffset);\r | |
1608 | skuInfo.setHiiDefaultValue(hiiDefault);\r | |
1609 | }\r | |
1610 | else if (vpdOffset != null){\r | |
1611 | skuInfo.setVpdOffset(vpdOffset);\r | |
1612 | }\r | |
1613 | else{\r | |
1614 | skuInfo.setValue(value);\r | |
1615 | }\r | |
1616 | }\r | |
1617 | }\r | |
1618 | \r | |
1619 | public void updateDynamicPcdBuildDataSkuInfo(String id, String varName, String varGuid, String varOffset, \r | |
1620 | String hiiDefault, String vpdOffset, String value, int i){\r | |
e232295e | 1621 | // if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {\r |
1622 | // return;\r | |
1623 | // }\r | |
a13899c5 | 1624 | \r |
1625 | XmlCursor cursor = getfpdDynPcdBuildDefs().newCursor();\r | |
1626 | if (cursor.toFirstChild()) {\r | |
1627 | for (int j = 0; j < i; ++j) {\r | |
1628 | cursor.toNextSibling();\r | |
1629 | }\r | |
1630 | DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData pcdData = (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject();\r | |
1631 | ListIterator<DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData.SkuInfo> li = pcdData.getSkuInfoList().listIterator();\r | |
1632 | while (li.hasNext()) {\r | |
1633 | DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData.SkuInfo skuInfo = li.next();\r | |
1634 | if (skuInfo.getSkuId().toString().equals(id)){\r | |
1635 | if (varName != null){\r | |
1636 | skuInfo.setVariableName(varName);\r | |
1637 | skuInfo.setVariableGuid(varGuid);\r | |
1638 | skuInfo.setVariableOffset(varOffset);\r | |
1639 | skuInfo.setHiiDefaultValue(hiiDefault);\r | |
1640 | }\r | |
1641 | else if (vpdOffset != null){\r | |
1642 | skuInfo.setVpdOffset(vpdOffset);\r | |
1643 | }\r | |
1644 | else{\r | |
1645 | skuInfo.setValue(value);\r | |
1646 | }\r | |
1647 | break;\r | |
1648 | }\r | |
1649 | }\r | |
1650 | }\r | |
1651 | }\r | |
1652 | \r | |
a13899c5 | 1653 | public BuildOptionsDocument.BuildOptions getfpdBuildOpts() {\r |
1654 | if (fpdBuildOpts == null) {\r | |
1655 | fpdBuildOpts = fpdRoot.addNewBuildOptions();\r | |
1656 | }\r | |
1657 | return fpdBuildOpts;\r | |
1658 | }\r | |
1659 | \r | |
2b70a636 | 1660 | public void genBuildOptionsUserExtensions(String fvName, String outputFileName, Vector<String[]> includeModules) {\r |
eb8ea829 | 1661 | QName elementFvName = new QName (xmlNs, "FvName");\r |
1662 | QName elementIncludeModules = new QName(xmlNs, "IncludeModules");\r | |
1663 | QName elementInfFileName = new QName(xmlNs, "InfFileName");\r | |
1664 | QName elementModule = new QName(xmlNs, "Module");\r | |
1665 | \r | |
1bf9fa5a | 1666 | UserExtensionsDocument.UserExtensions userExts = getfpdBuildOpts().addNewUserExtensions();\r |
1667 | userExts.setUserID("IMAGES");\r | |
1668 | userExts.setIdentifier(new BigInteger("1"));\r | |
1669 | XmlCursor cursor = userExts.newCursor();\r | |
1670 | cursor.toEndToken();\r | |
1671 | \r | |
eb8ea829 | 1672 | cursor.beginElement(elementFvName);\r |
1bf9fa5a | 1673 | cursor.insertChars(fvName);\r |
1674 | cursor.toNextToken();\r | |
1675 | \r | |
eb8ea829 | 1676 | cursor.beginElement(elementInfFileName);\r |
61919f8c | 1677 | cursor.insertChars(fvName + ".inf");\r |
1bf9fa5a | 1678 | cursor.toNextToken();\r |
1679 | \r | |
eb8ea829 | 1680 | cursor.beginElement(elementIncludeModules);\r |
2b70a636 | 1681 | for (int i = 0; i < includeModules.size(); ++i) {\r |
eb8ea829 | 1682 | cursor.beginElement(elementModule);\r |
2b70a636 | 1683 | cursor.insertAttributeWithValue("ModuleGuid", includeModules.get(i)[0]);\r |
1684 | cursor.insertAttributeWithValue("BaseName", includeModules.get(i)[1]);\r | |
1bf9fa5a | 1685 | cursor.toEndToken();\r |
1686 | cursor.toNextToken();\r | |
1687 | }\r | |
1688 | cursor.dispose();\r | |
1689 | }\r | |
1690 | \r | |
1691 | public int getUserExtsIncModCount (String fvName) {\r | |
1692 | if (getfpdBuildOpts().getUserExtensionsList() == null) {\r | |
1693 | return -1;\r | |
1694 | }\r | |
1695 | ListIterator<UserExtensionsDocument.UserExtensions> li = getfpdBuildOpts().getUserExtensionsList().listIterator();\r | |
eb8ea829 | 1696 | QName elementIncludeModules = new QName(xmlNs, "IncludeModules");\r |
1bf9fa5a | 1697 | while (li.hasNext()) {\r |
1698 | UserExtensionsDocument.UserExtensions ues = li.next();\r | |
1699 | if (!ues.getUserID().equals("IMAGES")) {\r | |
1700 | continue;\r | |
1701 | }\r | |
1702 | XmlCursor cursor = ues.newCursor();\r | |
1703 | cursor.toFirstChild();\r | |
1704 | String elementName = cursor.getTextValue();\r | |
1705 | if (elementName.equals(fvName)) {\r | |
eb8ea829 | 1706 | cursor.toNextSibling(elementIncludeModules);\r |
1bf9fa5a | 1707 | if (cursor.toFirstChild()) {\r |
1708 | int i = 1;\r | |
1709 | for (i = 1; cursor.toNextSibling(); ++i);\r | |
1710 | cursor.dispose();\r | |
1711 | return i;\r | |
1712 | }\r | |
1713 | cursor.dispose();\r | |
1714 | return 0;\r | |
1715 | }\r | |
1716 | cursor.dispose();\r | |
1717 | }\r | |
1718 | return -1;\r | |
1719 | }\r | |
1720 | \r | |
1721 | public void getUserExtsIncMods(String fvName, String[][] saa) {\r | |
1722 | if (getfpdBuildOpts().getUserExtensionsList() == null) {\r | |
1723 | return;\r | |
1724 | }\r | |
eb8ea829 | 1725 | \r |
1726 | XmlCursor cursor = getfpdBuildOpts().newCursor();\r | |
1727 | QName elementUserExts = new QName (xmlNs, "UserExtensions");\r | |
1728 | QName attribUserId = new QName ("UserID");\r | |
1729 | QName elementFvName = new QName (xmlNs, "FvName");\r | |
1730 | QName elementIncludeModules = new QName(xmlNs, "IncludeModules");\r | |
1731 | QName attribModuleGuid = new QName("ModuleGuid");\r | |
1732 | QName attribBaseName = new QName("BaseName");\r | |
1733 | \r | |
1734 | if (cursor.toChild(elementUserExts)) {\r | |
1735 | do {\r | |
1736 | cursor.push();\r | |
1737 | if (cursor.getAttributeText(attribUserId).equals("IMAGES")) {\r | |
1738 | cursor.toChild(elementFvName);\r | |
1739 | String elementName = cursor.getTextValue();\r | |
1740 | if (elementName.equals(fvName)) {\r | |
1741 | cursor.toNextSibling(elementIncludeModules);\r | |
1742 | if (cursor.toFirstChild()) {\r | |
1743 | int i = 0;\r | |
1744 | do {\r | |
1745 | saa[i][0] = cursor.getAttributeText(attribModuleGuid);\r | |
1746 | saa[i][1] = cursor.getAttributeText(attribBaseName);\r | |
1747 | ++i;\r | |
1748 | }while (cursor.toNextSibling());\r | |
1749 | }\r | |
1750 | break;\r | |
1751 | }\r | |
1752 | }\r | |
1753 | cursor.pop();\r | |
1754 | }while (cursor.toNextSibling(elementUserExts));\r | |
1755 | }\r | |
1756 | cursor.dispose();\r | |
1757 | \r | |
1758 | }\r | |
1759 | \r | |
1760 | public void updateBuildOptionsUserExtensions (String oldFvName, String newFvName) {\r | |
1761 | if (getfpdBuildOpts().getUserExtensionsList() == null) {\r | |
1762 | return;\r | |
1763 | }\r | |
1bf9fa5a | 1764 | ListIterator<UserExtensionsDocument.UserExtensions> li = getfpdBuildOpts().getUserExtensionsList().listIterator();\r |
1765 | while (li.hasNext()) {\r | |
1766 | UserExtensionsDocument.UserExtensions ues = li.next();\r | |
1767 | if (!ues.getUserID().equals("IMAGES")) {\r | |
1768 | continue;\r | |
1769 | }\r | |
1770 | XmlCursor cursor = ues.newCursor();\r | |
1771 | cursor.toFirstChild();\r | |
1772 | String elementName = cursor.getTextValue();\r | |
eb8ea829 | 1773 | if (elementName.equals(oldFvName)) {\r |
1774 | cursor.setTextValue(newFvName);\r | |
1bf9fa5a | 1775 | }\r |
1776 | cursor.dispose();\r | |
1777 | }\r | |
1778 | \r | |
1779 | }\r | |
1780 | \r | |
61919f8c | 1781 | public void removeBuildOptionsUserExtensions (String fvName) {\r |
1782 | if (getfpdBuildOpts().getUserExtensionsList() == null) {\r | |
1783 | return;\r | |
1784 | }\r | |
1785 | \r | |
1786 | ListIterator<UserExtensionsDocument.UserExtensions> li = getfpdBuildOpts().getUserExtensionsList().listIterator();\r | |
1787 | while (li.hasNext()) {\r | |
1788 | UserExtensionsDocument.UserExtensions ues = li.next();\r | |
1789 | if (!ues.getUserID().equals("IMAGES")) {\r | |
1790 | continue;\r | |
1791 | }\r | |
1792 | XmlCursor cursor = ues.newCursor();\r | |
1793 | cursor.toFirstChild();\r | |
1794 | String elementName = cursor.getTextValue();\r | |
1795 | if (elementName.equals(fvName)) {\r | |
1796 | cursor.toParent();\r | |
1797 | cursor.removeXml();\r | |
1798 | cursor.dispose();\r | |
1799 | return;\r | |
1800 | }\r | |
1801 | cursor.dispose();\r | |
1802 | }\r | |
1803 | \r | |
1804 | }\r | |
1805 | \r | |
1806 | \r | |
a13899c5 | 1807 | public void genBuildOptionsUserDefAntTask (String id, String fileName, String execOrder) {\r |
1808 | UserDefinedAntTasksDocument.UserDefinedAntTasks udats = getfpdBuildOpts().getUserDefinedAntTasks();\r | |
1809 | if (udats == null) {\r | |
1810 | udats = getfpdBuildOpts().addNewUserDefinedAntTasks();\r | |
1811 | }\r | |
1812 | \r | |
1813 | AntTaskDocument.AntTask at = udats.addNewAntTask();\r | |
1814 | setBuildOptionsUserDefAntTask(id, fileName, execOrder, at);\r | |
1815 | }\r | |
1816 | \r | |
1817 | private void setBuildOptionsUserDefAntTask(String id, String fileName, String execOrder, AntTaskDocument.AntTask at) {\r | |
1818 | at.setId(new Integer(id));\r | |
bf5abaff | 1819 | XmlCursor cursor = at.newCursor();\r |
a13899c5 | 1820 | if (fileName != null){\r |
1821 | at.setFilename(fileName);\r | |
1822 | }\r | |
bf5abaff | 1823 | else if (cursor.toChild(xmlNs, "Filename")) {\r |
1824 | cursor.removeXml();\r | |
1825 | }\r | |
202c4f38 | 1826 | if (execOrder != null) {\r |
a13899c5 | 1827 | at.setAntCmdOptions(execOrder);\r |
1828 | }\r | |
bf5abaff | 1829 | else if (cursor.toChild(xmlNs, "AntCmdOptions")) {\r |
1830 | cursor.removeXml();\r | |
1831 | }\r | |
1832 | cursor.dispose();\r | |
a13899c5 | 1833 | }\r |
1834 | \r | |
1835 | public void removeBuildOptionsUserDefAntTask(int i) {\r | |
1836 | XmlObject o = getfpdBuildOpts().getUserDefinedAntTasks();\r | |
1837 | if (o == null) {\r | |
1838 | return;\r | |
1839 | }\r | |
1840 | XmlCursor cursor = o.newCursor();\r | |
1841 | if (cursor.toFirstChild()) {\r | |
1842 | for (int j = 0; j < i; ++j) {\r | |
1843 | cursor.toNextSibling();\r | |
1844 | }\r | |
1845 | cursor.removeXml();\r | |
af25df16 | 1846 | if (getBuildOptionsUserDefAntTaskCount() == 0) {\r |
1847 | cursor.toParent();\r | |
1848 | cursor.removeXml();\r | |
1849 | }\r | |
a13899c5 | 1850 | }\r |
1851 | cursor.dispose();\r | |
1852 | }\r | |
1853 | \r | |
1854 | public void updateBuildOptionsUserDefAntTask(int i, String id, String fileName, String execOrder){\r | |
1855 | XmlObject o = getfpdBuildOpts().getUserDefinedAntTasks();\r | |
1856 | if (o == null) {\r | |
1857 | return;\r | |
1858 | }\r | |
1859 | XmlCursor cursor = o.newCursor();\r | |
1860 | if (cursor.toFirstChild()) {\r | |
1861 | for (int j = 0; j < i; ++j) {\r | |
1862 | cursor.toNextSibling();\r | |
1863 | }\r | |
1864 | AntTaskDocument.AntTask at = (AntTaskDocument.AntTask)cursor.getObject();\r | |
1865 | setBuildOptionsUserDefAntTask(id, fileName, execOrder, at);\r | |
1866 | }\r | |
1867 | cursor.dispose();\r | |
1868 | }\r | |
1869 | \r | |
1870 | public int getBuildOptionsUserDefAntTaskCount() {\r | |
1871 | UserDefinedAntTasksDocument.UserDefinedAntTasks udats = getfpdBuildOpts().getUserDefinedAntTasks();\r | |
1872 | if (udats == null || udats.getAntTaskList() == null) {\r | |
1873 | return 0;\r | |
1874 | }\r | |
1875 | \r | |
1876 | return udats.getAntTaskList().size();\r | |
1877 | }\r | |
1878 | \r | |
1879 | public void getBuildOptionsUserDefAntTasks(String[][] saa) {\r | |
1880 | UserDefinedAntTasksDocument.UserDefinedAntTasks udats = getfpdBuildOpts().getUserDefinedAntTasks();\r | |
1881 | if (udats == null || udats.getAntTaskList() == null) {\r | |
1882 | return ;\r | |
1883 | }\r | |
1884 | \r | |
1885 | List<AntTaskDocument.AntTask> l = udats.getAntTaskList();\r | |
1886 | ListIterator li = l.listIterator();\r | |
1887 | int i = 0;\r | |
1888 | while (li.hasNext()) {\r | |
1889 | AntTaskDocument.AntTask at = (AntTaskDocument.AntTask)li.next();\r | |
1890 | saa[i][0] = at.getId() + "";\r | |
1891 | saa[i][1] = saa[i][2] = "";\r | |
1892 | if (at.getFilename() != null){\r | |
1893 | saa[i][1] = at.getFilename();\r | |
1894 | }\r | |
1895 | if (at.getAntCmdOptions() != null) {\r | |
1896 | saa[i][2] = at.getAntCmdOptions();\r | |
1897 | }\r | |
1898 | ++i;\r | |
1899 | }\r | |
1900 | }\r | |
1800d80f | 1901 | public void genBuildOptionsOpt(Vector<Object> buildTargets, String toolChain, String tagName, String toolCmd, Vector<Object> archList, String contents) {\r |
a13899c5 | 1902 | OptionsDocument.Options opts = getfpdBuildOpts().getOptions();\r |
1903 | if (opts == null) {\r | |
1904 | opts = getfpdBuildOpts().addNewOptions();\r | |
1905 | }\r | |
1906 | OptionDocument.Option opt = opts.addNewOption();\r | |
1907 | setBuildOptionsOpt(buildTargets, toolChain, tagName, toolCmd, archList, contents, opt);\r | |
1908 | }\r | |
1909 | \r | |
1800d80f | 1910 | private void setBuildOptionsOpt(Vector<Object> buildTargets, String toolChain, String tagName, String toolCmd, Vector<Object> archList, String contents, OptionDocument.Option opt){\r |
a13899c5 | 1911 | opt.setStringValue(contents);\r |
1800d80f | 1912 | \r |
1913 | opt.setBuildTargets(buildTargets);\r | |
a13899c5 | 1914 | opt.setToolChainFamily(toolChain);\r |
1915 | opt.setTagName(tagName);\r | |
1916 | opt.setToolCode(toolCmd);\r | |
1800d80f | 1917 | \r |
bf5abaff | 1918 | if (archList != null) {\r |
1919 | opt.setSupArchList(archList);\r | |
1920 | }\r | |
1921 | else {\r | |
1922 | if (opt.isSetSupArchList()) {\r | |
1923 | opt.unsetSupArchList();\r | |
1924 | }\r | |
1925 | }\r | |
a13899c5 | 1926 | }\r |
1927 | \r | |
1928 | public void removeBuildOptionsOpt(int i){\r | |
1929 | \r | |
1930 | XmlObject o = getfpdBuildOpts().getOptions();\r | |
1931 | if (o == null) {\r | |
1932 | return;\r | |
1933 | }\r | |
1934 | \r | |
1935 | XmlCursor cursor = o.newCursor();\r | |
1936 | if (cursor.toFirstChild()) {\r | |
1937 | for (int j = 0; j < i; ++j) {\r | |
1938 | cursor.toNextSibling();\r | |
1939 | }\r | |
1940 | cursor.removeXml();\r | |
af25df16 | 1941 | if (getBuildOptionsOptCount() == 0) {\r |
1942 | cursor.toParent();\r | |
1943 | cursor.removeXml();\r | |
1944 | }\r | |
a13899c5 | 1945 | }\r |
1946 | cursor.dispose();\r | |
1947 | }\r | |
1948 | \r | |
1800d80f | 1949 | public void updateBuildOptionsOpt(int i, Vector<Object> buildTargets, String toolChain, String tagName, String toolCmd, Vector<Object> archList, String contents) {\r |
a13899c5 | 1950 | XmlObject o = getfpdBuildOpts().getOptions();\r |
1951 | if (o == null) {\r | |
1952 | return;\r | |
1953 | }\r | |
1954 | \r | |
1955 | XmlCursor cursor = o.newCursor();\r | |
1956 | if (cursor.toFirstChild()) {\r | |
1957 | for (int j = 0; j < i; ++j) {\r | |
1958 | cursor.toNextSibling();\r | |
1959 | }\r | |
1960 | OptionDocument.Option opt = (OptionDocument.Option)cursor.getObject();\r | |
1961 | setBuildOptionsOpt(buildTargets, toolChain, tagName, toolCmd, archList, contents, opt);\r | |
1962 | }\r | |
1963 | cursor.dispose();\r | |
1964 | }\r | |
1965 | \r | |
1966 | public int getBuildOptionsOptCount(){\r | |
1967 | if (getfpdBuildOpts().getOptions() == null || getfpdBuildOpts().getOptions().getOptionList() == null) {\r | |
1968 | return 0;\r | |
1969 | }\r | |
1970 | return getfpdBuildOpts().getOptions().getOptionList().size();\r | |
1971 | }\r | |
1972 | \r | |
1973 | public void getBuildOptionsOpts(String[][] saa) {\r | |
1974 | if (getfpdBuildOpts().getOptions() == null || getfpdBuildOpts().getOptions().getOptionList() == null) {\r | |
1975 | return ;\r | |
1976 | }\r | |
1977 | \r | |
1978 | List<OptionDocument.Option> lOpt = getfpdBuildOpts().getOptions().getOptionList();\r | |
1979 | ListIterator li = lOpt.listIterator();\r | |
1980 | int i = 0;\r | |
1981 | while(li.hasNext()) {\r | |
1982 | OptionDocument.Option opt = (OptionDocument.Option)li.next();\r | |
6cba26e8 | 1983 | if (opt.getBuildTargets() != null) {\r |
1984 | saa[i][0] = listToString(opt.getBuildTargets());\r | |
1985 | }\r | |
a13899c5 | 1986 | saa[i][1] = opt.getToolChainFamily();\r |
1987 | if (opt.getSupArchList() != null){\r | |
6cba26e8 | 1988 | saa[i][2] = listToString(opt.getSupArchList());\r |
1989 | \r | |
a13899c5 | 1990 | }\r |
1991 | saa[i][3] = opt.getToolCode();\r | |
1992 | saa[i][4] = opt.getTagName();\r | |
1993 | saa[i][5] = opt.getStringValue();\r | |
1994 | \r | |
1995 | ++i;\r | |
1996 | }\r | |
1997 | }\r | |
1998 | \r | |
6cba26e8 | 1999 | public void genBuildOptionsFfs(String ffsKey, String type) {\r |
2000 | BuildOptionsDocument.BuildOptions.Ffs ffs = getfpdBuildOpts().addNewFfs();\r | |
2001 | ffs.setFfsKey(ffsKey);\r | |
2002 | if (type != null) {\r | |
2003 | ffs.addNewSections().setEncapsulationType(type);\r | |
2004 | }\r | |
2005 | }\r | |
2006 | \r | |
3b405e9b | 2007 | public void updateBuildOptionsFfsSectionsType(int i, String type) {\r |
2008 | BuildOptionsDocument.BuildOptions.Ffs ffs = getfpdBuildOpts().addNewFfs();\r | |
2009 | if (type != null) {\r | |
2010 | ffs.addNewSections().setEncapsulationType(type);\r | |
2011 | }\r | |
2012 | }\r | |
2013 | \r | |
6cba26e8 | 2014 | public void genBuildOptionsFfsAttribute(int i, String name, String value) {\r |
2015 | BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r | |
2016 | BuildOptionsDocument.BuildOptions.Ffs.Attribute attrib = ffs.addNewAttribute();\r | |
2017 | attrib.setName(name);\r | |
2018 | attrib.setValue(value);\r | |
2019 | }\r | |
2020 | \r | |
2021 | /**update jth attribute of ith ffs.\r | |
2022 | * @param i\r | |
2023 | * @param j\r | |
2024 | */\r | |
2025 | public void updateBuildOptionsFfsAttribute(int i, int j, String name, String value){\r | |
2026 | BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r | |
2027 | XmlCursor cursor = ffs.newCursor();\r | |
2028 | QName qAttrib = new QName(xmlNs, "Attribute");\r | |
2029 | if (cursor.toChild(qAttrib)) {\r | |
2030 | for (int k = 0; k < j; ++k) {\r | |
2031 | cursor.toNextSibling(qAttrib);\r | |
2032 | }\r | |
2033 | BuildOptionsDocument.BuildOptions.Ffs.Attribute attrib = (BuildOptionsDocument.BuildOptions.Ffs.Attribute)cursor.getObject();\r | |
2034 | attrib.setName(name);\r | |
2035 | attrib.setValue(value);\r | |
2036 | }\r | |
2037 | cursor.dispose();\r | |
2038 | }\r | |
2039 | \r | |
2040 | public void removeBuildOptionsFfsAttribute(int i, int j){\r | |
2041 | BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r | |
2042 | XmlCursor cursor = ffs.newCursor();\r | |
2043 | QName qAttrib = new QName(xmlNs, "Attribute");\r | |
2044 | if (cursor.toChild(qAttrib)) {\r | |
2045 | for (int k = 0; k < j; ++k) {\r | |
2046 | cursor.toNextSibling(qAttrib);\r | |
2047 | }\r | |
2048 | cursor.removeXml();\r | |
2049 | }\r | |
2050 | cursor.dispose();\r | |
2051 | }\r | |
2052 | \r | |
2053 | public void genBuildOptionsFfsSectionsSection(int i, String sectionType) {\r | |
2054 | BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r | |
2055 | if (ffs == null) {\r | |
2056 | return;\r | |
2057 | }\r | |
2058 | BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections();\r | |
2059 | \r | |
2060 | if (sections == null){\r | |
2061 | sections = ffs.addNewSections();\r | |
2062 | }\r | |
2063 | sections.addNewSection().setSectionType(EfiSectionType.Enum.forString(sectionType));\r | |
2064 | }\r | |
2065 | \r | |
3b405e9b | 2066 | public void removeBuildOptionsFfsSectionsSection(int i, int j) {\r |
2067 | BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r | |
2068 | BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections();\r | |
2069 | if (sections == null) {\r | |
2070 | return;\r | |
2071 | }\r | |
2072 | XmlCursor cursor = sections.newCursor();\r | |
2073 | QName qSection = new QName(xmlNs, "Section");\r | |
2074 | if (cursor.toChild(qSection)) {\r | |
2075 | for (int k = 0; k < j; ++k) {\r | |
2076 | cursor.toNextSibling(qSection);\r | |
2077 | }\r | |
2078 | cursor.removeXml();\r | |
2079 | }\r | |
2080 | cursor.dispose();\r | |
2081 | }\r | |
2082 | \r | |
2083 | public void updateBuildOptionsFfsSectionsSection(int i, int j, String type){\r | |
2084 | BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r | |
2085 | BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections();\r | |
2086 | if (sections == null) {\r | |
2087 | return;\r | |
2088 | }\r | |
2089 | XmlCursor cursor = sections.newCursor();\r | |
2090 | QName qSection = new QName(xmlNs, "Section");\r | |
2091 | if (cursor.toChild(qSection)) {\r | |
2092 | for (int k = 0; k < j; ++k) {\r | |
2093 | cursor.toNextSibling(qSection);\r | |
2094 | }\r | |
2095 | BuildOptionsDocument.BuildOptions.Ffs.Sections.Section section = (BuildOptionsDocument.BuildOptions.Ffs.Sections.Section)cursor.getObject();\r | |
2096 | section.setSectionType(EfiSectionType.Enum.forString(type));\r | |
2097 | }\r | |
2098 | cursor.dispose();\r | |
2099 | } \r | |
2100 | \r | |
6cba26e8 | 2101 | public void genBuildOptionsFfsSectionsSections(int i, String encapType) {\r |
2102 | BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r | |
2103 | if (ffs == null) {\r | |
2104 | return;\r | |
2105 | }\r | |
2106 | BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections();\r | |
2107 | \r | |
2108 | if (sections == null){\r | |
2109 | sections = ffs.addNewSections();\r | |
2110 | }\r | |
2111 | sections.addNewSections().setEncapsulationType(encapType);\r | |
2112 | }\r | |
2113 | \r | |
3b405e9b | 2114 | public void removeBuildOptionsFfsSectionsSections(int i, int j) {\r |
2115 | BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r | |
2116 | BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections();\r | |
2117 | if (sections == null) {\r | |
2118 | return;\r | |
2119 | }\r | |
2120 | XmlCursor cursor = sections.newCursor();\r | |
2121 | QName qSections = new QName(xmlNs, "Sections");\r | |
2122 | if (cursor.toChild(qSections)) {\r | |
2123 | for (int k = 0; k < j; ++k) {\r | |
2124 | cursor.toNextSibling(qSections);\r | |
2125 | }\r | |
2126 | cursor.removeXml();\r | |
2127 | }\r | |
2128 | cursor.dispose();\r | |
2129 | }\r | |
2130 | \r | |
2131 | public void updateBuildOptionsFfsSectionsSections(int i, int j, String type) {\r | |
2132 | BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r | |
2133 | BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections();\r | |
2134 | if (sections == null) {\r | |
2135 | return;\r | |
2136 | }\r | |
2137 | XmlCursor cursor = sections.newCursor();\r | |
2138 | QName qSections = new QName(xmlNs, "Sections");\r | |
2139 | if (cursor.toChild(qSections)) {\r | |
2140 | for (int k = 0; k < j; ++k) {\r | |
2141 | cursor.toNextSibling(qSections);\r | |
2142 | }\r | |
2143 | BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2 sections2 = (BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2)cursor.getObject();\r | |
2144 | sections2.setEncapsulationType(type);\r | |
2145 | }\r | |
2146 | cursor.dispose();\r | |
2147 | }\r | |
2148 | \r | |
6cba26e8 | 2149 | public void genBuildOptionsFfsSectionsSectionsSection(int i, int j, String type) {\r |
2150 | BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r | |
2151 | if (ffs == null) {\r | |
2152 | return;\r | |
2153 | }\r | |
2154 | BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections();\r | |
2155 | XmlCursor cursor = sections.newCursor();\r | |
2156 | QName qSections = new QName(xmlNs, "Sections");\r | |
2157 | if (cursor.toChild(qSections)){\r | |
2158 | for (int k = 0; k < j; ++k) {\r | |
2159 | cursor.toNextSibling(qSections);\r | |
2160 | }\r | |
2161 | BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2 sections2 = (BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2)cursor.getObject();\r | |
2162 | sections2.addNewSection().setSectionType(EfiSectionType.Enum.forString(type));\r | |
2163 | }\r | |
2164 | cursor.dispose();\r | |
2165 | }\r | |
2166 | \r | |
3b405e9b | 2167 | public void removeBuildOptionsFfsSectionsSectionsSection(int i, int j, int k) {\r |
2168 | BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r | |
2169 | BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections();\r | |
2170 | if (sections == null) {\r | |
2171 | return;\r | |
2172 | }\r | |
2173 | XmlCursor cursor = sections.newCursor();\r | |
2174 | QName qSections = new QName(xmlNs, "Sections");\r | |
2175 | if (cursor.toChild(qSections)) {\r | |
2176 | for (int l = 0; l < j; ++l) {\r | |
2177 | cursor.toNextSibling(qSections);\r | |
2178 | }\r | |
2179 | if (cursor.toFirstChild()) {\r | |
af25df16 | 2180 | int m = 0;\r |
2181 | for (; m < k; ++m) {\r | |
3b405e9b | 2182 | cursor.toNextSibling();\r |
2183 | }\r | |
2184 | cursor.removeXml();\r | |
af25df16 | 2185 | if (m == 0) {\r |
2186 | cursor.toParent();\r | |
2187 | cursor.removeXml();\r | |
2188 | }\r | |
3b405e9b | 2189 | }\r |
2190 | }\r | |
2191 | cursor.dispose();\r | |
2192 | }\r | |
2193 | \r | |
2194 | public void updateBuildOptionsFfsSectionsSectionsSection(int i, int j, int k, String type) {\r | |
2195 | BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r | |
2196 | BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections();\r | |
2197 | if (sections == null) {\r | |
2198 | return;\r | |
2199 | }\r | |
2200 | XmlCursor cursor = sections.newCursor();\r | |
2201 | QName qSections = new QName(xmlNs, "Sections");\r | |
2202 | if (cursor.toChild(qSections)) {\r | |
2203 | for (int l = 0; l < j; ++l) {\r | |
2204 | cursor.toNextSibling(qSections);\r | |
2205 | }\r | |
2206 | if (cursor.toFirstChild()) {\r | |
2207 | for (int m = 0; m < k; ++m) {\r | |
2208 | cursor.toNextSibling();\r | |
2209 | }\r | |
2210 | BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2.Section section = (BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2.Section)cursor.getObject();\r | |
2211 | section.setSectionType(EfiSectionType.Enum.forString(type));\r | |
2212 | }\r | |
2213 | }\r | |
2214 | cursor.dispose();\r | |
2215 | }\r | |
2216 | \r | |
6cba26e8 | 2217 | public void getBuildOptionsFfsSectionsSectionsSection(int i, int j, ArrayList<String> al) {\r |
2218 | BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r | |
2219 | if (ffs == null) {\r | |
2220 | return;\r | |
2221 | }\r | |
2222 | BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections();\r | |
2223 | XmlCursor cursor = sections.newCursor();\r | |
2224 | QName qSections = new QName(xmlNs, "Sections");\r | |
2225 | if (cursor.toChild(qSections)){\r | |
2226 | for (int k = 0; k < j; ++k) {\r | |
2227 | cursor.toNextSibling(qSections);\r | |
2228 | }\r | |
2229 | BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2 sections2 = (BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2)cursor.getObject();\r | |
2230 | if (sections2.getSectionList() == null){\r | |
2231 | cursor.dispose();\r | |
2232 | return;\r | |
2233 | }\r | |
2234 | ListIterator<BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2.Section> li = sections2.getSectionList().listIterator();\r | |
2235 | while(li.hasNext()) {\r | |
2236 | BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2.Section section = li.next();\r | |
3b405e9b | 2237 | if (section.isSetSectionType()) {\r |
1800d80f | 2238 | al.add(section.getSectionType().toString());\r |
2239 | }\r | |
3b405e9b | 2240 | \r |
2241 | }\r | |
6cba26e8 | 2242 | }\r |
2243 | cursor.dispose();\r | |
2244 | \r | |
2245 | }\r | |
2246 | \r | |
2247 | public int getBuildOptionsFfsCount(){\r | |
2248 | if (getfpdBuildOpts().getFfsList() == null) {\r | |
2249 | return 0;\r | |
2250 | }\r | |
2251 | return getfpdBuildOpts().getFfsList().size();\r | |
2252 | }\r | |
2253 | \r | |
2254 | public void getBuildOptionsFfsKey(String[][] saa) {\r | |
2255 | if (getfpdBuildOpts().getFfsList() == null) {\r | |
2256 | return;\r | |
2257 | }\r | |
2258 | ListIterator<BuildOptionsDocument.BuildOptions.Ffs> li = getfpdBuildOpts().getFfsList().listIterator();\r | |
2259 | int i = 0;\r | |
2260 | while(li.hasNext()){\r | |
2261 | BuildOptionsDocument.BuildOptions.Ffs ffs = li.next();\r | |
2262 | saa[i][0] = ffs.getFfsKey();\r | |
2263 | ++i;\r | |
2264 | }\r | |
2265 | }\r | |
2266 | \r | |
3b405e9b | 2267 | public void updateBuildOptionsFfsKey(int i, String key) {\r |
2268 | BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r | |
2269 | ffs.setFfsKey(key);\r | |
2270 | }\r | |
2271 | \r | |
6cba26e8 | 2272 | /**Get ith FFS key and contents.\r |
2273 | * @param saa\r | |
2274 | */\r | |
2275 | public void getBuildOptionsFfs(int i, String[] sa, LinkedHashMap<String, String> ffsAttribMap, ArrayList<String> firstLevelSections, ArrayList<String> firstLevelSection) {\r | |
2276 | BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r | |
2277 | \r | |
2278 | if (ffs != null) {\r | |
2279 | \r | |
2280 | sa[0] = ffs.getFfsKey();\r | |
2281 | if (ffs.getSections() != null) {\r | |
2282 | if(ffs.getSections().getEncapsulationType() != null){\r | |
2283 | sa[1] = ffs.getSections().getEncapsulationType();\r | |
2284 | }\r | |
2285 | if (ffs.getSections().getSectionList() != null){\r | |
2286 | ListIterator<BuildOptionsDocument.BuildOptions.Ffs.Sections.Section> li = ffs.getSections().getSectionList().listIterator();\r | |
2287 | while (li.hasNext()) {\r | |
2288 | firstLevelSection.add(li.next().getSectionType().toString());\r | |
2289 | }\r | |
2290 | }\r | |
2291 | if (ffs.getSections().getSectionsList() != null) {\r | |
2292 | ListIterator<BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2> li = ffs.getSections().getSectionsList().listIterator();\r | |
2293 | while(li.hasNext()) {\r | |
2294 | firstLevelSections.add(li.next().getEncapsulationType());\r | |
2295 | }\r | |
2296 | }\r | |
2297 | }\r | |
2298 | if (ffs.getAttributeList() != null) {\r | |
2299 | ListIterator<BuildOptionsDocument.BuildOptions.Ffs.Attribute> li = ffs.getAttributeList().listIterator();\r | |
2300 | while(li.hasNext()) {\r | |
2301 | BuildOptionsDocument.BuildOptions.Ffs.Attribute attrib = li.next();\r | |
2302 | ffsAttribMap.put(attrib.getName(), attrib.getValue());\r | |
2303 | }\r | |
2304 | \r | |
2305 | }\r | |
2306 | }\r | |
2307 | \r | |
2308 | \r | |
2309 | }\r | |
2310 | \r | |
2311 | private BuildOptionsDocument.BuildOptions.Ffs getFfs(int i) {\r | |
2312 | XmlObject o = getfpdBuildOpts();\r | |
2313 | BuildOptionsDocument.BuildOptions.Ffs ffs = null;\r | |
2314 | \r | |
2315 | XmlCursor cursor = o.newCursor();\r | |
2316 | QName qFfs = new QName(xmlNs, "Ffs");\r | |
2317 | if (cursor.toChild(qFfs)) {\r | |
2318 | for (int j = 0; j < i; ++j) {\r | |
2319 | cursor.toNextSibling(qFfs);\r | |
2320 | }\r | |
2321 | ffs = (BuildOptionsDocument.BuildOptions.Ffs)cursor.getObject();\r | |
2322 | }\r | |
2323 | cursor.dispose();\r | |
2324 | return ffs;\r | |
2325 | }\r | |
2326 | \r | |
2327 | public void removeBuildOptionsFfs(int i) {\r | |
2328 | BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r | |
2329 | if (ffs == null){\r | |
2330 | return;\r | |
2331 | }\r | |
2332 | \r | |
2333 | XmlCursor cursor = ffs.newCursor();\r | |
2334 | cursor.removeXml();\r | |
2335 | cursor.dispose();\r | |
2336 | }\r | |
2337 | \r | |
3b405e9b | 2338 | \r |
2339 | \r | |
a13899c5 | 2340 | public PlatformDefinitionsDocument.PlatformDefinitions getfpdPlatformDefs(){\r |
2341 | if (fpdPlatformDefs == null){\r | |
2342 | fpdPlatformDefs = fpdRoot.addNewPlatformDefinitions();\r | |
2343 | }\r | |
2344 | return fpdPlatformDefs;\r | |
2345 | }\r | |
2346 | \r | |
6a09eb19 | 2347 | public void getPlatformDefsSupportedArchs(Vector<Object> archs){\r |
2348 | if (getfpdPlatformDefs().getSupportedArchitectures() == null) {\r | |
2349 | return;\r | |
2350 | }\r | |
2351 | ListIterator li = getfpdPlatformDefs().getSupportedArchitectures().listIterator();\r | |
2352 | while(li.hasNext()) {\r | |
2353 | archs.add(li.next());\r | |
2354 | }\r | |
2355 | }\r | |
2356 | \r | |
2357 | public void setPlatformDefsSupportedArchs(Vector<Object> archs) {\r | |
bf5abaff | 2358 | if (archs != null) {\r |
2359 | getfpdPlatformDefs().setSupportedArchitectures(archs);\r | |
2360 | }\r | |
2361 | // else {\r | |
2362 | // XmlCursor cursor = getfpdPlatformDefs().newCursor();\r | |
2363 | // if (cursor.toChild(xmlNs, "SupportedArchitectures")) {\r | |
2364 | // cursor.removeXml();\r | |
2365 | // }\r | |
2366 | // cursor.dispose();\r | |
2367 | // }\r | |
6a09eb19 | 2368 | }\r |
2369 | \r | |
2370 | public void getPlatformDefsBuildTargets(Vector<Object> targets) {\r | |
2371 | if (getfpdPlatformDefs().getBuildTargets() == null) {\r | |
2372 | return;\r | |
2373 | }\r | |
2374 | ListIterator li = getfpdPlatformDefs().getBuildTargets().listIterator();\r | |
2375 | while(li.hasNext()) {\r | |
2376 | targets.add(li.next());\r | |
2377 | }\r | |
2378 | }\r | |
2379 | \r | |
2380 | public void setPlatformDefsBuildTargets(Vector<Object> targets) {\r | |
2381 | getfpdPlatformDefs().setBuildTargets(targets);\r | |
2382 | }\r | |
2383 | \r | |
2384 | public void genPlatformDefsSkuInfo(String id, String name) {\r | |
2385 | SkuInfoDocument.SkuInfo skuInfo = null;\r | |
2386 | if (getfpdPlatformDefs().getSkuInfo() == null) {\r | |
2387 | skuInfo = getfpdPlatformDefs().addNewSkuInfo();\r | |
2388 | }\r | |
2389 | skuInfo = getfpdPlatformDefs().getSkuInfo();\r | |
2390 | if (skuInfo.getUiSkuNameList() == null || skuInfo.getUiSkuNameList().size() == 0) {\r | |
2391 | SkuInfoDocument.SkuInfo.UiSkuName skuName = skuInfo.addNewUiSkuName();\r | |
2392 | skuName.setSkuID(new BigInteger("0"));\r | |
2393 | skuName.setStringValue("DEFAULT");\r | |
2394 | }\r | |
2395 | if (id.equals("0")) {\r | |
2396 | return;\r | |
2397 | }\r | |
2398 | SkuInfoDocument.SkuInfo.UiSkuName skuName = skuInfo.addNewUiSkuName();\r | |
2399 | skuName.setSkuID(new BigInteger(id));\r | |
2400 | skuName.setStringValue(name);\r | |
2401 | }\r | |
2402 | \r | |
2403 | public int getPlatformDefsSkuInfoCount(){\r | |
2404 | if (getfpdPlatformDefs().getSkuInfo() == null || getfpdPlatformDefs().getSkuInfo().getUiSkuNameList() == null) {\r | |
2405 | return 0;\r | |
2406 | }\r | |
2407 | return getfpdPlatformDefs().getSkuInfo().getUiSkuNameList().size();\r | |
2408 | }\r | |
2409 | \r | |
2410 | public void getPlatformDefsSkuInfos(String[][] saa){\r | |
2411 | if (getfpdPlatformDefs().getSkuInfo() == null || getfpdPlatformDefs().getSkuInfo().getUiSkuNameList() == null) {\r | |
5af6b67f | 2412 | if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null) {\r |
2413 | removeElement(getfpdDynPcdBuildDefs());\r | |
2414 | fpdDynPcdBuildDefs = null;\r | |
2415 | }\r | |
6a09eb19 | 2416 | return ;\r |
2417 | }\r | |
2418 | \r | |
2419 | List<SkuInfoDocument.SkuInfo.UiSkuName> l = getfpdPlatformDefs().getSkuInfo().getUiSkuNameList();\r | |
2420 | ListIterator<SkuInfoDocument.SkuInfo.UiSkuName> li = l.listIterator();\r | |
2421 | int i = 0;\r | |
2422 | while(li.hasNext()) {\r | |
2423 | SkuInfoDocument.SkuInfo.UiSkuName sku = li.next();\r | |
2424 | saa[i][0] = sku.getSkuID()+"";\r | |
2425 | saa[i][1] = sku.getStringValue();\r | |
2426 | ++i;\r | |
2427 | }\r | |
2428 | }\r | |
2429 | \r | |
2430 | public void removePlatformDefsSkuInfo(int i) {\r | |
2431 | SkuInfoDocument.SkuInfo skuInfo = getfpdPlatformDefs().getSkuInfo();\r | |
2432 | if (skuInfo == null || i == 0) {\r | |
2433 | return ;\r | |
2434 | }\r | |
2435 | \r | |
2436 | XmlCursor cursor = skuInfo.newCursor();\r | |
2437 | if (cursor.toFirstChild()) {\r | |
2438 | for (int j = 0; j < i; ++j) {\r | |
2439 | cursor.toNextSibling();\r | |
2440 | }\r | |
2441 | cursor.removeXml();\r | |
2442 | }\r | |
2443 | cursor.dispose();\r | |
2444 | }\r | |
2445 | \r | |
2446 | public void updatePlatformDefsSkuInfo(int i, String id, String name) {\r | |
2447 | SkuInfoDocument.SkuInfo skuInfo = getfpdPlatformDefs().getSkuInfo();\r | |
2448 | if (skuInfo == null || i == 0) {\r | |
2449 | return ;\r | |
2450 | }\r | |
2451 | \r | |
2452 | XmlCursor cursor = skuInfo.newCursor();\r | |
2453 | if (cursor.toFirstChild()) {\r | |
2454 | for (int j = 0; j < i; ++j) {\r | |
2455 | cursor.toNextSibling();\r | |
2456 | }\r | |
2457 | SkuInfoDocument.SkuInfo.UiSkuName sku = (SkuInfoDocument.SkuInfo.UiSkuName)cursor.getObject();\r | |
2458 | sku.setSkuID(new BigInteger(id));\r | |
2459 | sku.setStringValue(name);\r | |
2460 | }\r | |
2461 | cursor.dispose();\r | |
2462 | }\r | |
2463 | \r | |
2464 | public String getPlatformDefsInterDir(){\r | |
2465 | if (getfpdPlatformDefs().getIntermediateDirectories() == null) {\r | |
2466 | return null;\r | |
2467 | }\r | |
2468 | return getfpdPlatformDefs().getIntermediateDirectories().toString();\r | |
2469 | }\r | |
2470 | \r | |
2471 | public void setPlatformDefsInterDir(String interDir){\r | |
2472 | getfpdPlatformDefs().setIntermediateDirectories(IntermediateOutputType.Enum.forString(interDir));\r | |
2473 | }\r | |
2474 | \r | |
2475 | public String getPlatformDefsOutputDir() {\r | |
2476 | return getfpdPlatformDefs().getOutputDirectory();\r | |
2477 | }\r | |
2478 | \r | |
2479 | public void setPlatformDefsOutputDir(String outputDir) {\r | |
af25df16 | 2480 | if (outputDir != null && outputDir.length() > 0) {\r |
2481 | getfpdPlatformDefs().setOutputDirectory(outputDir);\r | |
2482 | }\r | |
2483 | else{\r | |
2484 | XmlCursor cursor = getfpdPlatformDefs().newCursor();\r | |
2485 | if (cursor.toChild(new QName(xmlNs, "OutputDirectory"))) {\r | |
2486 | cursor.removeXml();\r | |
2487 | }\r | |
2488 | cursor.dispose();\r | |
2489 | }\r | |
6a09eb19 | 2490 | }\r |
2491 | \r | |
a13899c5 | 2492 | public FlashDocument.Flash getfpdFlash() {\r |
2493 | if (fpdFlash == null) {\r | |
2494 | fpdFlash = fpdRoot.addNewFlash();\r | |
2495 | }\r | |
2496 | return fpdFlash;\r | |
2497 | }\r | |
2498 | \r | |
2499 | public void genFlashDefinitionFile(String file) {\r | |
2500 | FlashDefinitionFileDocument.FlashDefinitionFile fdf = getfpdFlash().getFlashDefinitionFile();\r | |
2501 | if (fdf == null) {\r | |
2502 | fdf = getfpdFlash().addNewFlashDefinitionFile();\r | |
2503 | }\r | |
2504 | \r | |
2505 | fdf.setStringValue(file);\r | |
2506 | }\r | |
2507 | \r | |
2508 | public String getFlashDefinitionFile() {\r | |
2509 | FlashDefinitionFileDocument.FlashDefinitionFile fdf = getfpdFlash().getFlashDefinitionFile();\r | |
2510 | if (fdf == null) {\r | |
2511 | return "";\r | |
2512 | }\r | |
2513 | \r | |
2514 | return fdf.getStringValue();\r | |
2515 | }\r | |
2516 | \r | |
a13899c5 | 2517 | public void genFvImagesNameValue(String name, String value) {\r |
2518 | \r | |
2519 | FvImagesDocument.FvImages fi = getfpdFlash().getFvImages();\r | |
2520 | if (fi == null) {\r | |
2521 | fi = getfpdFlash().addNewFvImages();\r | |
2522 | }\r | |
2523 | \r | |
2524 | FvImagesDocument.FvImages.NameValue nv = fi.addNewNameValue();\r | |
2525 | nv.setName(name);\r | |
2526 | nv.setValue(value);\r | |
2527 | }\r | |
2528 | \r | |
2529 | public void removeFvImagesNameValue(int i){\r | |
2530 | \r | |
2531 | XmlObject o = getfpdFlash().getFvImages();\r | |
2532 | if (o == null) {\r | |
2533 | return;\r | |
2534 | }\r | |
2535 | \r | |
2536 | QName qNameValue = new QName(xmlNs, "NameValue");\r | |
2537 | XmlCursor cursor = o.newCursor();\r | |
2538 | if (cursor.toChild(qNameValue)) {\r | |
2539 | for (int j = 0; j < i; ++j) {\r | |
2540 | cursor.toNextSibling(qNameValue);\r | |
2541 | }\r | |
2542 | cursor.removeXml();\r | |
2543 | }\r | |
2544 | cursor.dispose();\r | |
2545 | }\r | |
2546 | \r | |
2547 | public void updateFvImagesNameValue(int i, String name, String value){\r | |
2548 | \r | |
2549 | XmlObject o = getfpdFlash().getFvImages();\r | |
2550 | if (o == null) {\r | |
2551 | return;\r | |
2552 | }\r | |
2553 | \r | |
2554 | QName qNameValue = new QName(xmlNs, "NameValue");\r | |
2555 | XmlCursor cursor = o.newCursor();\r | |
2556 | if (cursor.toChild(qNameValue)) {\r | |
2557 | for (int j = 0; j < i; ++j) {\r | |
2558 | cursor.toNextSibling(qNameValue);\r | |
2559 | }\r | |
2560 | FvImagesDocument.FvImages.NameValue nv = (FvImagesDocument.FvImages.NameValue)cursor.getObject();\r | |
2561 | nv.setName(name);\r | |
2562 | nv.setValue(value);\r | |
2563 | }\r | |
2564 | cursor.dispose();\r | |
2565 | }\r | |
2566 | \r | |
2567 | public int getFvImagesNameValueCount() {\r | |
2568 | \r | |
2569 | FvImagesDocument.FvImages fi = null;\r | |
2570 | if ((fi = getfpdFlash().getFvImages()) == null || fi.getNameValueList() == null) {\r | |
2571 | return 0;\r | |
2572 | }\r | |
2573 | return fi.getNameValueList().size();\r | |
2574 | }\r | |
2575 | \r | |
2576 | public void getFvImagesNameValues(String[][] nv) {\r | |
2577 | \r | |
2578 | FvImagesDocument.FvImages fi = getfpdFlash().getFvImages();\r | |
2579 | if (fi == null){\r | |
2580 | return;\r | |
2581 | }\r | |
2582 | List<FvImagesDocument.FvImages.NameValue> l = fi.getNameValueList();\r | |
2583 | int i = 0;\r | |
2584 | ListIterator li = l.listIterator();\r | |
2585 | while (li.hasNext()) {\r | |
2586 | FvImagesDocument.FvImages.NameValue e = (FvImagesDocument.FvImages.NameValue) li\r | |
2587 | .next();\r | |
2588 | nv[i][0] = e.getName();\r | |
2589 | nv[i][1] = e.getValue();\r | |
2590 | \r | |
2591 | i++;\r | |
2592 | }\r | |
2593 | }\r | |
2594 | \r | |
eb8ea829 | 2595 | public void getFvImagesFvImageFvImageNames (Vector<String> vImageNames) {\r |
98c20797 | 2596 | FvImagesDocument.FvImages fis = getfpdFlash().getFvImages();\r |
2597 | if (fis == null || fis.getFvImageList() == null) {\r | |
2598 | return;\r | |
2599 | }\r | |
eb8ea829 | 2600 | \r |
98c20797 | 2601 | ListIterator<FvImagesDocument.FvImages.FvImage> li = fis.getFvImageList().listIterator();\r |
2602 | while (li.hasNext()) {\r | |
2603 | FvImagesDocument.FvImages.FvImage fi = li.next();\r | |
2604 | if (fi.getType().toString().equals("ImageName")) {\r | |
2605 | vImageNames.addAll(fi.getFvImageNamesList());\r | |
2606 | return;\r | |
2607 | }\r | |
2608 | }\r | |
eb8ea829 | 2609 | }\r |
2610 | \r | |
54aa8673 | 2611 | public void addFvImageFvImageNames (String[] fvNames) {\r |
eb8ea829 | 2612 | FvImagesDocument.FvImages fis = getfpdFlash().getFvImages();\r |
2613 | if (fis == null || fis.getFvImageList() == null) {\r | |
2614 | genFvImagesFvImage (fvNames, "ImageName", null);\r | |
2615 | return;\r | |
2616 | }\r | |
2617 | \r | |
2618 | ListIterator<FvImagesDocument.FvImages.FvImage> li = fis.getFvImageList().listIterator();\r | |
2619 | while (li.hasNext()) {\r | |
2620 | FvImagesDocument.FvImages.FvImage fi = li.next();\r | |
2621 | if (fi.getType().toString().equals("ImageName")) {\r | |
54aa8673 | 2622 | addFvImageNamesInFvImage (fi, fvNames);\r |
eb8ea829 | 2623 | return;\r |
2624 | }\r | |
2625 | }\r | |
54aa8673 | 2626 | genFvImagesFvImage (fvNames, "ImageName", null); \r |
2627 | }\r | |
2628 | \r | |
2629 | public void addFvImageNamesInFvImage (FvImagesDocument.FvImages.FvImage fi, String[] fvNames) {\r | |
eb8ea829 | 2630 | \r |
54aa8673 | 2631 | for (int i = 0; i < fvNames.length; ++i) {\r |
2632 | fi.addFvImageNames(fvNames[i]);\r | |
2633 | }\r | |
2634 | }\r | |
2635 | \r | |
2636 | public void addFvImageNamesInFvImage (int i, String[] fvNames) {\r | |
2637 | XmlObject o = getfpdFlash().getFvImages();\r | |
2638 | if (o == null) {\r | |
2639 | return;\r | |
2640 | }\r | |
2641 | XmlCursor cursor = o.newCursor();\r | |
2642 | QName qFvImage = new QName(xmlNs, "FvImage");\r | |
2643 | if (cursor.toChild(qFvImage)) {\r | |
2644 | for (int j = 0; j < i; ++j) {\r | |
2645 | cursor.toNextSibling(qFvImage);\r | |
2646 | }\r | |
2647 | FvImagesDocument.FvImages.FvImage fi = (FvImagesDocument.FvImages.FvImage)cursor.getObject();\r | |
2648 | addFvImageNamesInFvImage(fi, fvNames);\r | |
2649 | }\r | |
2650 | cursor.dispose();\r | |
eb8ea829 | 2651 | }\r |
2652 | \r | |
a13899c5 | 2653 | public void genFvImagesFvImage(String[] names, String types, Map<String, String> options) {\r |
2654 | \r | |
2655 | FvImagesDocument.FvImages fis = null;\r | |
2656 | if ((fis = getfpdFlash().getFvImages()) == null) {\r | |
2657 | fis = getfpdFlash().addNewFvImages();\r | |
2658 | }\r | |
2659 | \r | |
2660 | //\r | |
2661 | //gen FvImage with FvImageNames array\r | |
2662 | //\r | |
2663 | FvImagesDocument.FvImages.FvImage fi = fis.addNewFvImage();\r | |
2664 | for (int i = 0; i < names.length; ++i) {\r | |
2665 | fi.addFvImageNames(names[i]);\r | |
2666 | }\r | |
2667 | fi.setType(FvImageTypes.Enum.forString(types));\r | |
2668 | if (options != null){\r | |
2669 | setFvImagesFvImageFvImageOptions(options, fi);\r | |
2670 | }\r | |
2671 | }\r | |
2672 | \r | |
2673 | private void setFvImagesFvImageFvImageOptions(Map<String, String> options, FvImagesDocument.FvImages.FvImage fi){\r | |
2674 | FvImagesDocument.FvImages.FvImage.FvImageOptions fio = fi.getFvImageOptions();\r | |
2675 | if (fio == null){\r | |
2676 | fio = fi.addNewFvImageOptions();\r | |
2677 | }\r | |
2678 | \r | |
2679 | Set<String> key = options.keySet();\r | |
2680 | Iterator<String> i = key.iterator();\r | |
2681 | while (i.hasNext()) {\r | |
44053733 | 2682 | \r |
a13899c5 | 2683 | FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue nv = fio.addNewNameValue();\r |
2684 | String k = (String)i.next();\r | |
ae0d4fd2 | 2685 | \r |
a13899c5 | 2686 | nv.setName(k);\r |
2687 | nv.setValue((String)options.get(k));\r | |
2688 | \r | |
2689 | }\r | |
2690 | \r | |
2691 | }\r | |
2692 | \r | |
44053733 | 2693 | \r |
a13899c5 | 2694 | public void removeFvImagesFvImage(int i) {\r |
2695 | \r | |
2696 | XmlObject o = getfpdFlash().getFvImages();\r | |
2697 | if (o == null) {\r | |
2698 | return;\r | |
2699 | }\r | |
2700 | \r | |
2701 | QName qFvImage = new QName(xmlNs, "FvImage");\r | |
2702 | XmlCursor cursor = o.newCursor();\r | |
2703 | if (cursor.toChild(qFvImage)) {\r | |
2704 | for (int j = 0; j < i; ++j) {\r | |
2705 | cursor.toNextSibling(qFvImage);\r | |
2706 | }\r | |
2707 | cursor.removeXml();\r | |
2708 | }\r | |
2709 | cursor.dispose();\r | |
2710 | }\r | |
2711 | \r | |
98c20797 | 2712 | /**\r |
2713 | * @param oldFvName\r | |
2714 | * @param newFvName The New FV Name. If null, remove the old FvImageNames entry.\r | |
2715 | */\r | |
eb8ea829 | 2716 | public void updateFvImageNameAll (String oldFvName, String newFvName) {\r |
2717 | if (getfpdFlash().getFvImages() == null || getfpdFlash().getFvImages().getFvImageList() == null) {\r | |
2718 | return;\r | |
2719 | }\r | |
2720 | ListIterator<FvImagesDocument.FvImages.FvImage> li = getfpdFlash().getFvImages().getFvImageList().listIterator();\r | |
2721 | while (li.hasNext()) {\r | |
2722 | FvImagesDocument.FvImages.FvImage fi = li.next();\r | |
2723 | updateFvImageNamesInFvImage (fi, oldFvName, newFvName);\r | |
701d95b3 | 2724 | if (fi.getFvImageNamesList().size() == 0) {\r |
2725 | li.remove();\r | |
2726 | }\r | |
eb8ea829 | 2727 | }\r |
2728 | }\r | |
2729 | \r | |
54aa8673 | 2730 | public void updateFvImageNamesInFvImage (int i, String oldFvName, String newFvName) {\r |
2731 | XmlObject o = getfpdFlash().getFvImages();\r | |
2732 | if (o == null) {\r | |
2733 | return;\r | |
2734 | }\r | |
2735 | XmlCursor cursor = o.newCursor();\r | |
2736 | QName qFvImage = new QName(xmlNs, "FvImage");\r | |
2737 | if (cursor.toChild(qFvImage)) {\r | |
2738 | for (int j = 0; j < i; ++j) {\r | |
2739 | cursor.toNextSibling(qFvImage);\r | |
2740 | }\r | |
2741 | FvImagesDocument.FvImages.FvImage fi = (FvImagesDocument.FvImages.FvImage)cursor.getObject();\r | |
2742 | updateFvImageNamesInFvImage (fi, oldFvName, newFvName);\r | |
2743 | }\r | |
2744 | cursor.dispose();\r | |
2745 | }\r | |
98c20797 | 2746 | /**\r |
2747 | * @param fi\r | |
2748 | * @param oldFvName The FV Name to be replaced.\r | |
2749 | * @param newFvName The New FV Name. If null, remove the old FvImageNames entry.\r | |
2750 | */\r | |
eb8ea829 | 2751 | public void updateFvImageNamesInFvImage (FvImagesDocument.FvImages.FvImage fi, String oldFvName, String newFvName) {\r |
2752 | QName qFvImageNames = new QName(xmlNs, "FvImageNames");\r | |
2753 | XmlCursor cursor = fi.newCursor();\r | |
2754 | \r | |
2755 | if (cursor.toChild(qFvImageNames)) {\r | |
2756 | do {\r | |
701d95b3 | 2757 | String xmlValue = cursor.getTextValue();\r |
2758 | if (xmlValue.equals(oldFvName)){\r | |
98c20797 | 2759 | if (newFvName != null) {\r |
2760 | cursor.setTextValue(newFvName);\r | |
2761 | }\r | |
2762 | else {\r | |
54aa8673 | 2763 | cursor.removeXml();\r |
98c20797 | 2764 | }\r |
eb8ea829 | 2765 | }\r |
2766 | }while (cursor.toNextSibling(qFvImageNames));\r | |
2767 | }\r | |
2768 | \r | |
2769 | cursor.dispose();\r | |
2770 | }\r | |
2771 | \r | |
72426064 | 2772 | /**update the Type attribute of ith FvImage with new type.\r |
2773 | * @param i\r | |
2774 | * @param type\r | |
2775 | */\r | |
2776 | public void updateFvImagesFvImageType (int i, String type) {\r | |
2777 | XmlObject o = getfpdFlash().getFvImages();\r | |
2778 | if (o == null) {\r | |
2779 | return;\r | |
2780 | }\r | |
2781 | XmlCursor cursor = o.newCursor();\r | |
2782 | QName qFvImage = new QName(xmlNs, "FvImage");\r | |
2783 | if (cursor.toChild(qFvImage)) {\r | |
2784 | for (int j = 0; j < i; ++j) {\r | |
2785 | cursor.toNextSibling(qFvImage);\r | |
2786 | }\r | |
2787 | FvImagesDocument.FvImages.FvImage fi = (FvImagesDocument.FvImages.FvImage)cursor.getObject();\r | |
2788 | fi.setType(FvImageTypes.Enum.forString(type));\r | |
2789 | }\r | |
2790 | cursor.dispose();\r | |
2791 | }\r | |
2792 | \r | |
a13899c5 | 2793 | public void updateFvImagesFvImage(int i, String[] names, String types, Map<String, String> options){\r |
2794 | \r | |
2795 | XmlObject o = getfpdFlash().getFvImages();\r | |
2796 | if (o == null) {\r | |
2797 | return;\r | |
2798 | }\r | |
2799 | XmlCursor cursor = o.newCursor();\r | |
2800 | QName qFvImage = new QName(xmlNs, "FvImage");\r | |
2801 | if (cursor.toChild(qFvImage)) {\r | |
2802 | for (int j = 0; j < i; ++j) {\r | |
2803 | cursor.toNextSibling(qFvImage);\r | |
2804 | }\r | |
2805 | FvImagesDocument.FvImages.FvImage fi = (FvImagesDocument.FvImages.FvImage)cursor.getObject();\r | |
2806 | fi.setType(FvImageTypes.Enum.forString(types));\r | |
2807 | \r | |
2808 | //\r | |
2809 | // remove old FvImageNames before adding new ones\r | |
2810 | //\r | |
2811 | QName qFvImageNames = new QName(xmlNs, "FvImageNames"); \r | |
2812 | cursor.toChild(qFvImageNames);\r | |
2813 | cursor.removeXml();\r | |
2814 | while (cursor.toNextSibling(qFvImageNames)) {\r | |
2815 | cursor.removeXml();\r | |
2816 | }\r | |
2817 | \r | |
2818 | for (int k = 0; k < names.length; ++k) {\r | |
2819 | fi.addFvImageNames(names[k]);\r | |
2820 | }\r | |
2821 | //\r | |
2822 | // remove old FvImageOptions before adding new options\r | |
2823 | //\r | |
2824 | QName qFvImageOptions = new QName(xmlNs, "FvImageOptions");\r | |
2825 | cursor.toNextSibling(qFvImageOptions);\r | |
2826 | cursor.removeXml();\r | |
2827 | \r | |
2828 | setFvImagesFvImageFvImageOptions(options, fi);\r | |
2829 | }\r | |
2830 | cursor.dispose();\r | |
2831 | }\r | |
2832 | \r | |
98c20797 | 2833 | public int getFvImagesFvImageCount(String type) {\r |
a13899c5 | 2834 | \r |
2835 | if (getfpdFlash().getFvImages() == null || getfpdFlash().getFvImages().getFvImageList() == null) {\r | |
2836 | return 0;\r | |
2837 | }\r | |
98c20797 | 2838 | List<FvImagesDocument.FvImages.FvImage> l = getfpdFlash().getFvImages().getFvImageList();\r |
2839 | ListIterator li = l.listIterator();\r | |
2840 | int i = 0;\r | |
2841 | while(li.hasNext()) {\r | |
2842 | FvImagesDocument.FvImages.FvImage fi = (FvImagesDocument.FvImages.FvImage)li.next();\r | |
2843 | if (!fi.getType().toString().equals(type) && !type.equals("ALL")) {\r | |
2844 | continue;\r | |
2845 | }\r | |
2846 | \r | |
2847 | ++i;\r | |
2848 | }\r | |
2849 | \r | |
2850 | return i;\r | |
a13899c5 | 2851 | }\r |
2852 | \r | |
98c20797 | 2853 | public Vector<FvImagesDocument.FvImages.FvImage> getFvImagesFvImageWithName (String fvName, String type) {\r |
2854 | Vector<FvImagesDocument.FvImages.FvImage> vFvImage = new Vector<FvImagesDocument.FvImages.FvImage>();\r | |
2855 | if (getfpdFlash().getFvImages() == null || getfpdFlash().getFvImages().getFvImageList() == null) {\r | |
2856 | return vFvImage;\r | |
2857 | }\r | |
2858 | List<FvImagesDocument.FvImages.FvImage> l = getfpdFlash().getFvImages().getFvImageList();\r | |
2859 | ListIterator li = l.listIterator();\r | |
2860 | while(li.hasNext()) {\r | |
2861 | FvImagesDocument.FvImages.FvImage fi = (FvImagesDocument.FvImages.FvImage)li.next();\r | |
2862 | if (!fi.getType().toString().equals(type) && !type.equals("ALL")) {\r | |
2863 | continue;\r | |
2864 | }\r | |
2865 | if (fi.getFvImageNamesList().contains(fvName)) {\r | |
2866 | vFvImage.add(fi);\r | |
2867 | }\r | |
2868 | }\r | |
2869 | \r | |
2870 | return vFvImage;\r | |
2871 | }\r | |
2872 | /**\r | |
ae0d4fd2 | 2873 | * @param saa\r |
98c20797 | 2874 | * @param type "ALL" means all FvImage types: ImageName, Options, Attributes, Components.\r |
ae0d4fd2 | 2875 | */\r |
98c20797 | 2876 | public void getFvImagesFvImages(String[][] saa, String type) {\r |
a13899c5 | 2877 | \r |
2878 | if (getfpdFlash().getFvImages() == null) {\r | |
2879 | return;\r | |
2880 | }\r | |
2881 | List<FvImagesDocument.FvImages.FvImage> l = getfpdFlash().getFvImages().getFvImageList();\r | |
2882 | if (l == null) {\r | |
2883 | return;\r | |
2884 | }\r | |
2885 | ListIterator li = l.listIterator();\r | |
2886 | int i = 0;\r | |
2887 | while(li.hasNext()) {\r | |
2888 | FvImagesDocument.FvImages.FvImage fi = (FvImagesDocument.FvImages.FvImage)li.next();\r | |
98c20797 | 2889 | if (!fi.getType().toString().equals(type) && !type.equals("ALL")) {\r |
2890 | continue;\r | |
2891 | }\r | |
a13899c5 | 2892 | //\r |
2893 | // get FvImageNames array, space separated\r | |
2894 | //\r | |
2895 | List<String> lfn = fi.getFvImageNamesList();\r | |
2896 | ListIterator lfni = lfn.listIterator();\r | |
2897 | saa[i][0] = " ";\r | |
2898 | while (lfni.hasNext()) {\r | |
2899 | saa[i][0] += (String)lfni.next();\r | |
2900 | saa[i][0] += " ";\r | |
2901 | }\r | |
2902 | saa[i][0] = saa[i][0].trim();\r | |
2903 | \r | |
2904 | saa[i][1] = fi.getType()+"";\r | |
2905 | \r | |
ae0d4fd2 | 2906 | ++i;\r |
2907 | }\r | |
2908 | }\r | |
2909 | \r | |
54aa8673 | 2910 | public void removeFvImageNameValue (int i, String attributeName) {\r |
2911 | XmlObject o = getfpdFlash().getFvImages();\r | |
2912 | if (o == null) {\r | |
2913 | return;\r | |
2914 | }\r | |
2915 | XmlCursor cursor = o.newCursor();\r | |
2916 | QName qFvImage = new QName(xmlNs, "FvImage");\r | |
2917 | if (cursor.toChild(qFvImage)) {\r | |
2918 | for (int j = 0; j < i; ++j) {\r | |
2919 | cursor.toNextSibling(qFvImage);\r | |
2920 | }\r | |
2921 | FvImagesDocument.FvImages.FvImage fi = (FvImagesDocument.FvImages.FvImage)cursor.getObject();\r | |
2922 | removeFvImageNameValue (fi, attributeName);\r | |
2923 | }\r | |
2924 | cursor.dispose();\r | |
2925 | }\r | |
72426064 | 2926 | /**Remove from fi the attribute pair with attributeName in FvImageOptions.\r |
2927 | * @param fi\r | |
2928 | * @param attributeName\r | |
2929 | */\r | |
2930 | public void removeFvImageNameValue (FvImagesDocument.FvImages.FvImage fi, String attributeName) {\r | |
2931 | if (fi.getFvImageOptions() != null && fi.getFvImageOptions().getNameValueList() != null) {\r | |
2932 | ListIterator<FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue> li = fi.getFvImageOptions().getNameValueList().listIterator();\r | |
2933 | while (li.hasNext()) {\r | |
2934 | FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue nv = li.next();\r | |
2935 | if (nv.getName().equals(attributeName)) {\r | |
2936 | li.remove();\r | |
2937 | }\r | |
2938 | }\r | |
2939 | }\r | |
2940 | }\r | |
2941 | \r | |
b411fc1f | 2942 | public void removeTypedNamedFvImageNameValue (String fvName, String type, String optName) {\r |
2943 | Vector<FvImagesDocument.FvImages.FvImage> vFvImage = getFvImagesFvImageWithName(fvName, type);\r | |
2944 | for (int i = 0; i < vFvImage.size(); ++i) {\r | |
2945 | FvImagesDocument.FvImages.FvImage fi = vFvImage.get(i);\r | |
72426064 | 2946 | removeFvImageNameValue (fi, optName);\r |
b411fc1f | 2947 | }\r |
2948 | }\r | |
2949 | \r | |
98c20797 | 2950 | /**Add name-value pair to FvImage element with type.\r |
2951 | * @param fvName FV name to add name-value pair.\r | |
2952 | * @param type FvImage attribute.\r | |
2953 | * @param name\r | |
2954 | * @param value\r | |
2955 | */\r | |
2956 | public void setTypedNamedFvImageNameValue (String fvName, String type, String name, String value) {\r | |
b411fc1f | 2957 | boolean fvImageExists = false;\r |
98c20797 | 2958 | if (getfpdFlash().getFvImages() == null) {\r |
2959 | return;\r | |
2960 | }\r | |
2961 | List<FvImagesDocument.FvImages.FvImage> l = getfpdFlash().getFvImages().getFvImageList();\r | |
2962 | if (l == null) {\r | |
2963 | return;\r | |
2964 | }\r | |
2965 | ListIterator li = l.listIterator();\r | |
2966 | while(li.hasNext()) {\r | |
2967 | FvImagesDocument.FvImages.FvImage fi = (FvImagesDocument.FvImages.FvImage)li.next();\r | |
2968 | if (!fi.getType().toString().equals(type) && !type.equals("ALL")) {\r | |
2969 | continue;\r | |
2970 | }\r | |
2971 | if (!fi.getFvImageNamesList().contains(fvName)) {\r | |
2972 | continue;\r | |
2973 | }\r | |
b411fc1f | 2974 | fvImageExists = true;\r |
98c20797 | 2975 | setFvImagesFvImageNameValue (fi, name, value, null);\r |
2976 | }\r | |
b411fc1f | 2977 | \r |
2978 | if (!fvImageExists) {\r | |
2979 | HashMap<String, String> map = new HashMap<String, String>();\r | |
2980 | map.put(name, value);\r | |
2981 | genFvImagesFvImage(new String[]{fvName}, type, map);\r | |
2982 | }\r | |
98c20797 | 2983 | }\r |
2984 | \r | |
2985 | /**Add to all FvImage elements with type, the name-value pair.\r | |
2986 | * @param type\r | |
2987 | * @param name\r | |
2988 | * @param value\r | |
2989 | */\r | |
2990 | public void setTypedFvImageNameValue (String type, String name, String value) {\r | |
2991 | if (getfpdFlash().getFvImages() == null) {\r | |
2992 | return;\r | |
2993 | }\r | |
2994 | List<FvImagesDocument.FvImages.FvImage> l = getfpdFlash().getFvImages().getFvImageList();\r | |
2995 | if (l == null) {\r | |
2996 | return;\r | |
2997 | }\r | |
2998 | ListIterator li = l.listIterator();\r | |
2999 | while(li.hasNext()) {\r | |
3000 | FvImagesDocument.FvImages.FvImage fi = (FvImagesDocument.FvImages.FvImage)li.next();\r | |
3001 | if (!fi.getType().toString().equals(type) && !type.equals("ALL")) {\r | |
3002 | continue;\r | |
3003 | }\r | |
3004 | setFvImagesFvImageNameValue (fi, name, value, null);\r | |
3005 | }\r | |
b411fc1f | 3006 | \r |
98c20797 | 3007 | }\r |
3008 | \r | |
54aa8673 | 3009 | public void setFvImagesFvImageNameValue (int i, String name, String value) {\r |
3010 | XmlObject o = getfpdFlash().getFvImages();\r | |
3011 | if (o == null) {\r | |
3012 | return;\r | |
3013 | }\r | |
3014 | XmlCursor cursor = o.newCursor();\r | |
3015 | QName qFvImage = new QName(xmlNs, "FvImage");\r | |
3016 | if (cursor.toChild(qFvImage)) {\r | |
3017 | for (int j = 0; j < i; ++j) {\r | |
3018 | cursor.toNextSibling(qFvImage);\r | |
3019 | }\r | |
3020 | FvImagesDocument.FvImages.FvImage fi = (FvImagesDocument.FvImages.FvImage)cursor.getObject();\r | |
3021 | setFvImagesFvImageNameValue (fi, name, value, null);\r | |
3022 | }\r | |
3023 | cursor.dispose();\r | |
3024 | }\r | |
3025 | \r | |
98c20797 | 3026 | /**Add to FvImage the name-value pair, or replace old name with newName, or generate new name-value pair if not exists before.\r |
3027 | * @param fi\r | |
3028 | * @param name\r | |
3029 | * @param value\r | |
3030 | * @param newName\r | |
3031 | */\r | |
3032 | public void setFvImagesFvImageNameValue (FvImagesDocument.FvImages.FvImage fi, String name, String value, String newName) {\r | |
3033 | if (fi.getFvImageOptions() == null || fi.getFvImageOptions().getNameValueList() == null) {\r | |
54aa8673 | 3034 | FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue nv = fi.addNewFvImageOptions().addNewNameValue();\r |
3035 | nv.setName(name);\r | |
3036 | nv.setValue(value);\r | |
3037 | if (newName != null) {\r | |
3038 | nv.setName(newName);\r | |
3039 | }\r | |
98c20797 | 3040 | return;\r |
3041 | }\r | |
3042 | \r | |
3043 | XmlCursor cursor = fi.getFvImageOptions().newCursor();\r | |
3044 | if (cursor.toFirstChild()) {\r | |
3045 | do {\r | |
3046 | FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue nv = (FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue)cursor.getObject();\r | |
3047 | if (nv.getName().equals(name)) {\r | |
3048 | nv.setValue(value);\r | |
3049 | if (newName != null) {\r | |
3050 | nv.setName(newName);\r | |
3051 | }\r | |
3052 | cursor.dispose();\r | |
3053 | return;\r | |
3054 | }\r | |
3055 | }while (cursor.toNextSibling());\r | |
3056 | }\r | |
3057 | \r | |
3058 | FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue nv = fi.getFvImageOptions().addNewNameValue();\r | |
3059 | nv.setName(name);\r | |
3060 | nv.setValue(value);\r | |
3061 | if (newName != null) {\r | |
3062 | nv.setName(newName);\r | |
3063 | }\r | |
3064 | cursor.dispose();\r | |
3065 | }\r | |
3066 | \r | |
3067 | public void getFvImagesFvImageOptions (String fvName, Map<String, String> m) {\r | |
3068 | Vector<FvImagesDocument.FvImages.FvImage> vFvImage = getFvImagesFvImageWithName (fvName, "Options");\r | |
3069 | for (int i = 0; i < vFvImage.size(); ++i) {\r | |
3070 | FvImagesDocument.FvImages.FvImage fi = vFvImage.get(i);\r | |
3071 | if (fi == null || fi.getFvImageOptions() == null || fi.getFvImageOptions().getNameValueList() == null) {\r | |
3072 | continue;\r | |
3073 | }\r | |
3074 | \r | |
3075 | ListIterator<FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue> li = fi.getFvImageOptions()\r | |
3076 | .getNameValueList()\r | |
3077 | .listIterator();\r | |
3078 | while (li.hasNext()) {\r | |
3079 | FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue nv = li.next();\r | |
3080 | m.put(nv.getName(), nv.getValue());\r | |
3081 | }\r | |
3082 | }\r | |
3083 | }\r | |
72426064 | 3084 | \r |
3085 | public int getFvImagePosInFvImages (String fvNameList, String type) {\r | |
3086 | XmlObject o = getfpdFlash().getFvImages();\r | |
3087 | if (o == null) {\r | |
3088 | return -1;\r | |
3089 | }\r | |
3090 | \r | |
3091 | int pos = -1;\r | |
54aa8673 | 3092 | String[] fvNameArray = fvNameList.trim().split(" ");\r |
72426064 | 3093 | Vector<String> vFvNames = new Vector<String>();\r |
3094 | \r | |
3095 | \r | |
3096 | XmlCursor cursor = o.newCursor();\r | |
3097 | QName qFvImage = new QName(xmlNs, "FvImage");\r | |
3098 | if (cursor.toChild(qFvImage)) {\r | |
3099 | do {\r | |
3100 | pos++;\r | |
3101 | vFvNames.removeAllElements();\r | |
3102 | for (int i = 0; i < fvNameArray.length; ++i) {\r | |
3103 | vFvNames.add(fvNameArray[i]);\r | |
3104 | }\r | |
3105 | FvImagesDocument.FvImages.FvImage fi = (FvImagesDocument.FvImages.FvImage)cursor.getObject();\r | |
3106 | if (!fi.getType().toString().equals(type)) {\r | |
3107 | continue;\r | |
3108 | }\r | |
3109 | if (fi.getFvImageNamesList() == null || fi.getFvImageNamesList().size() != vFvNames.size()) {\r | |
3110 | continue;\r | |
3111 | }\r | |
3112 | ListIterator<String> li = fi.getFvImageNamesList().listIterator();\r | |
3113 | while (li.hasNext()) {\r | |
3114 | String name = li.next();\r | |
3115 | vFvNames.remove(name);\r | |
3116 | }\r | |
3117 | if (vFvNames.size() == 0) {\r | |
3118 | cursor.dispose();\r | |
3119 | return pos;\r | |
3120 | }\r | |
3121 | \r | |
3122 | }while (cursor.toNextSibling(qFvImage));\r | |
3123 | \r | |
3124 | }\r | |
3125 | cursor.dispose();\r | |
3126 | return -1;\r | |
3127 | }\r | |
ae0d4fd2 | 3128 | /**Get FvImage Options for FvImage i\r |
3129 | * @param i the ith FvImage\r | |
3130 | */\r | |
3131 | public void getFvImagesFvImageOptions(int i, Map<String, String> m) {\r | |
3132 | XmlObject o = getfpdFlash().getFvImages();\r | |
3133 | if (o == null) {\r | |
3134 | return;\r | |
3135 | }\r | |
3136 | XmlCursor cursor = o.newCursor();\r | |
3137 | QName qFvImage = new QName(xmlNs, "FvImage");\r | |
3138 | if (cursor.toChild(qFvImage)) {\r | |
3139 | for (int j = 0; j < i; ++j) {\r | |
3140 | cursor.toNextSibling(qFvImage);\r | |
a13899c5 | 3141 | }\r |
ae0d4fd2 | 3142 | FvImagesDocument.FvImages.FvImage fi = (FvImagesDocument.FvImages.FvImage)cursor.getObject();\r |
3143 | if (fi.getFvImageOptions() == null || fi.getFvImageOptions().getNameValueList() == null){\r | |
72426064 | 3144 | cursor.dispose();\r |
ae0d4fd2 | 3145 | return;\r |
a13899c5 | 3146 | }\r |
ae0d4fd2 | 3147 | ListIterator<FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue> li = fi.getFvImageOptions().getNameValueList().listIterator();\r |
3148 | while(li.hasNext()){\r | |
3149 | FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue nv = li.next();\r | |
a13899c5 | 3150 | m.put(nv.getName(), nv.getValue());\r |
3151 | }\r | |
a13899c5 | 3152 | }\r |
72426064 | 3153 | cursor.dispose();\r |
a13899c5 | 3154 | }\r |
3155 | \r | |
3156 | /**\r | |
3157 | Get platform header element\r | |
3158 | @return PlatformHeaderDocument.PlatformHeader\r | |
3159 | **/\r | |
3160 | public PlatformHeaderDocument.PlatformHeader getFpdHdr() {\r | |
3161 | if (fpdHdr == null) {\r | |
3162 | fpdHdr = fpdRoot.addNewPlatformHeader();\r | |
3163 | }\r | |
1faac7b6 | 3164 | \r |
a13899c5 | 3165 | return fpdHdr;\r |
3166 | }\r | |
3167 | \r | |
a13899c5 | 3168 | public String getFpdHdrPlatformName() {\r |
3169 | return getFpdHdr().getPlatformName();\r | |
3170 | }\r | |
3171 | \r | |
3172 | public String getFpdHdrGuidValue() {\r | |
3173 | return getFpdHdr().getGuidValue();\r | |
3174 | }\r | |
3175 | \r | |
3176 | public String getFpdHdrVer() {\r | |
3177 | return getFpdHdr().getVersion();\r | |
3178 | }\r | |
3179 | \r | |
3180 | public String getFpdHdrAbs() {\r | |
3181 | return getFpdHdr().getAbstract();\r | |
3182 | }\r | |
3183 | \r | |
3184 | public String getFpdHdrDescription() {\r | |
3185 | return getFpdHdr().getDescription();\r | |
3186 | }\r | |
3187 | \r | |
3188 | public String getFpdHdrCopyright() {\r | |
3189 | return getFpdHdr().getCopyright();\r | |
3190 | }\r | |
3191 | \r | |
3192 | public String getFpdHdrLicense() {\r | |
3193 | LicenseDocument.License l = getFpdHdr().getLicense();\r | |
3194 | if (l == null) {\r | |
3195 | return null;\r | |
3196 | }\r | |
3197 | return l.getStringValue();\r | |
3198 | }\r | |
3199 | \r | |
3200 | public String getFpdHdrUrl() {\r | |
3201 | LicenseDocument.License l = getFpdHdr().getLicense();\r | |
3202 | if (l == null) {\r | |
3203 | return null;\r | |
3204 | }\r | |
3205 | return l.getURL();\r | |
3206 | }\r | |
3207 | \r | |
3208 | public String getFpdHdrSpec() {\r | |
3209 | \r | |
c06e8657 | 3210 | return "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052";\r |
a13899c5 | 3211 | // return getFpdHdr().getSpecification();\r |
3212 | }\r | |
3213 | \r | |
3214 | public void setFpdHdrPlatformName(String name){\r | |
3215 | getFpdHdr().setPlatformName(name);\r | |
3216 | }\r | |
3217 | \r | |
3218 | public void setFpdHdrGuidValue(String guid){\r | |
3219 | getFpdHdr().setGuidValue(guid);\r | |
3220 | }\r | |
3221 | \r | |
3222 | public void setFpdHdrVer(String v){\r | |
3223 | getFpdHdr().setVersion(v);\r | |
3224 | }\r | |
3225 | \r | |
3226 | public void setFpdHdrAbs(String abs) {\r | |
3227 | getFpdHdr().setAbstract(abs);\r | |
3228 | }\r | |
3229 | \r | |
3230 | public void setFpdHdrDescription(String desc){\r | |
3231 | getFpdHdr().setDescription(desc);\r | |
3232 | }\r | |
3233 | \r | |
3234 | public void setFpdHdrCopyright(String cr) {\r | |
3235 | getFpdHdr().setCopyright(cr);\r | |
3236 | }\r | |
3237 | \r | |
3238 | public void setFpdHdrLicense(String license){\r | |
3239 | LicenseDocument.License l = getFpdHdr().getLicense();\r | |
3240 | if (l == null) {\r | |
3241 | getFpdHdr().addNewLicense().setStringValue(license);\r | |
3242 | }\r | |
3243 | else {\r | |
3244 | l.setStringValue(license);\r | |
3245 | }\r | |
3246 | }\r | |
3247 | \r | |
3248 | public void setFpdHdrUrl(String url){\r | |
3249 | LicenseDocument.License l = getFpdHdr().getLicense();\r | |
3250 | \r | |
3251 | l.setURL(url);\r | |
3252 | \r | |
3253 | }\r | |
3254 | \r | |
3255 | public void setFpdHdrSpec(String s){\r | |
c06e8657 | 3256 | s = "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052";\r |
a13899c5 | 3257 | getFpdHdr().setSpecification(s);\r |
3258 | }\r | |
3259 | /**\r | |
3260 | Save the processed xml contents to file\r | |
3261 | \r | |
3262 | @param fpdFile The file to save xml contents\r | |
3263 | @throws IOException Exceptions during file operation\r | |
3264 | **/\r | |
3265 | public void saveAs(File fpdFile) throws IOException {\r | |
3266 | \r | |
3267 | XmlOptions options = new XmlOptions();\r | |
3268 | \r | |
3269 | options.setCharacterEncoding("UTF-8");\r | |
3270 | options.setSavePrettyPrint();\r | |
3271 | options.setSavePrettyPrintIndent(2);\r | |
3272 | try {\r | |
3273 | fpdd.save(fpdFile, options);\r | |
3274 | } catch (IOException e) {\r | |
3275 | e.printStackTrace();\r | |
3276 | }\r | |
3277 | \r | |
3278 | }\r | |
3279 | \r | |
1800d80f | 3280 | private String listToString(List l) {\r |
a13899c5 | 3281 | if (l == null) {\r |
3282 | return null;\r | |
3283 | }\r | |
3284 | String s = " ";\r | |
3285 | ListIterator li = l.listIterator();\r | |
3286 | while(li.hasNext()) {\r | |
3287 | s += li.next();\r | |
3288 | s += " ";\r | |
3289 | }\r | |
3290 | return s.trim();\r | |
3291 | }\r | |
e232295e | 3292 | \r |
3293 | private void removeElement(XmlObject o) {\r | |
3294 | XmlCursor cursor = o.newCursor();\r | |
3295 | cursor.removeXml();\r | |
3296 | cursor.dispose();\r | |
3297 | }\r | |
a13899c5 | 3298 | }\r |
82961247 | 3299 | \r |
3300 | class PcdItemTypeConflictException extends Exception {\r | |
3301 | \r | |
3302 | /**\r | |
3303 | * \r | |
3304 | */\r | |
3305 | private static final long serialVersionUID = 1L;\r | |
3306 | private String details = null;\r | |
3307 | \r | |
34c614e1 | 3308 | PcdItemTypeConflictException(String pcdName, String info){\r |
1bf9fa5a | 3309 | ModuleIdentification mi = WorkspaceProfile.getModuleId(info);\r |
3658f95e | 3310 | details = pcdName + " ItemType Conflicts with " + mi.getName() + " in Pkg " + mi.getPackageId().getName();\r |
82961247 | 3311 | }\r |
3312 | \r | |
3313 | public String getMessage() {\r | |
3314 | return details;\r | |
3315 | }\r | |
3316 | }\r | |
3317 | \r | |
3318 | class PcdDeclNotFound extends Exception {\r | |
3319 | \r | |
3320 | /**\r | |
3321 | * \r | |
3322 | */\r | |
3323 | private static final long serialVersionUID = 1L;\r | |
3324 | private String details = null;\r | |
3325 | \r | |
3326 | PcdDeclNotFound(String info) {\r | |
4da2e625 | 3327 | details = "PcdDeclNotFound: " + info;\r |
82961247 | 3328 | }\r |
3329 | \r | |
3330 | public String getMessage() {\r | |
3331 | return details;\r | |
3332 | }\r | |
3333 | }\r | |
3334 | \r | |
3335 | class PcdValueMalFormed extends Exception {\r | |
3336 | \r | |
3337 | /**\r | |
3338 | * \r | |
3339 | */\r | |
3340 | private static final long serialVersionUID = 1L;\r | |
3341 | private String details = null;\r | |
3342 | \r | |
3343 | PcdValueMalFormed(String info) {\r | |
4da2e625 | 3344 | details = "PcdValueMalFormed: " + info;\r |
82961247 | 3345 | }\r |
3346 | \r | |
3347 | public String getMessage() {\r | |
3348 | return details;\r | |
3349 | }\r | |
3350 | }\r |