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