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