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