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