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