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