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