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