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