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